Repository navigation
🐛 scanner: refuse claims on issues that already have an open linked PR - #14808
hivecommons-hive[bot] wants to merge 2 commits into
Conversation
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>
|
[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
|
|
hive/awaiting-ci: CI pending — sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
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:2683and:5821callb.ghClient.SetSkipIssuesWithOpenPR(...)on the live client at the two resync sites, right next toSetHoldLabels/SetNeverClaimLabels.- The ratchet (
src/cmd/hive/github_client_config_test.go:548-551) only permits a live-client setter there if it is listed inclientResyncSetters(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": truetoclientResyncSettersis the repo's convention for exactly this case and should clear the shard;coverageis red only because it refuses to report withrest=failure.
Two smaller things I verified while reading the tree:
has-open-pris applied (src/pkg/github/issue_open_pr_guard.go:174-199) but nothing in the tree reads or removes it (onlydocs/andconfig.gomention 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 stalehas-open-pras "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 vialedger.Lookup) match the body's description; the relayclaimpath inissue_request_watcher.go:583-585has 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>
|
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:
DetailsInstructions 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. |
|
PR needs rebase. DetailsInstructions 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. |
There was a problem hiding this comment.
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-753andsrc/docs/labels-and-control-signals.md:101say 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-processopenLinkedPRCache.labelledmap (issue_open_pr_guard.go:210-216, no persistence), so ahas-open-prapplied 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.mddoes 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
There was a problem hiding this comment.
Reviewed (correctness, delta 5eebcc7→3d2a791) — both prior findings fixed.
SetSkipIssuesWithOpenPRis now inclientResyncSetters(src/cmd/hive/github_client_config_test.go:88) and is installed on every rebuilt client byapplyGitHubClientConfigHooks(src/cmd/hive/github_client_config.go:94). ✅has-open-pris now cleared on readmission viaunlabelHasOpenPR(src/pkg/github/issue_open_pr_guard.go:154, 209-230);RemoveLabeltreats 404 as success (src/pkg/github/client.go:3141), andTestIssueOpenPRClaimClearsLabelOnReadmitcovers 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
There was a problem hiding this comment.
Style / idioms — delta re-review at 3d2a791 (vs. 5eebcc7)
Previous findings:
SetSkipIssuesWithOpenPRmissing fromclientResyncSetters— fixed (src/cmd/hive/github_client_config_test.go:87-88).has-open-prnever 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
|
Superseded by #14812 (merged into v5): it landed the same live open-PR claim guard ( 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
Why
The contributor-lane gate (
evaluateContributorNeutralAdmission→issueClaimedByOpenPR) and the agent-lane gate (IssueClaimBlockReason, which ledger admission and theclaimrelay request use) only see open PRs through the duplicate-PR claim ledger. That ledger is refreshed only by the eval cycle'sFetchClaimScan, 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 asrequires_humandecisions.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, andclaim skipped: open PR already linkedis 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'sopen_pr_claimwithheld 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 theReleaseBlockedrecheck. If the listing fails, the claim is admitted, because the ledger's next scan still covers the issue.scanner.skip_issues_with_open_pr(defaulttrue) 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