Skip to content

Keep a vendored pnpm patch when pnpm 11.0.0 to 11.0.2 rewrite its lock entry without the tarball - #2434

Merged
Mikola Lysenko (mikolalysenko) merged 3 commits into
mainfrom
fix/pnpm-11-0-vendored-lock-rewrite
Dec 2, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 3 commits into
mainfrom
fix/pnpm-11-0-vendored-lock-rewrite

Conversation

@mikolalysenko

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

Copy link
Copy Markdown
Collaborator

Problem

The pinned pnpm matrix (pnpm hosted compatibility) fails on pnpm 11.0.0, on main, in one cell of the vendored suite. The cell puts pnpm-lock.yaml back as it was while the overrides stay, lets a plain pnpm install write the lock again, and expects vex to attest once more. On 11.0.0 vex exits 1 with vendor_unwired.

The workflow had been switched off since 2026-10-09, so the cell never ran on 11.0.0 in CI. It is on again, and this is its only failure: pnpm 1.0.0 to 8.15.9 and every other pnpm 9 to 12 pass.

Cause

vex is right. pnpm 11.0.0, 11.0.1 and 11.0.2 write the lock entry of a file: tarball without its tarball when they resolve it themselves:

# what the scan writes, and what every other pnpm writes back
resolution: {integrity: sha512-…, tarball: file:.socket/vendor/npm/<uuid>/minimist-1.2.2.tgz}
# what pnpm 11.0.0 to 11.0.2 write back
resolution: {integrity: sha512-…}

The installed tree still holds the patched files. But a frozen install of that lock from an empty store asks the registry for the release and fails on the vendored integrity (ERR_PNPM_TARBALL_INTEGRITY). It never installs the unpatched package, and it never installs the patched one either, so the lock wires nothing an install is sure to consume.

Measured with real pnpm against the production patch service (minimist@1.2.2):

pnpm lock it writes frozen install of that lock, empty store
11.0.0, 11.0.1, 11.0.2 no tarball fails, ERR_PNPM_TARBALL_INTEGRITY
11.0.3, 11.0.4, 11.0.9, 11.1.0, 11.2.0, 11.13.0, 11.27.0 keeps tarball installs the patched package
10.34.9, 12.0.0 keeps tarball installs the patched package

vex refusing is not a regression: the released 5.1.0 gives the same vendor_unwired for that lock.

A bug behind it

The lock reader took that entry for a file: directory of the user's, so nothing kept the vendored patch in use. Measured on pnpm 11.0.0 against the production patch service, on a checkout with no installed tree (a CI clone):

Command before with this PR
scan --mode vendored skips the patch as "no longer used by the lockfile", lock unchanged writes the entry back
scan --mode vendored --prune reverts the vendored patch (artifact and override removed) keeps it and writes the entry back

With an installed tree both builds write the entry back. So a project on pnpm 11.0.0 to 11.0.2 that let pnpm rewrite the lock and then ran a prune in CI lost its patch without being told.

Changes

  • The lock reader recognises the entry. A name@file:<vendored artifact> entry with an integrity and no tarball is the vendored entry, withheld: vex omits the patch (vendor_unwired), the prune keeps it, and the next vendored scan writes the entry back, with or without an installed tree. A file: directory dependency, which records no integrity, is read as before.
  • vendor --check gives the reader's reason. It used to say "no lockfile or config references" the artifact, so "a fresh install gets the unpatched package", and to re-run socket-patch vendor. None of that holds here: the lock still names the artifact, a fresh install fails instead, and a project vendored through scan --mode vendored has no manifest for vendor to read. It now says wiring incomplete, names the lock, the pnpm releases and what the install does, and points at scan --mode vendored as well as vendor. Other states keep their messages.
  • The cell tells the truth on 11.0.0 to 11.0.2. It checks that the lock pnpm rewrote has no tarball, that vex omits the patch with the patched tree installed and without it, and that a frozen install from an empty store fails for want of the tarball. Every other pnpm must still attest, and from pnpm 9 on must write the tarball.
  • The matrix pins the boundary and the newest releases. It gains 11.0.3 (the first release that keeps the tarball) next to 11.0.0, plus 11.29.0 and 12.25.1.
  • Docs. docs/ecosystems.md tells a user on those three releases what happens and how to get out of it; docs/testing/pnpm-compatibility.md records the measurement; the contract lists the new vendor --check reason.

