Repository navigation
Sweep scan/gc.rs - #1892
Sweep scan/gc.rs#1892Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
Conversation
Assisted-by: Claude Code:claude-opus-5-5
Drop the count wrapper over ui::plural. Write the pre-lock ledger gate and the GC lock acquire once instead of in both run_apply_gc and run_vendor_only_gc. Narrow GcSummary's fields and total_bytes to the file. Trim comments that restate the code or cite bare issue numbers. Tests: fold the detect_prunable spelling tests, which re-tested core PurlKey, into one test that checks the wiring. Merge the uncrawled-ecosystem and vendored tests. Merge the duplicated vendored-line and corrupt-manifest tests, and fold the preview test into the preview/wet parity test with exact counts. Fix the stale contract doc on the human GC lines test. No behavior change. Assisted-by: Claude Code:claude-opus-5-5
Pin that every spelling variant prunes on an empty scan, the short composer version spelling, and that an unloadable manifest frees no diffs, packages or bytes. Rewrap a test doc comment. Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
Assisted-by: Claude Code:claude-opus-5-5
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 9afadf9. Configure here.
|
Ready for review at
Generated by Claude Code |
Final review briefWhat it does. A sweep of Risk: low. The non-test code is a mechanical refactor of a deleting command, and I checked the deletion paths specifically.
Look here
Verified
Changes I made: none. Open questions (non-blocking):
Auto-merge is armed, so approving sends it straight to the merge queue. Generated by Claude Code |
LLM Description written by Claude Code:claude-opus-5-5
Sweep of
crates/socket-patch-cli/src/commands/scan/gc.rsby the architecture refactor routine. It works through the file's notes incoverage/files.tsv(ledger) and the structure and tests parts of the living document. The file's callers,scan/mod.rsandscan/vendor_flow.rs, are changed by #1856 and #1884, so itspub(super)API stays the same.print_gc_vendored_lineis not inlined intovendor_flow.rsfor the same reason.Changes
count, which only calledui::plural.run_apply_gcandrun_vendor_only_gc. Each is now written once, ashas_ledgerandlock.print_human_gcbuilds its[dry-run]prefix once instead of using an if/elseprintln!.GcSummary'spruned,blobs,diffsandpackagesfields andtotal_bytesare private now, since nothing outside the file reads them.#998,#1063,#1278andB20references, comments that restated the code, a stale "split out so it's unit-testable" note, and 6 test banners. The contract test's doc saidGC: skipped (<code>): <message>., but the code printsGC: skipped: <message>., so the doc now matches the code.detect_prunablespelling tests re-tested corePurlKey, whichpurl_key.rsalready covers. They are merged intodetect_prunable_matches_by_purl_key. It checks that the encoded, mixed-case, PEP 503, padded and short composer, and qualified spellings of installed releases are kept; that a gone composer release prunes; and that every entry prunes on an empty scan. Red→green: comparing raw strings instead ofPurlKeyfails it.uncrawled_ecosystemsandmaven_and_nugetare merged into one test, and the two vendored-exemption tests intodetect_prunable_exempts_vendored_purls. Red→green: dropping thepurl_keys_coverconjunct fails it.format_gc_vendored_lines_countsis folded intogc_vendored_lines_render_the_contract_vocabulary, which now asserts the full drift-keep line and the plural dir count exactly instead of usingstarts_with.preview_apply_gc_reports_blobs_of_prunable_entryis folded intopreview_and_apply_gc_agree_on_orphan_counts. That test now asserts the preview's exact counts (1 blob, 64 bytes), so it can no longer pass when both sides report 0.run_apply_gc_deletes_nothing_when_manifest_corruptand the corrupt half of the preview test duplicatedapply_gc_reports_an_unloadable_manifest. That test now also asserts that the manifest bytes are unchanged and that zero diffs, packages and bytes are freed.Size
git diff --stat: 1 file, +173 / −442. Production is 627 → 590 lines (−37), tests 1,213 → 981 (−232).Behavior change
None. Output bytes, JSON, exit codes and error codes are unchanged.
Verification
cargo clippy --workspace --all-features -- -D warningsis clean.cargo test -p socket-patch-cli --libpasses (927).cli_parse_scan,cli_scan_silent,e2e_scanande2e_composer_version_identitypass./code-review highran. Its test-coverage and comment findings are fixed. These were not fixed:--cwdand notproject_root(). This predates the PR (the C43 note) and the fix changes behavior, so it is left for an issue.[dry-run] GC: reverted …wording is past tense. It predates the PR and changing it changes output bytes.lockreturnsBox<GcSummary>. The box satisfiesclippy::result_large_errand keeps the skip summary in one place.Also noted, not changed: the preview path drops the
cargo_cache_patch_keptwarnings that the wet path reports (let _ = keep_patched_cargo_copies(...)).Risk
Low. The change is local to one file and covered by its own tests. No platform-specific code changed.
A stray branch
arch-refactor/sweep-scan-gc-policy(same SHA as this PR's first commit) could not be deleted from the sandbox, and can be removed.🤖 Generated with Claude Code
https://claude.ai/code/session_011f9aeSPFg9U8dSnJ1cikwy
Note
Low Risk
Internal refactor of scan GC in one module with expanded unit tests; public
pub(super)API and user-visible behavior are unchanged.Overview
Refactors
scan --pruneGC ingc.rswithout changing CLI output, JSON, or exit behavior.Production: Duplicated pre-lock ledger checks and apply-lock acquisition in
run_apply_gcandrun_vendor_only_gcmove intohas_ledgerandlock. The localcountwrapper is removed in favor ofui::plural.GcSummarysweep counters andtotal_bytesare file-private. Comments are trimmed (issue refs, restatements).print_human_gcapplies a single[dry-run]prefix for vendored lines.Tests: Overlapping
detect_prunablecases merge into fewer, stricter tests (PurlKey matching, uncrawled ecosystems, vendored exemptions). Redundant corrupt-manifest and preview-blob tests fold intoapply_gc_reports_an_unloadable_manifestandpreview_and_apply_gc_agree_on_orphan_counts. Human GC line tests gain exact drift-keep and plural assertions. Net ~270 lines removed from the file.Reviewed by Cursor Bugbot for commit 9afadf9. Configure here.
Generated by Claude Code