Repository navigation
Report an unreadable vendor ledger and a still-wired orphan in scan --prune - #2261
Mikola Lysenko (mikolalysenko) wants to merge 8 commits into
Conversation
Refs #2253. Assisted-by: Claude Code
The vendored half of the prune returned an empty summary in two cases where the other commands speak up, so the scan reported a clean pass. A vendor ledger that could not be read (a merge conflict left in the committed state.json) read as an empty one. The pass now carries a vendor_state_unreadable warning, as rollback, list and apply do: no entry was reverted and no orphan dir swept, and the manifest half still runs. A ledger that cannot be stat'd no longer counts as absent at the pass's existence gate, which also reads the manifest's project instead of --cwd, and a scan whose crawl found nothing runs the vendored half for an unreadable ledger too. A vendored dir that no ledger entry owns and a project file still installs from was kept without a word, where vendor --revert, rollback and remove report vendor_orphan_still_wired. The pass reports it too, also when the ledger holds no entry at all, where it still deletes nothing. Its remedy leaves out "then revert again": a prune was not asked to revert, and the phrase reads as vendor --revert. The scan's status and exit code are unchanged. Refs #2253, #1910. Assisted-by: Claude Code
Plain vendor with no manifest and a vendor ledger it could not read warned on stderr in human mode and printed a bare noManifest envelope under --json, the shape of a project with nothing vendored. The envelope now carries the same finding as a vendor_state_unreadable warning. The run is still the exit-0 no-op. Fixes #2253. Assisted-by: Claude Code
A wet prune of a project with neither a manifest nor a ledger file stopped at its existence gate, so a vendored dir a lockfile still installs from was reported by --dry-run and not by the run itself. The gate now asks for the ledger's directory, .socket/vendor/, which the artifacts share, and the wet pass reports what the preview does. The still-wired warning of a prune names a second way out, pointing the lockfile back at the registry release: the ledger need not have lost an entry. The unreadable-ledger warning strips control characters from the ledger's error, which a human run prints. Plain vendor with no manifest and an unreadable ledger pointed at repair, which stops at the same ledger. Both modes now say to restore the file from version control. Refs #2253. Assisted-by: Claude Code
From the second review. The still-wired warning of a prune ends its second way out with deleting the directory: with no ledger entry to judge ownership by the prune never deletes one, so pointing the lockfile at the registry alone left a committed directory nothing would mention again. Plain vendor's human warning for an unreadable ledger strips control characters from the ledger's error, as the prune's warning does. The gate test now loops .socket/vendor/ itself as well as the ledger, so the "cannot be stat'd" arm of the gate is covered: reading that arm as "nothing vendored" fails the test. Refs #2253. Assisted-by: Claude Code
|
bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview The prune existence gate now treats Plain
Reviewed by Cursor Bugbot for commit d5a7728. Configure here. |
The corrupt-ledger scan suite defined its own warning_codes, which the ratchet in tests/cli/envelope_helper_copies.rs forbids: CI's coverage job failed on it. The suite now uses common::envelope's reader. Also separates two unrelated comment paragraphs in vendor's no-manifest branch. Refs #2253. Assisted-by: Claude Code
From Bugbot. A scan whose crawl finds nothing runs the vendored half of the prune only for ledger entries the lock no longer wires. A lost ledger names none, so a lockfile that installs from a vendored dir no entry owns went unreported there: with nothing installed, a package-lock file: entry is no package of the crawl. That path now reports what the half could not reconcile, read-only, as it already does for a recorded PyPI patch still on disk: no lock is taken and nothing is written. The unreadable ledger takes the same route, in place of running the half for it, so both are a Warning line on stderr in human mode and a warnings[] entry under --json. Refs #2253. Assisted-by: Claude Code
From the third review. A vendored run's group commit replaces the lockfiles before the ledger. If it is interrupted, a lockfile is ahead of its ledger entry until the next run that takes the apply lock finishes the commit from its journal. A prune that holds no lock (a --dry-run, or the read-only report of an empty crawl) read that state as a lost ledger entry and said the directory could be deleted. Such a pass now reports no still-wired directory while a commit journal is pending, or cannot be checked. A locked pass has finished the commit before it looks, and reports as before. Also: the vendor suite's new test reads the envelope through common::envelope, and the contract says when the empty-crawl warning is a stderr line. Refs #2253. Assisted-by: Claude Code
|
[agent] What fails. Nine tests of Why it isn't this PR's.
Nothing in this repository can fix it. The job needs a re-run once the patch service recovers; I have not re-run it, since a third run against the same outage would only fail again. Generated by Claude Code |
|
bugbot run Generated by Claude Code |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit d5a7728. Configure here.
LLM Description written by Claude Code
Fixes #2253. Takes the still-wired orphan bullet of #1910 (that issue stays open for its Go undo warning).
Problem
scan --prunereconciles vendored state: it reverts entries the project no longer uses and sweeps vendor directories nothing owns. In two states it did none of that and reported a clean pass, so a CI job that runs it stays green while the project stays unreconciled:.socket/vendor/state.jsonis enough.rollback,list,applyandvendor --checkall name the ledger on the same project.state.json).vendor --revert,rollbackandremovereportvendor_orphan_still_wiredorvendor_ledger_missing. The prune pass ran the same sweep and dropped that part of its result.Plain
vendorwith no manifest had the first gap under--jsononly: human mode warned on stderr, and the envelope was a barenoManifest.Evidence on
main(cfc870f)The built binary, against a local stand-in for the patch API that answers "no patches":
The tests this PR adds fail on
main's production code. Unit tests inscan/gc.rs(cargo test -p socket-patch-cli --lib -- scan::gc::tests::gc_):CLI tests, through the built binary (
--test scan -- scan_prune_corrupt_vendor_ledger,--test vendor -- missing_manifest_with_an_unreadable):(Two of these were renamed in review: the first unit test is
gc_takes_only_a_missing_vendor_dir_for_nothing_vendoredon this branch, and the first CLI test isscan_prune_of_an_empty_crawl_says_what_it_could_not_reconcile.)Fix
run_vendor_gcreturned an empty summary for a ledger that failed to load (_ => return out). It now returns avendor_state_unreadablewarning: nothing is reverted or swept, and the manifest half of the prune still runs, as before.vendor_orphan_still_wiredwarnings, also when the ledger holds no entry at all. That case still deletes nothing: it only reports.remove,rollbackandrepair), and read--cwdwhere the pass reads the manifest's project. It now asks whether.socket/vendor/of the manifest's project is known to be missing. A wet pass therefore reports a still-wired directory in a project with no manifest and no ledger, as--dry-rundoes.vendor --jsonwith no manifest carries the warning human mode prints.One test repair rides along:
corrupt_ledger_scan_prune_keeps_vendored_manifest_entrychecked "not pruned" by readinggc.prunedManifestEntries, a key the envelope does not have, so that assertion could not fail. It now reads theevents. The test's on-disk checks were sound.After the fix:
Deleted
The catch-all arm that turned a ledger load error into an empty summary, and the
has_ledgerstat probe. No copy was left behind.Behavior change
All additive, and no exit code or
statuschanges:scan --prunegains two entries inwarnings[](human:GC: …lines, orWarning:lines on stderr when the crawl found nothing), in the two states above. Both codes already exist on other commands.vendor --jsonwith no manifest gains awarnings[]entry for an unreadable ledger.vendor's human warning for that state ended with "Runsocket-patch repairto check the vendored artifacts".repairstops at the same ledger (Error: Could not read the vendor ledger, exit 1), so it now says "Restore .socket/vendor/state.json from version control", and strips control characters from the ledger's error..socket/vendor/directory, now takes the apply lock and runs the vendored half, where it returned at the gate. With nothing to report it prints what it printed before.vendor --revert, which un-vendors the project.CLI_CONTRACT.mddescribes all of this: thescan --pruneparagraph, thevendor_state_unreadablerow, and a new row forvendor_orphan_still_wired, which three commands emitted and the contract never listed.Risk
Low. Nothing new is deleted or reverted: every new branch only reports. The one path that does more work than before is the gate (a lock taken where the pass used to return), and
run_apply_gc_creates_no_socket_dir_on_a_pristine_projectstill holds. The existing testapply_gc_says_why_a_vendored_revert_failedgained a second expected line: its fixture hand-edits a ledger entry's ecosystem, which disowns that entry's directory.No
cfg(unix)orcfg(windows)production code changed. One new test is#[cfg(unix)](it needs a symlink loop).Review
/code-review highran three times. The first pass found the wet-versus-dry gap at the gate, therepairremedy and an unsanitized error; the second found the incomplete "point the lockfile back" remedy, the unsanitized humanvendorline and a gate test that no longer covered a failed stat. The third, after Bugbot's fix, found that a pass holding no apply lock (a--dry-run, or the empty crawl's read-only report) would call a directory deletable while an interrupted vendored run's commit is pending: that commit replaces the lockfiles before the ledger. Such a pass now reports no still-wired directory while a commit journal is pending; a locked pass has finished the commit before it looks. All are fixed, and the gate test fails with the gate's error arm inverted.Bugbot found one more (medium): on an empty crawl the still-wired report never ran when the ledger was simply missing. It reproduces: a
package-lock.jsonthat resolves from an orphan vendored tarball, with nothing installed, scans as zero packages. Fixed in 587d443, and the thread is answered and resolved.Three findings are left as they are:
gc_skippedand not the new warnings. A skipped pass says it was skipped, and the next run reports..socket/vendora plain file and no manifest,--dry-runreportsvendor_state_unreadableand the wet rungc_skipped(lock_io, from the lock's own check of that directory). Both name the path. The contract already giveslock_iofor a.socket/vendor/that cannot be entered onremove,rollbackandrepair; the prune's preview takes no lock, so it has no such check.Warning:line and then the existing "--pruneskipped: no installed packages were found … runsocket-patch repair" line. The second line is about the manifest half, which the empty crawl did skip, and its remedy holds once the ledger is restored, which the first line asks for.Verification
d5a77284: 48 of 50 checks pass.hosted-e2eand its aggregateci-okfail because the production patch service answers HTTP 500 to hosted artifact downloads; the comment below has the evidence. It needs a re-run once the service recovers.cargo clippy --locked -p socket-patch-cli --all-features -- -D warnings: clean.cargo test -p socket-patch-cli --lib: 1081 passed.cli(125), the suite with the test-tree ratchets, passes. CI's first run on this PR failedcoverage (1): the scan suite's new test defined its ownwarning_codes, which the ratchet intests/cli/envelope_helper_copies.rsforbids. It now usescommon::envelope's reader.scan(268),vendor(146),in_process_scan(31),scan_vendor_e2e(43),scan_vendor_requirements_unwired(4),cli_scan_silent(12),in_process_rollback_vendored(27),manifest_load_error_matrix(10),cli_remove_silent(10): all passed.Diff
7 files, +647 −43: production +163 −26 (four files under
src/commands/), tests +481 −15 (unit +305 −7, CLI suites +176 −8), contract +3 −2.CLI_CONTRACT.mdis also changed by #2258, one line in the gem section about 100 lines from the nearest hunk here, so the two merge cleanly in either order.Generated by Claude Code