Skip to content

Stop attesting a vendored pnpm package whose override no settings file declares - #2396

Open
Mikola Lysenko (mikolalysenko) wants to merge 7 commits into
mainfrom
arch-refactor/2382-pnpm-override-confirms-vendored
Open

Mikola Lysenko (mikolalysenko) wants to merge 7 commits into
mainfrom
arch-refactor/2382-pnpm-override-confirms-vendored

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

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 with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH, and a plain pnpm install takes the package from the registry again and rewrites the lock. vendor --check and vex read 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 on vendor --check.

A project gets there without a hand edit of a wiring file: a pnpm-workspace.yaml left out of the commit (it is a new file after the first vendored run), a package.json put back by a merge, or a move from pnpm 9 to 11.

Evidence on main (1b3f422)

Real pnpm with left-pad 1.3.0 and a stand-in patch record, the tree vendor wrote, then the override taken out of one place. On main every row is vendor --check exit 0 and vex not_affected.

pnpm Override declared in Frozen install Plain install main
8.15.9, 9.15.9 nowhere ERR_PNPM_LOCKFILE_CONFIG_MISMATCH upstream, lock unwired verified, attested
9.15.9, 10.2.0, 10.4.1, 10.5.0 pnpm-workspace.yaml only the same error upstream verified, attested
10.5.1, 10.28.0 nowhere the same error upstream verified, attested
10.28.0 the workspace file, beside a pnpm.overrides table of the project's own the same error upstream verified, attested
11.29.0, 12.23.0 package.json only the same error upstream verified, attested

The two CLI tests of the first commit fail on main (cargo test -p socket-patch-cli --test vendor_pnpm_override_e2e):

a_lock_whose_override_no_file_declares_is_not_verified
  (vendor --check exit code, not_affected statements)
  pkg:npm/alpha@1.0.0: committed artifact and wiring verified
  pkg:npm/beta@1.0.0: committed artifact and wiring verified
  Emitted 1 VEX statement
  left: (0, 1)   right: (1, 0)
the_override_counts_only_where_the_projects_pnpm_reads_it
  pnpm Some("11.29.0") without the override in pnpm-workspace.yaml
  left: (0, 1)   right: (1, 0)

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 vex and vendor --check both 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.

