Repository navigation
fix(lockfile): fail a frozen install when a recorded setting drifts - #13386
Conversation
`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.
|
Warning Review limit reached
Next review available in: 2 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughFrozen lockfile validation now detects drift in ChangesFrozen settings drift validation
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
PR Summary by Qodofix(lockfile): fail frozen installs when recorded settings drift
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
Confidence Score: 3/5The 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 |
Micro-Benchmark ResultsLinux |
Code Review by Qodo
Context used✅ Compliance rules (platform):
32 rules 1.
|
PR Code Suggestions ✨Warning
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.
`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.
|
Code review by qodo was updated up to the latest commit a449c6b |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
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.
|
Code review by qodo was updated up to the latest commit 8736926 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Summary
Closes the error-code half of item 1 of #13315 — with one field left over, filed as #13385.
pnpm's
getOutdatedLockfileSettingnames eleven fields whose drift makes a lockfile unreproducible, and refuses a frozen install withERR_PNPM_LOCKFILE_CONFIG_MISMATCHnaming 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:Same for
dedupePeersandexcludeLinksFromLockfile. The install went ahead against a lockfile whose recorded resolution no longer matched the settings that produced it —autoInstallPeersdecides whether peers are folded into the importer snapshot, andexcludeLinksFromLockfiledecides whetherlink:deps are recorded at all.Each comparison follows pnpm's exactly:
autoInstallPeersandexcludeLinksFromLockfileare checked only when the lockfile records asettingsblock, since a lockfile written before the field says nothing about it, whilededupePeersis written only while it is on, so an absent key reads asfalse.Order matters too
Only the first drifted field is reported, so the comparison order decides which name the user sees. pacquet checked
injectWorkspacePackageswhere pnpm checksautoInstallPeers, and pnpm checksinjectWorkspacePackageslast. 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 ahooksobject, so telling "no pnpmfile" from "a pnpmfile with no hooks" means evaluating it through the Node worker — oncheck_lockfile_settings_drift, which is sync and is also what the repeat-install fast path calls to stay cheap. WiringNonethere 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_configadopts 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
settingsblock would let a caller mint a distinct leaked config perpeersSuffixMaxLengthvalue and exhaustMAX_INTERNED_CONFIGS, after which no caller gets a config at all), and the frozen short-circuit now checks the lockfile'scatalogssnapshot 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_settingsnow 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 letcatalogsbe 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-lockfileinstall, which is the regression this class of check risks.Unit tests cover each new comparison, the "no
settingsblock 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 theautoInstallPeerscomparison fails it.cargo nextest runoverpacquet-lockfile(252),pacquet-package-manager(800),pacquet-cli+pnpr(2925), plus clippy,cargo doc, and dylint: clean.Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting.(TypeScript already refuses these installs; this is the pacquet side.)
pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Written by an agent (Claude Code, claude-opus-5).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
autoInstallPeers,dedupePeers, andexcludeLinksFromLockfile.