Repository navigation
Fix uv script lock revert stuck as drift (#1214) - #1231
Conversation
Assisted-by: Claude Code:claude-opus-5-5
After `uv remove --script job.py six`, neither the PEP 723 script nor its lock names the vendored wheel any more, but vendor --revert, scan --prune, remove and rollback all kept the entry as "drift". The wheel and ledger entry stayed forever and vendor --check stayed red, with every remedy it named looping. The script/pylock revert now probes the wired files once before restoring: when none of them names the entry's uuid, each record that routed through the wheel warns vendor_lock_entry_removed and the revert finishes, as #1147 already does for uv projects. Real third-party edits while any file still names the wheel stay drift. Fixes #1214 Assisted-by: Claude Code:claude-opus-5-5
95fcbe4 to
eec1e33
Compare
|
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 eec1e33. Configure here.
|
Ready for review at
Generated by Claude Code |
Final review briefWhat it does: Reverting a PEP 723 script lock or Risk: low. The new arm fires only when no wired file names the uuid. The dispatcher's residual-reference probe still keeps the wheel if anything else in the project names it. Python-lock records are whole-file and their Look here:
Verified:
Changes I made: none. Open questions (non-blocking):
Auto-merge is armed: approving sends this straight to the merge queue. Generated by Claude Code |
LLM Description written by Claude Code:claude-opus-5-5
Fixes #1214
Summary
After
uv remove --script job.py sixdrops a vendored package from a PEP 723 script and its.py.lock, every vendored unwind (vendor --revert,scan --prune,remove,rollback) kept the entry as "drift". The wheel and ledger entry stayed forever,vendor --checkstayed red, and thescan --pruneremedy it names was a no-op that exited 0. Now the revert sees that nothing references the vendored wheel any more, retires the entry, andvendor --checkturns green.Root cause
revert_python_locks(crates/socket-patch-core/src/vendor/pypi_lock.rs) reverts thepython_script_metadataandpython_lock_documentrecords. After the removal the lock no longer matches what was recorded, so the structural restore reportedvendor_lock_entry_drifted. #1147 added a "nothing names the uuid →vendor_lock_entry_removed" arm for uv projects (revert_uv) only.Fix
revert_python_locksprobes every wired file once, before reverting anything. When none of them names the entry's uuid, each record whose written text carried it warnsvendor_lock_entry_removedand is skipped, which matchesrevert_uv(Fix vendored revert reading a removed dependency as drift (#1132, #1140, #1142) #1147). The pypi dispatcher then deletes the wheel and ledger entry, and its residual-reference probe still keeps them if some other file installs from the wheel.revert_uv's pair gate.uv remove --script. For example, a regeneratedpylock.tomlthat re-pins the package from PyPI also retires the vendored entry rather than reporting drift.revert_uvalready behaves this way for uv projects (Fix vendored revert reading a removed dependency as drift (#1132, #1140, #1142) #1147).mode_migration_pypi.rs~1437-1448 is a rustfmt-only reformat of the unrelatedledger_update_failure_changes_nothingtest, with no behaviour change.Hosted lane
scan --mode hostednever reverts vendored entries, for any ecosystem: it warnsvendor_ledger_entry_unwiredand namesscan --pruneas the fix. Before this change, following that remedy looped. Now it retires the entry, and the test asserts that end to end.Tests (red → green)
pypi_lock::tests::script_revert_after_uv_remove_is_removed_not_driftvendor_lock_entry_drifted"job.py.lock changed since vendoring"pypi_lock::tests::script_revert_keeps_drift_while_any_wired_file_names_the_uuidvendor --revert,scan --prune,remove,rollback, hosted scan → its prune remedy)mode_migration_pypi::script_lock_unwinds_after_uv_remove_scriptvendor_lock_entry_drifted+vendor_artifact_kept+vendor_revert_keptThe CLI fixture for the post-removal script and lock is byte-identical to what real
uv 0.11.32 remove --scriptwrites. I checked this locally.Local verification (head eec1e33)
cargo clippy --workspace --all-features -- -D warnings: clean.cargo fmt --all -- --check: the two changed files are clean.main(f3c6313) already has rustfmt drift in 16 unrelated files, which I did not touch. CI has no fmt job.cargo test -p socket-patch-core --all-features: 5889 passed. 4 failed, all permission tests (copy_tree,vlt_heal,pypi_poetry,pypi_requirementswrite-failure tests) that cannot fail a write when run as root in this sandbox. They are unrelated to this change.socket-patch-clilib/bins, plus every PyPI/uv/vendor/rollback/remove suite with--include-ignored(mode_migration_pypi,e2e_vendor_pypi_build,in_process_rollback_vendored,in_process_vendor_pypi_takeover,in_process_remove_repair_lifecycle,in_process_rollback_all_ecosystems,hosted_superseding_pypi,in_process_python_envs,covgap_commands_rollback,cli_remove_silent,e2e_pypi_multi_copy,in_process_pypi_apply,in_process_redirect_{pipenv,poetry,pdm}): all pass except 10 tests that fail the same way with this fix reverted (environmental:e2e_pypineeds the real API, 4e2e_redirect_uv_buildhosted pylock lanes on the sandbox's uv 0.11.32,pipenv_hosted_to_vendored_names_the_unpatched_requirements).cargo test --workspacebuild exceeded the sandbox's disk allowance, so CI is the full-workspace gate.Generated by Claude Code