Skip to content

Commit 246cc4d

Browse files
committed
refactor: sweep scan/hosted.rs (#1897)
Assisted-by: Claude Code:claude-opus-5-5
1 parent 3c07b1f commit 246cc4d

3 files changed

Lines changed: 41 additions & 3 deletions

File tree

‎coverage/files.tsv‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ crates/socket-patch-cli/src/commands/repair.rs 1349 audit-cli-tests c8e26f6 2026
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)
2020
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)
21-
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
21+
crates/socket-patch-cli/src/commands/scan/hosted.rs 4955 audit-cli-tests 5ca5623 2026-10-30 PR #1897 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
2424
crates/socket-patch-cli/src/commands/scan/hosted/takeover.rs 721 audit-cli-tests 5ca5623 2026-10-30 - 425-line plan/stage/retract/finish engine belongs in core (C12), imports commands::vendor::dispatch_revert_one; residual_only_keep L570-591 parses core warning prose; revert_keeps_wiring L565 literal not RESIDUAL_REFERENCE_CODE; finish L411 removes all PurlKey::same entries (T33); hand purl split L601 (A14); json warnings (T27); no unit tests
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 still has files held by an open PR:
4+
- A30 (#1886), A05 (#1865) and A32 (#1882, and now the fixer's #1895);
5+
- T09, T01 and T25 (#1864, #1698).
6+
7+
The free candidates, A20 and A26, score about 4. So I ran a sweep, per the rule. The next audited, unswept row with free files is `scan/hosted.rs`. There was no maintainer steering, and no PR of mine merged or closed.
8+
9+
**PR:** [#1897](https://github.com/SocketDev/socket-patch/pull/1897), ready for review. `/code-review high` ran first and found no bugs in the diff. CI and Bugbot were pending at handoff.
10+
11+
### Per file
12+
- **`scan/hosted.rs`** (all but the 1,233-line `run_redirect_selected_untracked`, which is T24):
13+
- 1 fn inlined (`emit_json_error`), and `run_redirect`'s dead human arm deleted (it runs only under `--json`).
14+
- 1 test-only wrapper deleted (`installed_stale_positive_evidence`), and 1 `#[cfg(test)]` re-export shim of 17 core items deleted.
15+
- The gem probe's vendor/cache fold is flattened. Shown red→green.
16+
- About 120 comment lines removed, including 3 banners and bare issue references.
17+
- Tests: 13 guidance tests moved to core `hosted/guidance.rs`, and 2 pnpm lock-sniff tests moved to `formats/pnpm/mod.rs`.
18+
- 1 duplicate test deleted.
19+
- 1 test's missing `\/`-escaped assertion added, shown red→green.
20+
- Net: production −147, tests −595 in the file. Repository-wide: +696 / −847, most of it the move.
21+
- **Callers:** `scan/mod.rs` passes the envelope by value (±1).
22+
23+
### Behavior
24+
None.
25+
26+
### Merges recorded
27+
None.
28+
29+
### Lessons
30+
- **/code-review found two pre-existing gaps in the gem stale probe's pass 3:**
31+
- it dedups vendor/cache warnings by purl string;
32+
- it builds the archive name without the platform suffix.
33+
34+
Both change output, so they were noted for an issue rather than fixed in the sweep.
35+
- **When a doc comment claims a case, check that an assert covers it.** The moved heal-probe test documented three URL spellings but asserted only two.

‎register/90-refactor.md‎

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

44
#### In flight
55
| PR | Kind | Scope | State |
@@ -12,6 +12,7 @@ _Last updated 2026-10-30T07:25Z · main @ 5ca5623_
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 |
1414
| [#1892](https://github.com/SocketDev/socket-patch/pull/1892) | sweep | `cli/src/commands/scan/gc.rs` | ready; CI (82 checks) and Bugbot green |
15+
| [#1897](https://github.com/SocketDev/socket-patch/pull/1897) | sweep | `cli/src/commands/scan/hosted.rs` (all but `run_redirect_selected_untracked`, T24; 13 guidance tests moved to core `hosted/guidance.rs`, 2 to `formats/pnpm/mod.rs`) | ready; CI and Bugbot pending |
1516

1617
#### Merged
1718
_None._
@@ -26,7 +27,7 @@ Structural candidates, scored `3·B + 2·U + 2·D + 2·C − risk`:
2627

2728
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`).
2829

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).
30+
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/{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/utils/cargo_home.rs`. `core/lib.rs` is in #1891 and `core/utils/cargo_workspace.rs` in #1866. 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).
3031

3132
#### Notes
3233
- The PRs of the first thread (`arch-refactor/<issue>-*`) are listed in `review/2026-10-v1/register/90-refactor.md`.
@@ -44,3 +45,5 @@ The next run is structural if a candidate scores 6 or more and its files are fre
4445
- 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).
4546
- `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.
4647
- 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.
48+
- `scan::hosted::run_redirect` runs only under `--json` (scan/mod.rs calls it inside `if args.common.json`); the human arm goes through `boxed_run_redirect_selected`. `run_redirect_selected` still takes `Option<Envelope>` keyed on `common.json`; making it a value touches `get.rs` (#1698) and the T24 body.
49+
- The gem stale probe (`scan/hosted.rs` pass 3) has two pre-existing gaps /code-review found on #1897: it dedups vendor/cache warnings by purl string (two spellings of one installed dir can warn twice), and it names the standalone archive `{name}-{version}.gem`, missing a platform gem's suffix. Both change output, so they want an issue.

0 commit comments

Comments
 (0)