Fix vendored requirements.txt re-vendoring removed pins (#786) - #787
Open
Mikola Lysenko (mikolalysenko) wants to merge 2 commits into
Open
Mikola Lysenko (mikolalysenko) wants to merge 2 commits into
Mikola Lysenko (mikolalysenko) wants to merge 2 commits into
Conversation
Assisted-by: Claude Code:claude-opus-5-5
A vendored requirements.txt entry stayed "in use" forever, because the in-use probe behind the ledger supplement and `scan --prune` had no pypi arm. After a user removed a vendored pin, the next vendored scan re-added the package as a "(transitive)" line. After a bump, every scan failed with pypi_requirement_not_pinned. `--prune` never reverted the entry. The requirements flavor now asks its requirements tree (the root file plus in-root -r includes) whether any requirement line still installs the vendored wheel. A removed or bumped pin now gets the vendor_ledger_entry_unwired warning, and `--prune` reverts it with exit 0. An unreadable tree still keeps the entry. Fixes #786 Assisted-by: Claude Code:claude-opus-5-5
Mikola Lysenko (mikolalysenko)
marked this pull request as ready for review
October 4, 2026 14:55
Collaborator
Author
|
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 580fff7. Configure here.
Collaborator
Author
|
Ready for review — head
Generated by Claude Code |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LLM Description written by Claude Code:claude-opus-5-5
Fixes #786
Root cause
dispatch_in_use_one(crates/socket-patch-cli/src/commands/vendor.rs) only has lockfile in-use probes fornpmandcargo. Forpypiit returnsNone("can't tell"). The vendor-ledger discovery supplement and thescan --pruneGC both treatNoneas "still wired". So when a user removes or bumps a vendored requirements.txt pin, the next vendored scan rediscovers the ledger entry. It then re-adds the package as a(transitive)line, or refuses withpypi_requirement_not_pinnedon every run, and--prunenever reverts the entry.Change
vendor::pypi_requirements::requirements_entry_in_use: for therequirementsflavor, the requirements tree is the lock pip installs from. The probe reads the rootrequirements.txtplus every in-root-rinclude (the same walk the planner and the unwired-revert guard use).Some(true)when a requirement line's code (not its comment) still names.socket/vendor/pypi/<uuid>/.Some(false)when the tree was read and nothing does.None(keep the entry, fail-safe) when no file could be read, or when a reached include exists but is unreadable.vendor::pypi::vendored_entry_in_useroutes therequirementsflavor to that probe. Every other pypi flavor still returnsNone.dispatch_in_use_onegains thepypiarm.Tests (red → green)
crates/socket-patch-cli/tests/scan_vendor_requirements_unwired.rs(built binary, mock patch API with no patches, seeded requirements-flavor ledger):removed_vendored_pin_is_unwired_and_pruned(Vendored requirements.txt after the user removes or bumps a vendored pin: the rescan re-adds the removed package as a "(transitive)" line (exit 0), or exits 1 forever after a bump, andscan --prunenever reverts the entry #786 case A) andbumped_vendored_pin_is_unwired_and_pruned(Vendored requirements.txt after the user removes or bumps a vendored pin: the rescan re-adds the removed package as a "(transitive)" line (exit 0), or exits 1 forever after a bump, andscan --prunenever reverts the entry #786 case B). A plain rescan warnsvendor_ledger_entry_unwired, exits 0, never sends the stale purl to the patch API and leaves requirements.txt untouched.--prunethen reports the entry ingc.revertedVendoredEntries, exits 0, keeps the user's own pin and removes the uuid dir and the ledger entry.wired_vendored_pin_stays_discoverable(control: the fresh-clone supplement still works).pypiarm removed fromdispatch_in_use_one, both Vendored requirements.txt after the user removes or bumps a vendored pin: the rescan re-adds the removed package as a "(transitive)" line (exit 0), or exits 1 forever after a bump, andscan --prunenever reverts the entry #786 tests fail at thevendor_ledger_entry_unwiredassertion (0 warnings). The control passes either way.pypi_requirements.rs:in_use_probe_sees_wired_vendor_lines(root pin, transitive line,-rinclude),in_use_probe_reports_removed_or_bumped_pins_unused(removed, bumped, commented-out, another uuid),in_use_probe_is_undeterminable_without_a_readable_tree(no requirements.txt, FIFO include).removed_vendored_pin_is_unwired_and_prunedbumped_vendored_pin_is_unwired_and_prunedLocal verification
cargo clippy --workspace --all-features -- -D warningscargo test -p socket-patch-core --all-features --librelax_loop_must_not_traverse_symlinked_root,an_unremovable_hidden_lock_keeps_every_store_entry,wire_write_failure_maps_error_and_leaves_lock_untouched,wire_failure_rolls_back_already_written_files) pass when re-run as an unprivileged usercargo test -p socket-patch-cli --all-features --lib--test scan_vendor_requirements_unwired--test scan_requirements_lock_only--test scan_vendor_e2e--test e2e_vendor_pypi_build -- --include-ignored(uv 0.8.17, real pip)node --test npm/socket-patch/bin/socket-patch.test.mjsI couldn't run the full
cargo test --workspacelocally: building every test binary exceeds the session's disk allowance. CI runs it.CI
All 475 checks are green on 580fff7, and Bugbot reviewed 580fff7 with no findings. The first attempt had three compatibility-matrix cells fail on paths this change can't reach, so I re-ran them once and all passed:
preexisting-manifest vendored(refusalCodesExact, an 80s case).rescanIdempotent.The same jobs were green on other open PRs.
Notes
cargo fmt-clean onmainwith the pinned toolchain, and CI has no fmt gate.cargo fmt --allrewrites about 130 unrelated files, so this PR carries only its own hunks, which are rustfmt-clean.None.npm/only dispatches to the binary; the pypi and gem wrappers were dropped in v5).🤖 Generated with Claude Code
Generated by Claude Code