Skip to content

Agent-mode PyPI variant selection uses one representative file, not the installed wheel's tags, so wheels that share .py files all match #2194

Open

Description

Summary

In agent mode a release variant of a PyPI package (a record keyed ?artifact_id=<wheel filename>) is matched to the installed distribution by the hash state of ONE file: the lexicographically smallest key with a non-empty beforeHash (representative_file, crates/socket-patch-cli/src/commands/apply.rs:1199, mirrored by select_installed_variants in core). The installed wheel's own WHEEL Tag: lines are not consulted; they are read only on the hosted path (crates/socket-patch-core/src/hosted/wheel_record.rs:121).

Why this matters

Platform wheels of one release usually share their .py files byte for byte and differ only in the compiled extension. Measured on pillow 12.3.0: all 97 .py files are identical across the manylinux x86_64, manylinux aarch64, musllinux and macOS arm64 wheels. If a patch changes both a .py file and the extension (or only the extension, with a .py file also listed), the representative file is the shared .py, so every variant record "matches" the install. Each matching variant is then applied; for the variants built for another platform the extension's beforeHash does not match. With the default policy that fails closed, so the user gets a failure for a package that has a correct variant; with --force / --allow-patch-conflicts a library built for another platform can be written.

This is from reading the code; I did not reproduce it end to end.

Suggested direction

Select the variant from what the install says it is: the Tag: lines of *.dist-info/WHEEL (and the gem platform, which agent mode already consults) against the variant's artifact_id. Keep the hash probe as a second check, on a file that actually differs between variants when one exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpm:pippip / requirements.txt

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions