Repository navigation
Stop attesting a vendored pnpm package whose override no settings file declares - #2396
Mikola Lysenko (mikolalysenko) wants to merge 7 commits into
Conversation
Refs #2382. Empty commit that opens the draft pull request; the fix follows. Assisted-by: Claude Code
Two CLI tests for #2382 that fail on main. They vendor the pnpm fixture through the built binary and take the override out of the file the project's pnpm reads it from: both files with no pin, the workspace file under pnpm 11 and 12, package.json under pnpm 9. Real pnpm 8.15.9 to 12.23.0 then refuses a frozen install with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH, and a plain install puts the registry release back. On main `vendor --check` exits 0 and `vex` attests not_affected for each of those trees: the tests see (0, 1) where (1, 0) is right. Refs #2382. Assisted-by: Claude Code
pnpm installs a lock only when the lock's `overrides:` equal the ones its settings declare. With a vendored override missing from the file pnpm reads, a frozen install fails and a plain install takes the package from the registry again. Discovery read the vendored reference from the lock alone, so `vendor --check` verified such a tree and `vex` attested it. A vendored entry of the root lock is now a reference only while each override the lock records for its artifact is declared where the project's pnpm reads it: package.json for pnpm 9 and older, either file for pnpm 10 or when no file states the pnpm, the workspace file for pnpm 11 and newer. Those are the readings real pnpm 8.15.9, 9.15.9, 10.28.0, 11.29.0 and 12.23.0 showed. The pnpm is the one every other pnpm setting is read for. An undeclared entry is diagnosed patched_ref_invalid with the file that lacks the override and the remedy, and stays wiring to the prune GC. `vendor --check` fails it as "wiring incomplete" with that sentence, where it used to say no lockfile references the artifact. An entry the lock records no override for, and a Rush lock, are not asked. The lock-off reader and the new one share one read of the two override maps. docs/ecosystems.md states the rule. Fixes #2382. Assisted-by: Claude Code
A review of the last commit, run against real pnpm, showed trees it still verified although pnpm does not install them, and messages that were wrong: - pnpm 10.2.0, 10.4.1 and 10.5.0 read package.json alone; the workspace file is read from 10.5.1 on. The rule went by major and let every pnpm 10 read either file. - pnpm 10.28.0 reads a `pnpm.overrides` table of package.json in place of the workspace file's, so a table without the vendored entry hides the workspace declaration. - The install record outranked the committed pin, so a stale node_modules failed a tree a fresh checkout verified. The rule now lives beside the other pnpm pin readers, at release precision. A pin counts when every release it admits reads the same place; pins that disagree leave either file, as no pin does. A pre-9 lock and an env lockfile document still say which pnpm wrote them. A declaration the reader cannot follow (an inline `overrides:` mapping, a package.json that is not JSON) may hold the override, so the reference stands there as it did on main. The by-hand remedy is given only for a version 9 lock, where `vendor` skips package.json; the legacy backend always writes it. `vendor --check` finds its reason by the override wording, not by the first diagnostic that names the patch. Refs #2382. Assisted-by: Claude Code
A second review, run against real pnpm, showed where the last commit still disagreed with what pnpm installs: - An install record in node_modules decided alone. It is not committed, so one checkout failed a tree that CI verified. Only the pins package.json commits are read now, then the lock's own format. - Pins naming releases that read different places left either file, even where neither release reads it. Each stated source is kept, and a declaration counts when one of them reads it. - pnpm 9.15.9 and 10.28.0 read the top-level `resolutions` as overrides (11.29.0 does not), and 10.5.1 and 10.28.0 read the workspace file beside an empty `pnpm.overrides` table. package.json now declares what `pnpm.overrides` over `resolutions` holds, and declares nothing when that is empty. The by-hand remedy asks the backend's own predicate for when a re-run writes no package.json table, so the message says "re-run" only where a re-run helps. Refs #2382. Assisted-by: Claude Code
A third review pass found three more gaps, each checked before it
was fixed:
- With overrides declared through `resolutions` alone, pnpm 10.28.0
reads package.json, and a re-run of `vendor` writes nothing there
(it looks for a `pnpm.overrides` table). The message said to
re-run. It now gives the entry to add whenever the re-run would
declare the override only where no pnpm the project names reads
it. Checked on real pnpm 10.28.0: the re-run is idle, and after
the entry is added the frozen install is patched.
- An empty inline `overrides: {}` (or a null) in the workspace file
switched the check off as unreadable. It declares nothing.
- A package.json or workspace file that is there and cannot be read
was taken for one that declares nothing. The reference stands
there, as for one that does not parse.
Refs #2382.
Assisted-by: Claude Code
|
bugbot run Generated by Claude Code |
PR SummaryMedium Risk Overview Discovery adds Adds Reviewed by Cursor Bugbot for commit d303c0b. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit d303c0b. Configure here.
Cursor Bugbot's finding, reproduced with the binary: with an empty
inline `overrides: {}` (or a null) in pnpm-workspace.yaml, the
message said to re-run `vendor`, and the re-run refuses to edit an
inline mapping. The user learned what to do only from that second
error.
The remedy now says to take the empty inline `overrides:` out first.
Checked on real pnpm 11.29.0: after that the re-run declares the
override, `vendor --check` passes and the frozen install is patched.
Refs #2382.
Assisted-by: Claude Code
|
[agent] PR shepherd: review brief for the approver What it does. A vendored pnpm package used to count as patched whenever Risk: medium. No install or build path changes. But Look here
Verified
Changes I made: none. Open questions: none blocking. One for product: release notes should mention that Generated by Claude Code |

LLM Description written by Claude Code
Fixes #2382.
Problem
pnpm installs a lock only when the lock's
overrides:equal the overrides its settings declare. With a vendored override missing from the place the project's pnpm reads, every frozen install fails withERR_PNPM_LOCKFILE_CONFIG_MISMATCH, and a plainpnpm installtakes the package from the registry again and rewrites the lock.vendor --checkandvexread the vendored reference from the lock alone, so both called such a package patched. Who it hurts: anyone who ships the VEX document, or gates CI onvendor --check.A project gets there without a hand edit of a wiring file: a
pnpm-workspace.yamlleft out of the commit (it is a new file after the first vendored run), apackage.jsonput back by a merge, or a move from pnpm 9 to 11.Evidence on
main(1b3f422)Real pnpm with
left-pad1.3.0 and a stand-in patch record, the treevendorwrote, then the override taken out of one place. Onmainevery row isvendor --checkexit 0 andvexnot_affected.mainERR_PNPM_LOCKFILE_CONFIG_MISMATCHpnpm-workspace.yamlonlypnpm.overridestable of the project's ownpackage.jsononlyThe two CLI tests of the first commit fail on
main(cargo test -p socket-patch-cli --test vendor_pnpm_override_e2e):The four unit tests fail the same way with the new check switched off at its call site (
left: [(pkg:npm/left-pad@1.3.0, …, Vendored)],right: []).Fix
One rule, in core pnpm discovery, which
vexandvendor --checkboth read: a vendored entry of the root lock is a reference only while each override the lock records for its artifact is declared where the project's pnpm reads it.package.jsonalonepackage.jsonwhen it declares any, elsepnpm-workspace.yamlpnpm-workspace.yamlalonepackage.jsondeclarespnpm.overridesover the top-levelresolutions(9.15.9 and 10.28.0 readresolutions, 11.29.0 does not); an empty table declares nothing (10.5.1, 10.28.0).package.jsoncommits (packageManager,devEngines,engines.pnpm), each counted when every release it admits reads the same place, else from the lock (a pre-9 lock, an env lockfile document). With no pin, either file counts. With pins that name different places, a declaration counts when one of them reads it. The install record innode_modulesis not read, so a commit gets the same verdict on every machine.patched_ref_invalidwith the file that lacks the override and the remedy, and is no reference; it stays wiring to the prune GC, which would otherwise revert it.vendor --checkfails it aswiring incomplete: <that sentence>.overrides:mapping with entries, apackage.jsonthat is not JSON, a file that cannot be read). Those stand as onmain.With this branch, 22 trees on those nine pnpm releases, each pinned by
packageManager: wherever real pnpm refuses the lock,vendor --checkexits 1 andvexattests nothing; wherever it installs the patched copy, both pass. Where the message says to re-runvendor, the re-run restored the declaration, the check passed and real pnpm installed the patched copy.What was deleted
Nothing is removed. The lock-off reader's read of the two override maps became the shared
PnpmOverrideMaps, and the writer's inline-overrides:test became a predicate both sides call.Behavior change
vexomits a vendored pnpm package whose override is undeclared (patched_ref_invalidandvendor_unwiredwarnings). When that leaves nothing to attest it exits 1 with "No applied patches…", as it does onmainfor any project with nothing to attest.vendor --checkexits 1 for such a package, with the message above wheremainsaid "verified".list,rollback,remove,repair,vendor --revertandvendor --dry-runprint the same asmainon such a tree (run with both binaries).package.jsonnames the pnpm.Risk
vendor --checkthat passed onmaincan now fail in CI. Every case found is a tree real pnpm does not install. The lenient sides (no pin, unreadable declaration, disagreeing pins) are there so that it fails only on what the files prove.package.jsonand the override is left only in the workspace file, a re-run ofvendorwrites nopnpm.overridestable (it treats the workspace file as the one pnpm reads), so the message gives the entry to add. Checked on pnpm 9.15.9 and 10.28.0: the re-run is idle, and after the entry is added the check passes and the frozen install is patched.cfg(windows)orcfg(unix)code changed.Review
Three passes of
/code-review high, then Cursor Bugbot. Every finding was run against real pnpm, or against the binary, before it was fixed; the last four commits say which each one fixes. The first pass found the rule too coarse (pnpm 10.0 to 10.5.0 readpackage.jsonalone; apnpm.overridestable hides the workspace file on pnpm 10) and three wrong messages. The second found the install record deciding alone, disagreeing pins accepting a file neither pnpm reads,resolutionsand the empty table. The third found a "re-run" remedy that cannot work beside aresolutionstable, an empty inlineoverrides: {}switching the check off, and an unreadable file read as "declares nothing". Bugbot found one more remedy that did not work as stated: beside an empty inlineoverrides: {}the re-run refuses to edit the mapping, so the message now says to take it out first (checked on real pnpm 11.29.0). Its thread is answered and resolved. Left as they are:PnpmLockOff::routes): with pnpm'slockfilesetting off it accepts a workspace override for every pnpm 10. Onmaintoo, and not changed here. Measured since, with the lock off, on real pnpm 10.4.1, 10.5.0 and 10.28.0: pnpm installs the upstream release with exit 0 andvexattests, with this branch's binary as withmain's. Filed as With pnpm's lockfile off,vexattests a vendored package through apnpm-workspace.yamloverride its pnpm 10 does not read:pnpm installputs the upstream release back and exits 0 #2403, to follow this PR.vendordoes not restore apackage.jsonoverride while the workspace file carries one the lock records (pnpm older than 10.5.1, or a project that declares overrides throughresolutions). The writer's inference is deliberate for pnpm 10.5.1+ (a new table would replace the user's workspace overrides), and telling the cases apart needs the pin reader in the writer. The message gives the by-hand entry meanwhile; checked on 9.15.9 and 10.28.0.vendor --dry-runstill previews "already vendored" over such a tree, while the wet run rewrites the declaration. Onmaintoo.file:./.socket/…forfile:.socket/…) still verifies. Measured since on real pnpm 9.15.9, 10.28.0 and 11.29.0: pnpm does compare the strings, so a frozen install fails withERR_PNPM_LOCKFILE_CONFIG_MISMATCH, and the plain install installs the patched copy and rewrites only the lock'soverrides:line. No unpatched copy installs, so the statement holds;vendorwrites one spelling to all three places.vendor_prebuilt_requiredinstead. Both are refusals.overrides:to the lock and the workspace file as well; its references are not checked this way. Measured since on real pnpm 11.29.0 and 12.23.0: with the override gone from the workspace filevexattests, a frozen install fails and a plain install puts the upstream release back. Filed asvexattests a hosted pnpm package on the registry route after its override leavespnpm-workspace.yaml: frozen installs fail and a plain install puts the upstream release back #2404, to follow this PR.CLI_CONTRACT.mdis not touched because two open agent PRs (#2390, #2392) change it. The sentence for its pnpm lock row: "A vendored reference whose override the lock records is a reference only while the project declares that override where its pnpm reads it (patched_ref_invalidotherwise;vendor --checkreportswiring incomplete)".docs/ecosystems.mdhas the rule in full.Checks
cargo clippy --locked --workspace --all-features -- -D warnings: clean.vendor_pnpm_override_e2e(new),cli,in_process_vendor, the twoin_process_vendor_pnpm_*,in_process_vendor_bun_takeover,in_process_pnpm_registry_cleanup,in_process_redirect_pnpm,in_process_get_modes,scan,in_process_scan,scan_vendor_e2e,rollback,remove,user_patches,e2e_vex,e2e_vex_vendor,e2e_vex_redirect,e2e_vendor_rush,e2e_vendor_pnpm_build,e2e_vendored_production,hosted_memory_engine,hosted_memory_parity,vendor_ledger_schema_e2e,vendor_group_commit_e2e,vendor_revert_tamper_e2e: all passed.in_process_redirect: 135 passed; its 3 chmod tests fail as root in the sandbox, onmaintoo.Diff
8 files, +1448 −43: production +537 −43 (core
vex/discover/npm.rs+333 −30,formats/pnpm/version.rs+94 −1,vendor/pnpm_lock.rs+46 −9,vex/discover/mod.rs+38 −1,formats/pnpm/mod.rs+17 −2, CLIcommands/vendor.rs+9), tests +885 (unit +654, CLI +231), docs +26.https://claude.ai/code/session_011f9aeTFFymq2ZUPFLmHzAa
Generated by Claude Code