Repository navigation
Description
[agent] Filed by the scheduled architecture refactor routine. Register: register comment, leads L23 and L24.
Kind: bug (an error that is dropped). Checked on main at da012af.
Problem
A merge conflict left in the committed .socket/vendor/state.json makes the vendor ledger unreadable. rollback, list and vendor --check say so. scan --prune does not: its vendored half returns without doing anything, and the run reports a clean pass.
$ cat .socket/vendor/state.json
{
<<<<<<< HEAD
$ socket-patch scan --prune --json # the envelope's status and gc; it has no warnings[]
"status": "success",
"gc": { "removedBlobs": 0, "removedDiffArchives": 0, "removedPackageArchives": 0, "bytesFreed": 0, "removedRegistryEntries": 0 }
$ socket-patch scan --prune # human mode: no GC line, no warning, exit 0
No SOCKET_API_TOKEN set (and no socket-cli login found) — using the public patch API proxy (free patches only). […]
Found 1 package (1 npm)
No patches available for installed packages.
(The scans ran against a local stand-in for the patch API that answers "no patches".)
The same project, the other commands:
| Command | What it reports |
|---|---|
rollback --json |
partialFailure, warnings[]: vendor_state_unreadable and gc_skipped ("artifact GC skipped: the vendor ledger is unreadable, so artifact ownership cannot be established"), exit 1 |
list --json |
warnings[]: vendor_state_unreadable |
vendor --check --json |
error.code: vendor_state_unreadable, exit 1 |
scan --prune --json, also with --dry-run or --mode vendored |
success, a gc of zeros, no warning |
So someone who runs scan --prune in CI to keep vendored state reconciled gets a green run that reconciled nothing, for as long as the ledger stays broken, and nothing in the output tells them to look at the ledger.
The manifest half is safe: with an unreadable ledger the scan recovers the vendored purls from the committed artifacts, so no vendored package's manifest record is pruned (corrupt_ledger_recovers_vendored_purls_from_committed_artifacts and its siblings in scan/discovery.rs). Only the report is wrong.
Where the error is dropped
run_vendor_gcmatches the ledger load with_ => return out, so a read error and an empty ledger give the same empty summary.- One step earlier,
has_ledgerismetadata(..).is_ok_and(..): a ledger that cannot be stat'd counts as no ledger, and with no manifest the pass returns before the lock (run withstate.jsonas a symlink to itself: the same cleansuccess). Just above its use inrun_apply_gc, a manifest that cannot be stat'd counts as present, under the comment "A manifest that cannot be stated is not absent". (Report an unreadable vendor ledger instead of "No patch found" in remove and rollback #2250 fixes this stat probe inremove,rollbackandrepair.)
The same class, in plain vendor
With no manifest and an unreadable ledger, plain vendor warns in human mode and says nothing under --json (vendor.rs L1109-L1116 loads the ledger only when the run is neither --json nor --silent):
$ socket-patch vendor
Warning: No manifest to vendor from, and the vendor ledger could not be read: corrupt ./.socket/vendor/state.json: key must be a string at line 3 column 1
Run `socket-patch repair` to check the vendored artifacts.
$ socket-patch vendor --json # the envelope's status; it has no warnings[]
"status": "noManifest"
list --json had the same gap and closed it: the contract's vendor_state_unreadable row says "list --json (additive): … the warning says so (human mode already printed it on stderr)".
Evidence
A unit test in scan/gc.rs, next to apply_gc_reports_drift_kept_vendored_entry: seed a manifest, write the conflicted ledger above, run run_apply_gc, and assert that the recorded envelope has a vendor_state_unreadable warning. On da012af it fails:
recorded: {"command":"scan","status":"success","dryRun":false,"events":[], … ,"gc":{"removedBlobs":0,"removedDiffArchives":0,"removedPackageArchives":0,"bytesFreed":0,"removedRegistryEntries":0},"removedVendorOrphanDirs":0}
the vendored half did not run, and the pass must say why
test result: FAILED. 0 passed; 1 failed
Planned fix
run_vendor_gcreturns the ledger's load error instead of an empty summary. The prune pass records it as avendor_state_unreadableentry inwarnings[](human: aGC: …line), asrollbackandlistdo. The manifest half still runs.has_ledgertakes only "not found" for absence.vendor --json'snoManifestenvelope carries the warning human mode prints.- Exit codes stay as they are: in the contract a failed GC revert and a skipped pass leave the scan's exit alone, and the no-manifest
vendoris a clean exit-0 no-op.CLI_CONTRACT.mdgains the warning in thescan --pruneparagraph and thevendor_state_unreadablerow.
#2246 changes run_vendor_gc and scan/gc.rs, so this waits for it to merge.
Generated by Claude Code
Activity
refactor: #2253, #2254 filed; #1982 confirmed
refactor: #2246 and #2241 merged; #1910 claim released
mikolalysenko commentedon Nov 25, 2026
[agent] Claiming this for the architecture refactor routine. Branch: arch-refactor/2253-prune-unreadable-ledger.
Re-ran on
mainat cfc870f:scan --prune --jsonis stillsuccesswith no warning over a conflicted ledger and over a ledger that cannot be stat'd, andvendor --jsonis still a barenoManifest. Three unit tests inscan/gc.rsthat assert the warning fail there.The PR also takes the still-wired orphan bullet of #1910: it is in the same function, and the prune pass is the only one of the sweep's four callers that says nothing about a vendored directory a project file installs from and no ledger entry owns.
Generated by Claude Code
Report what scan --prune could not reconcile
Carry the unreadable ledger in vendor --json
Close the gaps the first review found
Finish the remedies and cover the stat gate
Read warnings through the shared envelope reader
Report unreconciled vendored state on an empty crawl
Hold the still-wired report while a commit is pending
refactor: #2261 ready for #2253 and L21; L25 to L27 added