Proof

  • Both real-pnpm suites, pinned legs, run locally on pnpm 9.0.0, 9.15.9, 10.0.0, 10.33.0, 10.34.5, 11.0.0, 11.0.3, 11.27.0, 11.29.0, 12.0.0, 12.4.2 and 12.25.1: all pass. The cell reports "not attested, pnpm rewrote the lock without the tarball" on 11.0.0 and "attested once reinstalled" on the other eleven.
  • A new offline test (pnpm_lock_entry_rewritten_without_its_tarball_is_not_attested) builds the lock both ways: with the tarball vex attests and vendor --check passes; without it vex omits the patch and vendor --check fails with the new reason. A lock resolved from the registry again gets the old message and no mention of a pnpm release.
  • A new unit test of the lock reader (pnpm_entry_without_its_tarball_is_dead_but_kept_by_the_prune_gc) pins that the entry is not live, is still in use for the prune, carries the reason, and that a file: directory is not taken for one.
  • cargo fmt --check, cargo clippy --locked --workspace --all-features -- -D warnings, the core unit tests (8,819), the CLI unit tests and the cli, cli_parse_vendor, command_module_layering and e2e_vex_vendor suites pass locally.
  • The compatibility workflow is dispatched on this branch; its result is the check to look at, since pnpm 1 to 8 on Node 10 and 16 only run there.

Code review

/code-review high ran on the first commit. It found that the first version of the vendor --check wording fired for any dead entry a pnpm lock still mentions, that the remedy it named did not work on a checkout with no installed tree, and that the prune reverted the patch there. The second commit fixes all three at the lock reader. Its smaller points are fixed too: the cell checks why the frozen install fails and runs vex with the tree installed, the texts agree on what the install does, and a git-branch lock is read like pnpm-lock.yaml.

For a maintainer

  • The workflow runs on a pull request only when the PR touches pnpm-named paths or these two suites, and it is not a required check. Whether it should be is your call.
  • Vendored mode still works on pnpm 11.0.0 to 11.0.2 until that pnpm rewrites the lock. The scan does not warn about those releases up front. A warning at scan time for a project pinned to one of them would be a small follow-up.

🤖 Generated with Claude Code

…lock entry

The pinned pnpm matrix failed on pnpm 11.0.0 in one cell of the vendored
suite: the lock is put back while the overrides stay, a plain `pnpm
install` writes it again, and `vex` was expected to attest once more. It
exits 1 with `vendor_unwired` there.

That verdict is right. pnpm 11.0.0 to 11.0.2 write the lock entry of a
`file:` tarball without its `tarball` when they resolve it themselves
(measured: 11.0.2 drops it, 11.0.3 keeps it, as do pnpm 9.0.0 to 10.34.9
and 12.0.0 on). The installed tree holds the patched bytes, but a frozen
install of that lock from an empty store asks the registry for the
release and fails on the vendored integrity (ERR_PNPM_TARBALL_INTEGRITY),
so the lock wires nothing an install is sure to consume. The released
5.1.0 answers the same way, and running the scan again writes the entry
back.

- The cell expects `vendor_unwired` on those three releases, after
  checking that the lock has no tarball and that a frozen install of it
  from an empty store fails. Every other pnpm must still attest.
- `vendor --check` said "no lockfile or config references" the artifact
  and that "a fresh install gets the unpatched package". Neither holds
  here: the lock still names it, and the install fails. It now reports
  `wiring incomplete`, names the lock and the pnpm releases, and points
  at `scan --mode vendored` as well as `vendor` (a project vendored
  through the scan has no manifest for `vendor` to read).
- The matrix gains 11.0.3 as the other side of the boundary, and 11.29.0
  and 12.25.1, the newest release of each line.

The matrix workflow had been switched off since 2026-10-09, so the cell
never ran on 11.0.0 in CI.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Review of the first commit found that its `vendor --check` wording fired
for any dead entry whose patch a pnpm lock still mentions, and that the
remedy it names did not always work. Both come from one place: the lock
reader took a `name@file:<artifact>` entry with an integrity and no
tarball (what pnpm 11.0.0 to 11.0.2 write) for a `file:` directory of the
user's. Nothing then kept the ledger entry:

- `scan --mode vendored` on a checkout with no installed tree skipped it
  as "no longer used by the lockfile" and left the lock as it was;
- `scan --mode vendored --prune` there reverted the vendored patch
  (measured against the production patch service on pnpm 11.0.0: the
  artifact and the override were removed).

The reader now recognises the entry by its key, withholds it, and says
why. So `vex` still omits the patch (`vendor_unwired`), `vendor --check`
reports the reader's own reason (`wiring incomplete`, naming the lock,
the pnpm releases and the remedy), the prune keeps the patch, and the
next vendored scan writes the entry back, with or without an installed
tree. A `file:` directory dependency, which records no integrity, is read
as before, and a lock that was resolved from the registry again gets the
old message and no mention of a pnpm release.

