From 1e4d274eb91b7a37b2cb796dbbdfe4e2cf2ed177 Mon Sep 17 00:00:00 2001 From: Danathar <6772335+Danathar@users.noreply.github.com> Date: Wed, 18 Nov 2026 06:42:29 -0500 Subject: [PATCH] fix(automerge): let the stale-red base refresh update 072 PRs The stale-red base refresh merges the base into a red PR only when every failing check is green on the base tip, so the red it clears is the base's. It still skipped PRs at stage/072-returned-to-contributor on the assumption that the contributor's hive pushes there, but nothing asks the contributor to merge the base: projectbluefin/actions#765 and #766 stayed red at 072 for ten hours after main fixed their checks in #768 (both green on the base tip all night), until a person pressed "Update branch". The 072 skip is lifted for the stale-red refresh only; the missing-check refresh keeps it. The update stays pinned to the evaluated head, so a push from the contributor wins. Signed-off-by: Danathar <6772335+Danathar@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 --- changelog.d/fixed-stale-red-refresh-072.md | 1 + src/cmd/hive/stale_red_base_refresh.go | 24 +++++++++++++++---- src/cmd/hive/stale_red_base_refresh_test.go | 4 +++- .../sweeps-and-operations.md | 12 +++++++--- 4 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 changelog.d/fixed-stale-red-refresh-072.md diff --git a/changelog.d/fixed-stale-red-refresh-072.md b/changelog.d/fixed-stale-red-refresh-072.md new file mode 100644 index 0000000000..ab1871c629 --- /dev/null +++ b/changelog.d/fixed-stale-red-refresh-072.md @@ -0,0 +1 @@ +- The stale-red base refresh now updates a red PR at `stage/072-returned-to-contributor` when its base has since fixed every failing check. The 072 skip assumed the contributor's hive would merge the base, but nothing asks it to, so such a PR (projectbluefin/actions#765, #766) stayed red until a person pressed "Update branch". The update is pinned to the evaluated head, so a contributor's push wins. diff --git a/src/cmd/hive/stale_red_base_refresh.go b/src/cmd/hive/stale_red_base_refresh.go index 80ecdbd392..39f3d12620 100644 --- a/src/cmd/hive/stale_red_base_refresh.go +++ b/src/cmd/hive/stale_red_base_refresh.go @@ -58,8 +58,10 @@ var staleRedRefresh = &staleRedRefreshState{} // It leaves alone a PR that is a draft, held or exempt, still running CI, // deferred to an open shared-CI incident, red on the base as well, a fork // with "allow edits by maintainers" off, a dependency bot's branch (the bot -// rebases it), returned to its contributor (072, whose hive pushes there) -// or adopted by the hive (074, whose recovery owns it). Each update goes +// rebases it) or adopted by the hive (074, whose recovery owns it). A PR +// returned to its contributor (072) is a candidate: the red is the base's, +// not the contributor's, and nobody tells the contributor to merge the base +// (see staleRedRefreshSkip). Each update goes // through the write-back gate (base_refresh). It runs at most every // staleRedRefreshInterval and makes at most staleRedRefreshMaxPerRepo // updates per repository and staleRedRefreshMaxPerPass in all. @@ -172,6 +174,16 @@ func refreshStaleRedBehindPRs( // "" when it is: an open, non-draft PR whose settled CI is red on named // checks that are not red on the base, with nothing that owns its branch // sync elsewhere. +// +// Unlike the missing-check refresh it does not skip a PR at 072. The pass +// only updates a PR whose every failing check is green on the base tip, so +// the red it clears is the base's: the 072 nudge asked the contributor to +// fix a check the base has since fixed, and a person, or a relay hive that +// is offline, never merges the base for that. projectbluefin/actions#765 +// and #766 sat at 072 for ten hours after main fixed `Audit GitHub Actions` +// and `pytest` in #768, both green on the base tip all night, until a person +// pressed "Update branch". The update is pinned to the evaluated head, so a +// push from the contributor wins (head-moved) and is never merged over. func staleRedRefreshSkip(pr github.PullRequest) string { switch { case pr.Draft: @@ -187,7 +199,10 @@ func staleRedRefreshSkip(pr github.PullRequest) string { case len(pr.BaseRedChecks) > 0: return "base-red" } - return baseRefreshBranchOwnerSkip(pr) + if skip := baseRefreshBranchOwnerSkip(pr); skip != "returned-to-contributor" { + return skip + } + return "" } // baseRefreshBranchOwnerSkip names why the hive must not update pr's branch @@ -195,7 +210,8 @@ func staleRedRefreshSkip(pr github.PullRequest) string { // fork's with "allow edits by maintainers" off, or something else owns the // branch sync (a dependency bot rebases its own branch, 072's contributor // hive pushes there, 074's adoption recovery owns it). The stale-red and the -// missing-check base refresh share it. +// missing-check base refresh share it; the stale-red refresh lets 072 +// through (staleRedRefreshSkip). func baseRefreshBranchOwnerSkip(pr github.PullRequest) string { switch { case strings.TrimSpace(pr.HeadSHA) == "" || strings.TrimSpace(pr.BaseRef) == "": diff --git a/src/cmd/hive/stale_red_base_refresh_test.go b/src/cmd/hive/stale_red_base_refresh_test.go index 1149b73576..d38f059835 100644 --- a/src/cmd/hive/stale_red_base_refresh_test.go +++ b/src/cmd/hive/stale_red_base_refresh_test.go @@ -182,9 +182,11 @@ func TestStaleRedRefreshSkip(t *testing.T) { {"no base ref", func(p *github.PullRequest) { p.BaseRef = "" }, "head-or-base-unknown"}, {"fork without maintainer edits", func(p *github.PullRequest) { p.MaintainerCanModify = false }, "fork-not-editable"}, {"dependency bot branch", func(p *github.PullRequest) { p.HeadRef = "renovate/actions"; p.Author = "app/mergeraptor" }, "dependency-bot-branch"}, + // The base cleared the red, so a 072 PR is a candidate + // (projectbluefin/actions#765). {"returned to contributor", func(p *github.PullRequest) { p.Labels = append(p.Labels, stagelabels.ReturnedToContributor.Label()) - }, "returned-to-contributor"}, + }, ""}, {"adopted by the hive", func(p *github.PullRequest) { p.Labels = append(p.Labels, stagelabels.AdoptedByHive.Label()) }, "adopted-by-hive"}, } for _, tc := range cases { diff --git a/src/docs/operator-reference/sweeps-and-operations.md b/src/docs/operator-reference/sweeps-and-operations.md index 81c5a88e47..34017c086b 100644 --- a/src/docs/operator-reference/sweeps-and-operations.md +++ b/src/docs/operator-reference/sweeps-and-operations.md @@ -403,11 +403,17 @@ in repositories with auto-merge off: - It merges the base in with `update-branch`, pinned to the evaluated head (the same merge commit the "Update branch" button makes). It posts nothing. - It skips drafts, held and exempt PRs, fork PRs with "allow edits by - maintainers" off, dependency-bot branches (the bot rebases them), PRs at - `stage/072-returned-to-contributor` (the author's hive pushes there) and at + maintainers" off, dependency-bot branches (the bot rebases them) and PRs at `stage/074-adopted-by-hive` (the adoption recovery owns them). Repositories in `auto_merge.require_current_base` are left to the automerge preparation front. +- PRs at `stage/072-returned-to-contributor` are candidates. The update only + happens when the base fixed every failing check, so the red is the base's, + and the 072 nudge asked the contributor to fix something nobody tells them + to merge in: projectbluefin/actions#765 and #766 stayed red at 072 for ten + hours after main fixed their checks, until a person pressed "Update + branch". The update is pinned to the evaluated head, so a push from the + contributor (or their hive) wins. - Each update goes through the write-back gate as `base_refresh`: allowed on hive-authored PRs, and on other PRs at L6 with the opt-in label by default. `writeback.kinds.base_refresh.unlabeled_min_level: 6` lets it reach every @@ -636,7 +642,7 @@ that level, the power the write-back exists to govern? | Shared-CI tracking issues (`shared_ci_issues.go`) | 15-min sweep (`shared_ci_issues`) | **new** `[shared-ci] failing across ` issue, body edits of its own issue | repos where one check fails on `shared_ci_issues.min_prs`+ open PRs or trips the red-main breaker | `issue_file` → L3, no label (own items) | | Shared-CI rerun (`shared_ci_rerun.go`) | CI failure watcher | `rerun-failed-jobs`, `hive-shared-ci-rerun-` comment | PRs with failed shared workflows | `ci_rerun` → L6 + label | | Transient-CI rerun (`transient_ci_rerun.go`) | eval cycle, before the stuck-PR reaper | `rerun-failed-jobs`, once per head, no comment | hive-authored and `auto_merge.trusted_bot_authors` red PRs whose every failing run carries `hive-ci-transient` | `ci_rerun` (own items: allowed unless the repo is paused, off or issues-only; trusted-bot PRs: L6 + label, or `writeback.kinds.ci_rerun.unlabeled_min_level`; a refused re-run hands the bot PR to a person with the reason) | -| Stale-red base refresh (`cmd/hive/stale_red_base_refresh.go`, `pkg/github/stale_red_base_refresh.go`) | eval cycle, before the stuck-PR reaper, at most every 5 min | **branch push** (`update-branch` merge of the base), once per head and base tip, no comment | red PRs behind their base whose every failing check is green on the base tip; not drafts, held, non-editable forks, dependency-bot branches, 072 or 074 | `base_refresh` → hive-authored PRs, else L6 + label | +| Stale-red base refresh (`cmd/hive/stale_red_base_refresh.go`, `pkg/github/stale_red_base_refresh.go`) | eval cycle, before the stuck-PR reaper, at most every 5 min | **branch push** (`update-branch` merge of the base), once per head and base tip, no comment | red PRs behind their base whose every failing check is green on the base tip, 072 included; not drafts, held, non-editable forks, dependency-bot branches or 074 | `base_refresh` → hive-authored PRs, else L6 + label | | Missing-check base refresh (`cmd/hive/missing_check_base_refresh.go`, `pkg/github/missing_check_base_refresh.go`) | eval cycle, after the stale-red base refresh, at most every 5 min | **branch push** (`update-branch` merge of the base), once per head and base tip and once per missing check, no comment | PRs behind their base, otherwise green, whose head has no run at all for a required check that runs on the base tip or another open PR; not drafts, held, parked, non-editable forks, dependency-bot branches, 072 or 074 | `base_refresh` → hive-authored PRs, else L6 + label | | Dependency-bot rebase request (`cmd/hive/dependency_bot_rebase_request.go`, `pkg/github/dependency_bot_rebase.go`) | governor eval, in the dependency-bot hand-off sweep | ticks Renovate's rebase/retry checkbox (only that line of the PR description changes); once per head, no other comment. Never asks Dependabot, which refuses commands from apps: a stranded Dependabot PR is handed to a person at once | dependency-bot PRs behind or conflicting with their base past `governor.dependency_bot_rebase_after_s` (4h) whose bot stopped rebasing them; never a branch carrying someone else's non-merge commit | `bot_rebase_request` → L6 + label; refused: the PR is handed to a person instead (see [README](README.md)) | | Dependency-bot adoption request (`cmd/hive/dependency_bot_adopt.go`) | governor eval, in the dependency-bot hand-off sweep, where the red-CI hand-off would fire; only with `auto_merge.dependency_bot_adopt.enabled` (default off) | `adoption/supersede` label (the dashboard Adopt decision's label); once per head, no comment | red dependency-bot PRs by a `trusted_bot_authors` bot whose head the review swarm marked `changes_requested`; never held, human-merge-labelled or `human_merge_paths` PRs, or with stage adoption off | `contributor_adopt` → L6 + label; refused: the PR gets the usual person hand-off |