Skip to content

πŸ› scanner: skip issues with an open linked PR and auto-resolve duplicate fixes - #14812

Merged
hivecommons-hive[bot] merged 1 commit into
v5from
fix/skip-linked-issue-dispatch
Oct 28, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
v5from
fix/skip-linked-issue-dispatch

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Fixes #14799

…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>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 28, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kellyaa for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Oct 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#14702 ✨ review: scale reviewer concurrency up and down with backlog same files src/cmd/hive/main.go
src/pkg/config/config.go
#14524 ✨ feat(hub,agent): Hub-coordinated live CLI session pool for multi-tenant runner capacity same files src/cmd/hive/main.go
#14808 πŸ› scanner: refuse claims on issues that already have an open linked PR CONFLICT src/cmd/hive/claimswire.go
src/cmd/hive/github_client_config.go
src/cmd/hive/main.go
src/docs/operator-reference.md
src/pkg/config/config.go
src/pkg/config/scanner_config_test.go
src/pkg/dashboard/deps.go
src/pkg/dashboard/settings_parity_allowlist.txt
src/pkg/github/client.go

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 28, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

@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.

@hivecommons-hive hivecommons-hive Bot added author/human A person pushed this PR themselves dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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:

  1. src/pkg/github/open_pr_links.go:112-113 says "The PR-opened watcher path calls it when the hive itself opens a PR", but the only caller of InvalidateOpenPRLinks in 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.
  1. src/docs/operator-reference.md:754 lists "the central IssueClaimBlockReason gate" as a place the guard runs, but the diff deliberately keeps IssueClaimBlockReason guard-free and adds IssueDispatchBlockReason for it (src/pkg/github/issue_claim_gate.go:152-170); contribute_claims.go:134 still 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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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) sets Closing only for closing-keyword refs, so buildOpenPRLinkIndex filtering on claim.Closing correctly ignores Refs #N and branch-name claims.
  • claimswire.go:207 routes only !held && !req.PRStarted to IssueDispatchBlockReason; renewals/ReleaseBlocked keep IssueClaimBlockReason, so the holder's own PR cannot evict its claim. claims_admission_test.go covers all three paths and asserts a single listing.
  • listOpenPRsForSupersessionSweep (pr_supersession_sweep.go:135) lists state=open, so the index is open-only; labelAndCloseSupersededPR / parkSupersededPR are the existing supersession helpers, reused unchanged.
  • duplicateFixCheckState treats "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 is SweepDuplicateFixPRs. Consequence is nil today (a hive-opened PR reaches the ledger via ClaimsFromPROpened, #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-pr is 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.md does 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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 add ScannerConfig with the identical key scanner.skip_issues_with_open_pr (*bool, unset = on). Accessor differs: IsSkipIssuesWithOpenPR() here vs SkipIssuesWithOpenPREnabled() in #14808. Same golden change in testdata/agent_runtime_golden.json and settings_parity_allowlist.txt.
  • src/pkg/github/client.go β€” same insertion point before sentinelMu: openPRLinkOnce/openPRLinkState here vs skipIssuesWithOpenPR atomic.Bool/openLinkedPRCache in #14808.
  • src/cmd/hive/claimswire.go β€” same intent (skip the guard for PRStarted and for a renewal by the current holder), different shape: here IssueDispatchBlockReason replaces IssueClaimBlockReason and the holder check is !held; #14808 keeps IssueClaimBlockReason and compares held.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 (OpenPRLinkingIssue vs IssueOpenPRClaimed; reason code open_pr_linked here vs falling through issueClaimedByOpenPR in #14808).
  • Both label the issue has-open-pr and log claim 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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed (correctness) at 29c01f1 β€” no blocking findings. Three advisories, worst first:

  1. Sweep ignores a person-applied needs-human park β€” resolveDuplicateFixGroup skips only isHeld/isExempt (src/pkg/github/pr_duplicate_fix_sweep.go:239); needs-human is not a hold label (src/pkg/github/client.go:1315). The supersession sweep deliberately protects an owner's park via supersessionNeedsHumanByPerson (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
    		}
    
  2. Red earlier + pending later closes the later PR β€” DecideDuplicateFix (pr_duplicate_fix_sweep.go:100-108) returns close when the keeper is red/stale and the later PR's checks are merely pending; duplicateFixCheckState also 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 a defer verdict (skip this sweep) when earlierWeak && LaterChecks == Pending.

  3. has-open-pr is 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

@hivecommons-hive
hivecommons-hive Bot merged commit 5793c19 into v5 Oct 28, 2026
81 of 85 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the fix/skip-linked-issue-dispatch branch October 28, 2026 02:56
@hivecommons-hive

Copy link
Copy Markdown
Contributor
Evidence bundle `#1481229c01f1` sha256:88c3c22e5d75ad289b9eb5db71b1765897834acb05d91f365a815e5e4999982f β€” download from the dashboard or `hivectl review evidence #14812`.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at 29c01f1.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

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

Labels

author/human A person pushed this PR themselves conflicts-with-open-pr Open PR has a merge conflict with another open PR dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scanner dispatches issues that already have an open linked PR; duplicates escalate to owner instead of auto-resolving

1 participant