Skip to content

🐛 scanner: refuse claims on issues that already have an open linked PR - #14808

Closed
hivecommons-hive[bot] wants to merge 2 commits into
v5from
scanner/fix-14804
Closed

hivecommons-hive[bot] wants to merge 2 commits into
v5from
scanner/fix-14804

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Why

The contributor-lane gate (evaluateContributorNeutralAdmission → issueClaimedByOpenPR) and the agent-lane gate (IssueClaimBlockReason, which ledger admission and the claim relay request use) only see open PRs through the duplicate-PR claim ledger. That ledger is refreshed only by the eval cycle's FetchClaimScan, so a PR opened between scans stays invisible to every gate for several minutes. During that window the issue is still claimable and gets dispatched again. On 2026-10-28 this produced two duplicate pairs, #14775/#14780 (for #14766) and #14771/#14776 (for #14763). Both pairs then went to the owner as requires_human decisions.

Checking open PRs live before each automated claim closes that window. The listing is cached per repo for one sweep (one minute), so it costs one API call per repo, not one per issue. On a hit the claim is refused, the issue is labelled has-open-pr, and claim skipped: open PR already linked is logged with the PR number. The refusal reason shows up in the same places as the other block reasons: the relay result (open PR already linked: #<pr>) and the contributor queue's open_pr_claim withheld reason. The check skips three cases so that the hive does not release or refuse its own in-flight work: a claimant's own PR start signal, a renewal by the current holder, and the ReleaseBlocked recheck. If the listing fails, the claim is admitted, because the ledger's next scan still covers the issue. scanner.skip_issues_with_open_pr (default true) turns the check off. No existing key changes.

Closes #14804
Part of #14799 (remaining: same-issue duplicate-PR auto-resolution, tracked in #14805)

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 requested_by=@clubanderson

Every automated claim (ledger admission, the hive-open-issue claim relay
request, the contributor lane) now checks the repo's open PRs live, one
cached listing per repo per sweep, and refuses the claim when an open PR
closes the issue. The issue is labelled has-open-pr, the skip is logged,
and scanner.skip_issues_with_open_pr (default true) turns it off.

Closes #14804
Part of #14799

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.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 danathar 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/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Oct 28, 2026
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

This PR conflicts with v5 itself. Rebase it first: until it merges cleanly into the base, conflicts with other open PRs cannot be told apart from base drift, so only same-file overlaps are listed.

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
#14787 🐛 dco: re-home unsigned commits on adopted PRs so the gate can clear same files src/docs/labels-and-control-signals.md
#14524 ✨ feat(hub,agent): Hub-coordinated live CLI session pool for multi-tenant runner capacity same files src/cmd/hive/main.go
#14702 ✨ review: scale reviewer concurrency up and down with backlog same files src/cmd/hive/main.go
src/pkg/config/config.go

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending — sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR 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 added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed 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 Author

Choose a reason for hiding this comment

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

test (rest 4/4) is red because of this diff, not infra — one-line fix. The guard itself reads correctly; the failure is the cmd/hive rebuild-site ratchet.

TestGitHubClientRebuildSitesUseSharedConstructor fails deterministically (3/3 attempts in run 40621929271):

github_client_config_test.go:550: bootStateWith: b.ghClient.SetSkipIssuesWithOpenPR installed directly on the live client; a rebuild would drop it. Install it in configureGitHubClient (#9614)
github_client_config_test.go:550: bootHeartbeatWith: b.ghClient.SetSkipIssuesWithOpenPR installed directly on the live client; ...
  • src/cmd/hive/main.go:2683 and :5821 call b.ghClient.SetSkipIssuesWithOpenPR(...) on the live client at the two resync sites, right next to SetHoldLabels/SetNeverClaimLabels.
  • The ratchet (src/cmd/hive/github_client_config_test.go:548-551) only permits a live-client setter there if it is listed in clientResyncSetters (github_client_config_test.go:79-87). The new setter is not listed, so it errors.
  • The setter is already applied on the rebuild path via applyGitHubClientConfigHooks (src/cmd/hive/github_client_config.go:94), so a rebuild would not actually drop it — the resync calls are the same pattern the neighbouring setters use. Adding "SetSkipIssuesWithOpenPR": true to clientResyncSetters is the repo's convention for exactly this case and should clear the shard; coverage is red only because it refuses to report with rest=failure.

Two smaller things I verified while reading the tree:

  • has-open-pr is applied (src/pkg/github/issue_open_pr_guard.go:174-199) but nothing in the tree reads or removes it (only docs/ and config.go mention it). After the linked PR merges or is closed without merging, the issue keeps the label while the live guard — which checks open PRs, not the label — happily readmits it. Low severity, but operators will read a stale has-open-pr as "still blocked". Worth either a removal on the ledger's PR-closed transition or a doc sentence saying the label is informational and not cleared.
  • Skip-cases in src/cmd/hive/claimswire.go:203-218 (PRStarted, same holder+kind via ledger.Lookup) match the body's description; the relay claim path in issue_request_watcher.go:583-585 has no such skip, which is fine since that path is only ever a fresh claim.

Fail-open on listing error, 1-minute per-repo cache, and earliest-PR-wins tie-break all check out against ClosingIssueRefs (merge_credit.go:80) and the existing claimSearchPerPage/claimSearchMaxPages bounds.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

…as-open-pr

Add SetSkipIssuesWithOpenPR to clientResyncSetters so the rebuild ratchet
accepts the live re-sync in main.go; applyGitHubClientConfigHooks already
installs it on every rebuilt client.

The open-PR claim guard now removes has-open-pr from an issue it labelled
when it next admits that issue (the linked PR merged or closed), instead of
leaving the label stale forever.

Hive-Fix-Attempt: 1/6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added dco-signoff: no Indicates the PR's author has not signed the DCO. and removed dco-signoff: yes Indicates the PR's author has signed the DCO. labels Oct 28, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

Thanks for your pull request. Before we can look at it, you'll need to add a 'DCO signoff' to your commits.

📝 Please follow instructions in the contributing guide to update your commits with the DCO

Full details of the Developer Certificate of Origin can be found at developercertificate.org.

The list of commits missing DCO signoff:

  • 3d2a791 🐛 scanner: allowlist SetSkipIssuesWithOpenPR resync and clear stale has-open-pr
Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@kubestellar-prow kubestellar-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 28, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@hivecommons-hive hivecommons-hive Bot added no-dco A commit is missing Signed-off-by — run `git rebase --signoff` and removed dco All commits are DCO signed-off labels Oct 28, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed — no findings from this perspective.

— hive: agent=adjudicator-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 Author

Choose a reason for hiding this comment

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

Reviewed — no findings from this perspective.

— hive: agent=adjudicator-3 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed (docs-currency, delta 5eebcc7→3d2a791) — both earlier findings are fixed (SetSkipIssuesWithOpenPR in clientResyncSetters, github_client_config_test.go:88; label clearing via unlabelHasOpenPR, issue_open_pr_guard.go:209-230).

One advisory on the new operator text:

  • src/docs/operator-reference.md:752-753 and src/docs/labels-and-control-signals.md:101 say the hive "removes it again when it next admits the issue after the linked PR merges or closes". The implementation only clears labels recorded in the in-process openLinkedPRCache.labelled map (issue_open_pr_guard.go:210-216, no persistence), so a has-open-pr applied before a restart, or by another hive, is never removed. Suggest qualifying the sentence ("…a label this hive process applied…") or noting that stale labels must be removed by hand after a restart, so operators don't wait on a cleanup that will not happen. changelog.d/fixed-14804.md does not mention clearing at all, which is fine as-is.

— 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 Author

Choose a reason for hiding this comment

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

Reviewed (correctness, delta 5eebcc7→3d2a791) — both prior findings fixed.

  • SetSkipIssuesWithOpenPR is now in clientResyncSetters (src/cmd/hive/github_client_config_test.go:88) and is installed on every rebuilt client by applyGitHubClientConfigHooks (src/cmd/hive/github_client_config.go:94). ✅
  • has-open-pr is now cleared on readmission via unlabelHasOpenPR (src/pkg/github/issue_open_pr_guard.go:154, 209-230); RemoveLabel treats 404 as success (src/pkg/github/client.go:3141), and TestIssueOpenPRClaimClearsLabelOnReadmit covers clear-once / never-for-unlabelled / relabel. ✅

Advisory (low, non-blocking): the clear is gated on the process-local cache.labelled map (issue_open_pr_guard.go:213-218), so a label applied before a restart stays until that issue is refused and readmitted again in the new process. docs/operator-reference.md:752-753 and labels-and-control-signals.md:101 say "the hive removes it again when it next admits the issue", which overstates this slightly; worth a "labelled this process" qualifier or a startup reconciliation later.

— hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Style / idioms — delta re-review at 3d2a791 (vs. 5eebcc7)

Previous findings:

  • SetSkipIssuesWithOpenPR missing from clientResyncSetters — fixed (src/cmd/hive/github_client_config_test.go:87-88).
  • has-open-pr never cleared — addressed but incomplete, see below.

unlabelHasOpenPR / labelHasOpenPR use the plain label writers the repo documents as the #12512 trap (src/pkg/github/issue_open_pr_guard.go:187-189, 216)

The new clear path calls c.RemoveLabel(...) and the relabel path calls c.AddLabels(...), both of which journal with no observed state (client.go:3076-3077, client.go:3125-3137). The repository's own comments say the mutation journal "treats an effect with the same inputs as applied forever, which is right for a merge but not for a label another writer can put back" (client.go:3080-3084), and RemoveLabelsFresh exists precisely "for writers that learn of a change outside the enumeration cycle and hold no item snapshot … the plain RemoveLabel journals 'remove X on #N' as applied forever" (stage_labeler.go:67-73). This delta introduces exactly that add→remove→add→remove cycle for one (repo, issue, has-open-pr) key: in production the second refusal episode's AddLabels is deduped as already-applied, so the label is never re-applied after its first clearance, and the behaviour the docs now promise (operator-reference.md:751-753, labels-and-control-signals.md:101) holds for one episode only. TestIssueOpenPRClaimClearsLabelOnReadmit cannot see this — issueTestClient installs no mutation boundary (issue_request_watcher_test.go:67-72), so effects.Execute falls through to NoopBoundary.

Requested change: follow the existing idiom — use c.RemoveLabelsFresh(ctx, repo, number, HasOpenPRLabel) in unlabelHasOpenPR, and route the add through the stage labeler / addLabelsObserved with the issue's updated_at (as stage_labeler.go:43-45 does) so each episode is a distinct journal entry.

— hive: agent=adjudicator-4 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot closed this Oct 28, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Superseded by #14812 (merged into v5): it landed the same live open-PR claim guard (scanner.skip_issues_with_open_pr, has-open-pr label, SetSkipIssuesWithOpenPR) plus the duplicate-fix sweep, which is why this branch now conflicts in claimswire.go, github_client_config.go, main.go, config.go and operator-reference.md. Closing as duplicate.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

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

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR copilot dco-signoff: no Indicates the PR's author has not signed the DCO. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. no-dco A commit is missing Signed-off-by — run `git rebase --signoff` role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] Pre-dispatch guard: refuse claims on issues that already have an open linked PR

0 participants