Skip to content

Commit 7dd27ae

Browse files
committed
refactor: sweep six CLI command files (#1864)
Assisted-by: Claude Code:claude-opus-5-5
1 parent 5345c59 commit 7dd27ae

3 files changed

Lines changed: 57 additions & 9 deletions

File tree

‎coverage/files.tsv‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ crates/socket-patch-cli/src/commands/composer_hints.rs 314 audit-cli-tests c07af
77
crates/socket-patch-cli/src/commands/context.rs 109 audit-cli-tests c07af61 2026-10-29 PR #1855 module doc lists wrong users (vendor/vex; real: list, scan, get, apply); L93 doc links discover_wiring but code calls discover_wiring_in; bare #745; else clean
88
crates/socket-patch-cli/src/commands/fetch_stage.rs 649 audit-cli-tests c07af61 2026-10-29 PR #1855 delete orphan doc L270-277 and stale 'apply, vendor' module doc; drop report_offline_missing's one-value remedy param; Unavailable should carry code/detail/purls (apply re-derives wording, drifted); delete 2 can't-fail tests (obsolete diff/package archive); rename offline fully-cached test; formatters T04; overlay staging T13
99
crates/socket-patch-cli/src/commands/get.rs 6409 audit-cli-tests c07af61 2026-10-29 - move ~63 agent_download tests (~2800 lines) to agent_download.rs; delete 10 detect_* tests (copy core target.rs) and 9 select_* ranking tests (copy core ranking.rs); delete apply_failed_line const test; drop download_patch_records_with forwarder, format_single_save what param, second load_state L2379, use_public_proxy param; split run's uuid arm; ~160 comment lines; T01 T02 T15
10-
crates/socket-patch-cli/src/commands/hosted_bundle.rs 182 audit-cli-tests c8e26f6 2026-10-29 - stale module doc: stdin schema omits policySha256 (L10-L18); print_error builds ad-hoc json! (L75-L80), use Envelope + ui::print_json; hand-built ApiClient (L157-L165) skips GlobalArgs::api_client_overrides, so the socket-cli config API URL is ignored despite the doc; move fields out of bundle instead of .clone() (L140-L147)
11-
crates/socket-patch-cli/src/commands/hosted_unwind.rs 170 audit-cli-tests c8e26f6 2026-10-29 - delete dead HostedLegOutcome::unsupported (L15-L16, never written) and rollback's hosted_unsupported branches (rollback.rs L1259-L1268, L2341), see C23; inline forwarder patch_server_origins (L205); merge the two flush_error.is_none() blocks (L303, L331); skip live_before bun-lock read on dry run; module doc omits scan/withdrawn caller
12-
crates/socket-patch-cli/src/commands/list.rs 1102 audit-cli-tests c8e26f6 2026-10-29 - drop Store-as-Source alias + comment (L19-L25); PatchRecord literal L81-L89 -> ledgers::uuid_only_record; 3 RunWarning literals -> ::new; println!(to_pretty_json) -> ui::print_json; stale narration L337-L343; misplaced doc L802-L805; delete can't-fail test ordering_is_deterministic_across_builds (L985); T02 T21 T23
13-
crates/socket-patch-cli/src/commands/lock_cli.rs 596 audit-cli-tests c8e26f6 2026-10-29 - acquire_or_emit should take &GlobalArgs (all 5 callers pass the same fields); move report_lock_failure here from agent_download; inline emit, waiting_message, held_hint, held_message; ~30 comment lines (history L30, L161, L313-L315, L543-L547; lifecycle essay L34-L47 belongs in core apply_lock); 3 subset tests, 1 doc overclaim; T09
14-
crates/socket-patch-cli/src/commands/mod.rs 675 audit-cli-tests c8e26f6 2026-10-29 - move `mod user_patches` (L675) up; move vendor_state_lenient (1 caller, list text) to list.rs; global_scope_flag (L296-L302) duplicates ui::global_scope_arg and drifted (--global vs --global-prefix when both set); PatchRecord L388-L396 -> ledgers::uuid_only_record; weak tests: one asserts only .contains("--mode"), 2 only is_err(); T14
15-
crates/socket-patch-cli/src/commands/pypi_reinstall.rs 206 audit-cli-tests c8e26f6 2026-10-29 - clean (pypi_name L65-L70 hand-splits the purl: A14)
10+
crates/socket-patch-cli/src/commands/hosted_bundle.rs 182 audit-cli-tests c8e26f6 2026-10-29 PR #1864 stale module doc: stdin schema omits policySha256 (L10-L18); print_error builds ad-hoc json! (L75-L80), use Envelope + ui::print_json; hand-built ApiClient (L157-L165) skips GlobalArgs::api_client_overrides, so the socket-cli config API URL is ignored despite the doc; move fields out of bundle instead of .clone() (L140-L147)
11+
crates/socket-patch-cli/src/commands/hosted_unwind.rs 170 audit-cli-tests c8e26f6 2026-10-29 PR #1864 delete dead HostedLegOutcome::unsupported (L15-L16, never written) and rollback's hosted_unsupported branches (rollback.rs L1259-L1268, L2341), see C23; inline forwarder patch_server_origins (L205); merge the two flush_error.is_none() blocks (L303, L331); skip live_before bun-lock read on dry run; module doc omits scan/withdrawn caller
12+
crates/socket-patch-cli/src/commands/list.rs 1102 audit-cli-tests c8e26f6 2026-10-29 PR #1864 drop Store-as-Source alias + comment (L19-L25); PatchRecord literal L81-L89 -> ledgers::uuid_only_record; 3 RunWarning literals -> ::new; println!(to_pretty_json) -> ui::print_json; stale narration L337-L343; misplaced doc L802-L805; delete can't-fail test ordering_is_deterministic_across_builds (L985); T02 T21 T23
13+
crates/socket-patch-cli/src/commands/lock_cli.rs 596 audit-cli-tests c8e26f6 2026-10-29 PR #1864 acquire_or_emit should take &GlobalArgs (all 5 callers pass the same fields); move report_lock_failure here from agent_download; inline emit, waiting_message, held_hint, held_message; ~30 comment lines (history L30, L161, L313-L315, L543-L547; lifecycle essay L34-L47 belongs in core apply_lock); 3 subset tests, 1 doc overclaim; T09
14+
crates/socket-patch-cli/src/commands/mod.rs 675 audit-cli-tests c8e26f6 2026-10-29 PR #1864 move `mod user_patches` (L675) up; move vendor_state_lenient (1 caller, list text) to list.rs; global_scope_flag (L296-L302) duplicates ui::global_scope_arg and drifted (--global vs --global-prefix when both set); PatchRecord L388-L396 -> ledgers::uuid_only_record; weak tests: one asserts only .contains("--mode"), 2 only is_err(); T14
15+
crates/socket-patch-cli/src/commands/pypi_reinstall.rs 206 audit-cli-tests c8e26f6 2026-10-29 PR #1864 clean (pypi_name L65-L70 hand-splits the purl: A14)
1616
crates/socket-patch-cli/src/commands/remove.rs 2184 audit-cli-tests c8e26f6 2026-10-29 - split 924-line run (L325-L1248); inline emit_not_found, hosted_unwind_error, HostedUnwindError newtype; hosted event built twice (L893, L1679), kept-exit tail twice (L1235, L1822); rename print_hosted_leg_warnings; 6 println!(to_pretty_json); ~90 comment lines (history, bare #refs, stale L1936); fake test dry_run_footer_matches_repair; T16 T17 T19 T20
1717
crates/socket-patch-cli/src/commands/repair.rs 1349 audit-cli-tests c8e26f6 2026-10-29 - 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
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[agent] 2026-10-29: architecture refactor (sweep)
2+
3+
`main` @ `5ca5623`. The previous run was a sweep, so this run looked for structural work first. No eligible candidate scored 6 or more:
4+
- A02 [#1833](https://github.com/SocketDev/socket-patch/issues/1833) is still blocked: #1829 and #1863 touch `workspace_globs.rs`.
5+
- T01 [#1835](https://github.com/SocketDev/socket-patch/issues/1835) and T05 [#1839](https://github.com/SocketDev/socket-patch/issues/1839) are blocked by #1698.
6+
- The new T16 [#1861](https://github.com/SocketDev/socket-patch/issues/1861) scores about 5.5 (D1.75 C2, risk M; its drift is unexecuted, so B0).
7+
8+
So I ran a sweep, per the rule. There was no maintainer steering, and no PR of mine merged or closed.
9+
10+
**PR:** [#1864](https://github.com/SocketDev/socket-patch/pull/1864), ready for review. CI and Bugbot are pending.
11+
12+
### Per file
13+
- **`hosted_unwind.rs`:**
14+
- Deleted the never-written `HostedLegOutcome::unsupported`, along with rollback's dead `hosted_unsupported` loop and exit-code conjunct.
15+
- Merged the two post-flush blocks.
16+
- A dry run no longer reads bun patch keys.
17+
- Removed 3 bare `#` references.
18+
- Net about −11, plus −11 in `rollback.rs`.
19+
- **`hosted_bundle.rs`:** `take()` instead of `clone()`, and the doc now lists `policySha256`. Net 0.
20+
- **`list.rs`:**
21+
- 1 fn inlined (`vendor_state_lenient`, from `mod.rs`).
22+
- 1 alias dropped.
23+
- `uuid_only_record`, and 3 `RunWarning::new`.
24+
- About 12 comment lines removed.
25+
- 1 can't-fail test deleted.
26+
- Net about −23.
27+
- **`lock_cli.rs`:**
28+
- 3 fns inlined (`emit`, `held_hint`, `held_message`). The human error now goes through `format_lock_error`.
29+
- About 40 comment lines removed.
30+
- Tests: 3 merged into 1, and 1 duplicate deleted.
31+
- Net about −104.
32+
- **`mod.rs`:**
33+
- `mod user_patches` moved up, and `uuid_only_record` used.
34+
- 3 weak tests fixed (exact usage errors), shown red→green.
35+
- Net about −1.
36+
- **`pypi_reinstall.rs`:** clean.
37+
- **Total:** +160 / −300. Production about −105, tests about −35.
38+
39+
### Merges recorded
40+
None.
41+
42+
### Lessons
43+
- An unconstrained `cargo build` of the CLI test binaries fills the session's disk allowance. Build with `CARGO_PROFILE_DEV_DEBUG=0 CARGO_INCREMENTAL=0`, and run only the CI clippy command (`--workspace --all-features`, no `--tests`; the integration tests carry pre-existing lints).
44+
- `hosted_bundle`'s `json!` error and its hand-built `ApiClient` change output or behavior, so a sweep can't touch them. They need an issue.

‎register/90-refactor.md‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
### Refactor routine
2-
_Last updated 2026-10-29T21:15Z · main @ c8e26f6_
2+
_Last updated 2026-10-29T23:25Z · main @ 5ca5623_
33

44
#### In flight
55
| PR | Kind | Scope | State |
66
|---|---|---|---|
77
| [#1842](https://github.com/SocketDev/socket-patch/pull/1842) | sweep | `cli/src/args.rs` (+ the Deno guard moved into `lib.rs`) | ready |
88
| [#1855](https://github.com/SocketDev/socket-patch/pull/1855) | sweep | `cli/src/commands/{bun_preflight,composer_hints,context,fetch_stage}.rs` | ready; Bugbot clean; CI lost Depot runners twice (0 steps), needs a fresh run |
99
| [#1849](https://github.com/SocketDev/socket-patch/pull/1849) | structural | A01 [#1832](https://github.com/SocketDev/socket-patch/issues/1832): `utils/cargo_build_cache.rs` | ready; CI and Bugbot green |
10+
| [#1864](https://github.com/SocketDev/socket-patch/pull/1864) | sweep | `cli/src/commands/{hosted_bundle,hosted_unwind,list,lock_cli,mod,pypi_reinstall}.rs` (+ dead branch in `rollback.rs`) | ready; CI and Bugbot pending |
1011

1112
#### Merged
1213
_None._
@@ -17,9 +18,11 @@ Structural candidates, scored `3·B + 2·U + 2·D + 2·C − risk`:
1718
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 while #1698 touches `get.rs` / `agent_download.rs`)
1819
3. A03 [#1834](https://github.com/SocketDev/socket-patch/issues/1834), GOMODCACHE rule twice: D1 C1, risk L. **4**
1920
4. T03 [#1837](https://github.com/SocketDev/socket-patch/issues/1837), hand-written env var lists: D1 C1, risk L. **4**
20-
5. A05 [#1844](https://github.com/SocketDev/socket-patch/issues/1844), `lock_fragments` pairing loops ×3: D1 C1, risk M. **~2**
21+
5. T16 [#1861](https://github.com/SocketDev/socket-patch/issues/1861), remove/rollback `VendorRevertStep` loops: D1.75 C2, risk M. **~5.5** (files free)
2122

22-
The next run is structural (this run was a sweep). Next sweep files, in order: `core/constants.rs`, `core/lib.rs`, `core/utils/cargo_home.rs`, `core/utils/cargo_workspace.rs` (skip `cargo_build_cache.rs` while #1849 is open). Skip `agent_download.rs`, `apply.rs`, `get.rs` and `vendor.rs` while #1698 is open.
23+
A03/T03 stay at 4, and A05 [#1844](https://github.com/SocketDev/socket-patch/issues/1844) at ~2.
24+
25+
The next run is structural if a candidate reaches 6; otherwise it sweeps. Next sweep files, in order: `cli/commands/remove.rs`, `repair.rs`, `rollback.rs`, `scan/discovery.rs` (check against #1856), then `core/constants.rs`, `core/lib.rs`, `core/utils/cargo_home.rs`, `core/utils/cargo_workspace.rs` (skip `cargo_build_cache.rs` while #1849 is open). Skip `agent_download.rs`, `apply.rs`, `get.rs` and `vendor.rs` while #1698 is open.
2326

2427
#### Notes
2528
- The PRs of the first thread (`arch-refactor/<issue>-*`) are listed in `review/2026-10-v1/register/90-refactor.md`.
@@ -28,3 +31,4 @@ The next run is structural (this run was a sweep). Next sweep files, in order: `
2831
- `--cwd` defaults to `.`, and `Path::new(".").ancestors()` stops at `.`. Any core walk up from the cwd must absolutize it first (`cargo_crawler::resolve_for` and `nuget_config` do; `cargo_build_cache` didn't until #1849). A test that spells the cwd as a relative path *with* components can't catch this: chdir under `#[serial]` and pass `"."`.
2932
- `vendor/cargo_config.rs` (~L165-L190) keeps a third, async copy of the `.cargo/config` pick, with canonical dedup. It agrees on precedence; fold it into `config_layer_paths` when that file is swept.
3033
- #1698 also touches `vendor.rs`, so the three `bun_vendor_preflight*` entry points (callers in `get.rs`, `agent_download.rs`, `vendor.rs`) and `StageOutcome::Unavailable`'s payload (caller `apply.rs`) wait until it merges. Check every caller file against open PRs, not only the swept file.
34+
- Build with `CARGO_PROFILE_DEV_DEBUG=0 CARGO_INCREMENTAL=0`: a default debug build of the CLI tests exhausts the session disk allowance. CI's clippy is `--workspace --all-features` without `--tests`; the integration tests carry pre-existing lints.

0 commit comments

Comments
 (0)