Repository navigation
Fix duplicate references request on hosted rescans (#1606, #1607) - #1695
Merged
Mikola Lysenko (mikolalysenko) merged 3 commits intoOct 23, 2026
Merged
Mikola Lysenko (mikolalysenko) merged 3 commits into
Mikola Lysenko (mikolalysenko) merged 3 commits into
Conversation
Assisted-by: Claude Code:claude-opus-5-5
A hosted scan asked the patch API's reference endpoint about the same patches twice: once in the withdrawn-pin sweep, and again in the redirect. On a rescan those are the same uuids, so every hosted rescan paid for one extra network round trip. The sweep now keeps the answers it fetched and hands them to the redirect through the rollout gate. The redirect asks only about the selected uuids the sweep did not, and sends no request at all when the sweep covered them. A uuid the sweep asked about but the endpoint left out keeps reading as not found, as a second request would say. Refs #1606, #1607 Assisted-by: Claude Code:claude-opus-5-5
Review fixes for the reused reference answers. The redirect now reuses only settled answers (granted, reused, withdrawn, not_found, forbidden) for uuids the sweep actually asked about. A pending build, an unknown status, or a uuid the response left out (a 404 chunk) is asked again, so a patch that finishes building mid-run is still pinned. Assisted-by: Claude Code:claude-opus-5-5
Mikola Lysenko (mikolalysenko)
marked this pull request as ready for review
October 23, 2026 17:07
Collaborator
Author
|
BugBot review Generated by Claude Code |
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 4fd3d54. Configure here.
Tanmay Singla (Tanmay182003)
approved these changes
Oct 23, 2026
Mikola Lysenko (mikolalysenko)
deleted the
agent/fix-rescan-duplicate-references-fetch
branch
October 23, 2026 17:57
This was referenced Oct 23, 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.
LLM Description written by Claude Code:claude-opus-5-5
Refs #1606
Refs #1607
Hosted rescans no longer send the same reference request twice. This is one slice of #1606/#1607, so both use
Refsand stay open for the rest (see Not fixed here).Root cause
A hosted
scanasked the patch API's reference endpoint about the same patch uuids twice:scan/withdrawn.rs) asks about every uuid the lockfiles pin.run_redirect_selected_untrackedinscan/hosted.rs) then asks about every selected uuid.On a rescan, the pins and the selection are the same patches, so the second request repeated the first. That cost one extra network round trip on every hosted rescan, in every ecosystem, including the bun and yarn-berry rescan scenarios in these issues. #1693 found this while profiling them.
Changes
KnownReferences. It keeps only settled answers (granted,reused,withdrawn,not_found,forbidden), and only for uuids it actually asked about.rollout::Gate::with_references, in both the--jsonarm and the human arm. The redirect asks only about the selected uuids that have no known answer. When the sweep covered all of them, it sends no request.pending_buildor an unknown status, because the answer may change while the run goes on (a build that finishes mid-run still gets pinned)get --mode hostedruns no sweep and passes no gate, so it is unchanged.Test evidence
Red → green:
cargo test -p socket-patch-cli --all-features --test in_process_scan_withdrawna_json_rescan_asks_about_a_pinned_uuid_onceanda_human_rescan_asks_about_a_pinned_uuid_oncefailed on main with two identical requests ([[UUID], [UUID]]vs[[UUID]]). Both pass with the fix.the_redirect_asks_only_about_uuids_the_sweep_did_not: a replacement uuid is still looked up, and only ita_pending_build_answer_is_asked_againwithdrawn::tests::only_settled_answers_are_knownLocal checks on
4fd3d54:cargo fmt --all -- --check: cleancargo clippy --workspace --all-features -- -D warnings: cleancargo test --workspace --all-features --no-fail-fast: 14,867 passed, 11 failed. All 11 are environmental, and none touch the changed code:0o555directory fails, which can't happen in the sandbox because it runs as root. They are the same set Speed up bun and yarn-berry rescans (#1606, #1607) #1693 lists: copy_tree, vlt_heal, pypi_poetry, pypi_requirements, in_process_redirect, repair.e2e_bun_lockb:binary_shared_bundled_record_hosted_pin_is_managed(the sandbox proxy refuses the real patch host) andworkspace_text_migration_heals_on_rerun, which fails the same way withmain's sources.Per-issue checklist
*_rescan_asks_about_a_pinned_uuid_oncetests (the path every ecosystem shares)Not fixed here (why the issues stay open)
.bunstore liveness walk (With Bun's isolated linker,vexrefuses every hosted patch as not_applied after the usual in-placebun install, because it checks orphanednode_modules/.bunregistry entries that Bun never removes (regression from #496) #599), as listed in Speed up bun and yarn-berry rescans (#1606, #1607) #1693/code-review high
The review reported 8 findings. I fixed 6:
pending_buildanswersanswers_for, now a consuminginto_answersI skipped 2:
ApiClient. The only duplicate is scan's sweep→redirect handoff, andgetruns no sweep. A client-wide memo would also have to handle when an answer goes stale, for every caller.Generated by Claude Code