Repository navigation
Description
[agent] Found by the architecture refactor routine while fixing #2381 (PR #2453), on that PR's branch at 2e5af57 over main at 2440352. Lead L145. The first point is on main for Bun's lock as well.
The problem
#2453 makes vendor --check and vex read the content pin of a NuGet lock, as they already read Bun's: a lock that pins other bytes than the committed vendored artifact does not install it. Three places still do not agree with that rule.
1. vex --no-verify attests a package whose lock pins other bytes
The contract says of --no-verify: "verified against on-disk state (unless --vex-no-verify; the wiring gates apply either way)". It calls a pin mismatch a wiring failure ("vendor --check reports the same as a wiring failure"). The pin is compared in the verification step (core vex/verify.rs, the lock_pin_mismatch arms), which --no-verify skips, and not in the wiring gates.
The real .NET SDK 8, the tree dotnet restore --force-evaluate leaves (the lock on the upstream contentHash, nuget.config and the vendored nupkg as vendored, the app loading the upstream assembly), the binary of #2453:
$ socket-patch vex --product pkg:nuget/app@1.0.0
Warning: omitting pkg:nuget/Fx.Alpha@1.0.0 from VEX: the lockfile pins the vendored artifact to a sha512 that is not that file's, so an install does not deliver it; re-run socket-patch scan --mode vendored (vendor_lock_pin_mismatch)
Error: No applied patches with vulnerability metadata to attest.
[exit 1]
$ socket-patch vex --product pkg:nuget/app@1.0.0 --no-verify
Warning: 1 of 1 VEX statement was emitted without on-disk verification of the patch […]
Wrote OpenVEX document with 1 statement # "status": "not_affected"
[exit 0]
apply --vex, scan --vex and vendor --vex with --vex-no-verify go the same way. For Bun the same holds on main (read, and run for NuGet only): the Bun arm is in the same skipped step.
2. The run that pins a stale lock again needs the patch service, though the committed nupkg is intact
On that tree the committed nupkg holds the patch and only the lock's hash is stale. The re-vendor takes the path of a missing or stale artifact: it asks the patch service for the nupkg again, and only then pins the lock.
$ SOCKET_OFFLINE=1 socket-patch vendor
Error: Cannot vendor pkg:nuget/Fx.Alpha@1.0.0: --vendor-source=service needs the network but --offline is set
Vendored 0 packages; 1 failed.
[exit 1] # the lock still holds the upstream hash
With the service unreachable it fails the same way ("patch service request failed"). The writer has the sha512 of the committed bytes in hand at that point (core vendor/nuget_feed.rs, nuget_prelude: pin_stale), and could pin from it. The open point is the warning: that run reports vendor_artifact_rebuilt today, which would no longer be true, and vendor_artifact_reused ("re-wired as-is, no service download, no rebuild") is the contract's code for PyPI only.
3. Read, not run
scan --mode vendored --dry-runandget --mode vendored --dry-runsayalready_vendoredfrom the ledger's uuid alone (CLIcommands/scan/vendor_flow.rs, the preview'sAlreadyVendoredarm), where the wet run pins the lock again. Stop verifying and attesting a vendored NuGet package whose lock pins other bytes #2453 fixed the same answer forvendor --dry-run.- One lock whose target frameworks pin different hashes for the package (a hand-resolved merge;
dotnetdoes not write one) is reported byvendor --checkas "wiring missing … re-runsocket-patch vendorto rewire it". The config still names the feed, and the re-run fails on "conflicting contentHash values". Run at the writer: the re-vendor fails and the lock is unchanged. - The "wiring missing … re-run
socket-patch vendor" text ofvendor --checknames a command that does nothing in a project with no.socket/manifest.json(whatscan --mode vendoredleaves): it exits 0 with "No manifest to vendor from". Every ecosystem's unwired state lands on that text.
Planned fix
- Judge the pin where the wiring gates are, so that
--no-verifyreads it, for Bun and NuGet alike; a CLI test for each. - When only the pin is stale, pin from the committed nupkg with no download; a maintainer's word on the warning code would help.
- Run the three read-only points before changing them.
Not run: Bun under --no-verify, SDK 10, Windows and macOS.
Generated by Claude Code
Activity
refactor: #2453 opened for #2381, ready; #2431, #2441, #2445 merged; #…
mikolalysenko commentedon Dec 5, 2026
[agent] The third "read, not run" point above is now run, on
mainat cd7c5c5, and it is wider than the one message. Lead L259 of the architecture refactor routine.What happens
In a project vendored by
scan --mode vendoredorget --mode vendoredthere is no.socket/manifest.json(the contract: "everyscan/get --mode vendored… project is manifest-less"). When such a project loses its lock wiring, every command the CLI names to put it back exits 0 and changes nothing:uv.lockandpyproject.tomlare the pre-vendor files throughout. The one command that wires the three packages again issocket-patch scan --mode vendored, which no line above names, and which needs the patch service although the artifacts and the ledger's embedded records are on disk:So
--preserve-statekeeps, in a vendored project, a state that nothing can re-apply offline, and its closing line names two commands that do not re-apply it. That line also says "Manifest entries … preserved" in a project that has no manifest (format_preserved_note(manifest_scope.len(), …)is called with 0).repair's part is true as written: it does check the artifacts' bytes, and downloads one again after I appended a byte to a vendored wheel. It does not look at the wiring.It does not need
--preserve-stateThe unwired state is what an ordinary re-lock leaves. Both of these give the pre-vendor lock byte for byte, and then the same exchange:
poetry lock --regenerate(a plainpoetry lockkeeps the wiring).rm package-lock.json && npm install --package-lock-only. The npm text is another one:vendored wiring drifted: package-lock.json node_modules/ms still resolve ms@2.0.0 outside the vendored artifact, so that copy installs unpatched; re-run socket-patch vendor to rewire every copy.vexis right in each of these states: it omits the unwired packages (vendor_unwired) and exits 1 when none is left. A CI step that runssocket-patch vendorto keep the wiring in place passes while the lock installs the registry packages.Run on uv, Poetry, PDM 2.25.9 (lock 4.5.0), Pipenv and npm for the
--preserve-stateroute (the same six exit codes and an unchanged tree in each), and on Poetry and npm for the re-lock route, with a stand-in patch API that serves real patched wheels and tarballs.remove <purl> --preserve-stateunwires the same way and prints no closing note in such a project (run on uv).Where
vendor --check, every ecosystem:commands/vendor.rsL692-L695, and the half-unwound uv text above it (L682-L689).vendor/npm_lock.rsL1038-L1041.--preserve-statenote ofrollback(removeshares it for a project with a manifest):commands/rollback.rsL592-L610.vendor:commands/vendor.rsL3018-L3029. Its doc comment already says of these projects that "their refresh path isscan --mode vendored".CLI_CONTRACT.md, the--preserve-statesection: "vendorre-runs re-wire them", and underremove: "a re-vendor re-wires from the live lock probe".socket-patch vendoras the command to run again (vendor/verify.rs,vex/discover/npm.rs,vex/discover/cargo.rs,vendor/maven_repo.rs,vendor/jvm/gradle.rs,vendor/cargo.rs,vex.rs,vex_sources.rs, and others). Some of them are for a project that has a manifest, where the command is right. Two already name both commands: the pnpm 11 text of Keep a vendored pnpm patch when pnpm 11.0.0 to 11.0.2 rewrite its lock entry without the tarball #2434 andNO_FILE_INVENTORYinvendor/redownload.rs.The order of the changes explains it. The contract sentence dates from the change that added
--preserve-state(d5e1815, 2026-08-28), when a vendored project had a manifest. Vendored mode became manifest-free in 09956d9 (2026-09-23), which gavevendorits "tracked in the ledger" line. The "wiring missing" text came after that, in b194fa1 (2026-10-05, #725), and namesvendorall the same.#2275 is the same loop for a ledger that cannot be read.
Planned fix
socket-patch scan --mode vendoredfor a ledger entry with no manifest record,socket-patch vendorfor one that has a record.vendor --check, thevexwarnings, the--preserve-statenote andvendor's no-manifest line take their wording from it. The note stops naming manifest entries andapplywhen the manifest holds none.rollback --preserve-state, then each command a message names must either re-wire or not be named.That is a change of message text only. The other reading of the contract sentence is that plain
vendorshould re-wire a manifest-less project from the ledger's embedded records and the committed artifacts, with no network. That would make--preserve-stateuseful offline, and it is a larger change that I would not make without a maintainer's word.Not run: Cargo, Go, gem, Composer, NuGet and the JVM backends (the
vendor --checktext is shared; their own texts were read only); a project that has both a manifest and ledger-only entries; Windows and macOS.Generated by Claude Code
refactor: L258 to L262; L259 on #2455