Repository navigation
Fix vendor reporting a mismatched installed copy as not installed (#2289) - #2463
Mikola Lysenko (mikolalysenko) wants to merge 6 commits into
Conversation
Refs #2289: a sole PyPI or gem record whose installed copy holds other bytes is reported as not installed by the vendor path. Assisted-by: Claude Code:claude-fable-5-2
Refs #2289. Two end-to-end tests that fail before the fix: a gem and a PyPI package whose installed copy holds an earlier agent patch or an edited file, with one patch to vendor. The run reports the package as not installed and exits 1. Assisted-by: Claude Code:claude-fable-5-2
The vendor path probes one patched file of an installed PyPI or gem copy to choose among several records of one release. A copy that held neither side of the record was dropped even when the record was the only one for the package, and the run then reported "no installed package found on disk" and exited 1. An agent-mode project whose patch was superseded is in that state, so its switch to vendored mode failed. The only record of a package is now vendored whatever the copy holds: a gem from its installed dir, a PyPI package from the stand-in source, as the three earlier fixes already did for the causes they named. One of several records is still set aside, and when no sibling matches either, the report names the copy and the file instead of calling the package not installed. Fixes #2289 Assisted-by: Claude Code:claude-fable-5-2
Refs #2289. With several records for a release, the copy's own wheel metadata can set one record aside before the probe sets the other aside, so the mismatch is kept by release: every record of it is reported with the copy and the file, not as a package that is not installed. An end-to-end test covers the report in both outputs. Assisted-by: Claude Code:claude-fable-5-2
Refs #2289. Review of the fix found that a release with a record per artifact (a wheel's and an sdist's, a ruby gem's and a platform gem's) still failed over an agent-patched copy: with several records, none was vendored. The copy's own metadata already says which record is its own (the wheel in its WHEEL tags, the platform in its gemspec), so that record is now treated like the only one. Only a file that is there with other content is reported as the copy's mismatch; a record for a file the copy lacks is another distribution's. The report is chosen by purl, so it is the same on every run, and it says only what was compared. Assisted-by: Claude Code:claude-fable-5-2
Refs #2289. The detail names the copy and the file only when the file is there with other content; a record for a file the copy lacks keeps the earlier text. Assisted-by: Claude Code:claude-fable-5-2
|
bugbot run Generated by Claude Code |
PR SummaryMedium Risk Overview Vendor gating replaces separate When multiple records apply and the installed copy has unmatched content, the run still exits 1 but adds Reviewed by Cursor Bugbot for commit 00b8151. Configure here. |
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 00b8151. Configure here.
|
[agent] PR shepherd: review brief for the approver What it does. Risk: medium. It changes which packages vendor succeeds on, so a run that used to fail now rewrites the lock. A copy that is a private rebuild gets replaced in the lock by the service's patched build, as already happens on a checkout with nothing installed. The change is limited to the PyPI/gem variant probe ( Look here
Verified. I read the whole diff against Changes I made. None. Open questions
Generated by Claude Code |
LLM Description written by Claude Code:claude-fable-5-2
Fixes #2289
Summary
scan --mode vendored,get --mode vendoredandvendorrefused a PyPI package or a gem whose installed copy held a patched file at bytes that are neither side of the patch, and reported it as "no installed package found on disk" (exit 1). The usual way into that state is an agent-mode project whose patch was superseded, so the switch from agent mode to vendored mode failed for every such package, after a--dry-runthat previewed success.Now the record that is the copy's is vendored, whatever the copy holds. Vendoring commits the patch service's artifact and takes no file of the installed copy, so this is what a checkout with nothing installed,
vendor --forceand every other ecosystem already did. The installed copy is left as it is.Root cause
CandidateGates::judge(CLIcommands/vendor.rs) hashes one patched file of the installed copy to choose among several records of one release. A miss dropped the candidate even when there was nothing to choose, and the dropped purl fell into the "not installed" report. Three earlier fixes each let one named cause through (#769, #1105, #2129). They are now one rule,probe_miss:WHEELtags, the platform in its gemspec)A gem keeps its installed dir so the gem backend still reads its name and gemspec and refuses a platform gem or a native extension.
When several records are set aside and none is vendored, the report now names the copy and the file ("the copy in … is installed, but nothing says which of the patches recorded for this version is its own: six.py there has neither the original nor the patched content"). The event code stays
package_not_installedand the run still exits 1.Do-no-harm notes for the reviewer
--forceand a package with nothing installed take the paths they took.Evidence
Red to green: commit 5babef7 adds the first two tests before the fix, and each failed on
mainwithpackage_not_installed.e2e_redirect_gem_stale_install::vendored_takes_a_gem_whose_installed_copy_holds_other_bytes: an agent-patched copy and an edited one, throughscan --mode vendoredandget --mode vendored; dry run, real run and re-run.mode_migration_pypi::an_installed_copy_at_other_bytes_is_vendored_not_called_missing: requirements, uv, Poetry and Pipenv projects, a venv on an earlier patch and an edited one, with one record and with a wheel record beside an sdist record.an_installed_copy_no_record_was_made_for_is_named_not_called_missing: two records, neither the copy's; nothing is wired, exit 1, the new text in--jsonand on stderr.probe_miss_only_drops_a_record_with_siblings(every row of the table),judge_sends_a_sole_gem_record_on_from_its_installed_dir,other_bytes_detail_names_the_copy_and_the_file. They replacehosted_pin_marks_a_pypi_install_supersededandhosted_pin_keeps_a_gem_install_as_the_source, which pinned the narrower rule.Run locally on this branch:
cargo test -p socket-patch-cli --liband 45 integration suites (scan,get,in_process_vendor*,scan_*,vendor_*,mode_migration_*,e2e_gem*,e2e_pypi*,e2e_redirect_gem_*,e2e_vendor_gem_build,e2e_vendor_pypi_build,e2e_vex_vendor,in_process_gem_*,hosted_superseding_pypi,in_process_rollback_vendored)cargo clippy --locked -p socket-patch-cli --all-features -- -D warningscargo clippy --all-targetsreports errors in test helpers onmainas well (none in files this PR touches); CI does not run it that way. The suites that need a real Ruby or Python toolchain ran only their non-ignored tests here.Review
/code-review highran twice. Fixed from it: a release with a wheel record and an sdist record still failed (the copy's own record is now treated like the only one); the report could name a file the copy does not have, and could differ between runs; the contract sentence said more than the code does.Not fixed, with reasons:
package_not_installedor takesapply'sno_matching_variantis the point the issue leaves open. Changing an event code is a contract change for a maintainer to decide.main, another cause: a gem with a ruby record and a platform record, under a lock that pins only the ruby gem, fails withplatform_gem_unsupportedfor the platform record when the installed ruby copy is pristine (the reviewer reproduced it). The gemspec is only asked after a probe miss; asking it first for gems would fix it. Not part of this change.main, not reproduced: the dry-run preview of a hosted gem takeover is given the installed dir where the real run can be given the stand-in, so the two could disagree about a platform gem dir.CI
ci-okandclippyare green on 00b8151 (83 checks, none failed). Cursor Bugbot reviewed that commit and found no issues.Docs
CLI_CONTRACT.md, thevendor --forcerow: what the probe chooses, which record is vendored whatever the copy holds, and what the remaining skip says.Not checked
Real
pipand Bundler installs (the fixtures lay the installed copies down as files), a platform gem or a native-extension gem in this state, macOS and Windows.https://claude.ai/code/session_011f9aeSrRYzNT1nGCWDjWz6
Generated by Claude Code