feat(pypi): narrow/broad release breadth + multi-variant remove/rollback fixes#90
Merged
Mikola Lysenko (mikolalysenko) merged 1 commit intoMay 28, 2026
Conversation
…ack fixes PyPI is the only ecosystem that carries a Socket-specific `artifact_id` PURL qualifier, so a single `package@version` can resolve to several patch variants (one per wheel/sdist release). Only the installed distribution can ever apply, but scan/get downloaded every variant and remove/rollback mishandled the qualified keys. Feature — download-time release breadth (narrow default): - Add `--all-releases` (env `SOCKET_ALL_RELEASES`, default off) to `scan` and `get`. Narrow keeps only the variant matching the installed distribution; broad keeps every variant (portable across environments). - `select_installed_variant` (core `patch/apply.rs`) picks the variant whose first patched file is Ready/AlreadyPatched against the on-disk package — shared by the narrow filter and rollback dedupe. - `filter_to_installed_releases` (commands/get.rs) runs in the shared download path; non-PyPI ecosystems and single-variant packages pass through untouched. Falls back to broad (with a warning surfaced in the JSON `warnings` array) when the package is not installed or no variant matches the on-disk bytes. Correctness fixes surfaced by multi-release manifests: - Base-PURL matching (`purl_matches_identifier`, core utils/purl.rs): `remove`/`rollback` of a base PURL now affect every release variant; a qualified PURL or UUID still targets exactly one. Previously a base PURL matched nothing because manifest keys are qualified. - Rollback variant dedupe: rollback groups discovered packages by base PURL and rolls back only the installed-dist variant, ending the spurious HashMismatch failures that broad manifests would have caused (the non-installed variants resolve to the same on-disk file). - `remove` lists each variant when a base PURL expands, so the blast radius is visible before confirmation. - `detect_prunable` compares on stripped base PURLs, so `scan --all-releases --sync` no longer prunes the very variants it just downloaded. Tests: - New in_process_pypi_multi_release.rs: real `pip install six` + a three-variant wiremock exercising narrow-keeps-one, broad-keeps-all, remove-base-clears-all-and-rolls-back, and rollback-all-succeeds. - Unit tests for purl_matches_identifier, find_patches_to_rollback, remove_patch_from_manifest, detect_prunable (PyPI keep/prune), and `--all-releases` parse defaults for scan + get. Full workspace suite: 1573 passed, 0 failed; clippy clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Wenxin Jiang (Wenxin-Jiang)
approved these changes
May 28, 2026
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.
Summary
PyPI is the only ecosystem that carries a Socket-specific
artifact_idPURL qualifier, so onepackage@versioncan resolve to several patch variants (one per wheel/sdist release). Only the installed distribution can ever apply, yetscan/getdownloaded every variant andremove/rollbackmishandled the qualified manifest keys. This PR adds a download-time breadth control and fixes the multi-variant lifecycle bugs it exposed.Feature — download-time release breadth (narrow by default)
--all-releasesflag (envSOCKET_ALL_RELEASES, default off) onscanandget..socket/.--all-releases): keep every release variant → manifest portable across environments (cross-platform CI caches).select_installed_variant(corepatch/apply.rs): picks the variant whose first patched file isReady/AlreadyPatchedagainst the on-disk package. Shared by the narrow filter and the rollback dedupe so selection stays consistent with apply.filter_to_installed_releases(commands/get.rs): runs in the shared download path. Non-PyPI ecosystems and single-variant packages pass through untouched. Falls back to broad (with a warning surfaced in the JSONwarningsarray) when the package isn't installed or no variant matches the on-disk bytes.Correctness fixes surfaced by multi-release manifests
purl_matches_identifier, coreutils/purl.rs):remove/rollbackof a base PURL now affect every release variant; a qualified PURL or UUID still targets exactly one. Previously a base PURL matched nothing (manifest keys are qualified for PyPI).HashMismatchfailures a broad manifest would otherwise cause (all variants resolve to the same on-disk file).removelists each variant when a base PURL expands, so the blast radius is visible before confirmation.detect_prunablecompares on stripped base PURLs, soscan --all-releases --syncno longer prunes the variants it just downloaded.Tests
in_process_pypi_multi_release.rs: realpip install six==1.16.0+ a three-variant wiremock exercising narrow-keeps-one, broad-keeps-all, remove-base-clears-all-and-rolls-back, and rollback-all-succeeds.purl_matches_identifier,find_patches_to_rollback,remove_patch_from_manifest,detect_prunable(PyPI keep/prune), and--all-releasesparse defaults forscan+get.Full workspace suite: 1573 passed, 0 failed; clippy clean under the pinned 1.93.1 toolchain.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com