pnpm Reads overrides from Measured on
older than 10.5.1 package.json alone 8.15.9, 9.15.9, 10.2.0, 10.4.1, 10.5.0
10.5.1 to 10.x package.json when it declares any, else pnpm-workspace.yaml 10.5.1, 10.5.2, 10.6.0, 10.9.0, 10.13.1, 10.20.0, 10.28.0
11 and newer pnpm-workspace.yaml alone 11.29.0, 12.23.0
  • package.json declares pnpm.overrides over the top-level resolutions (9.15.9 and 10.28.0 read resolutions, 11.29.0 does not); an empty table declares nothing (10.5.1, 10.28.0).
  • The pnpm comes from the pins package.json commits (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 in node_modules is not read, so a commit gets the same verdict on every machine.
  • An undeclared entry is diagnosed patched_ref_invalid with 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 --check fails it as wiring incomplete: <that sentence>.
  • Not asked: an entry the lock records no override for, a Rush lock, and a declaration the reader cannot follow (an inline overrides: mapping with entries, a package.json that is not JSON, a file that cannot be read). Those stand as on main.

With this branch, 22 trees on those nine pnpm releases, each pinned by packageManager: wherever real pnpm refuses the lock, vendor --check exits 1 and vex attests nothing; wherever it installs the patched copy, both pass. Where the message says to re-run vendor, the re-run restored the declaration, the check passed and real pnpm installed the patched copy.

$ socket-patch vendor --check        # pnpm 11.29.0, pnpm-workspace.yaml not committed; exit 1
pkg:npm/left-pad@1.3.0: wiring incomplete: pnpm-lock.yaml: the lock records the override `left-pad@1.3.0` for pkg:npm/left-pad@1.3.0 (.socket/vendor/npm/11111111-…/left-pad-1.3.0.tgz), but pnpm-workspace.yaml `overrides` does not declare it, and that is the only place this project's pnpm (pnpm@11.29.0 (package.json packageManager)) reads overrides from. pnpm installs a lock only when its `overrides:` equal the declared ones: a frozen install fails (ERR_PNPM_LOCKFILE_CONFIG_MISMATCH) and a plain `pnpm install` takes the package from the registry again; not counted. Re-run `socket-patch vendor` to declare it again, and commit the files it changes

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

  • vex omits a vendored pnpm package whose override is undeclared (patched_ref_invalid and vendor_unwired warnings). When that leaves nothing to attest it exits 1 with "No applied patches…", as it does on main for any project with nothing to attest.
  • vendor --check exits 1 for such a package, with the message above where main said "verified".
  • No flag, default, JSON shape or file format changes, and no command writes anything new. list, rollback, remove, repair, vendor --revert and vendor --dry-run print the same as main on such a tree (run with both binaries).
  • A project with no pnpm pin is judged leniently (either file), so the pnpm 9 to 11 upgrade is caught once package.json names the pnpm.

Risk

  • A vendor --check that passed on main can 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.
  • One remedy is by hand: where the project's pnpm reads package.json and the override is left only in the workspace file, a re-run of vendor writes no pnpm.overrides table (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.
  • No cfg(windows) or cfg(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 read package.json alone; a pnpm.overrides table 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, resolutions and the empty table. The third found a "re-run" remedy that cannot work beside a resolutions table, an empty inline overrides: {} 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 inline overrides: {} 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:

  • The lock-off reader still goes by major (PnpmLockOff::routes): with pnpm's lockfile setting off it accepts a workspace override for every pnpm 10. On main too, 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 and vex attests, with this branch's binary as with main's. Filed as With pnpm's lockfile off, vex attests a vendored package through a pnpm-workspace.yaml override its pnpm 10 does not read: pnpm install puts the upstream release back and exits 0 #2403, to follow this PR.
  • vendor does not restore a package.json override while the workspace file carries one the lock records (pnpm older than 10.5.1, or a project that declares overrides through resolutions). 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-run still previews "already vendored" over such a tree, while the wet run rewrites the declaration. On main too.
  • A declared override is matched by its artifact, not by its spelling. A hand-respelled entry (file:./.socket/… for file:.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 with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH, and the plain install installs the patched copy and rewrites only the lock's overrides: line. No unpatched copy installs, so the statement holds; vendor writes one spelling to all three places.
  • An unserved newer patch no longer reports "kept the vendored patch" over an entry whose override is undeclared: the entry is dead to that gate as an orphaned yarn berry entry is, and the run reports vendor_prebuilt_required instead. Both are refusals.
  • Hosted mode's registry route writes 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 file vex attests, a frozen install fails and a plain install puts the upstream release back. Filed as vex attests a hosted pnpm package on the registry route after its override leaves pnpm-workspace.yaml: frozen installs fail and a plain install puts the upstream release back #2404, to follow this PR.

CLI_CONTRACT.md is 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_invalid otherwise; vendor --check reports wiring incomplete)". docs/ecosystems.md has the rule in full.

Checks

  • cargo clippy --locked --workspace --all-features -- -D warnings: clean.
  • Core lib: 8669 passed. CLI lib: 1083 passed.
  • CLI suites vendor_pnpm_override_e2e (new), cli, in_process_vendor, the two in_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, on main too.

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, CLI commands/vendor.rs +9), tests +885 (unit +654, CLI +231), docs +26.

https://claude.ai/code/session_011f9aeTFFymq2ZUPFLmHzAa


Generated by Claude Code

Refs #2382. Empty commit that opens the draft pull request; the fix
follows.

Assisted-by: Claude Code
@mikolalysenko Mikola Lysenko (mikolalysenko) added arch-refactor PR opened by the scheduled architecture refactor routine refactor Structural change: duplicated code or logic, missing abstraction, layering, dead code labels Dec 1, 2026
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
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review December 1, 2026 07:05
@mikolalysenko

Mikola Lysenko (mikolalysenko) commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator Author

bugbot run


Generated by Claude Code

@cursor

cursor Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes verification and VEX output for pnpm vendored trees—CI that passed vendor --check on mismatched override declarations will now fail, though that matches real pnpm install behavior.

Overview
pnpm vendored patches are no longer treated as wired when pnpm-lock.yaml records an override that is missing from the settings file(s) that project's pnpm actually reads—where older vendor --check and vex still looked only at the lock.

Discovery adds confirm_pnpm_overrides, which compares lock overrides: to package.json (pnpm.overrides / resolutions) and pnpm-workspace.yaml, using OverrideSource and pinned pnpm version to pick the authoritative file (pre-10.5.1 manifest only; 10.5.1–10.x manifest-or-workspace; 11+ workspace). Undeclared entries become patched_ref_invalid / withheld wiring (still kept for prune), surfaced as wiring incomplete via pnpm_override_undeclared on vendor --check. vex stops emitting not_affected for those packages.

Adds vendor_pnpm_override_e2e and large unit coverage; docs/ecosystems.md documents the rule and remedies (re-run vendor or hand-add overrides where the writer skips package.json).

Reviewed by Cursor Bugbot for commit d303c0b. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief for the approver

What it does. A vendored pnpm package used to count as patched whenever pnpm-lock.yaml wired it, even when the override the lock records was no longer declared in the file the project's pnpm reads (package.json before 10.5.1, either file on 10.5.1–10.x, pnpm-workspace.yaml on 11+). pnpm refuses such a lock, or reinstalls from the registry. With this PR, vex leaves those entries out of the attestation and vendor --check fails them as wiring incomplete, naming the missing file and the fix. Prune GC still keeps the artifact.

Risk: medium. No install or build path changes. But vendor --check can now fail in a user's CI where it passed before. That is the intent (those trees really don't install the patch). A wrong guess about which pnpm the project uses could still fail a tree that installs fine. It holds back where it can't tell: with no pin, a declaration in either file counts, a pin range that spans a boundary is ignored, and an override file it can't parse skips the check.

Look here

Verified

  • Read the full diff.
  • OverrideSource::of uses inclusive upper bounds from version_bounds, so ^10.5.1 maps to the 10.x row and >=9 states nothing.
  • Member locks and Rush locks are handled as described, and the lock-off path is unchanged apart from moving onto the shared maps.
  • No debug code, no ignored tests, CHANGELOG.md untouched.
  • Ran cargo test -p socket-patch-core --lib pnpm_vendored (5 passed) and cargo test -p socket-patch-cli --test vendor_pnpm_override_e2e (9 passed).
  • CI on 82814cb: ci-ok and clippy green, no failing check. The one Bugbot thread is resolved.

Changes I made: none.

Open questions: none blocking. One for product: release notes should mention that vendor --check may start failing on trees whose pnpm override declaration has drifted.


Generated by Claude Code

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-refactor PR opened by the scheduled architecture refactor routine Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review refactor Structural change: duplicated code or logic, missing abstraction, layering, dead code

Projects

None yet

2 participants