fix(vendor): resolve installed packages via the qualified-purl-aware lookup - #157
Open
Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
Open
fix(vendor): resolve installed packages via the qualified-purl-aware lookup#157Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
Conversation
… lookup Every real production gem/pypi/maven patch PURL is QUALIFIED (`?platform=`, `?artifact_id=`, `?classifier=&ext=`), but the crawler only knows the BASE PURL. `vendor_records` resolved installed packages via `find_packages_for_purls` (vendor.rs:684), whose result map is keyed by the base PURL. The subsequent `all_packages.contains_key(purl)` check (vendor.rs:706) therefore missed every installed qualified-PURL package and falsely classified it "not installed", triggering the auto-fetch fallback: a spurious `vendor_fetched_missing` warning plus a redundant per-run registry download, and — for gem — staging into a tempdir named `gem` that could never match `<name>-<version>`, a HashMap-iteration-order `platform_gem_unsupported` coin-flip. Switch the lookup to `find_packages_for_rollback`, which fans each base path back out to every qualified manifest PURL (the same invariant the repo already documents on `find_manifest_package_paths`). The diff is scoped to the lookup; vendor event-count semantics are untouched. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Mikola Lysenko (mikolalysenko)
enabled auto-merge (squash)
August 12, 2026 23:35
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.
Problem
Every real production gem / pypi / maven patch PURL is qualified —
pkg:gem/activestorage@7.0.2.2?platform=ruby,pkg:pypi/urllib3@1.26.18?artifact_id=py2-py3-none-any-whl— but thecrawler only ever knows the base PURL.
vendor_recordsresolved installed packages withfind_packages_for_purls(crates/socket-patch-cli/src/commands/vendor.rs:684),whose unified
purl -> pathmap is keyed by the base PURL forrelease-variant ecosystems (it uses
merge_first_wins). The subsequentall_packages.contains_key(purl)"is it installed?" check(
vendor.rs:706) is done against the qualified manifest PURLs, so itmissed every installed qualified-PURL package and falsely classified it
"not installed". That triggered the auto-fetch fallback:
vendor_fetched_missingwarning ("…is not installed;fetched the pristine artifact from
<registry>…") plus a redundantregistry download on every run, and
gem, which can never equalactivestorage-7.0.2.2— aHashMap-iteration-order-dependent
platform_gem_unsupportedcoin-flip.
The repo already documents the correct invariant on
find_manifest_package_paths(ecosystem_dispatch.rs:406-417):qualified-PURL lookups must use
find_packages_for_rollback, notfind_packages_for_purls.Fix
Resolve installed packages in
vendor_recordswithfind_packages_for_rollback(crates/socket-patch-cli/src/commands/vendor.rs:684,import at
:43). Itsmerge_qualifiedmerge fans each base install pathback out to every qualified manifest PURL, so
all_packagesis keyed bythe qualified PURLs the
contains_keycheck uses — the installed packageis now found, no false "not installed", no redundant fetch, no gem
coin-flip. The downstream match loop (
vendor.rs:860) already strips tothe base PURL and dedups on it, so it is unaffected.
The diff is scoped to the lookup; vendor event-count semantics are
untouched (owned by another change).
Test
ecosystem_dispatch::tests::find_packages_for_rollback_resolves_installed_qualified_gem(
crates/socket-patch-cli/src/ecosystem_dispatch.rs) — hermetic, nonetwork. Lays down a real installed gem fixture
(
activestorage-7.0.2.2/lib) and a qualified manifest PURL(
?platform=ruby), then asserts:find_packages_for_rollbackresolves it under its exact qualifiedkey (the vendor lookup path now finds the installed gem), and
find_packages_for_purlsdoes not contain the qualified key —demonstrating the exact base-keyed miss that produced the false "not
installed".
The bug's runtime damage (redundant fetch +
vendor_fetched_missing+gem coin-flip) only manifests online, and
--offlinemasks itbecause the downstream loop recovers via the base key — so the resolver's
contains_keysemantics is the correct hermetic surface to guard, and isexactly what vendor's
missingcomputation depends on.cargo build -p socket-patch-cliclean; the fullecosystem_dispatch::(34) and
commands::vendor::(9) lib test modules pass.Scope
Only vendor's installed-package lookup.
apply.rs:1027andrepair_vendor.rs:491also callfind_packages_for_purlswith qualifiedmanifest PURLs and may have a related latent issue, but they are out of
scope for this bug and left untouched.
🤖 Generated with Claude Code
Note
Medium Risk
Changes vendor’s installed-package detection for release-variant ecosystems; behavior fix aligns with existing rollback/manifest resolution but alters fetch warnings and gem vendoring when qualified PURLs are used.
Overview
Vendor now resolves on-disk packages with
find_packages_for_rollbackinstead offind_packages_for_purls, matchingfind_manifest_package_paths.Manifest keys for gem, PyPI, and Maven use qualified PURLs (
?platform=,?artifact_id=, etc.), while crawlers return base PURLs. The old map was keyed by base only, soall_packages.contains_key(qualified)failed for installed packages. That wrongly triggered auto-fetch (vendor_fetched_missing), redundant registry downloads, and gem platform nondeterminism.A hermetic test in
ecosystem_dispatchasserts rollback resolves a qualified gem under its exact key and thatfind_packages_for_purlsdoes not.Reviewed by Cursor Bugbot for commit 6bfe328. Configure here.