Skip to content

fix(pacquet): preserve libc metadata shape - #13436

Merged
zkochan merged 3 commits into
mainfrom
test-astro2
Jul 27, 2026
Merged

zkochan merged 3 commits into
mainfrom
test-astro2

Conversation

@zkochan

@zkochan zkochan commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #13435 by preserving whether package libc metadata was declared as a string or an array when pacquet writes pnpm-lock.yaml.

TypeScript pnpm already preserves this distinction. With this change, clean lockfile-only installs of withastro/astro at 112d3ea14cf997218239fd8a436707e56a3815fb produce byte-identical TypeScript and Rust lockfiles with SHA-256 2d5f4badfb12ef4ca3ea692ef9c8415298556a054b1c24585e617e91ad6416d8.

Squash Commit Body

Represent libc metadata as an untagged string-or-list value in the Rust lockfile model. Preserve the source manifest shape when building package metadata, while exposing a normalized slice to installability consumers.

This keeps scalar libc declarations scalar and singleton arrays as arrays, matching TypeScript pnpm's lockfile serialization.

Fixes pnpm/pnpm#13435.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.

Written by an agent (Codex, GPT-5).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes
    • Lockfiles now preserve the original libc shape from the manifest (scalar vs list) when writing libc into PackageMetadata.
    • Improved handling of optional libc values so the same representation is propagated through lockfile generation and installability checks.
  • Tests
    • Updated libc parsing/serialization assertions to match shape preservation.
    • Added coverage that generated lockfiles reproduce scalar and list forms exactly.

Copilot AI review requested due to automatic review settings July 27, 2026 19:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 82e98653-dbf1-41a3-8840-e0fd0fcca7e3

📥 Commits

Reviewing files that changed from the base of the PR and between 570dce2 and f41b111.

📒 Files selected for processing (1)
  • pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs

📝 Walkthrough

Walkthrough

The lockfile pipeline now preserves whether libc metadata was declared as a scalar string or an array, while installability consumers continue receiving vector-backed values.

Changes

libc shape preservation

Layer / File(s) Summary
StringOrList metadata contract
pnpm/crates/lockfile/src/package_metadata.rs, pnpm/crates/lockfile/src/package_metadata/tests.rs
Introduces StringOrList, updates PackageMetadata.libc, and tests scalar/list parsing and serialization.
Lockfile metadata extraction
pnpm/crates/env-installer/src/manifest_lockfile.rs, pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs, pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs, .changeset/quiet-wolves-remember.md
Preserves scalar versus array libc values while reading manifests and generating lockfiles.
Installability conversion
pnpm/crates/package-manager/src/hoisted_dep_graph.rs, pnpm/crates/package-manager/src/installability.rs, pnpm/crates/env-installer/src/install_config_deps.rs
Converts preserved metadata into vector-backed installability and normalized subdependency fields.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Manifest
  participant LockfileGenerator
  participant PackageMetadata
  participant Lockfile
  Manifest->>LockfileGenerator: Read libc as string or array
  LockfileGenerator->>PackageMetadata: Store StringOrList
  PackageMetadata->>Lockfile: Serialize matching libc shape
Loading

Assessment against linked issues

