Skip to content

Commit 78f118d

Browse files
committed
refactor: sweep python_lock/python_script (#1990)
Assisted-by: Claude Code:claude-opus-5-5
1 parent a894b5c commit 78f118d

3 files changed

Lines changed: 57 additions & 14 deletions

File tree

‎coverage/files.tsv‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,8 @@ crates/socket-patch-core/src/utils/process.rs 783 audit-core c07af61 2026-10-29
526526
crates/socket-patch-core/src/utils/purl.rs 1428 audit-core c07af61 2026-10-29 PR #1920 make parse_name_version private; inline parse_jsr_purl/build_jsr_purl into deno_crawler; drop JsrPurlParts alias and is_purl; 7 build_*_purl are bare format! wrappers; ~25 comment lines (strip_purl_qualifiers essay, REGRESSION/B73/#1024 tags, banner); delete 7 test_build_*_purl + 7 *_round_trip + test_is_purl tautologies; move PurlKey asserts to purl_key.rs; fold 3 test mods; three splitters: A14
527527
crates/socket-patch-core/src/utils/purl_key.rs 633 audit-core c07af61 2026-10-29 - inline release_identity/nuget_identity/composer_identity into PurlKey::new and is_canonical_base into canonical_base_purl; hand purl splits -> A14; CLI scan/rollout.rs L18-141 and policy.rs L451 key maps by into_string(): key by PurlKey; test nuget_key_agrees_with_the_vendored_version_match recomputes expected via normalize_nuget_version; ~8 comment lines; imports crawlers+vendor: A08
528528
crates/socket-patch-core/src/utils/purl_key_nuget_vendor_tests.rs 151 audit-core c07af61 2026-10-29 - misplaced: end-to-end vendor_nuget + vex test with nothing purl_key-specific; move beside vendor nuget tests (test_support::vendor_nuget); drop history module doc (#1202 story)
529-
crates/socket-patch-core/src/utils/python_lock.rs 2283 audit-core c07af61 2026-10-29 - delete dead pub complete_python_lock_metadata(+_in); fold PythonLockProbe into PythonLockSession::plan, drop probe_equivalence_tests; inline check_python_lock_source_scope; one repoint(table, artifact) helper for 4 copies; source_identity is a 2nd uv-source reader beside UvSource; ~15 comment lines; 'ours' test asserts is_ok() (passes on Ok(None)); fold 5 test mods; see A24, A25
530-
crates/socket-patch-core/src/utils/python_script.rs 1768 audit-core c07af61 2026-10-29 - drop always-None script param of refuse_uv_no_sources/no_binary and fold the 4 refuse_uv_* wrappers into refuse_package_setting; make is_hosted_override private; one tool_uv(doc) for 4 chains; one direct-deps fn for 3 copies (L319, L383, L891); inline push_hosted_override; ancestor_uv_config_files: use relpath (A19); trim SourcesLayout doc; ~12 bare #refs; untested no_binary; see A15, A22, A24
529+
crates/socket-patch-core/src/utils/python_lock.rs 2283 audit-core c07af61 2026-10-29 PR #1990 delete dead pub complete_python_lock_metadata(+_in); fold PythonLockProbe into PythonLockSession::plan, drop probe_equivalence_tests; inline check_python_lock_source_scope; one repoint(table, artifact) helper for 4 copies; source_identity is a 2nd uv-source reader beside UvSource; ~15 comment lines; 'ours' test asserts is_ok() (passes on Ok(None)); fold 5 test mods; see A24, A25
530+
crates/socket-patch-core/src/utils/python_script.rs 1768 audit-core c07af61 2026-10-29 PR #1990 drop always-None script param of refuse_uv_no_sources/no_binary and fold the 4 refuse_uv_* wrappers into refuse_package_setting; make is_hosted_override private; one tool_uv(doc) for 4 chains; one direct-deps fn for 3 copies (L319, L383, L891); inline push_hosted_override; ancestor_uv_config_files: use relpath (A19); trim SourcesLayout doc; ~12 bare #refs; untested no_binary; see A15, A22, A24
531531
crates/socket-patch-core/src/utils/redact.rs 552 audit-core c07af61 2026-10-29 PR #1923 dead pub url_userinfo/strip_url_credentials + test: A20; fix module doc L22-24; private is_uuid_shaped twin: A15; move the_service_download_advisory_has_one_builder to vendor/service_fetch.rs (it lints that file)
532532
crates/socket-patch-core/src/utils/relpath.rs 232 audit-core c07af61 2026-10-29 - code clean; module doc 'every normalizer in the crate' is false (4 copies, A19); trim history in regression-test doc L217-220
533533
crates/socket-patch-core/src/utils/repo_root.rs 363 audit-core c07af61 2026-10-29 PR #1923 inline GitRepo::dot_git (1 caller, policy/mod.rs); home(): A10; module doc 'the one walk' is false (A21); drop bare 'B22' tag L240
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[agent] 2026-11-02: architecture refactor (sweep)
2+
3+
`main` @ `cbbbdb9`, unchanged since the last run. The previous entry was structural (#1988), so this run is a sweep. None of my 28 open PRs has merged or closed, and the discussion has no maintainer steering.
4+
5+
I took core `utils/{python_lock,python_script}.rs`, the next free audited rows on the queue. No open PR touches them; I checked by diffing all 73 open heads locally. The callers I changed in `hosted/engine.rs` and `patch/redirect/mod.rs` are held by 10 PRs, and `git merge-tree` shows the branch merges cleanly with each. No open PR adds a caller of a removed or changed item.
6+
7+
**PR:** [#1990](https://github.com/SocketDev/socket-patch/pull/1990), ready for review, with Bugbot triggered. CI is green on all 82 checks, and Bugbot found no issues.
8+
9+
### Per file
10+
- **`python_lock.rs`:**
11+
- 2 dead fns deleted (`complete_python_lock_metadata`, `complete_python_lock_metadata_in`).
12+
- `PythonLockProbe` deleted. The wheel gate now calls `PythonLockSession::plan`, and the probe-equivalence test went with it.
13+
- New `names` and `repoint` helpers replace 5 name checks and 4 repoint copies.
14+
- The planner reuses `lock_package_collection`, and new `artifact_filename` replaces 2 copies.
15+
- `python_lock_paths` is one iterator chain.
16+
- 4 test modules are folded into one.
17+
- About 20 comment lines removed (a banner, 6 bare issue numbers, docs).
18+
- 1 fake test fixed: the "ours" case asserted only `is_ok()`, which passes on `Ok(None)`.
19+
- **`python_script.rs`:**
20+
- New `tool_uv` replaces 3 lookup chains, and new `declares_directly` replaces 3 copies.
21+
- 1 fn inlined (`push_hosted_override`), and `is_hosted_override` is now private.
22+
- `refuse_uv_no_sources`/`no_binary` lose their always-`None` `script` parameter.
23+
- About 30 comment lines removed (15 bare issue numbers, the `SourcesLayout` doc).
24+
- 1 test added for no-binary's combine rules.
25+
- **Total:** +226 / −531. Production is about −195 and tests about −110.
26+
27+
### Evidence
28+
- Clippy (workspace, all features) is clean.
29+
- Core lib passes 6,995. The 4 failures are the known root-sandbox ones.
30+
- Red→green:
31+
- "ours" with `plan` returning `Ok(None)`: red.
32+
- The PEP 751 hash kept as the old digest: red.
33+
- The no-binary script bool not winning: red, and redirect's own test is red too.
34+
- `/code-review high` found no correctness bugs and raised 9 findings. 3 are fixed: the "ours" assert still passed because the input already held the URL, a local shadowed `tool_uv`, and the transitive-revert caveat had been dropped. The PR gives a reason for each of the other 6.
35+
36+
### Merges recorded
37+
None.
38+
39+
### Lessons
40+
- When you tighten a fake test, check that the new assert can't pass on the input itself. Here the input already contained the URL the assert looked for.
41+
- A `/// #NNN: text` doc rewritten with a regex that capitalizes the first letter turns "uv" into "Uv". Lowercase tool names need a hand check.
42+
- The audit noted `python_script`'s project no-binary refusal as untested. Redirect's `no_binary_refuses_a_wheel_uv_would_not_install` does cover it end to end, so grep the other modules' tests before you call something untested.

‎register/90-refactor.md‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
### Refactor routine
2-
_Last updated 2026-11-02T13:35Z · main @ cbbbdb9_
2+
_Last updated 2026-11-02T15:45Z · main @ cbbbdb9_
33

44
#### In flight
55
| PR | Kind | Scope | State |
66
|---|---|---|---|
7-
| #1842 | sweep | `cli/src/args.rs` (+ the Deno guard moved into `lib.rs`) | ready |
7+
| #1842 | sweep | `cli/src/args.rs` | ready |
88
| #1855 | sweep | `commands/{bun_preflight,composer_hints,context,fetch_stage}.rs` | ready; CI needs a re-run (Depot) |
99
| #1849 | structural | A01 #1832: `utils/cargo_build_cache.rs` | ready; green |
10-
| #1864 | sweep | `commands/{hosted_bundle,hosted_unwind,list,lock_cli,mod,pypi_reinstall}.rs` (+ `rollback.rs` dead branch) | ready; green |
10+
| #1864 | sweep | `commands/{hosted_bundle,hosted_unwind,list,lock_cli,mod,pypi_reinstall}.rs` | ready; green |
1111
| #1870 | structural | A27 #1869: `api/client.rs`, one serve GET and one vendor retry loop | ready; green |
1212
| #1875 | sweep | `commands/{remove,repair}.rs` | ready; green |
13-
| #1884 | sweep | `scan/discovery.rs` (+ T18 #1859; tests to core `ranking.rs`, `lock_inventory/tests.rs`, `ui/text.rs`) | ready; green |
13+
| #1884 | sweep | `scan/discovery.rs` (+ T18 #1859; tests moved to core) | ready; green |
1414
| #1892 | sweep | `scan/gc.rs` | ready; green |
15-
| #1897 | sweep | `scan/hosted.rs` (all but `run_redirect_selected_untracked`, T24; tests to core `hosted/guidance.rs`, `formats/pnpm/mod.rs`) | ready; green |
15+
| #1897 | sweep | `scan/hosted.rs` (all but `run_redirect_selected_untracked`, T24) | ready; green |
1616
| #1903 | sweep | `scan/hosted/{nuget,takeover}.rs` | ready; green |
17-
| #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; green |
18-
| #1914 | sweep | core `utils/{http,mod,hatch_workspace,hatch}.rs` (`line_endings.rs` clean) | ready; green |
17+
| #1907 | sweep | core `constants.rs`, 8 `utils/` files (`cargo_home`…`failpoint`) | ready; green |
18+
| #1914 | sweep | core `utils/{http,mod,hatch_workspace,hatch}.rs` | ready; green |
1919
| #1920 | sweep | core `utils/{notice,npm_range,package_manager,pep440,pipenv,purl}.rs` (+ `target.rs` callers) | ready; green |
20-
| #1923 | sweep + A20 #1848 | core `utils/{redact,repo_root,serde,toml_edit_ext,uri,uv_workspace}.rs` (+ `vex/product.rs`, `redirect/upstream/npm.rs`, advisory lint moved to `vendor/service_fetch.rs`) | ready; green |
21-
| #1929 | sweep | `commands/{update,user_patches,vendor_orphans,vlt_heal}.rs` (+ `InstallChannel::id` in core `update/channel.rs`) | ready; green |
20+
| #1923 | sweep + A20 #1848 | core `utils/{redact,repo_root,serde,toml_edit_ext,uri,uv_workspace}.rs` | ready; green |
21+
| #1929 | sweep | `commands/{update,user_patches,vendor_orphans,vlt_heal}.rs` | ready; green |
2222
| #1936 | structural | A54 #1932: `formats/gem/{gemspec,manifest}.rs`, `vex/product.rs` (`for_each_code_line` → `code_lines`) | ready; green |
2323
| #1939 | sweep | `commands/vendored_backend/{mod,repair}.rs` | ready; green |
2424
| #1944 | structural | T51 #1941: 11 `tests/apply` suites + `common/envelope.rs` onto `apply_fixture` (test-only, −635 net) | ready; `hosted-e2e` red on a live 403, not this diff |
2525
| #1955 | structural | T52 #1942: 7 PTY runners → `common/pty_io::{run,run_command}` (test-only, +172/−567) | ready; green |
26-
| #1948 | sweep | `commands/{vex_consumed,vex_sources}.rs` (+ 2 tests moved to `ecosystem_dispatch.rs`) | ready; green |
26+
| #1948 | sweep | `commands/{vex_consumed,vex_sources}.rs` | ready; green |
2727
| #1961 | sweep | `cli/src/ui/{mod,prompt,status}.rs` (`test_support.rs` clean) | ready; green |
2828
| #1964 | structural | T59 #1958: `tests/common/hermetic.rs` color scrub; seeds → parent-env canary (test-only, +69/−82) | ready; green |
2929
| #1967 | sweep | `cli/src/{json_envelope,update_notifier,main,interrupt,path_scope}.rs` (path_scope tests only, #1864) | ready; green |
3030
| #1972 | structural | T60 #1968 slice 1: `tests/docker_common` + 15 `docker_e2e_*` suites (test-only, +260/−1,113) | ready; green |
3131
| #1975 | sweep | core `api/{blob_fetcher,date,retry,types}.rs` | ready; green |
3232
| #1978 | structural | T56 #1956: 9 `cli_parse_*`/`cli_global_args` suites onto `hermetic::try_parse` + new `common/clap_parse.rs` (test-only, +418/−1,471) | ready; green |
33-
| #1985 | sweep | `scan/{rollout,rollout_args,withdrawn}.rs` (+ `Stage::may_admit` and 11 tests moved to core `rollout/stage.rs`) | ready; green |
33+
| #1985 | sweep | `scan/{rollout,rollout_args,withdrawn}.rs` (+ core `rollout/stage.rs`) | ready; green |
3434
| #1988 | structural | T64 #1979 slice 1: `tests/common/{fs_tree,scan_proxy}.rs`; 28 copiers + 4 proxy copies deleted (test-only, +218/−589) | ready; green |
35+
| #1990 | sweep | core `utils/{python_lock,python_script}.rs` (+ `hosted/engine.rs` wheel gate, `vendor/pypi_uv.rs`, 2 lines of `redirect/mod.rs`) | ready; green |
3536

3637
#### Merged
3738
_None._
@@ -40,7 +41,7 @@ _None._
4041
Structural, scored `3·B + 2·U + 2·D + 2·C − risk`. Nothing merged since 2026-10-29, so most candidates ≥6 stay blocked: A30 #1887 (~8.7, #1886), T09 #1858 (~7, #1864/#1698), A41 #1899 (~6, #1891/#1829/#1906), A43 #1900 (~6, #1863/#1698), T01 #1835 / T25 #1877 (#1698), A53 #1931 / A57 #1935 (`ruby_crawler.rs`, #1882/#1895/#1943), A55 #1933 (`redirect/mod.rs`). Free test-only: T64 #1979 rest (copies held by 9 PRs; then a `shared_helper_copies` guard), T60 #1968 rest (~7, after #1972: CI REQUIRED export, `assert_api_exercised`, `GIT_SHA256_FN` ×3, bash summary greps), T61 #1969 (~6; `e2e_bun_lockb.rs` held by #1905), T50 #1940 (~7; land the suites not held by #1698/#1843/#1893/#1894), T55 #1959 (~7, ~35 files; `tests/apply` is #1944), T58 #1957 (~6).
4142
A26 #1867, A46 #1917, A44 #1918 score ~4.
4243

43-
Next sweep files, in order: `scan/policy.rs`, `scan/render.rs` after #1856/#1884; `python_lock.rs` (2,283), `python_script.rs` (1,768), `api/vendor_prefetch.rs`, crawler rows; `group_commit.rs` (2,163, region); `tests/apply/*` rows not covered by #1944 (their notes list fake tests). Held: `vlt_preflight.rs`, `agent_download.rs`, `apply.rs`, `get.rs`, `vendor.rs` (#1698); `rollback.rs` (#1864); `utils/fs.rs`, core `lib.rs` (#1891); `lock_fragments.rs`/`pdm_lock.rs` (#1898); `poetry_lock.rs` (#1865/#1898); `pnpm_workspace.rs` (#1863); `process.rs` (#1895); `go_env.rs` (#1876); `cargo_workspace.rs` (#1866). Leftovers from merged-pending sweeps: `socket_yml_args.rs` `min_severity` → `Option<u8>` + injected env (held by #1978/#1864), `cli_parse_scan` env subset test + `"1.5"` reject row (#1978), rollout `offer`/`manifest` fixtures in CLI+core → `test-fixtures` (#1985); `ui/text.rs` sweep and the text-shaping move out of `ui/mod.rs` (#1884), `StatusLine::stderr(json, silent)` → one `report` bool (scan/mod.rs, lock_cli.rs) (#1961); `toml_edit_ext` deletion and `uv_workspace` fold (#1923); 7 `build_*_purl` wrappers + `parse_jsr_purl`, purl's PurlKey asserts → `purl_key.rs`, pipenv `installed_major`'s `_root` (#1920); String `read_capped` wrapper, `lock_fragments`/`pdm_lock` `pub mod` → `pub(crate)` (#1914); `CargoCrawler::cargo_home`, `vendor/jvm` digest copies, async `fs::is_symlink` (#1907); `api_auth_fallback_warning` → `json_envelope` and `PlanNote` → `RunWarning` (#1698), `store_variants` test → core `npm_crawler.rs` (#1829/#1891/#1906/#1915) (#1948); `PathScope::matches` (rollback L1814 loop) → `bind` once, plus `BoundScope::matching_pattern_indices` for rollback's `raw()` re-parse with `expect` (#1864); `AppliedVia` one-variant mirror + `from_core` (apply.rs, #1698) (#1967).
44+
Next sweep files, in order: `scan/policy.rs`, `scan/render.rs` after #1856/#1884; `api/vendor_prefetch.rs`, crawler rows (`fuzzy_match`, `listing`, `jvm_cache`, `ivy_cache`, `coursier_cache`, `gradle_cache`, `sbt_evidence`, `hatch_env` are free); `group_commit.rs` (2,163, region); `tests/apply/*` rows not covered by #1944 (their notes list fake tests). Held: `vlt_preflight.rs`, `agent_download.rs`, `apply.rs`, `get.rs`, `vendor.rs` (#1698); `rollback.rs` (#1864); `utils/fs.rs`, core `lib.rs` (#1891); `lock_fragments.rs`/`pdm_lock.rs` (#1898); `poetry_lock.rs` (#1865/#1898); `pnpm_workspace.rs` (#1863); `process.rs` (#1895); `go_env.rs` (#1876); `cargo_workspace.rs` (#1866). Leftovers from merged-pending sweeps: `socket_yml_args.rs` `min_severity` → `Option<u8>` + injected env (held by #1978/#1864), `cli_parse_scan` env subset test + `"1.5"` reject row (#1978), rollout `offer`/`manifest` fixtures in CLI+core → `test-fixtures` (#1985); `ui/text.rs` sweep and the text-shaping move out of `ui/mod.rs` (#1884), `StatusLine::stderr(json, silent)` → one `report` bool (scan/mod.rs, lock_cli.rs) (#1961); `toml_edit_ext` deletion and `uv_workspace` fold (#1923); 7 `build_*_purl` wrappers + `parse_jsr_purl`, purl's PurlKey asserts → `purl_key.rs`, pipenv `installed_major`'s `_root` (#1920); String `read_capped` wrapper, `lock_fragments`/`pdm_lock` `pub mod` → `pub(crate)` (#1914); `CargoCrawler::cargo_home`, `vendor/jvm` digest copies, async `fs::is_symlink` (#1907); `api_auth_fallback_warning` → `json_envelope` and `PlanNote` → `RunWarning` (#1698), `store_variants` test → core `npm_crawler.rs` (#1829/#1891/#1906/#1915) (#1948); `PathScope::matches` (rollback L1814 loop) → `bind` once, plus `BoundScope::matching_pattern_indices` for rollback's `raw()` re-parse with `expect` (#1864); `AppliedVia` one-variant mirror + `from_core` (apply.rs, #1698) (#1967); `check_python_lock_source_scope` is test-only (its caller in `redirect/mod.rs`, held by 7 PRs), `artifact_filename` ×4 (`pypi_locks::basename` also splits `\\`), `ancestor_uv_config_files` → `relpath` (A19), `PythonLockSession::plan`'s `text` arg → keep the rendering in the session (#1990).
4445

4546
#### Notes
4647
- Want issues (output-changing, found in sweeps): `ui::shell_word` misses `"`/`%VAR%` on cmd; `scan/gc.rs` `has_ledger` probes `--cwd` but `run_vendor_gc` reads `project_root()` (C43); gem stale probe dedups by purl and drops the platform suffix; `hatch::require_pip_installer_documents` ignores the `envs` override; `npm_range_admits(">=", v)` admits all; npm `upstream_registry_fallback` leaks `?token=` (use `redact_urls_in`); `vlt_heal` swallows `load_state`/lock read errors; `strip_url_userinfo`'s scp branch keeps `u:p@`.

0 commit comments

Comments
 (0)