Repository navigation
π scanner: skip issues with an open linked PR and auto-resolve duplicate fixes - #14812
Conversation
β¦ate fixes Both admission gates (contributor-lane neutral admission and IssueClaimBlockReason) consulted only the eval-cycle claim ledger, so an issue whose fix a person had just opened as a PR was still dispatched and a second PR appeared; nothing resolved two open same-issue PRs beyond labelling conflicts-with-open-pr and escalating to 085. - Add a live open-PR dispatch guard (IssueDispatchBlockReason, contributor lane hook, claims-ledger fresh-claim admission) that reads the forge, labels the issue has-open-pr and withholds the claim; renewals and PR-backed start signals keep using the ledger-only gate. - Add a duplicate-fix sweep: the earlier green/pending PR wins, the later hive PR is closed with one comment and duplicate-of:<keeper>; escalate to 085 only when the earlier is red/stale and the later green; human PRs are commented on and left open. - scanner.skip_issues_with_open_pr (default true) switches both off. Fixes #14799 Signed-off-by: Andy Anderson <andy@clubanderson.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
@clubanderson is auto-promoted for contributor-lane merging on this PR: the last 5 merged PRs by this author in this hive's repositories have no revert or sentinel-alert evidence. CI, reviewer verdict, diff fences, soak, holds and branch protection still apply. |
There was a problem hiding this comment.
Reviewed (intent alignment vs #14799) β the diff delivers both parts of the issue: the live open-PR guard runs on fresh ledger claims (src/cmd/hive/claimswire.go:207-209), claim relay requests (src/pkg/github/issue_request_watcher.go:579) and the contribute lane (src/pkg/dashboard/contribute_admission.go:208-213); the sweep's rule (src/pkg/github/pr_duplicate_fix_sweep.go:98-107) matches the issue's earlier-wins / red-or-stale-and-later-green escalates / human-never-closed spec. Two advisory doc-vs-code gaps, neither blocking:
src/pkg/github/open_pr_links.go:112-113says "The PR-opened watcher path calls it when the hive itself opens a PR", but the only caller ofInvalidateOpenPRLinksin this PR is the sweep itself (pr_duplicate_fix_sweep.go:218). Either wire that call or drop the sentence:
// InvalidateOpenPRLinks drops the cached listing for repo (every repo when
// repo is ""), so the next guard call lists again. The duplicate-fix sweep
// calls it after it closes or parks a PR in the repo.
src/docs/operator-reference.md:754lists "the centralIssueClaimBlockReasongate" as a place the guard runs, but the diff deliberately keepsIssueClaimBlockReasonguard-free and addsIssueDispatchBlockReasonfor it (src/pkg/github/issue_claim_gate.go:152-170);contribute_claims.go:134still calls the unguarded one as a post-admission recheck. Suggest naming the dispatch gate instead:
the central `IssueDispatchBlockReason` gate, the ledger admission check, the
β hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Security perspective (read at head 29c01f1)
Medium β untrusted PR text can now close hive-authored PRs (src/pkg/github/pr_duplicate_fix_sweep.go)
The keeper in a same-issue group is simply the earliest-created open PR whose title/body carries a closing keyword (open_pr_links.go buildOpenPRLinkIndex β claimsFromPR, which per prclaims.go:768 deliberately accepts any author). resolveDuplicateFixGroup then closes every later non-human PR unless the keeper is red or stale (DecideDuplicateFix, pr_duplicate_fix_sweep.go:94-101). A fork PR from an account with no repo relationship normally has no check runs (Actions gated on approval), and duplicateFixCheckState maps counted == 0 to pending (pr_duplicate_fix_sweep.go:409-411) β i.e. "not weak", so it wins. Net effect: anyone who can open a PR can write Fixes #N for an issue an agent is already working, and when the hive's real PR opens the sweep comments on it and closes it with labelAndCloseSupersededPR (pr_supersession_autoclose.go:444-456), repeatedly, with no human in the loop. Before this PR the ledger only suppressed dispatch on external claims (prclaims.go:1995-2000); closing a PR on that evidence is new and is the trust-boundary change here. #14799 specifies "earlier wins while green or pending" but says nothing about who authored the earlier PR.
Suggested fix β don't let an unassociated, un-CI'd keeper trigger a close; fall through to the owner instead (the escalate branch already exists):
--- a/src/pkg/github/pr_duplicate_fix_sweep.go
+++ b/src/pkg/github/pr_duplicate_fix_sweep.go
@@ type DuplicateFixFacts struct {
EarlierStale bool
// LaterHuman: a person authored the later PR.
LaterHuman bool
+ // EarlierUntrusted: the earlier PR's author has no relationship with the
+ // repo (author_association NONE/FIRST_TIMER/FIRST_TIME_CONTRIBUTOR) and
+ // is not the hive. Such a PR may hold the issue, but must not close
+ // another PR on its own say-so.
+ EarlierUntrusted bool
}
@@ func DecideDuplicateFix(f DuplicateFixFacts) DuplicateFixVerdict {
if earlierWeak && f.LaterChecks == DuplicateFixChecksGreen {
return DuplicateFixVerdictEscalate
}
+ if f.EarlierUntrusted && f.EarlierChecks != DuplicateFixChecksGreen {
+ return DuplicateFixVerdictEscalate
+ }
if f.LaterHuman {
return DuplicateFixVerdictCommentOnly
}
@@ func (c *Client) resolveDuplicateFixGroup(
EarlierStale: earlierStale,
LaterHuman: c.duplicateFixIsHuman(later),
+ EarlierUntrusted: !c.duplicateFixIsHive(keeper) && duplicateFixUntrustedAssociation(keeper.GetAuthorAssociation()),
}(client.go:2104 already reads pr.GetAuthorAssociation() from the same listing, so no extra API call.) A test for the "untrusted pending keeper vs green/pending hive PR" case would pin this.
β hive: agent=adjudicator-4 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether #14808 (same open-PR guard, same scanner.skip_issues_with_open_pr key and has-open-pr label, no sweep; test/coverage currently red) is closed in favour of this PR, since both cannot merge.
Code read from the tree at v5 63b231c, plus the diff: the guard and the sweep look correct to me; the one thing I can't settle is the overlap with #14808.
Overlap with #14808. Both PRs add the same pre-dispatch guard β config key scanner.skip_issues_with_open_pr, label has-open-pr, log line claim skipped: open PR already linked, refusal open PR already linked: #N β and both edit claimswire.go, contribute_admission.go, config.go, agent_runtime_golden.json, settings_parity_allowlist.txt and client.go, but in different files (issue_open_pr_guard.go there, open_pr_links.go here). They conflict rather than duplicate: #14808 closes #14804 only; this PR is the superset (Fixes #14799, adds the duplicate-fix sweep #14805 asked for). Checks here are green bar an in-progress arm64 build; #14808 has test (rest 4/4) and coverage red. I have not closed anything.
Verified against the tree
claimsFromPR(prclaims.go:766) setsClosingonly for closing-keyword refs, sobuildOpenPRLinkIndexfiltering onclaim.Closingcorrectly ignoresRefs #Nand branch-name claims.claimswire.go:207routes only!held && !req.PRStartedtoIssueDispatchBlockReason; renewals/ReleaseBlockedkeepIssueClaimBlockReason, so the holder's own PR cannot evict its claim.claims_admission_test.gocovers all three paths and asserts a single listing.listOpenPRsForSupersessionSweep(pr_supersession_sweep.go:135) listsstate=open, so the index is open-only;labelAndCloseSupersededPR/parkSupersededPRare the existing supersession helpers, reused unchanged.duplicateFixCheckStatetreats "no check runs" as pending, so a fresh head is never read as green.
Low
open_pr_links.go:113-116β the doc comment says "The PR-opened watcher path calls [InvalidateOpenPRLinks] when the hive itself opens a PR", but the only non-test caller isSweepDuplicateFixPRs. Consequence is nil today (a hive-opened PR reaches the ledger viaClaimsFromPROpened, #14472, so the ledger gates in both lanes still see it within the 60s TTL), but the comment describes a hook that doesn't exist.open_pr_links.go:27-31,:265βhas-open-pris added and never removed by any code path (same in #14808). After the linked PR closes unmerged, the issue keeps a label saying an open PR links it. The guard doesn't read the label so nothing is gated wrongly; it's informational drift for anyone filtering by it.labels-and-control-signals.mddoes document "Nothing" as the clearing action, so this is stated, not hidden.
Open question (decided in the changelog, noting for the record): pr_duplicate_fix_sweep.go:90-99 β earlier=red, later=pending, later hive-authored β the later PR is closed. That is what the fragment says ("only an earlier red/stale PR facing a later green one is escalated"), so I'm not calling it a defect; it does mean a red keeper outlives a sibling whose checks haven't finished yet.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether #14812 supersedes #14808 (close #14808, land this as the whole of #14799) or #14808 lands first and this PR is rebased down to the #14805 duplicate-sweep half.
Conclusion: this PR and #14808 implement the same open-PR claim guard with different identifiers at every seam, so they conflict rather than duplicate β exactly one of them can merge as-is. This one is the superset (it also carries the #14805 duplicate-fix sweep), so I am raising the question here and not touching #14808, whose current head already has a hive verdict.
Overlap I verified (both diffs read in full for these files):
src/pkg/config/config.goβ both addScannerConfigwith the identical keyscanner.skip_issues_with_open_pr(*bool, unset = on). Accessor differs:IsSkipIssuesWithOpenPR()here vsSkipIssuesWithOpenPREnabled()in #14808. Same golden change intestdata/agent_runtime_golden.jsonandsettings_parity_allowlist.txt.src/pkg/github/client.goβ same insertion point beforesentinelMu:openPRLinkOnce/openPRLinkStatehere vsskipIssuesWithOpenPR atomic.Bool/openLinkedPRCachein #14808.src/cmd/hive/claimswire.goβ same intent (skip the guard forPRStartedand for a renewal by the current holder), different shape: hereIssueDispatchBlockReasonreplacesIssueClaimBlockReasonand the holder check is!held; #14808 keepsIssueClaimBlockReasonand comparesheld.Holder == req.Holder && held.Kind == req.Kind. Note the renewal semantics differ slightly: this PR skips the guard whenever any claim is held on the issue, #14808 only when the same holder/kind holds it.src/pkg/github/issue_request_watcher.go,src/pkg/dashboard/deps.go,src/pkg/dashboard/contribute_admission.goβ parallel hooks (OpenPRLinkingIssuevsIssueOpenPRClaimed; reason codeopen_pr_linkedhere vs falling throughissueClaimedByOpenPRin #14808).- Both label the issue
has-open-prand logclaim skipped: open PR already linked.
Unique to this PR β src/pkg/github/pr_duplicate_fix_sweep.go: read it end to end. The rule in DecideDuplicateFix is sound: earliest-created PR is keeper (open_pr_links.go sorts by CreatedAt, then number); a red/stale keeper facing a green later PR escalates instead of closing; a later PR by a person is never closed (duplicateFixIsHuman reads the author/* label and falls back to supersessionIsHuman on the login/type when unlabeled, so a not-yet-labelled human PR is still safe); held/exempt labels and a prior <!-- hive:duplicate-fix --> marker short-circuit; closed issues are left to the supersession sweep. I did not find a defect in the code I read. It does, however, give the hive a new path that closes PRs automatically β that is the risk-class reason I am routing rather than calling this clean.
I did not execute the Go tests (blocked on this host) and did not read every one of the 29 files; the correctness statement above covers the sweep, the config, and the claim wiring only.
I have not closed or changed anything; flagging for @clubanderson to pick the survivor.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Reviewed (correctness) at 29c01f1 β no blocking findings. Three advisories, worst first:
-
Sweep ignores a person-applied
needs-humanpark βresolveDuplicateFixGroupskips onlyisHeld/isExempt(src/pkg/github/pr_duplicate_fix_sweep.go:239);needs-humanis not a hold label (src/pkg/github/client.go:1315). The supersession sweep deliberately protects an owner's park viasupersessionNeedsHumanByPerson(src/pkg/github/pr_supersession_resolve.go:158-167); this sweep will close a later hive PR the owner has parked at 085 to deliberate on. Suggest, right after the hold check:if c.isHeld(labels) || c.isExempt(labels) || c.supersessionNeedsHumanByPerson(ctx, owner, repoName, later) { continue } -
Red earlier + pending later closes the later PR β
DecideDuplicateFix(pr_duplicate_fix_sweep.go:100-108) returnsclosewhen the keeper is red/stale and the later PR's checks are merely pending;duplicateFixCheckStatealso maps "no check runs yet" to pending (:414-417), so a hive PR opened minutes before the 15-min sweep is closed in favour of a red PR. The test pins this (pr_duplicate_fix_sweep_test.go"earlier red, later pending"), so it's intentional per #14799's literal "AND the later is green", but it contradicts "earlier wins while green or pending". Consider returning adeferverdict (skip this sweep) whenearlierWeak && LaterChecks == Pending. -
has-open-pris never removed βmarkIssueHasOpenPR(src/pkg/github/open_pr_links.go:258-278) adds the label; nothing in this diff or the tree removes it once the linking PR merges/closes, so the tracker signal goes stale. Nothing reads it as a block (the guard re-lists live), so this is cosmetic.
Also noted: a ranked takeover (ledger.Lookup held by another holder, src/cmd/hive/claimswire.go:207) bypasses the open-PR guard and falls to IssueClaimBlockReason; acceptable since takeovers are rare, flagging for awareness.
β hive: agent=adjudicator-3 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at 29c01f1. |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Fixes #14799