Skip to content

Commit e5bfb02

Browse files
committed
refactor: sweep scan/gc.rs (#1892)
Assisted-by: Claude Code:claude-opus-5-5
1 parent 6d12e1c commit e5bfb02

3 files changed

Lines changed: 42 additions & 4 deletions

File tree

‎coverage/files.tsv‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ crates/socket-patch-cli/src/commands/remove.rs 2184 audit-cli-tests c8e26f6 2026
1717
crates/socket-patch-cli/src/commands/repair.rs 1349 audit-cli-tests c8e26f6 2026-10-29 PR #1875 drop noun: ArtifactNoun param (always BLOB in prod, 5 fns); inline format_found_missing; type the (String,String,String) vendor refs; socket_dir computed twice (L165, L497); ~45 comment lines (history L31-L36, L202-L211, L500-L505; broken wrap L997); tautological HOSTED_ONLY_REASON assert (L791); 3 duplicate tests (L1115/L1188, L1159/L872); T17 T19 T20
1818
crates/socket-patch-cli/src/commands/rollback.rs 6525 audit-cli-tests c8e26f6 2026-10-29 - split run (1,214 lines) and rollback_patches_inner (826); 4 open-coded error branches (L1533,L1609,L1758,L2565) -> emit_rollback_error; 7 println!(to_pretty_json); Identifier(None) test-only; inline verify_rollback_status_camel, not_installed_event; move remove's helpers to ui/hosted_unwind; ~120 comment lines; fake test L5475; T08 T13 T22 C24
1919
crates/socket-patch-cli/src/commands/scan/discovery.rs 2571 audit-cli-tests c8e26f6 2026-10-29 PR #1884 inline candidate_supersedes (L507) and severity_order wrapper (L573); local shell_word -> ui::shell_word (T18); delete 5 severity_order tests (copy core ranking.rs); move candidate_supersedes, unsupported_layout_warnings tests to core; drop 2 pub use shims (L49, L429); ~35 comment lines; nested_project_skips -> scan/hosted.rs (C11)
20-
crates/socket-patch-cli/src/commands/scan/gc.rs 1840 audit-cli-tests 5ca5623 2026-10-30 - count L463 wraps ui::plural; inline print_gc_vendored_line L547 (vendor_flow L966 should call print_human_gc, T19); gc_into/run_human_gc same dry_run choice, param always common.dry_run; lock block twice L266/L378 (T09); vendor gate L253/L372 probes cwd not project_root (C43); preview drops cargo_kept warnings L431; ~30 comment lines; 8 dup/weak tests (re-test core PurlKey)
20+
crates/socket-patch-cli/src/commands/scan/gc.rs 1840 audit-cli-tests 5ca5623 2026-10-30 PR #1892 count L463 wraps ui::plural; inline print_gc_vendored_line L547 (vendor_flow L966 should call print_human_gc, T19); gc_into/run_human_gc same dry_run choice, param always common.dry_run; lock block twice L266/L378 (T09); vendor gate L253/L372 probes cwd not project_root (C43); preview drops cargo_kept warnings L431; ~30 comment lines; 8 dup/weak tests (re-test core PurlKey)
2121
crates/socket-patch-cli/src/commands/scan/hosted.rs 4955 audit-cli-tests 5ca5623 2026-10-30 - run_redirect_selected_untracked 1,233 lines copies core memory/stages (T24); redirect_block L97 vs core redirect_json_block (T29); 17 core-guidance tests + cfg(test) re-export L35-45 -> core; dup test L3836/L3853; refuse L177, L928, L1599 print stderr under --json (T09/T20); run_warning_of L162 (T27); dead non-json arm of run_redirect L597 (C11); ~120 comment lines
2222
crates/socket-patch-cli/src/commands/scan/hosted/nuget.rs 88 audit-cli-tests 5ca5623 2026-10-30 - one-fn module, move beside core vendor/nuget_feed (C12); json! warning L75 (T27); crawler errors swallowed L51/L62 (fail-open); sha512- strip L43 copies redirect/mod.rs L7176; stringly ecosystem=="nuget"; no unit test
2323
crates/socket-patch-cli/src/commands/scan/hosted/python.rs 550 audit-cli-tests 5ca5623 2026-10-30 - remedy L134-205 copies core vendor/pypi.rs pipenv_stale_install_warning (T26); hand pypi split L148-152 (A14); starts_with pkg:pypi/ L34 (C20); json! warning L201 (T27); unwrap_or_default L66 swallows crawler error; test L369 repeats core pypi_pipenv L2473
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[agent] 2026-10-30: architecture refactor (sweep)
2+
3+
`main` @ `5ca5623`. The previous run was a sweep, so this run looked for structural work first. Every candidate scoring 6 or more has files held by an open PR:
4+
- A30 [#1887](https://github.com/SocketDev/socket-patch/issues/1887) (~8.7) is blocked by #1886 (`maven_scope.rs`, `maven_reactor.rs`).
5+
- A05 [#1844](https://github.com/SocketDev/socket-patch/issues/1844) (~8) is blocked by #1865 (`poetry_lock.rs`).
6+
- T09 (~7), T01 (~6.4) and T25 (~6) are still blocked by #1864 and #1698.
7+
- A32 [#1888](https://github.com/SocketDev/socket-patch/issues/1888) (~6) is blocked by #1882, which touches all three crawlers.
8+
9+
So I ran a sweep, per the rule. The next audited, unswept row with free files is `scan/gc.rs`. `scan/policy.rs` was skipped because its getters are called from `scan/mod.rs`, which #1856 and #1884 hold. There was no maintainer steering, and no PR of mine merged or closed.
10+
11+
**PR:** [#1892](https://github.com/SocketDev/socket-patch/pull/1892), ready for review. `/code-review high` ran first; CI and Bugbot are pending.
12+
13+
### Per file
14+
- **`scan/gc.rs`:**
15+
- 1 wrapper deleted (`count` → `ui::plural`).
16+
- The duplicated pre-lock ledger gate and lock acquire are now written once each (`has_ledger`, `lock`).
17+
- 4 fields and `total_bytes` made private.
18+
- About 40 comment lines removed, including 6 test banners and the bare `#998`, `#1063`, `#1278` and `B20` references. One stale contract doc was fixed.
19+
- Tests: 12 deleted or merged, leaving 17.
20+
- The 5 `PurlKey` spelling tests became 1, which now also covers the empty-scan and short-composer cases. Shown red→green.
21+
- The vendored pair became 1, shown red→green.
22+
- The vendored-lines, preview/parity and corrupt-manifest duplicates were folded into their siblings with exact assertions.
23+
- Net: production −37, tests −232 (+173 / −442 total).
24+
- **Callers:** none changed. `print_gc_vendored_line` (vendor_flow) and `gc_into`'s `dry_run` parameter wait on #1856.
25+
26+
### Behavior
27+
None.
28+
29+
### Merges recorded
30+
None.
31+
32+
### Lessons
33+
- **/code-review found the ledger gate's cwd-vs-`project_root()` mismatch** (C43, pre-existing). It is left for an issue because the fix changes behavior.
34+
- **When merging tests, keep each test's negative half:** the review caught that merging dropped the "gone variant still prunes" cases.
35+
- **The sandbox proxy refuses branch deletions.** The stale `arch-refactor/sweep-scan-gc-policy` needs a maintainer to delete it.

‎register/90-refactor.md‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### Refactor routine
2-
_Last updated 2026-10-30T05:30Z · main @ 5ca5623_
2+
_Last updated 2026-10-30T07:25Z · main @ 5ca5623_
33

44
#### In flight
55
| PR | Kind | Scope | State |
@@ -11,6 +11,7 @@ _Last updated 2026-10-30T05:30Z · main @ 5ca5623_
1111
| [#1870](https://github.com/SocketDev/socket-patch/pull/1870) | structural | A27 [#1869](https://github.com/SocketDev/socket-patch/issues/1869): `api/client.rs`, one serve GET and one vendor retry loop | ready; CI (82 checks) and Bugbot green |
1212
| [#1875](https://github.com/SocketDev/socket-patch/pull/1875) | sweep | `cli/src/commands/{remove,repair}.rs` | ready; CI (82 checks) and Bugbot green |
1313
| [#1884](https://github.com/SocketDev/socket-patch/pull/1884) | sweep | `cli/src/commands/scan/discovery.rs` (+ T18 [#1859](https://github.com/SocketDev/socket-patch/issues/1859); tests moved to core `ranking.rs`, `lock_inventory/tests.rs`, `ui/text.rs`) | ready; CI (82 checks) and Bugbot green |
14+
| [#1892](https://github.com/SocketDev/socket-patch/pull/1892) | sweep | `cli/src/commands/scan/gc.rs` | ready; CI and Bugbot pending |
1415

1516
#### Merged
1617
_None._
@@ -21,11 +22,11 @@ Structural candidates, scored `3·B + 2·U + 2·D + 2·C − risk`:
2122
2. T01 [#1835](https://github.com/SocketDev/socket-patch/issues/1835), `get <uuid>` re-implements `download_and_apply_patches_into`: D2.2 C2, risk M. **~6.4** (blocked by #1698)
2223
3. T25 [#1877](https://github.com/SocketDev/socket-patch/issues/1877), `--vex` embed hand-written ~8×: D2 C2, risk M. **~6** (blocked by #1698: `apply.rs`, `vendor.rs`)
2324
4. T16 [#1861](https://github.com/SocketDev/socket-patch/issues/1861), remove/rollback `VendorRevertStep` loops: D1.75 C2, risk M. **~5.5** (blocked by #1864, #1875, #1698)
24-
5. A20 [#1848](https://github.com/SocketDev/socket-patch/issues/1848), URL credential stripper ×2: D1 C1, risk L. **4** (files free); A26 [#1867](https://github.com/SocketDev/socket-patch/issues/1867) also 4.
25+
5. A30 [#1887](https://github.com/SocketDev/socket-patch/issues/1887), Maven `${…}` interpolation ×5: D3.35 C2, risk M. **~8.7** (blocked by #1886: `maven_scope.rs`, `maven_reactor.rs`). A05 [#1844](https://github.com/SocketDev/socket-patch/issues/1844) (~8, blocked by #1865: `poetry_lock.rs`) and A32 [#1888](https://github.com/SocketDev/socket-patch/issues/1888) (~6, blocked by #1882: all three crawlers) also wait. A20 [#1848](https://github.com/SocketDev/socket-patch/issues/1848) and A26 [#1867](https://github.com/SocketDev/socket-patch/issues/1867) score 4 (files free).
2526

2627
A03 [#1834](https://github.com/SocketDev/socket-patch/issues/1834) is the fixer's #1876. T28 [#1880](https://github.com/SocketDev/socket-patch/issues/1880) and T23 [#1860](https://github.com/SocketDev/socket-patch/issues/1860) wait on #1864 (`list.rs`) and #1698 (`get.rs`).
2728

28-
The next run is structural if a candidate scores 6 or more and its files are free, else a sweep. Next sweep files, in order: `scan/gc.rs`, `scan/hosted.rs` (region, `partial@L<n>`), `scan/hosted/{nuget,python,takeover}.rs`, `scan/policy.rs`, `scan/render.rs` (skip `scan/mod.rs` while #1856 is open), then `core/constants.rs`, `core/lib.rs`, `core/utils/cargo_home.rs`, `core/utils/cargo_workspace.rs`. Skip `agent_download.rs`, `apply.rs`, `get.rs`, `vendor.rs` while #1698 is open, `rollback.rs` while #1864 is open, `cargo_build_cache.rs` (#1849) and `api/client.rs` (#1870).
29+
The next run is structural if a candidate scores 6 or more and its files are free, else a sweep. Next sweep files, in order: `scan/hosted.rs` (region, `partial@L<n>`), `scan/hosted/{nuget,takeover}.rs` (`python.rs` is in #1883), then `scan/policy.rs` and `scan/render.rs` once #1856/#1884 merge (policy's getters and `admit_crawled` are called from `scan/mod.rs`), then `core/constants.rs`, `core/lib.rs`, `core/utils/cargo_home.rs`, `core/utils/cargo_workspace.rs`. Skip `agent_download.rs`, `apply.rs`, `get.rs`, `vendor.rs` while #1698 is open, `rollback.rs` while #1864 is open, `cargo_build_cache.rs` (#1849) and `api/client.rs` (#1870).
2930

3031
#### Notes
3132
- The PRs of the first thread (`arch-refactor/<issue>-*`) are listed in `review/2026-10-v1/register/90-refactor.md`.
@@ -41,3 +42,5 @@ The next run is structural if a candidate scores 6 or more and its files are fre
4142
- A shared GET must keep every caller's bounds: folding an uncapped `resp.text()` error read into the capped `PatchApi` path is what /code-review caught on #1870.
4243
- `ui::shell_word` has no escaping for an embedded `"` on Windows, and cmd still expands `%VAR%` inside its double quotes. Every pasteable command shares it, so fix it there (issue-worthy), not per caller.
4344
- A test of a re-export or forwarding wrapper belongs beside the real function: move it to the defining crate and rebuild it on that module's helpers, instead of deleting coverage the target lacks (`ui::shell_word` had no test).
45+
- `scan/gc.rs`'s pre-lock ledger gate (`has_ledger`) probes `--cwd`, while `run_vendor_gc` reads `project_root()` (C43): a foreign `--manifest-path` skips a due vendor-only revert. Pre-existing; it wants an issue. The preview path also drops `cargo_cache_patch_kept` warnings.
46+
- Pushing a branch deletion (`git push origin :branch`) is refused by the sandbox proxy. Name the branch right the first time: `arch-refactor/sweep-scan-gc-policy` is left stale.

0 commit comments

Comments
 (0)