Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-stale-red-refresh-072.md
Original file line number Diff line number Diff line change
@@ -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.
24 changes: 20 additions & 4 deletions src/cmd/hive/stale_red_base_refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand All @@ -187,15 +199,19 @@ 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
// itself, or "" when it may: the head or base is unknown, the branch is a
// 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) == "":
Expand Down
4 changes: 3 additions & 1 deletion src/cmd/hive/stale_red_base_refresh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 9 additions & 3 deletions src/docs/operator-reference/sweeps-and-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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] <check> failing across <owner/repo>` 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-<n>` 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 |
Expand Down
Loading