Repository navigation
Description
[agent] Filed by the architecture refactor routine. Checked on main at cfc870f with the built binary, real pnpm 12.23.0 (the registry's latest), 11.29.0 and 10.28.0, and node 22. The released v5.1.0 binary ran the same project as the control.
Kind: bug, and structure that keeps causing bugs. vex judges a store entry that no install loads. That was fixed for Bun's store in vex (#599) and for pnpm's store in the scan (#1197). vex over a pnpm store was left out, and since #2167 the default mode produces such an entry on every pnpm 11.20 or newer.
Problem
pnpm keeps the store entry of a package whose lock key changed, with nothing linking to it: pnpm 7 to 11 for up to 7 days, pnpm 12 until pnpm prune (docs/ecosystems.md, lines 770 to 775, says so).
- Hosted mode, pnpm 11.20 and newer. Since Route hosted pnpm pins through one named registry per patch #2167 (5d8378e, not in a release yet) the scan routes each patched release through its own named registry. The lock key becomes
left-pad@socket-<id>:1.3.0, so the store entry becomesleft-pad@socket-<id>+1.3.0. Thepnpm installthat the scan's next steps ask for links the project to the new entry and leavesleft-pad@1.3.0, with upstream's bytes, in the store.vexcounts it as an installed copy and omits the patch:not_applied, exit 1, no document. The message says the package is not installed and to reinstall; the reinstall prints "Already up to date". - Vendored mode, every pnpm. The vendored key (
left-pad@file:.socket/vendor/…) has always renamed the entry. There the same check is a warning,vendored_tree_out_of_sync, whose remedy ("re-run your package manager's install") changes nothing.
Who it hurts: a pnpm project scanned over an existing node_modules (a developer's checkout, or a CI job that restores node_modules from a cache). A clean install is not affected. v5.1.0 is not affected in hosted mode: it keeps the lock key, so pnpm reuses the one entry.
Evidence
Hosted mode, pnpm 12.23.0
A real project (left-pad 1.3.0 from the registry, "packageManager": "pnpm@12.23.0"). The patch API is a stand-in: the search, reference and view answers in the shapes the repository's bench mock uses, the reference's npmRegistryUrl (core api/types.rs, line 313), and the patched tarball with its version document at that address.
$ pnpm install # upstream left-pad 1.3.0
$ socket-patch scan
Switched 1 package to hosted patches; rewrote 2 files.
Next steps:
1. Commit pnpm-lock.yaml and pnpm-workspace.yaml to keep the hosted patches.
2. Reinstall from the updated lockfile, then run `socket-patch vex` to verify the installed patches.
$ pnpm install
dependencies:
- left-pad 1.3.0
+ left-pad socket-22222222:1.3.0 # exit 0
$ readlink node_modules/left-pad
.pnpm/left-pad@socket-22222222+1.3.0/node_modules/left-pad
$ grep -c "socket-patch test marker" node_modules/left-pad/index.js
1 # the copy node loads is patched
$ ls node_modules/.pnpm | grep left-pad
left-pad@1.3.0
left-pad@socket-22222222+1.3.0
$ find node_modules -lname "*left-pad@1.3.0*" | wc -l
0 # nothing links to the old entry
$ socket-patch vex --product pkg:generic/app@1.0.0 -O vex.json
Warning: omitting pkg:npm/left-pad@1.3.0 from VEX: the patched files still hold the original content (not_applied)
Error: No applied patches with vulnerability metadata to attest.
The patched packages are not installed yet: the installed copies still hold their original files. Reinstall from the lockfile (hosted or vendored patches) or run `socket-patch apply` (agent-mode patches), then run `socket-patch vex` again.
# exit 1, no vex.json; --json: error.code no_applicable_patches
$ pnpm install
Already up to date
$ socket-patch vex --product pkg:generic/app@1.0.0 -O vex.json # the same, exit 1
Three controls, each over the same files:
$ rm -r node_modules/.pnpm/left-pad@1.3.0 && socket-patch vex … # or: pnpm prune
Wrote OpenVEX document with 1 statement to vex.json # not_affected, exit 0
$ pnpm install --frozen-lockfile && socket-patch vex … # a clean checkout of the three committed files
Wrote OpenVEX document with 1 statement to vex.json # exit 0
$ socket-patch scan && pnpm install && socket-patch vex … # the v5.1.0 binary, same project, pnpm 12.23.0
Wrote OpenVEX document with 1 statement to vex.json # trustLockfile, one entry: left-pad@1.3.0
pnpm 11.29.0 gives the same refusal and the same two store entries. In the same state scan --vex writes its document and says to "run socket-patch vex after installing to verify against the installed tree", which is the command that refuses.
Vendored mode, pnpm 10.28.0 and 12.23.0
The same package, vendored against the repository's fixture vendor service:
$ socket-patch vendor
Vendored 1 package.
2. Run `pnpm install` to update the installed tree, then run `socket-patch vex` to verify the installed patches.
$ pnpm install # Packages: +1 -1
$ grep -c "socket-patch test marker" node_modules/left-pad/index.js
1
$ ls node_modules/.pnpm
left-pad@1.3.0
left-pad@file+.socket+vendor+npm+<uuid>+left-pad-1.3.0.tgz
$ socket-patch vendor --check
pkg:npm/left-pad@1.3.0: committed artifact and wiring verified
$ socket-patch vex --product pkg:generic/app@1.0.0 -O vex.json
Warning: pkg:npm/left-pad@1.3.0: the installed tree does not match its vendored artifact; […] but the live tree carries different bytes — re-run your package manager's install to resync it.
Wrote OpenVEX document with 1 statement to vex.json # exit 0
$ pnpm install
Already up to date
$ socket-patch vex … # the same warning
$ pnpm prune && socket-patch vex … # no warning
What the two orphan tests say about those trees
A throwaway unit test called both functions on the three trees pnpm left (hosted on 12.23.0, vendored on 10.28.0 and 12.23.0). The output is the same for each:
scan's test (orphaned_pnpm_store_entry_sync): left-pad@1.3.0 -> orphan=false
vex's filter (retain_live_store_copies) kept: ["left-pad@1.3.0", "left-pad@socket-22222222+1.3.0"]
Where
- core
crawlers/npm_crawler.rs,retain_live_store_copies(lines 1121 to 1138): "For a check of the live install (vex)". It drops only whatorphaned_bun_store_copies_sync(lines 1071 to 1100) finds, and that function looks for a.bunstore alone. Added by 2044d9e for With Bun's isolated linker,vexrefuses every hosted patch as not_applied after the usual in-placebun install, because it checks orphanednode_modules/.bunregistry entries that Bun never removes (regression from #496) #599. - Its two callers are
vex's lookups: CLIecosystem_dispatch.rs(line 1367) andcommands/vex_consumed.rs(line 121). - core
crawlers/npm_crawler.rs,orphaned_pnpm_store_entry_sync(lines 834 to 871), added by e9636bc for Vendored pnpm 7–11 scan exits 1 afterpnpm remove(or an upgrade) because it tries to vendor the orphanednode_modules/.pnpm/<name>@<ver>that pnpm keeps for 7 days, and the suggestedpnpm installdoesn't clear it #1197. It is called only by the scan's listing (lines 4103 to 4109, underlive_only). - That test names an entry by package name and version (
InstalledPackages, coreformats/pnpm/mod.rs, lines 563 to 655). A rewire by socket-patch keeps the name and the version and changes the entry, so the test calls the old entry live. Calling it fromvexas it stands would change nothing.
Planned fix
One rule for "this pnpm store entry is live", used by the scan's listing and by retain_live_store_copies, in place of the name-and-version test:
- an entry is live when a link reaches it from the importer's
node_modules, the store's hoist directory or a live entry'snode_modules. That is the rule Bun's store already has (live_bun_store_entries_sync), and neither stale entry above has a link; - when the walk cannot tell, every entry is kept, as today;
rollbackandremovekeep resolving without it, so a patched orphan is still restored.
Tests: the three store shapes above as unit fixtures (the hosted route's entry, the vendored file+ entry, and the upgraded-away entry of #1197), and an in-place pnpm install leg in the real-pnpm hosted and vendored suites that ends in vex.
Generated by Claude Code
Activity
refactor: #2353 filed; v5.1.0 projects ran
Compare bundled dependencies in the pnpm byte check, and skip it wher…
Read a dead link on Windows by the codes measured there
Read what a project's links lead to once, up to the home directory
Say only what was measured about dead links on Windows
Tell a dead link on Windows by its target too, and a missing director…
Bound the read outside a pnpm project by identity, order and budget
Merge branch 'fix/vex-pnpm-store-follow-links' into fix/vex-pnpm-stor…