Objective Addressed Explanation
Preserve scalar and array libc representations in generated lockfiles [#13435] ✅

Possibly related issues

  • pnpm/pnpm#12366 — Concerns the same PackageMetadata.libc lockfile parsing and serialization behavior.

Possibly related PRs

  • pnpm/pnpm#13346 — Changes the same dependency-graph lockfile path to preserve libc string-versus-array shape.
  • pnpm/pnpm#13367 — Updates related read_string_or_list array-handling tests.

Suggested labels: product: pacquet

Suggested reviewers: copilot

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test-astro2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix pacquet lockfile to preserve libc string vs array shape

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Preserve libc scalar vs array shape when writing pnpm-lock.yaml from Rust.
• Introduce StringOrList lockfile model while keeping installability consumers normalized.
• Add regression tests and a changeset describing the lockfile-serialization fix.
Diagram

graph TD
  pkg[/"package.json manifest"/] --> read["read_string_or_list()"] --> model["PackageMetadata.libc: StringOrList"] --> ser["YAML serialization"] --> lock[("pnpm-lock.yaml")]
  model --> inst["Installability checks"]
  subgraph Legend
    direction LR
    _in[/"Input"/] ~~~ _m["Model / logic"] ~~~ _f[("File")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Keep `Vec` + add a shape flag
  • ➕ Minimal changes to existing consumers that expect Vec
  • ➕ Explicitly encodes “was_string” vs “was_list” without new enum matching
  • ➖ More error-prone (two fields must stay consistent)
  • ➖ Harder to reuse for other fields that may gain the same requirement
2. Store raw `serde_json::Value` for `libc` in metadata
  • ➕ Perfect shape fidelity for current and future variants
  • ➕ Avoids designing a dedicated type for each polymorphic field
  • ➖ Pushes validation/typing problems to every consumer
  • ➖ Complicates serde/YAML model and makes downstream logic less type-safe

Recommendation: The chosen approach (a typed untagged StringOrList with Deref for normalized access) is the best trade-off: it preserves lockfile serialization shape for byte-identical output while keeping installability logic straightforward via slice access. Alternatives either add state-synchronization risk (flag + vec) or weaken typing and consumer ergonomics (raw JSON value).

Files changed (9) +69 / -66

Bug fix (6) +54 / -52
install_config_deps.rsNormalize 'libc' metadata for installer subdependency manifests +1/-1

Normalize 'libc' metadata for installer subdependency manifests

• Updates the subdependency manifest construction to convert 'StringOrList' into a 'Vec<String>' via 'as_deref()' when populating 'libc'. Keeps installer logic working with normalized values while the lockfile model preserves original shape.

pnpm/crates/env-installer/src/install_config_deps.rs

manifest_lockfile.rsPreserve 'libc' scalar vs list when building lockfile package metadata +10/-2

Preserve 'libc' scalar vs list when building lockfile package metadata

• Switches package metadata generation to parse 'libc' as a 'StringOrList' rather than always normalizing to a list. Adds 'read_string_or_list()' helper that preserves the manifest-provided shape while filtering invalid/empty values.

pnpm/crates/env-installer/src/manifest_lockfile.rs

package_metadata.rsModel 'libc' as 'StringOrList' to preserve lockfile serialization shape +31/-44

Model 'libc' as 'StringOrList' to preserve lockfile serialization shape

• Replaces the custom serde (de)serialization that normalized 'libc' into 'Vec<String>' with a dedicated untagged 'StringOrList' enum. Provides 'Deref<Target=[String]>' to expose a normalized slice for consumers, plus convenient conversions from vectors/iterators.

pnpm/crates/lockfile/src/package_metadata.rs

dependencies_graph_to_lockfile.rsPreserve 'libc' shape in dependency graph → lockfile conversion +10/-3

Preserve 'libc' shape in dependency graph → lockfile conversion

• Changes 'read_string_or_list()' to return 'pacquet_lockfile::StringOrList' instead of 'Vec<String>'. Ensures lockfile metadata keeps the original manifest scalar/array representation during lockfile generation.

pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs

hoisted_dep_graph.rsNormalize 'libc' when generating installability manifest from metadata +1/-1

Normalize 'libc' when generating installability manifest from metadata

• Updates 'manifest_for_installability()' to convert 'metadata.libc' from 'StringOrList' into 'Vec<String>' using 'as_deref()'. Maintains prior consumer expectations while allowing lockfile shape preservation upstream.

pnpm/crates/package-manager/src/hoisted_dep_graph.rs

installability.rsNormalize 'libc' when building manifest from lockfile metadata +1/-1

Normalize 'libc' when building manifest from lockfile metadata

• Updates 'manifest_from_metadata()' to convert 'StringOrList' into a 'Vec<String>' via 'as_deref()' for installability checks. Keeps installability logic operating on normalized lists without forcing lockfile serialization to normalize shape.

pnpm/crates/package-manager/src/installability.rs

Tests (2) +10 / -14
tests.rsAdd regression tests ensuring 'libc' YAML shape round-trips +9/-13

Add regression tests ensuring 'libc' YAML shape round-trips

• Updates assertions to reflect 'StringOrList' and adds a round-trip test that verifies both scalar and singleton-array inputs serialize back with the same shape. Protects against regressions that would collapse arrays into strings or vice versa.

pnpm/crates/lockfile/src/package_metadata/tests.rs

tests.rsAdjust tests for 'StringOrList' return type +1/-1

Adjust tests for 'StringOrList' return type

• Updates the 'read_string_or_list' test to expect the new 'StringOrList' value (via '.into()'). Keeps validation coverage for array inputs and rejection of unsupported types.

pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs

Documentation (1) +5 / -0
quiet-wolves-remember.mdAdd changeset noting libc shape preservation in lockfile output +5/-0

Add changeset noting libc shape preservation in lockfile output

• Introduces a patch-level changeset for the 'pacquet' package. Documents that lockfile writing now preserves whether 'libc' metadata was declared as a string or an array.

.changeset/quiet-wolves-remember.md

@greptile-apps

greptile-apps Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (3): Last reviewed commit: "test(pacquet): log generated lockfile fi..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm/crates/lockfile/src/package_metadata/tests.rs`:
- Around line 47-52: Extend the regression coverage beyond
libc_shape_is_preserved and PackageMetadata serialization by adding an
end-to-end fixture test through manifest extraction and lockfile writing.
Include both scalar and singleton-array libc manifests, then compare the
complete generated lockfile bytes with the TypeScript-produced expected artifact
to verify identical output shape and serialization.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c129c7ba-d08f-4d22-a90b-d616fa982c05

📥 Commits

Reviewing files that changed from the base of the PR and between bcd0b3c and fe44c06.

📒 Files selected for processing (9)
  • .changeset/quiet-wolves-remember.md
  • pnpm/crates/env-installer/src/install_config_deps.rs
  • pnpm/crates/env-installer/src/manifest_lockfile.rs
  • pnpm/crates/lockfile/src/package_metadata.rs
  • pnpm/crates/lockfile/src/package_metadata/tests.rs
  • pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs
  • pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs
  • pnpm/crates/package-manager/src/hoisted_dep_graph.rs
  • pnpm/crates/package-manager/src/installability.rs

@qodo-code-review

qodo-code-review Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (3) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Remediation recommended

1. Debug eprintln! in test 📘 Rule violation ⚙ Maintainability ⭐ New
Description
The generated_lockfile_preserves_libc_manifest_shape test unconditionally prints the full
generated lockfile YAML via eprintln!, which is unrelated to the bug fix and can unnecessarily
bloat CI logs, slow test runs, and reduce signal-to-noise even when the test passes. Bug-fix PRs
should avoid non-essential diagnostic output that isn’t required to validate the fix, keeping
failures easier to triage.
Code

pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs[349]

+    eprintln!("GENERATED LOCKFILE:\n{yaml}\n");
Relevance

⭐⭐⭐ High

Team has accepted removing unconditional debug output in tests to reduce noisy CI logs.

PR-#13329
PR-#12703

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 2255067 requires bug-fix changes to avoid unrelated additions, and the cited test
code adds an unconditional eprintln!("GENERATED LOCKFILE...", {yaml}) before the assertion,
causing the entire YAML lockfile content to be emitted to stderr on every run. Because this output
is not needed for the behavioral assertion and occurs even when the test passes, it matches the kind
of large/noisy logging the repo’s review guidance discourages unless it is actionable or opt-in.

Rule 2255067: Bug fix changes must not include unrelated refactors or reformatting
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs[349-349]
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs[311-350]
REVIEW_GUIDE.md[198-200]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A debug `eprintln!` was added to a bug-fix test and it prints the entire generated lockfile YAML to stderr on every run (including passing runs), creating unnecessary CI/log noise and overhead.

## Issue Context
This output is not required for the assertion and reduces signal-to-noise in CI, making real failures harder to spot. If the intent is to aid debugging, remove the unconditional logging or gate it behind an opt-in mechanism (env var/feature), or ensure diagnostics are only formatted/emitted on failure (e.g., only print when `yaml != expected`, or use an assertion approach that includes details in the failure path).

## Fix Focus Areas
- pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs[349-350]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Over-broad golden lockfile test 🐞 Bug ⚙ Maintainability
Description
The new test generated_lockfile_preserves_libc_manifest_shape asserts byte-for-byte equality of
the entire serialized lockfile YAML, so any unrelated lockfile formatting/default-field change will
fail the test even if libc shape preservation remains correct. It also hardcodes the fake integrity
value in the expected YAML instead of reusing the module’s FAKE_INTEGRITY constant, increasing
fixture drift risk.
Code

pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs[R311-350]

+    assert_eq!(
+        lockfile.to_yaml_string().expect("serialize generated lockfile"),
+        format!(
+            "{}\n",
+            text_block! {
+                "lockfileVersion: '9.0'"
+                ""
+                "settings:"
+                "  autoInstallPeers: false"
+                "  excludeLinksFromLockfile: false"
+                ""
+                "importers:"
+                ""
+                "  .:"
+                "    dependencies:"
+                "      list-libc:"
+                "        specifier: 1.0.0"
+                "        version: 1.0.0"
+                "      scalar-libc:"
+                "        specifier: 1.0.0"
+                "        version: 1.0.0"
+                ""
+                "packages:"
+                ""
+                "  [email protected]:"
+                "    resolution: {integrity: sha512-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==}"
+                "    libc: [glibc]"
+                ""
+                "  [email protected]:"
+                "    resolution: {integrity: sha512-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==}"
+                "    libc: musl"
+                ""
+                "snapshots:"
+                ""
+                "  [email protected]: {}"
+                ""
+                "  [email protected]: {}"
+            }
+        ),
+    );
Relevance

⭐⭐⭐ High

Team often accepts test robustness/determinism improvements; reducing fixture drift (reuse
constants) aligns with prior accepted test cleanups.

PR-#13256
PR-#13062
PR-#13350

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new test does a full-string assert_eq! against lockfile.to_yaml_string() with an embedded
full lockfile document (including importers/settings/snapshots), which makes the regression
sensitive to unrelated serialization changes. The same file defines FAKE_INTEGRITY, but the
expected YAML repeats the integrity literal instead of referencing the constant.

pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs[280-351]
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs[71-76]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new regression test validates libc scalar-vs-list preservation by comparing the *entire* lockfile YAML output to a hardcoded document. This couples the test to many unrelated serialization details (ordering/spacing/default settings sections) and duplicates the integrity fixture string, making future unrelated lockfile changes cause noisy failures.

## Issue Context
This test’s intent is to ensure `libc` is serialized as `libc: musl` for scalar input and `libc: [glibc]` for list input. The current assertion verifies far more than that, and repeats the `sha512-AAAA...` fixture text even though the module already defines `FAKE_INTEGRITY`.

## Fix Focus Areas
- pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs[280-351]

### Suggested approach
Option A (keep focused & robust):
- Serialize to YAML and assert only the relevant package stanzas/lines exist, e.g.:
 - that the YAML contains `"  [email protected]:"` followed by `"    libc: [glibc]"`
 - and contains `"  [email protected]:"` followed by `"    libc: musl"`

Option B (keep golden-style but reduce drift):
- Still compare a golden block, but interpolate `FAKE_INTEGRITY` (and any other shared fixtures) into the expected string so it can’t silently diverge.
- Consider narrowing the golden to just the `packages:` section if the purpose is libc shape in package metadata.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Duplicate read_string_or_list helper 📘 Rule violation ⚙ Maintainability
Description
read_string_or_list logic is now duplicated in two Rust modules with near-identical behavior. This
increases maintenance risk and the chance of future divergence in lockfile/manifest parsing
behavior.
Code

pnpm/crates/env-installer/src/manifest_lockfile.rs[R86-92]

+fn read_string_or_list(manifest: Option<&Value>, key: &str) -> Option<StringOrList> {
+    match manifest?.get(key)? {
+        Value::String(value) if !value.is_empty() => Some(StringOrList::String(value.clone())),
+        Value::Array(_) => read_string_list(manifest, key).map(StringOrList::List),
+        _ => None,
+    }
+}
Relevance

⭐⭐ Medium

Team sometimes extracts duplicated helpers, but also often rejects dedup/refactor requests as
non-essential.

PR-#13090
PR-#13173
PR-#13151

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713439 requires avoiding reimplementation of existing functionality and extracting
shared logic. The PR introduces/updates two separate read_string_or_list implementations that
perform the same manifest field parsing and only differ by local type paths, indicating avoidable
duplication.

Rule 713439: Avoid reimplementing existing functionality; extract and reuse shared modules
pnpm/crates/env-installer/src/manifest_lockfile.rs[86-92]
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs[676-689]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`read_string_or_list` is duplicated across modules; it should be extracted and reused to prevent drift.

## Issue Context
The two implementations are effectively the same (`String` -> `StringOrList::String`, `Array` -> parsed list -> `StringOrList::List`). Keeping them separate makes future fixes easy to miss in one place.

## Fix Focus Areas
- pnpm/crates/env-installer/src/manifest_lockfile.rs[86-92]
- pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs[676-689]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

4. Changeset missing pnpm bump 📘 Rule violation § Compliance
Description
The new changeset only bumps pacquet and does not include an entry for pnpm as required. This
can cause release tooling to omit the intended pnpm version bump for a user-visible lockfile
behavior fix.
Code

.changeset/quiet-wolves-remember.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

⭐ Low

Multiple recent PRs rejected adding pnpm bump to pacquet-only changesets (pnpm refers to TS CLI).

PR-#13416
PR-#13406
PR-#12981

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires each changeset to include a pnpm entry with a correct bump type.
The added changeset front-matter contains only "pacquet": patch and therefore does not satisfy the
rule.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/quiet-wolves-remember.md[1-3]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new changeset lacks a `pnpm` entry with a valid bump type (`patch`/`minor`/`major`).

## Issue Context
Compliance requires changesets to explicitly declare the `pnpm` package and bump type.

## Fix Focus Areas
- .changeset/quiet-wolves-remember.md[1-3]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Previous review results

Review updated until commit f41b111

Results up to commit fe44c06 ⚖️ Balanced


🐞 Bugs (0) 📘 Rule violations (2) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Duplicate read_string_or_list helper 📘 Rule violation ⚙ Maintainability
Description
read_string_or_list logic is now duplicated in two Rust modules with near-identical behavior. This
increases maintenance risk and the chance of future divergence in lockfile/manifest parsing
behavior.
Code

pnpm/crates/env-installer/src/manifest_lockfile.rs[R86-92]

+fn read_string_or_list(manifest: Option<&Value>, key: &str) -> Option<StringOrList> {
+    match manifest?.get(key)? {
+        Value::String(value) if !value.is_empty() => Some(StringOrList::String(value.clone())),
+        Value::Array(_) => read_string_list(manifest, key).map(StringOrList::List),
+        _ => None,
+    }
+}
Relevance

⭐⭐ Medium

Team sometimes extracts duplicated helpers, but also often rejects dedup/refactor requests as
non-essential.

PR-#13090
PR-#13173
PR-#13151

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713439 requires avoiding reimplementation of existing functionality and extracting
shared logic. The PR introduces/updates two separate read_string_or_list implementations that
perform the same manifest field parsing and only differ by local type paths, indicating avoidable
duplication.

Rule 713439: Avoid reimplementing existing functionality; extract and reuse shared modules
pnpm/crates/env-installer/src/manifest_lockfile.rs[86-92]
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs[676-689]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`read_string_or_list` is duplicated across modules; it should be extracted and reused to prevent drift.

## Issue Context
The two implementations are effectively the same (`String` -> `StringOrList::String`, `Array` -> parsed list -> `StringOrList::List`). Keeping them separate makes future fixes easy to miss in one place.

## Fix Focus Areas
- pnpm/crates/env-installer/src/manifest_lockfile.rs[86-92]
- pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs[676-689]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational
2. Changeset missing pnpm bump 📘 Rule violation § Compliance
Description
The new changeset only bumps pacquet and does not include an entry for pnpm as required. This
can cause release tooling to omit the intended pnpm version bump for a user-visible lockfile
behavior fix.
Code

.changeset/quiet-wolves-remember.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

⭐ Low

Multiple recent PRs rejected adding pnpm bump to pacquet-only changesets (pnpm refers to TS CLI).

PR-#13416
PR-#13406
PR-#12981

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires each changeset to include a pnpm entry with a correct bump type.
The added changeset front-matter contains only "pacquet": patch and therefore does not satisfy the
rule.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/quiet-wolves-remember.md[1-3]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new changeset lacks a `pnpm` entry with a valid bump type (`patch`/`minor`/`major`).

## Issue Context
Compliance requires changesets to explicitly declare the `pnpm` package and bump type.

## Fix Focus Areas
- .changeset/quiet-wolves-remember.md[1-3]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit 570dce2 ⚖️ Balanced


🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Over-broad golden lockfile test 🐞 Bug ⚙ Maintainability
Description
The new test generated_lockfile_preserves_libc_manifest_shape asserts byte-for-byte equality of
the entire serialized lockfile YAML, so any unrelated lockfile formatting/default-field change will
fail the test even if libc shape preservation remains correct. It also hardcodes the fake integrity
value in the expected YAML instead of reusing the module’s FAKE_INTEGRITY constant, increasing
fixture drift risk.
Code

pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs[R311-350]

+    assert_eq!(
+        lockfile.to_yaml_string().expect("serialize generated lockfile"),
+        format!(
+            "{}\n",
+            text_block! {
+                "lockfileVersion: '9.0'"
+                ""
+                "settings:"
+                "  autoInstallPeers: false"
+                "  excludeLinksFromLockfile: false"
+                ""
+                "importers:"
+                ""
+                "  .:"
+                "    dependencies:"
+                "      list-libc:"
+                "        specifier: 1.0.0"
+                "        version: 1.0.0"
+                "      scalar-libc:"
+                "        specifier: 1.0.0"
+                "        version: 1.0.0"
+                ""
+                "packages:"
+                ""
+                "  [email protected]:"
+                "    resolution: {integrity: sha512-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==}"
+                "    libc: [glibc]"
+                ""
+                "  [email protected]:"
+                "    resolution: {integrity: sha512-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==}"
+                "    libc: musl"
+                ""
+                "snapshots:"
+                ""
+                "  [email protected]: {}"
+                ""
+                "  [email protected]: {}"
+            }
+        ),
+    );
Relevance

⭐⭐⭐ High

Team often accepts test robustness/determinism improvements; reducing fixture drift (reuse
constants) aligns with prior accepted test cleanups.

PR-#13256
PR-#13062
PR-#13350

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new test does a full-string assert_eq! against lockfile.to_yaml_string() with an embedded
full lockfile document (including importers/settings/snapshots), which makes the regression
sensitive to unrelated serialization changes. The same file defines FAKE_INTEGRITY, but the
expected YAML repeats the integrity literal instead of referencing the constant.

pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs[280-351]
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs[71-76]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new regression test validates libc scalar-vs-list preservation by comparing the *entire* lockfile YAML output to a hardcoded document. This couples the test to many unrelated serialization details (ordering/spacing/default settings sections) and duplicates the integrity fixture string, making future unrelated lockfile changes cause noisy failures.

## Issue Context
This test’s intent is to ensure `libc` is serialized as `libc: musl` for scalar input and `libc: [glibc]` for list input. The current assertion verifies far more than that, and repeats the `sha512-AAAA...` fixture text even though the module already defines `FAKE_INTEGRITY`.

## Fix Focus Areas
- pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs[280-351]

### Suggested approach
Option A (keep focused & robust):
- Serialize to YAML and assert only the relevant package stanzas/lines exist, e.g.:
 - that the YAML contains `"  [email protected]:"` followed by `"    libc: [glibc]"`
 - and contains `"  [email protected]:"` followed by `"    libc: musl"`

Option B (keep golden-style but reduce drift):
- Still compare a golden block, but interpolate `FAKE_INTEGRITY` (and any other shared fixtures) into the expected string so it can’t silently diverge.
- Consider narrowing the golden to just the `packages:` section if the purpose is libc shape in package metadata.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

Copilot AI review requested due to automatic review settings July 27, 2026 19:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs`:
- Around line 311-350: Log the rendered lockfile YAML immediately before the
multiline assert_eq! in the test, using the value produced by
lockfile.to_yaml_string(). Preserve the existing expected-string comparison and
serialization error handling while ensuring CI output includes the actual
generated YAML.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 73686f8a-9d02-4cdb-9c53-891a20a15c76

📥 Commits

Reviewing files that changed from the base of the PR and between fe44c06 and 570dce2.

📒 Files selected for processing (1)
  • pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 570dce2

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@github-actions

github-actions Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.18     13.8±1.51ms    27.2 MB/sec    1.00     11.7±0.40ms    31.9 MB/sec
packument/parse                                  1.00     38.3±1.62µs  1731.6 MB/sec    1.05     40.1±0.64µs  1652.5 MB/sec
tarball/download_dependency                      1.27      3.2±0.57ms  1344.8 KB/sec    1.00      2.5±0.14ms  1713.6 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.27   256.9±18.62ms 62.3 KElem/sec    1.00   202.4±10.92ms 79.0 KElem/sec

Copilot AI review requested due to automatic review settings July 27, 2026 19:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 27, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit f41b111

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.64%. Comparing base (bcd0b3c) to head (f41b111).

Files with missing lines Patch % Lines
pnpm/crates/env-installer/src/manifest_lockfile.rs 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13436      +/-   ##
==========================================
- Coverage   87.64%   87.64%   -0.01%     
==========================================
  Files         545      545              
  Lines       93897    93894       -3     
==========================================
- Hits        82292    82289       -3     
  Misses      11605    11605              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zkochan
zkochan merged commit 516da52 into main Jul 27, 2026
35 checks passed
@zkochan
zkochan deleted the test-astro2 branch July 27, 2026 20:01
zkochan added a commit that referenced this pull request Sep 26, 2026
The install loaded only the global and project pnpmfiles, so a config
dependency plugin's pnpmfile contributed its updateConfig hook and
nothing else. Its readPackage, afterAllResolved and custom resolvers
never ran, and pnpmfileChecksum left it out. pnpm 11 puts plugin
pnpmfiles in the same requireHooks set as the project's.

PnpmfileSelection now carries the config dependencies, and
find_pnpmfiles returns the global pnpmfile, then the installed plugin
pnpmfiles, then the project's own, which is pnpm 11's order. Every
consumer of the selection now sees the same set: install, update,
deploy, the lockfile freshness checks, the optimistic repeat-install
state, and the updateConfig/beforePacking pass. The updateConfig pass
used to run plugins ahead of the global pnpmfile and now runs them
after it, as pnpm 11 does.

The up-to-date fast path already bails out whenever config dependencies
exist, so it is unaffected. The workspace state's pnpmfile list now
includes plugin pnpmfiles, as pnpm 11's does. A state written before
this change therefore triggers one re-validation.

Closes pnpm/pnpm#12366. Its env-lockfile items were already fixed by
#13382, #13346 and #13436. This was the last
lockfile divergence found while verifying them.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pacquet normalizes singleton libc arrays when generating Astro lockfile

3 participants