Repository navigation
🐛 fix: retire stale missing-check merge banners safely - #16031
Conversation
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 No conflicting open PRs or same-file overlaps were found. |
There was a problem hiding this comment.
The missing-check revalidation itself looks right to me — but narrowing the merge-time clear from repo to PR regresses #11924 for the alert keys that have no revalidation path.
Finding (medium) — src/pkg/github/client.go:4699-4701, merge_failure_alert.go:139-176
RecordPRMergedAudit (and both watcher sites at merge_request_watcher.go:200,516) now call clearMergeFailureAlertsForPR(repo, number) instead of clearMergeFailureAlertsForRepo. The comment this replaces said why the repo-wide clear existed: "A successful App merge on any path proves the repo is mergeable" (#11924). That reasoning still holds for the repo-level keys:
merge-method(merge_failure_alert.go:265) — "Enable squash/merge on the repository". Repo setting, not a PR property.review-required(:246) andnever-created-checks(:251) — also cleared today only by a successful repo merge.
After this PR, revalidateMergeFailureAlerts retires those keys only when the originating PR reaches state == "closed" (:141); the new missingMergeChecksResolved path is gated on the missing-checks: prefix (:145). So: PR A is quarantined with merge-method (quarantineMergeRequest renames the request to .exhausted, merge_request_watcher.go:581, so it never retries), the operator enables squash, PRs B/C/D then merge fine — the "merge method is not allowed" banner persists until someone closes or hand-merges A. That is exactly the stale-banner class this PR sets out to fix, reintroduced for a different key. TestRecordPRMergedAuditClearsMergeFailureAlerts asserts the new narrow behaviour, so CI will not catch it.
Suggested shape, keeping the per-PR tracking you added: in RecordPRMergedAudit / the watcher success paths, still clear every entry whose key is repo-level (merge-method, app-permission, review-required, never-created-checks) regardless of entry.number, and clear per-PR only for missing-checks:* and fork-run-approval, which genuinely are properties of one head. Alternatively add a revalidation probe for merge-method (repo allow_*_merge read), but the merge-time clear is the cheaper and already-proven signal.
Low — merge_failure_alert.go:170-176: clearMergeFailureAlertEntryLocked returns true when it drops this PR's entry but another PR still holds the same key (and so the sink banner is intentionally kept). The caller then logs "merge alert cleared: blocking condition resolved", which is misleading when the banner is still showing. Consider logging "origin retired, banner retained" in that branch.
Everything else I checked holds up: mergeFailureAlertID lower-cases/trims the repo (:187) so the sink ID computed from repoKey on clear matches the one used on raise; the dashboard sink only takes its own systemAlertsMu (dashboard/server.go:2833-2862) so calling it under mergeAlertMu cannot deadlock; the appID-0 ("any producer") semantics in missingMergeChecksResolved match nativeObservationRequired (native_queue_observation.go:207-250); pagination and the final head/base re-read fail closed.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. @clubanderson this PR is held at Failing checks:
Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path. hive/awaiting-ci: the only red check here, 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 Review findings from Style review (head ddded7e) — no blockers; two maintainability notes with fixes the author can apply. 1. Positional variadic -func (c *Client) raiseMergeFailureAlert(repo string, number int, errMsg string, provenance ...string) {
+// head is the refused PR head; requestedMethod is the merge method the request asked for ("" if unknown).
+func (c *Client) raiseMergeFailureAlert(repo string, number int, errMsg, head, requestedMethod string) {
...
- entry := &mergeAlertEntry{key: alert.key, number: number}
- if len(provenance) > 0 {
- entry.head = provenance[0]
- }
+ entry := &mergeAlertEntry{key: alert.key, number: number, head: head}
if alert.key == "merge-method" {
- var requested string
- if len(provenance) > 1 {
- requested = provenance[1]
- }
- entry.method = mergeFailureMethod(errMsg, requested)
+ entry.method = mergeFailureMethod(errMsg, requestedMethod)
}2. Two near-identical bounded pagination loops — // nextEvidencePage reports whether another page should be fetched; ok=false
// means the evidence is incomplete and the alert must be retained.
func nextEvidencePage(resp *gh.Response, page, cur int, total, got int) (next int, more, ok bool) {
if resp == nil || resp.NextPage == 0 {
return 0, false, total == got
}
if page+1 >= mergeAlertEvidenceMaxPages || resp.NextPage <= cur {
return 0, false, false
}
return resp.NextPage, true, true
}Minor: Review findings from Intent alignment (head ddded7e): the per-PR origin tracking, same-key banner retention and token-replacement semantics match #16030, and the unrelated-merge blanket clear is gone ( Missing-check revalidation uses a stricter required-check source than the gate that raised the alert, so the #16014-type banner may never retire
Suggested remediation: when the classic read is forbidden, derive the required set from the same chain the gate used, treating those contexts as producer-agnostic ( --- a/src/pkg/github/merge_failure_alert_checks.go
+++ b/src/pkg/github/merge_failure_alert_checks.go
@@
required, known := c.nativeObservationRequired(ctx, owner, repo, base)
if !known {
- // In particular, a denied protection read cannot establish that an
- // identically named check from another App satisfies this blocker.
- return false
+ // The CI gate that raised this alert falls back to the branch and
+ // rules endpoints when classic protection is forbidden; use the same
+ // sources (producer-agnostic) so the banner can actually retire.
+ if byName, ok, err := requiredStatusChecksFromBranchEndpoint(ctx, c.client, owner, repo, base); err == nil && ok {
+ required = make(map[string]int64, len(byName))
+ for name := range byName {
+ required[name] = 0
+ }
+ } else if byName, ok, err := requiredStatusChecksFromRulesEndpoint(ctx, c.client, owner, repo, base); err == nil && ok {
+ required = make(map[string]int64, len(byName))
+ for name := range byName {
+ required[name] = 0
+ }
+ } else {
+ return false
+ }
}and flip the |
|
CI triage — 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
|
CI triage follow-up: the 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
|
Acting on the current-head review, not awaiting an owner decision:
Adding direct regressions for these distinctions. This is a real, tightly coupled source correction, not an empty/new unrelated CI-trigger commit. The current gosec FAILURE annotation is verified directly on job124537436566: the self-hosted runner lost communication. It demonstrates no code finding and does not prove the underlying pool/OOM mechanism. No workflow rerun or infrastructure/configuration change performed. The corrected immutable head still requires actual terminal CI before guarded source merge. |
Signed-off-by: Andy Anderson <andy@clubanderson.com>
Signed-off-by: Andy Anderson <andy@clubanderson.com>
|
Review correction pushed, DCO intact: 228f532 preserves proven repository permission/method resolution, adds positive allow-method revalidation and scope regressions, and makes retained-banner logging explicit. Duplicate watcher clear calls were removed: the common audit path knows the actual effective merge method, including top-up upgrades, so the requested method cannot incorrectly retire another method blocker. One deliberate fresh-base sync followed, without conflicts: base 6fc5147. Final candidate head is ddded7e. No amendment, force push, empty commit, CI rerun or pool/config/protection change. The previous head 1151972 had 63 successes, 15 scope-skips and one real gosec runner-communication failure, not a terminal-green verdict. It will not be used for source merge. Fresh CI on the actual corrected immutable head is required; no gates are bypassed by the alert observer. |
There was a problem hiding this comment.
Correctness re-review @ ddded7e — delta since 1151972 is a v5 rebase plus the reworked alert bookkeeping. Prior correctness findings are fixed: client.go:4701 repo-level keys (app-permission, same-method merge-method) now clear on any App merge (merge_failure_alert.go:98-104) and merge-method additionally retires on a positive repo-settings read (merge_failure_alert.go:161-173); the retained-banner log now says origin retired with banner_retained (merge_failure_alert.go:198-202). Lock ordering is safe: sink calls now run under mergeAlertMu, and the dashboard sink is a leaf lock (dashboard/server.go:2835-2861). Watcher merges still clear via MergePR → RecordPRMergedAudit (pullrequest.go:509), so dropping the explicit watcher clears is behavior-preserving.
One advisory, unverified open question (does not block):
missingMergeChecksResolvedreturns early unlessnativeObservationRequiredreportsknown(merge_failure_alert_checks.go:20-25), and that helper setsknown = err == nilon the classicGetRequiredStatusChecksread (native_queue_observation.go:209-210) with no 404 special-case. On a branch protected only by rulesets, classic returns 404 "Branch not protected", so a missing-check banner would never retire via this path (only on PR close/merge). Ifhivecommons/hivev5is ruleset-only, the motivating #16014 banner would still not retire. I could not read the branch protection with my token — please confirmv5has classic protection, or treat a 404 classic read as "no classic contexts" when at least the rules read succeeds. That change touches the shared native-queue helper, so it may be better as a follow-up.
— hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Verified source-only completionMerged under explicit owner authorization by clubanderson at 2026-10-31T14:49:58Z using admin squash guarded by --match-head-commit ddded7e.
Actual review findings were repaired, with same-head correctness re-review confirming them fixed. The nonblocking ruleset-only question was answered by a current read-only GraphQL proof: v5 has a classic branchProtectionRule with all 11 required contexts, including changelog-fragment-guard. Unknown/unreadable producer metadata remains conservative, not falsely cleared. Root cause addressed: stale missing-check alerts had no open-PR resolution path; repo/reason aggregation retained only the last PR, and unrelated merges could clear head-specific blockers. The source now retains per-origin heads/tokens, verifies successful current-head evidence plus required producer and complete bounded pagination, rechecks head/base, and retires only proven resolved origins. It preserves real repository permission/same-method resolution, safely revalidates enabled merge methods and distinguishes retained aggregate banners in logs. Owned clean worktree and local feature branch removed; remote feature branch was already auto-deleted, verified absent. Fresh origin/v5 contains the squash. Shared checkout files untouched. No local test/build/vet/lint/docs guards, empty commits, manual CI reruns, protection/review/hold/authorization changes, App-permission widening, runtime configuration, native activation or production rollout. Source completion is not a claim that the live banner has already disappeared. |
Root cause
A real merge refusal for #16014 named a missing required guard. That guard later succeeded on its current head, but alert revalidation only handled closed PRs, approval-held runs and permission reads. Aggregate repo/reason bookkeeping also overwrote the originating PR and unrelated merges blanket-cleared all repository blockers.
Change
Validation
CI is the sole verdict per AGENTS; no local suites/build/vet/lint/docs guards were run. Gofmt and patch whitespace inspection only. Added lifecycle/producer/provenance/pagination/error/head-change/concurrent-refusal/multi-PR regressions, including unchanged closed-PR resolution.
Source only: no deployment, runtime configuration, branch-protection or App permission changes.
Closes #16030