Skip to content

Fix uv/Hatch hosted re-pin to a newer patch (#742, #650) - #743

Merged
Mikola Lysenko (mikolalysenko) merged 5 commits into
mainfrom
agent/fix-pypi-own-pin-repin
Oct 5, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 5 commits into
mainfrom
agent/fix-pypi-own-pin-repin

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-opus-5-5

Refs #742
Refs #650

Summary

Hosted scan now moves a uv project, a uv PEP 723 script lock or a Hatch
project to a superseding patch for a package it already wired. Before
this, the run listed the upgrade in updates[] and then refused its own
earlier pin as a user source. It exited 0 with
redirect_uv_project_unsupported, redirect_uv_script_unsupported or
redirect_hatch_unsupported, and the project kept installing the old
patch. If that artifact was ever withdrawn, every fresh install would 404.

Root cause

Both pyproject source writers decide whether an existing pin may be
replaced:

  • uv: same_hosted_artifact in utils/python_script.rs accepted only a
    rotated grant token on an identical path, and a test pinned a
    different patch uuid as a refusal.
  • Hatch: replacement in utils/hatch.rs accepted only a
    byte-identical URL.

Neither recognized socket-patch's own hosted reference under an older
patch uuid. Pipenv already handles this correctly through the shared
hosted_pypi_reference recognizer.

Fix

New replaceable_hosted_pin(previous, current, name, version) in
vendor/lock_inventory/pypi.rs. It is built on the shared hosted PyPI
recognizer: the pin must be on patch.socket.dev or the configured
--patch-server-url origin (path prefix allowed), with no userinfo, and
its /patch/pypi/<name>/<version>/<grant>/<uuid>/<artifact> coordinates
must match the package and version. The uv writer, the Hatch writer and
Pipenv's owned_url all use it, so every PyPI hosted lane shares one
definition of "our own pin". Pins on another host, with credentials, for
another release, or vendored path sources are still refused.

Scope / remaining slice

This PR covers hosted mode only. Vendored re-vendoring to a newer uuid
(pypi_uv_source_already_exists, pypi_lock_source_already_exists,
pypi_hatch_unsupported) needs a revert-then-rewire path in the vendored
PyPI backends. The requirements.txt vendored lane has the same gap. That
is why both issues are Refs, not Fixes, and stay open for the
vendored follow-up.

Tests (red → green)

Issue Test Before fix After
#742 project tests/hosted_superseding_pypi.rs::uv_project_repins_superseding_patch (two real CLI hosted scans vs. a mock API switching uuid A→B) FAIL redirect_uv_project_unsupported pass
#742 script ::uv_script_lock_repins_superseding_patch FAIL redirect_uv_script_unsupported pass
#650 pyproject ::hatch_pyproject_repins_superseding_patch FAIL redirect_hatch_unsupported pass
#650 hatch.toml ::hatch_toml_repins_superseding_patch FAIL redirect_hatch_unsupported pass
#742 patch::redirect::superseding_repin_tests::{uv_project,uv_script_lock}_repins_to_a_superseding_patch (LF + CRLF; uv.lock hash replaced) FAIL pass
#650 patch::redirect::superseding_repin_tests::hatch_project_repins_to_a_superseding_patch FAIL pass
#742 utils::python_script::tests::superseding_patch_repins_own_hosted_source (project + script, custom path-prefixed origin, foreign host/version/userinfo still refused) FAIL pass
#650 utils::hatch::tests::superseding_patch_repins_own_hosted_reference FAIL pass

Local checks:

  • cargo clippy --workspace --all-features -- -D warnings: clean.
  • New and changed code is rustfmt-clean. main itself is not
    rustfmt-clean, and CI has no fmt gate.
  • cargo test --workspace --all-features: 9733 passed, 12 failed. All 12
    failures are permission-denial tests (chmod 0o555 / read-only files)
    that cannot fail when run as root, which this sandbox is. None touch
    this change, and CI runs them as non-root.
  • CI on d0d9102: every check passed (3 skipped by path filters). Bugbot:
    no issues.

Docs: CHANGELOG [Unreleased] / Fixed entry; docs/testing/hatch.md
notes the hosted re-pin.


Generated by Claude Code

Assisted-by: Claude Code:claude-opus-5-5
A superseding patch for a package an earlier hosted scan already
wired is refused in uv projects, uv script locks and Hatch projects:
the writers treat socket-patch's own earlier pin as a user source.

Refs #742, #650

Assisted-by: Claude Code:claude-opus-5-5
When the patch API supersedes a patch a uv project, uv script or
Hatch project already uses, hosted scan now moves the pin to the new
patch. It used to list the upgrade, then refuse socket-patch's own
earlier pin as a user source and keep installing the old patch.

The uv sources writer and the Hatch direct-reference writer now share
the hosted PyPI recognizer Pipenv already uses: a pin on Socket's patch
server (or the configured one) for the same name and version is ours
to replace. Pins on other hosts, with credentials, or for another
release are still refused.

Refs #742, #650

Assisted-by: Claude Code:claude-opus-5-5
Refs #650

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review October 4, 2026 04:13
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 d0d9102. Configure here.

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Oct 4, 2026
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

Ready for review at d0d910218a.

  • CI: 475/475 latest check runs green on the head (skipped/neutral excluded: 3 skipped, 1 cancelled Bugbot re-request); mergeable, no conflicts.
  • Bugbot: reviewed d0d9102 — no issues found; no unresolved review threads.
  • Reviewer note: vendored re-vendor to a newer patch is a separate follow-up slice (per the status block).

Generated by Claude Code

Release notes are written when a release is cut, from the merged PR
log and the code, so PRs no longer edit CHANGELOG.md.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mikolalysenko
Mikola Lysenko (mikolalysenko) merged commit 0475695 into main Oct 5, 2026
463 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the agent/fix-pypi-own-pin-repin branch October 5, 2026 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants