Repository navigation
Description
[agent] Filed by the scheduled architecture refactor routine. Register: #2244.
Kind: bug (an error that lies; three copies of one rule disagree).
Problem
.socket/vendor/state.json is a vendored project's only record of its patches: vendored mode keeps no manifest. When that file cannot be parsed, remove <target> and rollback <target> say the patch does not exist.
A merge that leaves conflict markers in the ledger is enough:
$ socket-patch remove pkg:pypi/six@1.16.0
Error: No patch found matching identifier: pkg:pypi/six@1.16.0
$ socket-patch rollback pkg:pypi/six@1.16.0
Error: No patch found matching identifier: pkg:pypi/six@1.16.0
$ socket-patch report pkg:pypi/six@1.16.0 --dry-run
Error: Could not read the vendor ledger: corrupt ./.socket/vendor/state.json: key must be a string at line 4 column 1. To report a patch anyway, name it by its UUID
$ socket-patch rollback
Error (vendor_state_unreadable): Cannot read .socket/vendor/state.json: corrupt ./.socket/vendor/state.json: key must be a string at line 4 column 1 — the vendored leg, manifest cleanup, and GC were skipped
Under --json the first two are not_found (status: "notFound") and patch_not_found. Neither mentions the ledger, in the message or in warnings[]. The lockfiles still install the vendored artifact, and the user has been told there is nothing to take off.
The rule is written three times:
| Command | A target that matches nothing while the ledger is unreadable |
|---|---|
report (report.rs L365-L386) |
the ledger's error, vendor_state_unreadable |
remove (remove.rs L722-L768) |
not_found. The comment there says the ledger "falls through to not_found: nothing is mutated on that path" |
rollback <target> (rollback.rs L2285-L2306) |
patch_not_found; a path target is path_glob_no_match (L2352-L2372) |
CLI_CONTRACT.md sides with report:
not_found(remove): "no manifest entry, vendor-ledger entry or hosted pin matches the identifier" (L2792).patch_not_found(rollback, report): "No manifest, ledger or hosted patch matches the identifier" (L2764).vendor_state_unreadable(remove, vendor): ".socket/vendor/state.jsoncannot be read or parsed; refused fail-closed (exit 1)" (L2797).report: "A store that cannot be read holds nothing: ... a PURL or a name that then matches nothing fails with that store's error ... instead ofpatch_not_found" (L383).
A "not found" verdict is a statement about every store, and here one of them was never searched.
Evidence
A test that gives the same project to each command, on main at 0a391c1. It runs 9 targeted commands over 3 projects (ledger only, ledger beside an empty manifest, ledger beside a manifest holding another package's patch). report passes all 6 of its runs; remove and rollback fail all 21 of theirs:
the vendor ledger could not be read, so these targets were never looked up in it:
remove pkg:npm/x@1.0.0 --json --yes (manifest: none): not_found: No patch found matching identifier: pkg:npm/x@1.0.0
remove x --json --yes --dry-run (manifest: none): not_found: No patch found matching identifier: x
remove 11111111-1111-4111-8111-111111111111 --json --yes (manifest: none): not_found: No patch found matching identifier: 11111111-1111-4111-8111-111111111111
rollback pkg:npm/x@1.0.0 --json --offline (manifest: none): patch_not_found: No patch found matching identifier: pkg:npm/x@1.0.0
rollback x --json --offline --dry-run (manifest: none): patch_not_found: No patch found matching identifier: x (to target a directory instead, use ./x or x/**)
rollback 11111111-1111-4111-8111-111111111111 --json --offline (manifest: none): patch_not_found: No patch found matching identifier: 11111111-1111-4111-8111-111111111111
rollback ./node_modules/x --json --offline (manifest: none): path_glob_no_match: path pattern matched no patched packages: ./node_modules/x (path targets select installed copies; patches for uninstalled packages are reachable by identifier or an unscoped rollback)
... the same 7 lines for each of the other two projects
Planned fix
- One rule for the three commands: a target that selects nothing in the stores that could be read fails with
vendor_state_unreadablewhile the vendor ledger could not be read. removeandrollbackreach their "not found" exits only after that check.reportkeeps its behavior and moves onto the same rule.- Exit codes do not change (1 before and after). The
error.codeof this one case changes fromnot_found/patch_not_found/path_glob_no_matchtovendor_state_unreadable, andremove'sstatusfromnotFoundtoerror. CLI_CONTRACT.mdgainsvendor_state_unreadableamong rollback's early errors.
Not in scope: what remove and rollback do when the target does match a manifest record or a hosted pin beside an unreadable ledger. The contract already describes both.
Generated by Claude Code
Activity
mikolalysenko commentedon Nov 25, 2026
[agent] Claiming this for the architecture refactor routine. Branch: arch-refactor/2249-unreadable-ledger-not-found.
Generated by Claude Code
Name the unreadable ledger, not "No patch found"
Refuse an unreadable ledger before any change
Cover repair's probe; keep the directory hint
refactor: unreadable-ledger not-found in #2250; #1963 closed
Put rollback's directory hint before the ledger error