fix(miner): refuse a duplicate attempt when this miner already has an open PR for the exact issue#8815
Merged
Merged
Conversation
… open PR for the exact issue (#8808) The crash-retry double-open guard the audit found missing: claim-conflict resolution deliberately never treats the miner's own sibling PR as a competing claim, submission-freshness excludes same-author PRs, and nothing queried the issue-tagged own-submissions ledger before starting a new attempt — so a process killed after PR-open but before the finally block completed could double-open on retry, with no cleanup. - resolveOwnOpenPrForIssue (rejection-signal.ts, sharing the sibling resolver's option plumbing via a new extracted resolveHistoryOptions): reads the miner's own issue-matched submissions, live-checks the bounded most-recent candidates, returns the first still-OPEN PR number. FULLY fail-open — any read/fetch failure returns null so a hiccup never blocks a legitimate attempt (freshness + the claim ledger stay the backstops); a closed/merged prior PR never blocks a fresh one. - attempt-cli refuses BEFORE a worktree slot is consumed (mirroring the rejection-signal block): attempt_aborted/attempt_blocked events carry the existing PR number, outcome blocked_own_open_pr, exit 5. Refusing (not adopting) is the safe disposition — the open PR is already doing the job.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8815 +/- ##
==========================================
- Coverage 93.81% 92.27% -1.55%
==========================================
Files 797 797
Lines 79608 79635 +27
Branches 24127 24136 +9
==========================================
- Hits 74686 73484 -1202
- Misses 3556 5090 +1534
+ Partials 1366 1061 -305
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Contributor
|
Important 🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪 🔍 LoopOver is reviewing…AI analysis is in progress. This comment will update when the review is complete. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed · 🟪 Reviewing |
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
AMS audit fix (#8808): a crash between PR-open and the attempt's
finallyleft an orphaned open PR that nothing downstream would ever treat as a conflict — claim-conflict resolution deliberately exempts the miner's own PRs, freshness excludes same-author PRs, and the issue-tagged own-submissions ledger was never consulted — so a retry double-opened.Changes
rejection-signal.ts—resolveOwnOpenPrForIssue(repo, issue): issue-matched own submissions → bounded live PR-state checks (samemaxRejectionHistoryChecksfan-out cap) → first still-OPEN PR number, else null. Fully fail-open (store read failure, fetch rejection, degenerate inputs → null): an idempotency guard must never block a legitimate attempt on a hiccup. A closed/merged prior PR never blocks. Shared option plumbing extracted intoresolveHistoryOptions(reused by the Check a miner's own prior-rejection history on a repo (rejectionSignaled's second documented trigger) #5655 sibling — no duplicated arms).attempt-cli.ts— refuses before a worktree slot is consumed, mirroring the rejection-signal block:attempt_aborted/attempt_blockedevents +blocked_own_open_prresult naming the existing PR, exit 5, injection seam mirroringresolveRejectionSignaled. Refuse—not adopt: the still-open PR is already doing this issue's job.Test plan
npm run typecheckclean;@loopover/minerbuildsallocator.acquire, JSON + stderr shapes, null-proceeds)Closes #8808