Repository navigation
Sweep core utils/python_{lock,script}.rs - #1990
Mikola Lysenko (mikolalysenko) merged 4 commits into
Conversation
Assisted-by: Claude Code:claude-opus-5-5
Delete the dead complete_python_lock_metadata pair and PythonLockProbe: the hosted wheel gate now asks PythonLockSession::plan, which runs the same planner, so the probe-equivalence test goes with it. One names / repoint helper replaces five name checks and four repoint copies, the planner reuses lock_package_collection, and one artifact_filename replaces two copies. python_lock_paths is one iterator chain. The direct-URL test's "ours" case asserted is_ok(), which also passed on Ok(None); it now requires the rewritten lock. The five test modules are one. Bare issue numbers and a banner are gone. Assisted-by: Claude Code:claude-opus-5-5
One tool_uv reader replaces three [tool.uv] chains, and one declares_directly replaces the three "is this a direct dependency" copies in hosted_override_pins, wires_through_override and the two metadata rewriters. push_hosted_override is inlined into its one caller and is_hosted_override is private. refuse_uv_no_sources / refuse_uv_no_binary lose their script parameter: every caller passed None (scripts use the *_script_* variants). The SourcesLayout doc is trimmed to its why, bare issue numbers are gone, and a unit test now covers no-binary's combine rules. Assisted-by: Claude Code:claude-opus-5-5
The direct-URL test's "ours" case now requires the artifact digest to replace the fixture's, since the input already held the URL. Rename rewrite_project_metadata's local that shadowed tool_uv, and keep the SourcesLayout caveat about transitive override reverts. Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 82ac6bc. Configure here.
Assisted-by: Claude Code:claude-opus-5-5
There was a problem hiding this comment.
[agent] Reviewed 82ac6bc5cff596db23f17d6eb5c78f04df187e7f. Checked Python lock session/probe equivalence, metadata rewriting, canonical name matching and uv/script guard call sites. No major correctness issues found. Validation: The focused core utils::python_ tests passed locally (37 tests). Source and regression-test review plus available exact-head CI checks; broader local suites were not run.
|
Burn-down agent: labeled Ready for review.
Generated by Claude Code |
LLM Description written by Claude Code:claude-opus-5-5
This PR sweeps
crates/socket-patch-core/src/utils/python_lock.rsandpython_script.rs, working from theircoverage/files.tsvnotes. It is part of the architecture refactor routine, whose ledger is discussion #1830; the related findings are A15, A22, A24 and A25. Most of the diff deletes needless layers and duplicated readers.python_lock.rscomplete_python_lock_metadataandcomplete_python_lock_metadata_in. Neither had a caller;PythonLockSession::rewritedoes the completion.PythonLockProbedeleted. The hosted wheel gate (hosted/engine.rswheel_targets) now asksPythonLockSession::plandirectly. Both ran the sameplan_python_lock_rewriteand both treated an unparseable lock as "no", so theprobe_equivalence_testsmodule went with the probe. It compared the planner with itself.namesandrepointhelpers. They replace 5 inline "inline table namesname" checks and 4 copies of "remove specifier/url/path, insert the artifact".plan_python_lock_rewritenow useslock_package_collectioninstead of its own copy of that rule.legacyis only ever read behind!pep751, so the result is the same.artifact_filenamereplaces 2 copies of the query/fragment strip.python_lock_pathsis now one iterator chain, with a shorter version of its why-comments.PythonLockSessionandMetadataCompletiondocs trimmed.user_direct_url_entries_are_refused: the "ours" case asserted onlyis_ok(), which also passes onOk(None). It now requiresSomeand requires the fixture's old digest to be replaced by the artifact's. Red→green: withplanreturningOk(None)for our own artifact, the test fails. With the PEP 751 archive hash left as the old digest, it fails too. Onmain, both breaks pass.testsmodule, and the duplicate consts are dropped.python_script.rsNew
tool_uv(doc)replaces 3 copies of the[tool.uv]lookup chain.pyproject_has_uv_settingskeeps its own chain on purpose: it accepts a non-tabletool.uv.New
declares_directly(doc, script, name)replaces 3 copies of the "is this dependency declared directly?" check, inhosted_override_pins,wires_through_overrideand the two metadata rewriters.Inlined:
push_hosted_override, which had one caller. Its why-comment stays.Narrowed:
is_hosted_overrideis now private.Signature change:
refuse_uv_no_sourcesandrefuse_uv_no_binarydrop theirscriptparameter. Every caller passedNone, and scripts use the*_script_*variants. The callers invendor/pypi_uv.rsandpatch/redirect/mod.rsare updated.Comments: the
SourcesLayoutdoc is cut from 27 lines to 15 and keeps its why. 15 bare issue numbers removed.New test:
no_binary_refuses_by_uvs_combine_rulescoversrefuse_uv_no_binaryandrefuse_uv_script_no_binaryat the unit level:[tool.uv]in both directions;Red→green: with
Some((_, false)) => return Ok(())removed, both this test and redirect'sno_binary_refuses_a_wheel_uv_would_not_installfail.Size
git diff --stat: 5 files changed, +226 / −531.Behavior change: none. Output, JSON and error codes are identical.
Risk: low. The change is local to the Python lock and metadata rewriters, all edits are equivalence-preserving, and no platform-specific code is touched.
Verification
cargo clippy --workspace --all-features -- -D warningsis clean.cargo test -p socket-patch-core --lib: 6,995 pass. The 4 failures are the known root-sandbox ones, which pass in CI:copy_treesymlinked-root,vlt_healunremovable-lock, and thepypi_poetry/pypi_requirementswire-failure tests.git merge-treeagainst the 10 open PRs that touchhosted/engine.rsorpatch/redirect/mod.rsreports no conflicts: Fix yarn classic copy identity read two ways (#1951) #1984, Fix npm overrides to a URL treated as registry (#1965) #1966, Fix pnpm lock readers skipping main doc (#1949, #1952) #1960, Fix Go stale go.sum line after a downgrade (#1862) #1893, Fix Maven 4 implicit subprojects missed outside vendored (#1809) #1886, Fix silent PyPI hosted scan with no lockfile (#638) #1885, Fix hosted npm ignoring omit-lockfile-registry-resolved (#1871) #1872, Fix Cargo member globs with [..] classes (#1833) #1866, Fix Go replace target missed in go 1.16 graphs (#1840) #1843 and Fix hosted gem block mixing CRLF Gemfile endings (#1831) #1841. No open PR adds a caller of a removed or changed item./code-review highIt reported no correctness bugs and 9 other findings. 3 are fixed:
tool_uv;SourcesLayoutcaveat on transitive override reverts.6 are not fixed:
socket-patch-coreis the CLI's internal crate, and earlier sweeps removedpubitems the same way.declares_directlyruns once per marked override: a marked override is a hosted pin, so there are usually 0–2 of them.artifact_filenamevspypi_locks::basenameand two other copies: unifying them crosses into VEX and the API client. That is recorded as a leftover rather than widened here.plantakestextbeside the session: this is the existing API, unchanged by this PR. Moving the rendering into the session is a separate change.rewrite_python_lockis nowparseplus the sameplan_python_lock_rewrite, so a session-vs-text test would compare the function with itself.Left for later
check_python_lock_source_scope's only caller is a#[cfg(test)]helper inredirect/mod.rs, which 7 PRs hold.ancestor_uv_config_filesnormalization could reuserelpath(A19).source_identityis still a second uv-source reader besideUvSource. Its precedence differs (registry first,legacytag), so it was kept.🤖 Generated with Claude Code
https://claude.ai/code/session_011f9aeSihx4ZNBYZDYvqBqw
Note
Low Risk
Local refactor in Python lock/metadata rewriting with equivalence-preserving edits and no auth or platform-specific changes; one test assertion was strengthened without changing production paths.
Overview
Refactors the Python lock and uv metadata helpers by removing dead layers (
PythonLockProbe,complete_python_lock_metadata, and the probe equivalence tests) and routing the hosted wheel gate throughPythonLockSession::planinstead.python_lock.rsadds shared helpers (names,repoint,artifact_filename), reuseslock_package_collectionin planning, simplifiespython_lock_paths, merges test modules, and tightens the user-direct-URL test so a successful rewrite must replace the old hash—not merely returnOk.python_script.rscentralizestool_uv/declares_directly, inlines hosted override pushing, drops the unusedscriptargument fromrefuse_uv_no_sources/refuse_uv_no_binary(call sites updated), and adds unit tests forno-binarycombine rules.Comment-only issue references are trimmed; behavior is intended to stay the same aside from the stronger test assertion.
Reviewed by Cursor Bugbot for commit 82ac6bc. Configure here.
Generated by Claude Code