GeezerVison is showing github.com — refactor: sweep core constants and utils (#1907) · SocketDev/socket-patch@1c0fef8
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: coverage/files.tsv +9-9Lines changed: 9 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -492,18 +492,18 @@ crates/socket-patch-cli/build.rs 11 audit-cli-tests - - | 492 | 492 | crates/socket-patch-node/build.rs 3 audit-cli-tests - - | 493 | 493 | crates/socket-patch-node/src/lib.rs 369 audit-cli-tests - - | 494 | 494 | crates/socket-patch-node/src/provider.rs 276 audit-cli-tests - - | 495 | | -crates/socket-patch-core/src/constants.rs 108 audit-core b291caa 2026-10-29 - delete tautology tests user_agent_reports_real_crate_version, manifest_path_is_under_dot_socket; trim api_urls test to https/no-slash/distinct asserts; move test mod to file end; derive DEFAULT_PATCH_MANIFEST_PATH from SOCKET_DIR (concat!); ~8 comment lines (history L17-20) | | 495 | +crates/socket-patch-core/src/constants.rs 108 audit-core b291caa 2026-10-29 PR #1907 delete tautology tests user_agent_reports_real_crate_version, manifest_path_is_under_dot_socket; trim api_urls test to https/no-slash/distinct asserts; move test mod to file end; derive DEFAULT_PATCH_MANIFEST_PATH from SOCKET_DIR (concat!); ~8 comment lines (history L17-20) | 496 | 496 | crates/socket-patch-core/src/lib.rs 22 audit-core b291caa 2026-10-29 - clean | 497 | 497 | crates/socket-patch-core/src/utils/cargo_build_cache.rs 483 audit-core b291caa 2026-10-29 - make private: build_dirs_with, invalidate, BuildDirs, Invalidation, STALE_WARNING, cargo_purl_name (only invalidate_project is external); inline build_dirs, is_unit_hash; hex check x2 -> digest helper (A06); drop bare #387; config read duplicates config_layer_paths (A01 #1832); gap: warning text untested | 498 | | -crates/socket-patch-core/src/utils/cargo_home.rs 191 audit-core b291caa 2026-10-29 - cut module-doc story + #1135 (L5-13, L127); drop forwarder CargoCrawler::cargo_home (cargo_crawler.rs:266) and call utils::cargo_home directly; consider moving the one fn beside fs::home_dir (A10) | | 498 | +crates/socket-patch-core/src/utils/cargo_home.rs 191 audit-core b291caa 2026-10-29 PR #1907 cut module-doc story + #1135 (L5-13, L127); drop forwarder CargoCrawler::cargo_home (cargo_crawler.rs:266) and call utils::cargo_home directly; consider moving the one fn beside fs::home_dir (A10) | 499 | 499 | crates/socket-patch-core/src/utils/cargo_workspace.rs 690 audit-core b291caa 2026-10-29 - drop expand_glob (call expand_glob_bounded(..).0); inline is_real_dir; make is_real_dir_path private; expect() in member_manifests_in L41; trim FACTS_MEMO doc; drop B74:/V-7:/pre-memo notes; wildcard_match -> segment_glob_matches (A02 #1833); move glob walk to workspace_globs, normalize_rel+join_rel(x3) to relpath; is_real_dir x3 | 500 | | -crates/socket-patch-core/src/utils/composer_version.rs 415 audit-core b291caa 2026-10-29 - delete composer_version_identity_key (no external caller); composer_versions_equivalent = key(a)==key(b); drop \u{1} sentinel doc L22-26 and history L7-8; fold identity_key equality test into sentinel test; strip_leading_v duplicates composer_crawler::normalize_version (E37, #748) | 501 | | -crates/socket-patch-core/src/utils/concurrent.rs 429 audit-core b291caa 2026-10-29 - make API_CONCURRENCY, _FLOOR, REQUESTS_PER_SLOT, REGISTRY_CONCURRENCY private; MAX_API_CONCURRENCY==API_CONCURRENCY: keep one; drop adaptive_concurrency floor/ceiling params (one value); per_window_cap test recomputes via code under test: assert literals; env override read twice in api_concurrency_for_under; env parse style (A09) | 502 | | -crates/socket-patch-core/src/utils/containment.rs 216 audit-core b291caa 2026-10-29 - make linked_level_refusal private; move nearest_socket_dir/socket_project_root to socket_dir.rs (only user); is_link doc stale (claims all vendor probes delegate); delete async fs::is_symlink wrapper, call is_link; point lock_inventory/view.rs:895 at is_link | 503 | | -crates/socket-patch-core/src/utils/digest.rs 224 audit-core b291caa 2026-10-29 - PENDING_INLINE_DIGESTS doc cites #706 as pending: one-line instruction; vendor/jvm/mod.rs:621-631 sha1_hex/sha256_hex compute under the validator names: delete, use *_hex_of; move the listed pending inline digests and drop the list; lint only skips `mod tests {` (A06) | 504 | | -crates/socket-patch-core/src/utils/durability.rs 365 audit-core b291caa 2026-10-29 - make sync_all_blocking private; barrier = failpoint + spawn_blocking(barrier_blocking) (-10); ~25 comment lines (78-line module doc; history 'as it always did' L17/L41/L72/L166/L227); dead if-let in Pending::moved L128; join error loses panic L185; test sync_skips_vanished... asserts only Ok: rename | 505 | | -crates/socket-patch-core/src/utils/env_compat.rs 193 audit-core b291caa 2026-10-29 - is_debug_enabled/is_offline_env share one exact-'1'/'true' parse: private env_flag(); move debug_log/debug_message to utils/debug.rs; three env vocabularies with socket_cli_config/concurrent (A09); debug_lines_have_one_printer scan only skips `mod tests {` | 506 | | -crates/socket-patch-core/src/utils/failpoint.rs 87 audit-core b291caa 2026-10-29 - hit(): check point==name&&at==count once, then branch on pause; malformed @n silently becomes 1 (unwrap_or): panic instead (test-only) | | 500 | +crates/socket-patch-core/src/utils/composer_version.rs 415 audit-core b291caa 2026-10-29 PR #1907 delete composer_version_identity_key (no external caller); composer_versions_equivalent = key(a)==key(b); drop \u{1} sentinel doc L22-26 and history L7-8; fold identity_key equality test into sentinel test; strip_leading_v duplicates composer_crawler::normalize_version (E37, #748) | | 501 | +crates/socket-patch-core/src/utils/concurrent.rs 429 audit-core b291caa 2026-10-29 PR #1907 make API_CONCURRENCY, _FLOOR, REQUESTS_PER_SLOT, REGISTRY_CONCURRENCY private; MAX_API_CONCURRENCY==API_CONCURRENCY: keep one; drop adaptive_concurrency floor/ceiling params (one value); per_window_cap test recomputes via code under test: assert literals; env override read twice in api_concurrency_for_under; env parse style (A09) | | 502 | +crates/socket-patch-core/src/utils/containment.rs 216 audit-core b291caa 2026-10-29 PR #1907 make linked_level_refusal private; move nearest_socket_dir/socket_project_root to socket_dir.rs (only user); is_link doc stale (claims all vendor probes delegate); delete async fs::is_symlink wrapper, call is_link; point lock_inventory/view.rs:895 at is_link | | 503 | +crates/socket-patch-core/src/utils/digest.rs 224 audit-core b291caa 2026-10-29 PR #1907 PENDING_INLINE_DIGESTS doc cites #706 as pending: one-line instruction; vendor/jvm/mod.rs:621-631 sha1_hex/sha256_hex compute under the validator names: delete, use *_hex_of; move the listed pending inline digests and drop the list; lint only skips `mod tests {` (A06) | | 504 | +crates/socket-patch-core/src/utils/durability.rs 365 audit-core b291caa 2026-10-29 PR #1907 make sync_all_blocking private; barrier = failpoint + spawn_blocking(barrier_blocking) (-10); ~25 comment lines (78-line module doc; history 'as it always did' L17/L41/L72/L166/L227); dead if-let in Pending::moved L128; join error loses panic L185; test sync_skips_vanished... asserts only Ok: rename | | 505 | +crates/socket-patch-core/src/utils/env_compat.rs 193 audit-core b291caa 2026-10-29 PR #1907 is_debug_enabled/is_offline_env share one exact-'1'/'true' parse: private env_flag(); move debug_log/debug_message to utils/debug.rs; three env vocabularies with socket_cli_config/concurrent (A09); debug_lines_have_one_printer scan only skips `mod tests {` | | 506 | +crates/socket-patch-core/src/utils/failpoint.rs 87 audit-core b291caa 2026-10-29 PR #1907 hit(): check point==name&&at==count once, then branch on pause; malformed @n silently becomes 1 (unwrap_or): panic instead (test-only) | 507 | 507 | crates/socket-patch-core/src/utils/fs.rs 1991 audit-core b291caa 2026-10-29 - split grab-bag: home -> utils/home.rs, writers -> utils/atomic_write.rs (A10); delete asyncify, use run_blocking (two join policies); delete async is_symlink; make first_symlink sync; entry_file_type + its 2 tests -> npm oracle (test-only); WriteOpts presets -> enum; ~65 comment lines (L1543-1575 narrative, history/#refs); ~5 dup/merge tests; with_home_env -> injected closure | 508 | 508 | crates/socket-patch-core/src/utils/go_env.rs 287 audit-core b291caa 2026-10-29 - go_env_with private/cfg(test); env file re-read+parsed per go_env() call (go_workspace reads twice); Go-only code in utils: move with go_installed_tools to a golang module (A08); GOMODCACHE rule duplicated (A03 #1834); drop #344/#1799 refs | 509 | 509 | crates/socket-patch-core/src/utils/go_installed_tools.rs 644 audit-core b291caa 2026-10-29 - make private: GoBinary, BinDirs, Inspection, parse_version_m, bin_dirs(_with), installed_binaries, stale_tools(_with), audit_sync, unchecked/unlocated_detail; audit returns Vec<(code,detail)> with one code: return details; drop redundant !is_empty filters; test an_unlistable_directory_is_reported_unchecked asserts 0 when go on PATH: inject go path; A03 #1834 | |
Collapse file Copy file name to clipboard +50Lines changed: 50 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +[agent] 2026-11-01: architecture refactor (sweep) | | 2 | + | | 3 | +`main` @ `cbbbdb9`. 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); | | 5 | +- T09, T01 and T25 (#1864, #1698); | | 6 | +- A41 (`npm_crawler.rs`, now also held by the fixer's #1906); | | 7 | +- A43 (#1863, #1698). | | 8 | + | | 9 | +So I ran a sweep, per the rule. `scan/policy.rs` and `scan/render.rs` still wait on #1856 and #1884, so the next audited, unswept rows with free files were core `constants.rs` and `utils/{cargo_home,composer_version,concurrent,containment,digest,durability,env_compat,failpoint}.rs`. There was no maintainer steering, and no PR of mine merged or closed. | | 10 | + | | 11 | +**PR:** [#1907](https://github.com/SocketDev/socket-patch/pull/1907), ready for review. `/code-review high` ran first, and its 3 confirmed findings are fixed. Bugbot was triggered; CI was still running at hand-off. | | 12 | + | | 13 | +### Per file | | 14 | +- **`constants.rs`:** 2 tautological tests deleted, and the URL test trimmed to the https/no-slash/distinct asserts. About 4 history comment lines removed. Net −33. | | 15 | +- **`cargo_home.rs`:** about 9 comment lines of module-doc story and bare `#1135` refs removed. Net −7. | | 16 | +- **`composer_version.rs`:** | | 17 | + - 1 dead pub fn deleted (`composer_version_identity_key`). `composer_versions_equivalent` now uses the `PurlKey` key. | | 18 | + - 2 pairwise tests merged into 1 that is checked against an independent spec, shown red→green. | | 19 | + - About 8 comment lines removed. | | 20 | + - Net −37, plus −5 in `purl_key.rs` tests. | | 21 | +- **`concurrent.rs`:** | | 22 | + - 1 duplicate const deleted (`MAX_API_CONCURRENCY`), and 1 fn inlined (`adaptive_concurrency`). | | 23 | + - 5 consts made private or `pub(crate)`, and the env override is now read once. | | 24 | + - The per-window test asserts literals, shown red→green. | | 25 | + - Net −20. | | 26 | +- **`containment.rs`:** | | 27 | + - 1 fn inlined (`socket_project_root`), 1 fn moved to `socket_dir.rs` (`nearest_socket_dir`), and 1 fn made private. | | 28 | + - The moved test gains a nested-`.socket` case, shown red→green. | | 29 | + - Net −29 here, +19 in `socket_dir.rs`. | | 30 | +- **`digest.rs`:** a banner and a stale note removed. Net −4. | | 31 | +- **`durability.rs`:** | | 32 | + - The take/sync/restore sequence is shared (`sync_or_restore`), `sync_all_blocking` is private, and a dead `if let` is removed. | | 33 | + - About 6 history comment lines removed, and 1 overclaiming test renamed. | | 34 | + - Net −11. | | 35 | +- **`env_compat.rs`:** 1 private `env_flag` replaces 2 copies. Net −2. | | 36 | +- **`failpoint.rs`:** the match is flattened. Net +1. | | 37 | +- **Total:** +163 / −291, about −52 production and −76 test lines. | | 38 | + | | 39 | +### Behavior | | 40 | +None. | | 41 | + | | 42 | +### Merges recorded | | 43 | +None. | | 44 | + | | 45 | +### Lessons | | 46 | +- **`git checkout <file>` after a mutation test reverted my uncommitted `concurrent.rs` edits.** I redid them; commit before mutating. | | 47 | +- **Watch what /code-review flags:** | | 48 | + - narrowing `pub` items leaves private intra-doc links; | | 49 | + - an inlined `clamp` loses a `min` guard, now a `const` assert; | | 50 | + - a check placed ahead of the take split an atomic step. |
Collapse file Copy file name to clipboardExpand all lines: register/90-refactor.md +8-4Lines changed: 8 additions & 4 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | ### Refactor routine | 2 | | -_Last updated 2026-11-01T01:15Z · main @ cbbbdb9_ | | 2 | +_Last updated 2026-11-01T03:35Z · main @ cbbbdb9_ | 3 | 3 |
| 4 | 4 | #### In flight | 5 | 5 | | PR | Kind | Scope | State | | @@ -14,21 +14,22 @@ _Last updated 2026-11-01T01:15Z · main @ cbbbdb9_ | 14 | 14 | | [#1892](https://github.com/SocketDev/socket-patch/pull/1892) | sweep | `cli/src/commands/scan/gc.rs` | ready; CI (82 checks) and Bugbot green | | 15 | 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 green; burn-down final review done | | 16 | 16 | | [#1903](https://github.com/SocketDev/socket-patch/pull/1903) | sweep | `cli/src/commands/scan/hosted/{nuget,takeover}.rs` | ready; CI (82 checks) and Bugbot green | | | 17 | +| [#1907](https://github.com/SocketDev/socket-patch/pull/1907) | sweep | core `constants.rs`, `utils/{cargo_home,composer_version,concurrent,containment,digest,durability,env_compat,failpoint}.rs` (+ `socket_dir.rs`, `purl_key.rs` tests) | ready; CI and Bugbot pending at hand-off | | 17 | 18 |
| 18 | 19 | #### Merged | 19 | 20 | _None._ | 20 | 21 |
| 21 | 22 | #### Queue | 22 | | -Structural candidates, scored `3·B + 2·U + 2·D + 2·C − risk`. Every one scoring 6 or more is blocked by an open PR as of 2026-11-01: | | 23 | +Structural candidates, scored `3·B + 2·U + 2·D + 2·C − risk`. Every one scoring 6 or more is blocked by an open PR as of 2026-11-01T03Z: | 23 | 24 | 1. A30 [#1887](https://github.com/SocketDev/socket-patch/issues/1887), Maven `${…}` interpolation ×5: **~8.7** (blocked by #1886: `maven_scope.rs`, `maven_reactor.rs`). | 24 | 25 | 2. T09 [#1858](https://github.com/SocketDev/socket-patch/issues/1858), lock acquire open-coded 9×: **~7** (blocked by #1864 `lock_cli.rs`, #1698 `vendor.rs`/`get.rs`/`agent_download.rs`). | 25 | | -3. A41 [#1899](https://github.com/SocketDev/socket-patch/issues/1899), npm store-child classification ×3: D2 C2, risk M, **~6** (blocked by #1891 and #1829: `npm_crawler.rs`). | | 26 | +3. A41 [#1899](https://github.com/SocketDev/socket-patch/issues/1899), npm store-child classification ×3: D2 C2, risk M, **~6** (blocked by #1891, #1829 and #1906: `npm_crawler.rs`). | 26 | 27 | 4. A43 [#1900](https://github.com/SocketDev/socket-patch/issues/1900), package.json `workspaces` read 5×: **~6** (blocked by #1863 `governing_root.rs`, #1698 `vendor/mod.rs`). | 27 | 28 | 5. T01 [#1835](https://github.com/SocketDev/socket-patch/issues/1835) (~6.4) and T25 [#1877](https://github.com/SocketDev/socket-patch/issues/1877) (~6): blocked by #1698. | 28 | 29 |
| 29 | 30 | A05 is the fixer's #1898, A32 its #1895. A42 [#1901](https://github.com/SocketDev/socket-patch/issues/1901) (~4) waits on `npm_crawler.rs`; A45 [#1902](https://github.com/SocketDev/socket-patch/issues/1902) is a P1 bug (~5) for the fixer. 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). | 30 | 31 |
| 31 | | -The next run is structural if a candidate scoring 6 or more has free files, else a sweep. Next sweep files, in order: `scan/policy.rs` and `scan/render.rs` once #1856/#1884 merge, then core `constants.rs`, then `utils/cargo_home.rs` (its `CargoCrawler::cargo_home` forwarder waits on #1882), `utils/composer_version.rs`, `utils/concurrent.rs`, `utils/containment.rs`, `utils/digest.rs`. `scan/hosted/python.rs` is in #1883; `utils/fs.rs` and core `lib.rs` are in #1891, `go_env.rs`/`go_installed_tools.rs` in #1876, `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. | | 32 | +The next run is structural if a candidate scoring 6 or more has free files, else a sweep. Next sweep files, in order: `scan/policy.rs` and `scan/render.rs` once #1856/#1884 merge; core `utils/http.rs`, `utils/line_endings.rs` (clean), `utils/lock_fragments.rs` (wait on #1898), `utils/mod.rs`, then `utils/hatch.rs`/`hatch_workspace.rs`. Waiting on PRs: `utils/fs.rs` and core `lib.rs` (#1891), `go_env.rs`/`go_installed_tools.rs` (#1876), `cargo_workspace.rs` (#1866), `cargo_build_cache.rs` (#1849), `group_commit.rs` is free but 2,163 lines (sweep a region). `scan/hosted/python.rs` is in #1883. Skip `agent_download.rs`, `apply.rs`, `get.rs`, `vendor.rs` while #1698 is open, `rollback.rs` while #1864 is open. Left from #1907: `CargoCrawler::cargo_home` forwarder (#1882), digest's `vendor/jvm` copies (#1886), async `fs::is_symlink` (#1891). | 32 | 33 |
| 33 | 34 | #### Notes | 34 | 35 | - The PRs of the first thread (`arch-refactor/<issue>-*`) are listed in `review/2026-10-v1/register/90-refactor.md`. | @@ -49,3 +50,6 @@ The next run is structural if a candidate scoring 6 or more has free files, else | 49 | 50 | - `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. | 50 | 51 | - 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. | 51 | 52 | - A dead-branch proof needs the earlier branch's exact condition: in takeover's `stage`, the residual-reference conjunct of the keep-wiring branch was dead only because `residual_only_keep` returns `Some` whenever nothing drifted. Core's `kept_for_residual_reference` also requires `kept_artifact`, which a dry-run pypi revert doesn't set, so swapping it in would not have been behavior-neutral. | | 53 | +- Never restore a file with `git checkout <file>` after a mutation test while the sweep is uncommitted: it reverts the whole file to HEAD. Commit first, then mutate and `git checkout HEAD -- <file>`. | | 54 | +- Making a `pub` core item private can leave public docs linking it (`rustdoc::private_intra_doc_links`); CI doesn't run rustdoc, but /code-review checks. Unlink in the same commit. | | 55 | +- Folding an "is anything pending?" check ahead of a take splits one atomic step into two: keep take-then-act (durability `barrier`). |
|