The real-pnpm cell also runs `vex` with the patched tree still installed,
and checks that the frozen install fails for want of the tarball.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mikolalysenko Mikola Lysenko (mikolalysenko) changed the title Expect vendor_unwired after pnpm 11.0.0 to 11.0.2 rewrite a vendored lock entry, and say why in vendor --check Keep a vendored pnpm patch when pnpm 11.0.0 to 11.0.2 rewrite its lock entry without the tarball Dec 2, 2026
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review December 2, 2026 03:28
@cursor

cursor Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes vendored pnpm lock discovery, prune retention, and vendor verification messaging—supply-chain patching paths—but scoped to a known pnpm version quirk with explicit diagnostics and tests.

Overview
pnpm 11.0.0–11.0.2 can rewrite a vendored file: lock entry so it keeps integrity but drops tarball: file:…. A frozen install then fails (ERR_PNPM_TARBALL_INTEGRITY) instead of pulling an unpatched registry build, but the lock still names the artifact—so older behavior misclassified the entry and could prune away the vendored patch in CI.

The pnpm lock reader now treats name@file:<vendored artifact> entries that have integrity and no tarball as withheld vendored wiring: vex omits attestation (vendor_unwired), scan --prune keeps the patch, and a vendored scan/vendor can rewrite the entry again. Plain file: directory deps without integrity are unchanged.

vendor --check surfaces this as wiring incomplete (lock named, pnpm versions, install behavior, re-run scan --mode vendored / vendor) instead of implying “no lock references” / unpatched install.

CI and tests add matrix pins 11.0.3, 11.29.0, 12.25.1; the vendored cell expects no attestation and failed frozen install on 11.0.0–11.0.2; new offline/unit tests lock the boundary. Docs and CLI_CONTRACT.md document the drift case.

Reviewed by Cursor Bugbot for commit c0e50d4. Configure here.

…d-lock-rewrite

# Conflicts:
#	crates/socket-patch-core/src/vex/discover/npm.rs
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief for the approver

What it does
pnpm 11.0.0 to 11.0.2 rewrite a vendored file: tarball lock entry without its tarball: field. The pnpm lock reader used to take that entry for the user's own file: directory, so scan --mode vendored --prune could revert the vendored patch without saying so.

Now such an entry is read as the vendored entry, withheld:

  • vex reports vendor_unwired.
  • The prune keeps the patch.
  • vendor --check names the gap.

The CI matrix gains pnpm 11.0.3, 11.29.0 and 12.25.1.

Risk
Low. The new branch runs only for an entry that meets all three conditions:

  • it has no tarball;
  • its file: key points into .socket/vendor/npm/<uuid>/;
  • it carries an integrity.

Every other entry takes the old path unchanged. The user-visible change is more conservative output (attest less, prune less).

Look here

  • [npm.rs:1992-2030](https://github.com/SocketDev/socket-patch/blob/0ab2c9bbc4f100ee8ac9a807b08c096237d7ac40/crates/socket-patch-core/src/vex/discover/npm.rs#L1992-L2030): the new no-tarball vendored branch in pnpm_entry_ref.
  • [discover/mod.rs:1826-1842](https://github.com/SocketDev/socket-patch/blob/0ab2c9bbc4f100ee8ac9a807b08c096237d7ac40/crates/socket-patch-core/src/vex/discover/mod.rs#L1826-L1842): Discovery::pnpm_tarball_dropped.
  • vendor.rs:658-663: the new --check reason.
  • [e2e_vendor_pnpm_build.rs:150-156](https://github.com/SocketDev/socket-patch/blob/0ab2c9bbc4f100ee8ac9a807b08c096237d7ac40/crates/socket-patch-cli/tests/e2e_vendor_pnpm_build.rs#L150-L156): the 11.0.0 to 11.0.2 version gate.

Verified

  • Read the full diff and the surrounding lock-reader code.
  • Ran cargo test -p socket-patch-core --lib pnpm_entry_without_its_tarball and cargo test -p socket-patch-cli --test e2e_vex_vendor pnpm; both pass.
  • Disabled the new branch and both new tests fail, so they cover the change.
  • CHANGELOG.md is untouched.
  • CI on the head is green: ci-ok and clippy pass.
  • I did not run the real-pnpm suites locally.

Open questions (nits, not blocking)

  • The new branch skips the root-lock guard that pnpm_vendored_ref applies. A root-relative vendored path in a non-Rush member lock would be withheld instead of rejected, and the remedy "re-run scan --mode vendored" doesn't write member locks. This shape is unlikely, and the only effect is that the prune keeps a patch.
  • The message always blames pnpm 11.0.0 to 11.0.2, even when the tarball was hand-edited out. The remedy is the same either way.

Generated by Claude Code

@mikolalysenko
Mikola Lysenko (mikolalysenko) added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit f9cb634 Dec 2, 2026
84 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the fix/pnpm-11-0-vendored-lock-rewrite branch December 2, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants