Skip to content

fix(lockfile): fail a frozen install when a recorded setting drifts - #13386

Merged
zkochan merged 6 commits into
mainfrom
fix-frozen-install-settings-drift
Jul 26, 2026
Merged

zkochan merged 6 commits into
mainfrom
fix-frozen-install-settings-drift

Conversation

@zkochan

@zkochan zkochan commented Jul 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes the error-code half of item 1 of #13315 — with one field left over, filed as #13385.

pnpm's getOutdatedLockfileSetting names eleven fields whose drift makes a lockfile unreproducible, and refuses a frozen install with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH naming the first one that drifted. pacquet compared seven of them. Three of the four it skipped are checkable with what the freshness gate already has:

# lockfile written with the defaults, then the setting flipped
printf 'packages: []\nautoInstallPeers: false\n' > pnpm-workspace.yaml

$ pnpm@11 install --frozen-lockfile
[ERR_PNPM_LOCKFILE_CONFIG_MISMATCH] Cannot proceed with the frozen installation. The current "settings.autoInstallPeers" configuration doesn't match the value found in the lockfile

$ pnpm@12 install --frozen-lockfile     # before
Done in 228ms using pnpm v12.0.0-alpha.21

Same for dedupePeers and excludeLinksFromLockfile. The install went ahead against a lockfile whose recorded resolution no longer matched the settings that produced it — autoInstallPeers decides whether peers are folded into the importer snapshot, and excludeLinksFromLockfile decides whether link: deps are recorded at all.

Each comparison follows pnpm's exactly: autoInstallPeers and excludeLinksFromLockfile are checked only when the lockfile records a settings block, since a lockfile written before the field says nothing about it, while dedupePeers is written only while it is on, so an absent key reads as false.

Order matters too

Only the first drifted field is reported, so the comparison order decides which name the user sees. pacquet checked injectWorkspacePackages where pnpm checks autoInstallPeers, and pnpm checks injectWorkspacePackages last. The fields are now compared in pnpm's order, and a test pins the case where two fields drift at once.

Not in this PR

pnpmfileChecksum, the eleventh field, stays unchecked. pnpm records it only when a loaded pnpmfile exports a hooks object, so telling "no pnpmfile" from "a pnpmfile with no hooks" means evaluating it through the Node worker — on check_lockfile_settings_drift, which is sync and is also what the repeat-install fast path calls to stay cheap. Wiring None there instead would fail every frozen install in a project that has a pnpmfile, so it needs its own decision about loading the pnpmfile on those paths. Filed as #13385 with the repro.

The pnpr side (added in review)

The resolve protocol carries none of these three settings, so pnpr's per-request config kept the server's own defaults for them — and once the freshness gate compares them, a frozen request whose lockfile was written under any non-default value would be rejected against settings its owner never chose. On a frozen request the input lockfile is the contract (nothing is re-resolved, and the gate checks it against the config), so intern_config adopts the values it records.

Update-capable requests keep the server's defaults, unchanged by this PR: there the lockfile records what the last install used, which is stale exactly when the client has just changed one of these, and the server would keep resolving under the old value. Neither is the client's current setting — only the protocol can carry that, filed as #13389.

Two follow-ups from review on that: the interning key carries only the three adopted fields (keying on the whole settings block would let a caller mint a distinct leaked config per peersSuffixMaxLength value and exhaust MAX_INTERNED_CONFIGS, after which no caller gets a config at all), and the frozen short-circuit now checks the lockfile's catalogs snapshot against the request's catalogs instead of an empty set — a pre-existing bug that cost every catalog-bearing lockfile its short-circuit.

One cleanup

check_lockfile_settings now takes the options struct its catalog-aware twin took, and the twin is gone. The two had drifted into different field sets, and that is precisely what let catalogs be added to one of them while pnpr's call site kept passing the older, shorter list.

Verification

pnpm 11 and pacquet now produce the same line for each of the three, naming the same setting. A pacquet-written lockfile still passes its own --frozen-lockfile install, which is the regression this class of check risks.

Unit tests cover each new comparison, the "no settings block can't drift" case, and the report-order case; a CLI test pins the diagnostic code and the quoted setting name end to end. Breaking the autoInstallPeers comparison fails it.

cargo nextest run over pacquet-lockfile (252), pacquet-package-manager (800), pacquet-cli + pnpr (2925), plus clippy, cargo doc, and dylint: clean.

Squash Commit Body

`getOutdatedLockfileSetting` names eleven fields whose drift makes the
lockfile unreproducible; pacquet compared seven. A project that flipped
`autoInstallPeers`, `dedupePeers`, or `excludeLinksFromLockfile` after
writing its lockfile got a clean `--frozen-lockfile` install from
pacquet and `ERR_PNPM_LOCKFILE_CONFIG_MISMATCH` from pnpm — the install
proceeded against a lockfile whose recorded resolution no longer
matched the settings that produced it.

Each comparison follows pnpm's: `autoInstallPeers` and
`excludeLinksFromLockfile` are checked only when the lockfile records a
`settings` block, since one written before the field says nothing about
it, while `dedupePeers` is written only while it is on, so an absent key
reads as `false`.

The fields are now compared in pnpm's order too. Only the first drifted
field is reported, so the order decides which name a user sees, and
`injectWorkspacePackages` sat where pnpm checks `autoInstallPeers`.

`pnpmfileChecksum`, the eleventh field, is still unchecked: it needs the
pnpmfile's hooks gate, which means loading the pnpmfile through the Node
worker on a path that deliberately avoids it. Filed as pnpm/pnpm#13385.

`check_lockfile_settings` takes the same options struct its catalog-aware
twin took, and the twin is gone — the two had drifted into different
field sets, which is what let the new fields be added to one and missed
at the other's call site.

Closes the error-code half of item 1 of pnpm/pnpm#13315.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
    (TypeScript already refuses these installs; this is the pacquet side.)
  • 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.
  • Updated the documentation if needed.

Written by an agent (Claude Code, claude-opus-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
    • Frozen installs now detect changes to autoInstallPeers, dedupePeers, and excludeLinksFromLockfile.
    • Error messages identify the specific setting that differs from the lockfile.
    • Lockfile settings are consistently respected during frozen installation checks.
  • Tests
    • Added coverage for settings drift, detection precedence, and lockfile-only frozen installs.

zkochan added 2 commits July 26, 2026 01:10
`getOutdatedLockfileSetting` names eleven fields whose drift makes the
lockfile unreproducible; pacquet compared seven. A project that flipped
`autoInstallPeers`, `dedupePeers`, or `excludeLinksFromLockfile` after
writing its lockfile got a clean `--frozen-lockfile` install from
pacquet and `ERR_PNPM_LOCKFILE_CONFIG_MISMATCH` from pnpm — the install
proceeded against a lockfile whose recorded resolution no longer
matched the settings that produced it.

Each comparison follows pnpm's: `autoInstallPeers` and
`excludeLinksFromLockfile` are checked only when the lockfile records a
`settings` block, since one written before the field says nothing about
it, while `dedupePeers` is written only while it is on, so an absent key
reads as `false`.

The fields are now compared in pnpm's order too. Only the first drifted
field is reported, so the order decides which name a user sees, and
`injectWorkspacePackages` sat where pnpm checks `autoInstallPeers`.

`pnpmfileChecksum`, the eleventh field, is still unchecked: it needs the
pnpmfile's hooks gate, which means loading the pnpmfile through the Node
worker on a path that deliberately avoids it. Filed separately.

`check_lockfile_settings` takes the same options struct its catalog-aware
twin took, and the twin is gone — the two had drifted into different
field sets, which is what let the new fields be added to one and missed
at the other's call site.
Collapsing the settings-check calls onto one line left `.is_ok(),)`
behind, which the perfectionist dylint rejects, and one call that stayed
multi-line lost the comma the same rule requires.
Copilot AI review requested due to automatic review settings July 25, 2026 23:20

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 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@zkochan, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 2 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e8dbcdba-c133-4b02-a3a3-050ddc3119f6

📥 Commits

Reviewing files that changed from the base of the PR and between 8736926 and 51af0b2.

📒 Files selected for processing (2)
  • pnpr/crates/pnpr/src/resolver.rs
  • pnpr/crates/pnpr/src/resolver/tests.rs
📝 Walkthrough

Walkthrough

Frozen lockfile validation now detects drift in autoInstallPeers, dedupePeers, and excludeLinksFromLockfile. Resolver configuration adopts lockfile settings, freshness APIs use structured inputs, and tests cover mismatch reporting and precedence.

Changes

Frozen settings drift validation

Layer / File(s) Summary
Lockfile settings comparison
pnpm/crates/lockfile/src/freshness.rs
Adds structured checks and staleness reasons for three settings, including setting names, defaults, and mismatch ordering.
Resolver and install integration
pnpm/crates/package-manager/src/install.rs, pnpr/crates/pnpr/src/resolver.rs, pnpr/crates/pnpr/src/resolver/resolve.rs
Passes the expanded settings-check payload and adopts lockfile settings when constructing resolver configuration.
Freshness API and drift coverage
pnpm/crates/lockfile/src/freshness/tests.rs
Migrates tests to LockfileSettingsCheck and covers catalog, existing setting, new setting, and precedence cases.
CLI regression test and release note
pnpm/crates/cli/tests/lockfile_only.rs, .changeset/frozen-install-checks-drifted-settings.md, pnpr/crates/pnpr/src/resolver/tests.rs
Verifies frozen lockfile-only installation rejects changed settings and documents the behavior; tests resolver settings adoption.⟩

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • pnpm/pnpm#13117: Both changes modify frozen-lockfile freshness handling involving autoInstallPeers.
  • pnpm/pnpm#13152: Both changes touch the CLI test utility append_workspace_yaml_key.

Suggested labels: product: pacquet, product: pnpr

Suggested reviewers: copilot, yeshyungseok

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-frozen-install-settings-drift

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(lockfile): fail frozen installs when recorded settings drift

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Reject --frozen-lockfile installs when key settings.* values changed since lockfile creation.
• Align drift detection order and setting names with pnpm’s getOutdatedLockfileSetting.
• Add end-to-end and unit tests to pin mismatch diagnostics and ordering behavior.
Diagram

graph TD
  A["CLI: pnpm/pacquet install"] --> B["Install pipeline"] --> C["check_lockfile_settings_drift"] --> D["lockfile::freshness\ncheck_lockfile_settings"] --> E[("pnpm-lock.yaml")]
  D --> F["Config (pnpm-workspace.yaml + flags)"]
  D --> G["StalenessReason\n(setting_name)"] --> H["ERR_PNPM_LOCKFILE_CONFIG_MISMATCH"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Report all drifted settings instead of the first
  • ➕ Better UX: users see every mismatch in one run
  • ➕ Reduces iterative fix/re-run cycles in CI
  • ➖ Diverges from pnpm’s long-standing behavior and tests/log expectations
  • ➖ Requires deciding ordering/formatting for multiple names
2. Data-driven setting list shared with pnpm upstream
  • ➕ Reduces risk of future drift in checked fields and ordering
  • ➕ Simplifies maintaining parity as pnpm adds new settings
  • ➖ Likely requires cross-repo coordination or code generation
  • ➖ Higher upfront complexity than the current targeted fix
3. Eagerly load pnpmfile to validate pnpmfileChecksum
  • ➕ Closes the remaining parity gap for the 11th pnpm setting
  • ➕ More complete frozen reproducibility guarantee
  • ➖ Adds cost/IO to currently synchronous, performance-sensitive paths
  • ➖ Requires careful semantics for 'no pnpmfile' vs 'pnpmfile without hooks'

Recommendation: Keep the PR’s approach: it restores correctness while matching pnpm’s semantics and error naming, which is critical since only the first mismatch is surfaced and users rely on the reported field name in CI logs. The remaining pnpmfileChecksum parity gap is rightly deferred because it has non-trivial performance/semantics tradeoffs.

Files changed (6) +362 / -251

Bug fix (3) +105 / -48
freshness.rsExpand lockfile settings drift detection and align ordering with pnpm +85/-40

Expand lockfile settings drift detection and align ordering with pnpm

• Extends 'LockfileSettingsCheck' and 'StalenessReason' to cover 'settings.autoInstallPeers', 'settings.dedupePeers', and 'settings.excludeLinksFromLockfile' drift. Reorders checks to match pnpm’s 'getOutdatedLockfileSetting' and collapses the catalogs-aware variant into a single 'check_lockfile_settings' API taking the options struct.

pnpm/crates/lockfile/src/freshness.rs

install.rsPass additional config fields into lockfile drift checks +4/-1

Pass additional config fields into lockfile drift checks

• Updates 'check_lockfile_settings_drift' to call the unified freshness function and provides 'auto_install_peers', 'dedupe_peers', and 'exclude_links_from_lockfile' from 'Config'. This ensures frozen installs reject lockfiles produced under different recorded settings.

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

resolve.rsUpdate resolver frozen-input validation to use LockfileSettingsCheck +16/-7

Update resolver frozen-input validation to use LockfileSettingsCheck

• Switches the resolver’s 'fresh_frozen_input_lockfile' to construct a 'LockfileSettingsCheck' (including the new settings fields) and imports 'Catalogs' for the required struct field. Keeps the fast freshness gate consistent with the installer path.

pnpr/crates/pnpr/src/resolver/resolve.rs

Tests (2) +252 / -203
lockfile_only.rsAdd E2E test for drifted settings under frozen lockfile-only +47/-0

Add E2E test for drifted settings under frozen lockfile-only

• Introduces an end-to-end test that writes a lockfile, flips 'autoInstallPeers', and asserts the frozen install fails. Pins both the diagnostic code ('ERR_PNPM_LOCKFILE_CONFIG_MISMATCH') and the quoted setting name shown in stderr.

pnpm/crates/cli/tests/lockfile_only.rs

tests.rsUpdate freshness tests for new API and add drift/order coverage +205/-203

Update freshness tests for new API and add drift/order coverage

• Refactors test helpers to construct 'LockfileSettingsCheck' and routes tests through the unified 'check_lockfile_settings' entry point. Adds unit tests for the new drifted settings, the 'missing settings block' behavior, and the pinned ordering when multiple fields drift simultaneously.

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

Documentation (1) +5 / -0
frozen-install-checks-drifted-settings.mdDocument frozen install failures on settings drift +5/-0

Document frozen install failures on settings drift

• Adds a changeset noting that frozen installs now fail when 'autoInstallPeers', 'dedupePeers', or 'excludeLinksFromLockfile' drift from the lockfile. Clarifies that the error surfaces the drifted setting name, matching pnpm behavior.

.changeset/frozen-install-checks-drifted-settings.md

@greptile-apps

greptile-apps Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 3/5

The PR is not yet safe to merge because non-frozen pnpr requests can still resolve dependencies using server defaults instead of the client's peer and link settings.

The frozen-request mismatch is fixed, but non-frozen requests do not transmit or adopt the client's current autoInstallPeers, dedupePeers, and excludeLinksFromLockfile values, so full resolution can return a graph and lockfile produced under different semantics than the client selected.

Files Needing Attention: pnpr/crates/pnpr/src/resolver.rs

Reviews (5): Last reviewed commit: "fix(pnpr): adopt the lockfile's settings..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
lockfile/parse_pnpm_lock       1.00     11.0±0.11ms    34.0 MB/sec    1.00     11.0±0.08ms    33.9 MB/sec
packument/parse                1.00     39.1±0.25µs  1695.5 MB/sec    1.03     40.2±0.26µs  1650.5 MB/sec
tarball/download_dependency    1.01      2.9±0.14ms  1492.4 KB/sec    1.00      2.9±0.10ms  1504.6 KB/sec

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Context used
✅ Compliance rules (platform): 32 rules

Grey Divider


Action required

1. Config cache key bloat ✓ Resolved 🐞 Bug ⛨ Security ⭐ New
Description
intern_config keys the leaked-config cache on the full lockfile.settings object, but only
applies three of those fields to PacquetConfig; varying the unused fields creates distinct
interned entries with identical behavior. This increases cache fragmentation and makes it easier to
exhaust MAX_INTERNED_CONFIGS, after which the server returns 503 for all callers.
Code

pnpr/crates/pnpr/src/resolver.rs[R286-300]

+    // The protocol carries no `autoInstallPeers` / `dedupePeers` /
+    // `excludeLinksFromLockfile`, but an input lockfile records the values
+    // it was written under. Adopting them makes the server resolve as the
+    // client would; leaving the server's own defaults in place would make
+    // the frozen path reject a lockfile that is valid for its owner, since
+    // the freshness gate compares these against the config.
+    let lockfile_settings =
+        request.lockfile.as_ref().and_then(|lockfile| lockfile.settings.as_ref());
+
    let key = serde_json::json!({
        "registry": registry,
+        "lockfileSettings": lockfile_settings,
        "namedRegistries": request.named_registries,
        "overrides": overrides_key,
        "minimumReleaseAge": request.minimum_release_age,
Relevance

⭐⭐⭐ High

Team previously accepted fixes to prevent intern_config key fragmentation/exhaustion; this is same
leaked-config cap surface.

PR-#12674

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The cache is explicitly capped to prevent leaked-config exhaustion, but the new key now varies on
lockfile settings fields that are not applied to the config. This creates unnecessary distinct
interned entries and makes exhausting the cap easier without changing behavior.

pnpr/crates/pnpr/src/resolver.rs[228-249]
pnpr/crates/pnpr/src/resolver.rs[286-307]
pnpr/crates/pnpr/src/resolver.rs[341-346]
pnpm/crates/lockfile/src/lib.rs[62-87]
PR-#12674

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

### Issue description
`intern_config` includes `lockfileSettings` in the cache key, but only copies `auto_install_peers`, `dedupe_peers`, and `exclude_links_from_lockfile` into the leaked `PacquetConfig`. Because `LockfileSettings` also contains other fields, a client can vary those unused fields (e.g. `injectWorkspacePackages`, `peersSuffixMaxLength`) to create many unique keys and consume `MAX_INTERNED_CONFIGS` faster, causing config interning to refuse new configs and the server to return 503.

### Issue Context
- `MAX_INTERNED_CONFIGS` is a global hard cap used to prevent memory exhaustion from leaked configs.
- Adding unused fields to the cache key increases key cardinality without changing behavior.

### Fix Focus Areas
- pnpr/crates/pnpr/src/resolver.rs[286-307]
- pnpr/crates/pnpr/src/resolver.rs[341-346]

### Suggested fix approach
Choose one:
1) **Narrow the cache key** to only the settings actually adopted into `PacquetConfig` (e.g. a small struct/tuple `{autoInstallPeers, dedupePeers, excludeLinksFromLockfile}`), rather than serializing the entire `LockfileSettings`.
2) **Or** if all lockfile settings are intended to be authoritative for server resolution, then also **apply** the additional keyed settings to `PacquetConfig` so key cardinality matches semantics.

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


2. Catalogs fast-path disabled ✓ Resolved 🐞 Bug ➹ Performance
Description
pnpr::fresh_frozen_input_lockfile now calls check_lockfile_settings with an empty catalogs config,
so any input lockfile that contains a catalogs snapshot will fail freshness and skip the frozen
short-circuit, forcing the server down the slower resolve path. This regresses a pnpr hot path for
frozen requests that use catalog: dependencies/catalog snapshots.
Code

pnpr/crates/pnpr/src/resolver/resolve.rs[R276-287]

+        LockfileSettingsCheck {
+            catalogs: &Catalogs::new(),
+            overrides: None,
+            package_extensions_checksum: None,
+            ignored_optional_dependencies: None,
+            patched_dependencies: None,
+            auto_install_peers: config.auto_install_peers,
+            dedupe_peers: config.dedupe_peers,
+            exclude_links_from_lockfile: config.exclude_links_from_lockfile,
+            inject_workspace_packages: config.inject_workspace_packages,
+            peers_suffix_max_length: config.peers_suffix_max_length,
+        },
Relevance

⭐⭐ Medium

Potential real hot-path regression, but no clear precedent on catalogs handling in pnpr frozen
fast-path.

PR-#13233

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The fast-path uses &Catalogs::new() (empty) even though the request may include catalogs and the
main resolve path forwards them; check_lockfile_settings compares catalogs first and will treat
any snapshot entry as stale if the config is empty (missing key lookup).

pnpr/crates/pnpr/src/resolver/resolve.rs[229-233]
pnpr/crates/pnpr/src/resolver/resolve.rs[248-289]
pnpr/crates/pnpr/src/resolver/protocol.rs[72-85]
pnpm/crates/lockfile/src/freshness.rs[343-348]

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

### Issue description
`fresh_frozen_input_lockfile()` passes `catalogs: &Catalogs::new()` into `LockfileSettingsCheck`. After this PR, `check_lockfile_settings()` validates `lockfile.catalogs` snapshots against the provided catalogs config first; passing an empty config makes catalogs-bearing lockfiles look stale and disables the frozen-input short-circuit.

### Issue Context
The request already carries the effective catalogs via `ResolveRequest.catalogs`, and the resolver path forwards them into the install (`catalogs_override: request.catalogs.clone()`). The fast-path freshness check should use the same effective catalogs.

### Fix Focus Areas
- pnpr/crates/pnpr/src/resolver/resolve.rs[248-289]

### Suggested fix
In `fresh_frozen_input_lockfile`, derive a `&Catalogs` from `request.catalogs` (fallback to an empty local `Catalogs::new()`), and pass that reference into `LockfileSettingsCheck.catalogs` instead of `&Catalogs::new()`.

Example sketch:
```rust
let empty = Catalogs::new();
let catalogs = request.catalogs.as_ref().unwrap_or(&empty);
check_lockfile_settings(lockfile, LockfileSettingsCheck { catalogs, ... });
```

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



Remediation recommended

3. Unsafe YAML append in test ✓ Resolved 🐞 Bug ☼ Reliability
Description
The new E2E test appends autoInstallPeers: false to pnpm-workspace.yaml via string concatenation
without guarding for a missing trailing newline, which can produce invalid YAML if the existing file
ever stops ending with \n. The repo already has a helper that handles this case and should be used
for consistency and future-proofing.
Code

pnpm/crates/cli/tests/lockfile_only.rs[R128-131]

+    let workspace_yaml = workspace.join("pnpm-workspace.yaml");
+    let yaml = fs::read_to_string(&workspace_yaml).expect("read pnpm-workspace.yaml");
+    fs::write(&workspace_yaml, format!("{yaml}autoInstallPeers: false\n"))
+        .expect("flip autoInstallPeers");
Relevance

⭐⭐⭐ High

Precedent accepted: tests appending to pnpm-workspace.yaml were hardened to ensure trailing newline
before append.

PR-#13081

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The test performs a raw append without newline normalization, while the repository’s existing helper
explicitly guards !yaml.ends_with('\n') before appending. A past accepted bug documents this exact
failure mode when appending YAML without ensuring a trailing newline.

pnpm/crates/cli/tests/lockfile_only.rs[126-131]
pnpm/crates/cli/tests/_utils/mod.rs[79-96]
PR-#13081

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 test appends a YAML key by concatenating strings without ensuring the existing YAML ends with a newline. If the harness-written `pnpm-workspace.yaml` ever lacks a trailing `\n`, the appended key will join onto the last line and corrupt the YAML.

### Issue Context
There is already a shared helper `append_workspace_yaml_key()` that (1) asserts the key doesn’t already exist and (2) adds a newline when missing.

### Fix Focus Areas
- pnpm/crates/cli/tests/lockfile_only.rs[115-152]
- pnpm/crates/cli/tests/_utils/mod.rs[79-96]

### Suggested fix
In `lockfile_only.rs`, import the shared `_utils::append_workspace_yaml_key` (like other test files do via `pub mod _utils;`) and replace the manual read/format/write with:
```rust
append_workspace_yaml_key(&workspace, "autoInstallPeers", false);
```
(or replicate the helper’s newline guard locally if you intentionally don’t want the helper).

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



Informational

4. Hardcoded /tmp in test 🐞 Bug ☼ Reliability ⭐ New
Description
The new test uses fixed /tmp/... paths for StoreDir and cache_dir, which can cause cross-test
interference if future changes start touching the filesystem or if tests run in parallel with shared
state. Using a per-test temp directory avoids hidden coupling and keeps tests hermetic.
Code

pnpr/crates/pnpr/src/resolver/tests.rs[R1055-1058]

+    let configs = Mutex::new(HashMap::new());
+    let store_dir = StoreDir::new(PathBuf::from("/tmp/pnpr-lockfile-settings-store"));
+    let cache_dir = PathBuf::from("/tmp/pnpr-lockfile-settings-cache");
+    let request = |settings: Option<pacquet_lockfile::LockfileSettings>| ResolveRequest {
Relevance

⭐ Low

Very close precedent: request to replace hardcoded /tmp paths in intern_config tests with tempdir
was rejected.

PR-#12674

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The test introduces fixed /tmp paths; while StoreDir::new itself is path-only today, hardcoded
global paths are a known source of non-hermetic tests if any I/O is later introduced.

pnpr/crates/pnpr/src/resolver/tests.rs[1055-1058]
pnpm/crates/store-dir/src/store_dir.rs[101-105]

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 test `intern_config_adopts_the_input_lockfile_settings` hardcodes `/tmp/pnpr-lockfile-settings-*` paths.

### Issue Context
`StoreDir::new` currently just wraps the path (no I/O), but using global fixed paths is fragile and can become flaky if downstream code starts creating/reading these directories.

### Fix Focus Areas
- pnpr/crates/pnpr/src/resolver/tests.rs[1055-1058]

### Suggested fix approach
Use `tempfile::tempdir()` and derive `store_dir` and `cache_dir` from it, e.g.:
- `let temp = tempfile::tempdir()?;`
- `let store_dir = StoreDir::new(temp.path().join("store"));`
- `let cache_dir = temp.path().join("cache");`
Keep the `TempDir` alive for the test scope.

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


5. Comment says predates the field ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
A newly added comment/test doc comment uses historical phrasing ("predates the field") instead of
stating the current behavior/contract (e.g., that the setting is unchecked when settings is
absent). This makes the comment read like a history note rather than a present-tense invariant and
violates the no-historical-comments requirement.
Code

pnpm/crates/lockfile/src/freshness.rs[R397-400]

+    // A lockfile with no `settings` block predates the field and says
+    // nothing about the setting it was written under, so it can't drift
+    // — pnpm's `lockfile.settings?.autoInstallPeers != null` guard.
+    if let Some(settings) = lockfile.settings.as_ref()
Relevance

⭐ Low

Precedent: request to remove historical phrasing in test/doc comments was rejected; likely same
here.

PR-#13359

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 772199 forbids historical/temporal phrasing in comments and requires them to
describe current behavior/contracts. The cited comment in
pnpm/crates/lockfile/src/freshness.rs[397-400] explicitly says the lockfile "predates the field,"
and the new test doc comment in pnpm/crates/lockfile/src/freshness/tests.rs[1328-1330] uses the
same temporal framing, making both history-oriented rather than documenting present behavior (such
as the setting being unchecked when settings is absent).

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/lockfile/src/freshness.rs[397-400]
pnpm/crates/lockfile/src/freshness/tests.rs[1328-1330]

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 newly added comment and a newly added test doc comment use historical/temporal phrasing ("predates the field") instead of documenting the current behavior/contract. Update the wording so it reads as a present-tense statement of the invariant (e.g., that the setting is unchecked when `settings` is absent), in line with the no-historical-comments requirement.

## Issue Context
PR Compliance ID 772199 requires comments to describe current behavior/contracts and disallows history-oriented explanations about what the code/format "used to" do. The current phrasing makes the comments sound like implementation/format history rather than a clear statement of today’s expected behavior.

## Fix Focus Areas
- pnpm/crates/lockfile/src/freshness.rs[397-400]
- pnpm/crates/lockfile/src/freshness/tests.rs[1328-1330]

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


6. Changeset missing pnpm entry 📘 Rule violation § Compliance
Description
The new changeset only declares a bump for pacquet and omits pnpm, violating the requirement to
explicitly include pnpm with an appropriate bump type. This can cause releases to miss the
user-visible pnpm behavior change described in the changeset text.
Code

.changeset/frozen-install-checks-drifted-settings.md[R1-3]

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

⭐ Low

Close match precedent: bot request to add required pnpm entry to pacquet-only changeset was
rejected.

PR-#13349

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires changeset front-matter to contain an explicit pnpm entry with a
valid bump type. The added changeset front-matter contains only "pacquet": patch, so it does not
meet the rule.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/frozen-install-checks-drifted-settings.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 changeset front-matter is missing an explicit `pnpm` entry.

## Issue Context
Compliance requires changesets to explicitly include `pnpm` with a valid bump type (`patch`/`minor`/`major`). This changeset currently lists only `pacquet`.

## Fix Focus Areas
- .changeset/frozen-install-checks-drifted-settings.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 51af0b2

Results up to commit bb20652 ⚖️ Balanced


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


Action required
1. Catalogs fast-path disabled ✓ Resolved 🐞 Bug ➹ Performance
Description
pnpr::fresh_frozen_input_lockfile now calls check_lockfile_settings with an empty catalogs config,
so any input lockfile that contains a catalogs snapshot will fail freshness and skip the frozen
short-circuit, forcing the server down the slower resolve path. This regresses a pnpr hot path for
frozen requests that use catalog: dependencies/catalog snapshots.
Code

pnpr/crates/pnpr/src/resolver/resolve.rs[R276-287]

+        LockfileSettingsCheck {
+            catalogs: &Catalogs::new(),
+            overrides: None,
+            package_extensions_checksum: None,
+            ignored_optional_dependencies: None,
+            patched_dependencies: None,
+            auto_install_peers: config.auto_install_peers,
+            dedupe_peers: config.dedupe_peers,
+            exclude_links_from_lockfile: config.exclude_links_from_lockfile,
+            inject_workspace_packages: config.inject_workspace_packages,
+            peers_suffix_max_length: config.peers_suffix_max_length,
+        },
Relevance

⭐⭐ Medium

Potential real hot-path regression, but no clear precedent on catalogs handling in pnpr frozen
fast-path.

PR-#13233

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The fast-path uses &Catalogs::new() (empty) even though the request may include catalogs and the
main resolve path forwards them; check_lockfile_settings compares catalogs first and will treat
any snapshot entry as stale if the config is empty (missing key lookup).

pnpr/crates/pnpr/src/resolver/resolve.rs[229-233]
pnpr/crates/pnpr/src/resolver/resolve.rs[248-289]
pnpr/crates/pnpr/src/resolver/protocol.rs[72-85]
pnpm/crates/lockfile/src/freshness.rs[343-348]

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

### Issue description
`fresh_frozen_input_lockfile()` passes `catalogs: &Catalogs::new()` into `LockfileSettingsCheck`. After this PR, `check_lockfile_settings()` validates `lockfile.catalogs` snapshots against the provided catalogs config first; passing an empty config makes catalogs-bearing lockfiles look stale and disables the frozen-input short-circuit.

### Issue Context
The request already carries the effective catalogs via `ResolveRequest.catalogs`, and the resolver path forwards them into the install (`catalogs_override: request.catalogs.clone()`). The fast-path freshness check should use the same effective catalogs.

### Fix Focus Areas
- pnpr/crates/pnpr/src/resolver/resolve.rs[248-289]

### Suggested fix
In `fresh_frozen_input_lockfile`, derive a `&Catalogs` from `request.catalogs` (fallback to an empty local `Catalogs::new()`), and pass that reference into `LockfileSettingsCheck.catalogs` instead of `&Catalogs::new()`.

Example sketch:
```rust
let empty = Catalogs::new();
let catalogs = request.catalogs.as_ref().unwrap_or(&empty);
check_lockfile_settings(lockfile, LockfileSettingsCheck { catalogs, ... });
```

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



Remediation recommended
2. Unsafe YAML append in test ✓ Resolved 🐞 Bug ☼ Reliability
Description
The new E2E test appends autoInstallPeers: false to pnpm-workspace.yaml via string concatenation
without guarding for a missing trailing newline, which can produce invalid YAML if the existing file
ever stops ending with \n. The repo already has a helper that handles this case and should be used
for consistency and future-proofing.
Code

pnpm/crates/cli/tests/lockfile_only.rs[R128-131]

+    let workspace_yaml = workspace.join("pnpm-workspace.yaml");
+    let yaml = fs::read_to_string(&workspace_yaml).expect("read pnpm-workspace.yaml");
+    fs::write(&workspace_yaml, format!("{yaml}autoInstallPeers: false\n"))
+        .expect("flip autoInstallPeers");
Relevance

⭐⭐⭐ High

Precedent accepted: tests appending to pnpm-workspace.yaml were hardened to ensure trailing newline
before append.

PR-#13081

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The test performs a raw append without newline normalization, while the repository’s existing helper
explicitly guards !yaml.ends_with('\n') before appending. A past accepted bug documents this exact
failure mode when appending YAML without ensuring a trailing newline.

pnpm/crates/cli/tests/lockfile_only.rs[126-131]
pnpm/crates/cli/tests/_utils/mod.rs[79-96]
PR-#13081

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 test appends a YAML key by concatenating strings without ensuring the existing YAML ends with a newline. If the harness-written `pnpm-workspace.yaml` ever lacks a trailing `\n`, the appended key will join onto the last line and corrupt the YAML.

### Issue Context
There is already a shared helper `append_workspace_yaml_key()` that (1) asserts the key doesn’t already exist and (2) adds a newline when missing.

### Fix Focus Areas
- pnpm/crates/cli/tests/lockfile_only.rs[115-152]
- pnpm/crates/cli/tests/_utils/mod.rs[79-96]

### Suggested fix
In `lockfile_only.rs`, import the shared `_utils::append_workspace_yaml_key` (like other test files do via `pub mod _utils;`) and replace the manual read/format/write with:
```rust
append_workspace_yaml_key(&workspace, "autoInstallPeers", false);
```
(or replicate the helper’s newline guard locally if you intentionally don’t want the helper).

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



Informational
3. Changeset missing pnpm entry 📘 Rule violation § Compliance
Description
The new changeset only declares a bump for pacquet and omits pnpm, violating the requirement to
explicitly include pnpm with an appropriate bump type. This can cause releases to miss the
user-visible pnpm behavior change described in the changeset text.
Code

.changeset/frozen-install-checks-drifted-settings.md[R1-3]

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

⭐ Low

Close match precedent: bot request to add required pnpm entry to pacquet-only changeset was
rejected.

PR-#13349

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires changeset front-matter to contain an explicit pnpm entry with a
valid bump type. The added changeset front-matter contains only "pacquet": patch, so it does not
meet the rule.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/frozen-install-checks-drifted-settings.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 changeset front-matter is missing an explicit `pnpm` entry.

## Issue Context
Compliance requires changesets to explicitly include `pnpm` with a valid bump type (`patch`/`minor`/`major`). This changeset currently lists only `pacquet`.

## Fix Focus Areas
- .changeset/frozen-install-checks-drifted-settings.md[1-3]

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


4. Comment says predates the field ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
A newly added comment/test doc comment uses historical phrasing ("predates the field") instead of
stating the current behavior/contract (e.g., that the setting is unchecked when settings is
absent). This makes the comment read like a history note rather than a present-tense invariant and
violates the no-historical-comments requirement.
Code

pnpm/crates/lockfile/src/freshness.rs[R397-400]

+    // A lockfile with no `settings` block predates the field and says
+    // nothing about the setting it was written under, so it can't drift
+    // — pnpm's `lockfile.settings?.autoInstallPeers != null` guard.
+    if let Some(settings) = lockfile.settings.as_ref()
Relevance

⭐ Low

Precedent: request to remove historical phrasing in test/doc comments was rejected; likely same
here.

PR-#13359

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 772199 forbids historical/temporal phrasing in comments and requires them to
describe current behavior/contracts. The cited comment in
pnpm/crates/lockfile/src/freshness.rs[397-400] explicitly says the lockfile "predates the field,"
and the new test doc comment in pnpm/crates/lockfile/src/freshness/tests.rs[1328-1330] uses the
same temporal framing, making both history-oriented rather than documenting present behavior (such
as the setting being unchecked when settings is absent).

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/lockfile/src/freshness.rs[397-400]
pnpm/crates/lockfile/src/freshness/tests.rs[1328-1330]

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 newly added comment and a newly added test doc comment use historical/temporal phrasing ("predates the field") instead of documenting the current behavior/contract. Update the wording so it reads as a present-tense statement of the invariant (e.g., that the setting is unchecked when `settings` is absent), in line with the no-historical-comments requirement.

## Issue Context
PR Compliance ID 772199 requires comments to describe current behavior/contracts and disallows history-oriented explanations about what the code/format "used to" do. The current phrasing makes the comments sound like implementation/format history rather than a clear statement of today’s expected behavior.

## Fix Focus Areas
- pnpm/crates/lockfile/src/freshness.rs[397-400]
- pnpm/crates/lockfile/src/freshness/tests.rs[1328-1330]

ⓘ 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.

The resolve protocol carries no `autoInstallPeers` / `dedupePeers` /
`excludeLinksFromLockfile`, so a request's interned config kept the
server's own defaults for them. Once the freshness gate compares those
three, a frozen request whose lockfile was written under any of them
non-default is rejected against settings its owner never chose — a
server default deciding a client's install (found in review).

The input lockfile records what it was written under, so the per-request
config adopts those values, keyed alongside the rest of the request so
two clients don't share one interned config. It also makes the server
resolve peers the way the client would, which the forwarded registries,
overrides, and catalogs already do for their part of the config.

While here: the frozen short-circuit checked the lockfile's `catalogs`
snapshot against an empty set, so every catalog-bearing lockfile looked
stale and lost the short-circuit. The request's catalogs are the
effective ones — the install below already resolves `catalog:` against
them — so the check uses them too.
Copilot AI review requested due to automatic review settings July 25, 2026 23:32

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 25, 2026
`append_workspace_yaml_key` already guards the case the hand-rolled
concatenation didn't: a `pnpm-workspace.yaml` not ending in a newline
would have glued the two keys into one line. It also asserts the harness
hasn't started writing the key itself, which would make the append a
duplicate mapping key.

The two comments about a lockfile without a `settings` block now state
what the code guarantees rather than why old lockfiles lack one.
Comment thread pnpr/crates/pnpr/src/resolver.rs Resolved
@qodo-code-review

Copy link
Copy Markdown

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

@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 25, 2026 23:38

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.

The interning key carried the whole `settings` block while the config
reads three of its fields, so a caller could vary the rest —
`peersSuffixMaxLength` is a `u64` — and mint a distinct leaked config
per value until `MAX_INTERNED_CONFIGS` was spent, at which point no
caller gets a config at all (found in review).

`AdoptedLockfileSettings` is now both what the key carries and what the
config takes, so the two can't drift apart again, and the settings block
contributes at most eight distinct keys.
@qodo-code-review

Copy link
Copy Markdown

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

@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 25, 2026 23:42
@coderabbitai coderabbitai Bot mentioned this pull request Aug 8, 2026
4 tasks done
@qodo-code-review qodo-code-review Bot mentioned this pull request Sep 19, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet product: pnpr reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants