Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7f1189f
🐛 reviewer: park fixer-exhausted hive PRs at 085 needs-decision
clubanderson Oct 30, 2026
2e768b7
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
45148a1
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
336e089
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
2d94bd7
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
56bbf8f
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
e7eb2fa
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
276fa9d
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
6b35e96
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
cc0e3bf
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
8962179
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
d6ff168
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
3250c14
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
1fa32d4
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
5901b31
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
874da5e
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
05a0f81
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
cb4d833
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
5fa0cda
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
a0c0118
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
c57e82f
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
7095517
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
1ee0b0f
Merge branch 'v5' into fix/fixer-exhausted-stage
hivecommons-hive[bot] Oct 30, 2026
604fb38
test(stagelabels): cover fixer-exhausted reason, route and decision c…
clubanderson Oct 30, 2026
b8265b2
Merge remote-tracking branch 'origin/v5' into fix/fixer-exhausted-stage
clubanderson Oct 30, 2026
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-15744-fixer-exhausted-needs-decision.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Hive-authored PRs whose review fix dispatch is refused with `fix-attempts-exhausted` now move from `stage/070-fixing` to `stage/085-needs-decision` (reason `fixer-exhausted:<N>`) with a `fixer gave up after N attempts — <reviewer finding>` caption, a once-per-head decision comment and **Re-author** as the tracker's lead action; a 070 row no longer claims `Fixing · @bot` while no fix job is dispatched, a stale answered decision no longer clears `stage/stalled` while the fixer is excluded and the head is unchanged, and the `review fix dispatch excluded` warning is logged once per PR head instead of every cycle ([#15744](https://github.com/hivecommons/hive/issues/15744)).
1 change: 1 addition & 0 deletions src/cmd/hive/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2202,6 +2202,7 @@ func (b *boot) bootAgentsWith(deps bootAgentsDeps) {
}
return automerge.RebaseEpisode{Attempt: a.Count(), MaxAttempts: rebasemerge.MaxRebaseAttempts, Exhausted: a.Exhausted(), RequestedBy: a.RequestedBy}, true
}
autoMergeOpts.FixDispatchStatus = fixDispatchStatusReader()
autoMergeOpts.MergeTrain = func() automerge.MergeTrainPolicy {
if b.cfg == nil {
return automerge.DefaultMergeTrainPolicy
Expand Down
48 changes: 45 additions & 3 deletions src/cmd/hive/main_sweeps.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package main

import (
Expand Down Expand Up @@ -2832,12 +2832,19 @@
func auditWithheldReviewFixes(plan review.DispatchPlan, auditor reviewFixAuditor, logger *slog.Logger) {
// One WARN per changes_requested head that ends the cycle without a fix
// kick: a PR shown as "Fixing" that nobody is fixing must be loud
// (hivecommons/hive#14665).
// (hivecommons/hive#14665) — once per (pr, head, reason), Debug while
// the same exclusion persists (hivecommons/hive#15744).
active := make(map[string]struct{}, len(plan.FixExclusions))
defer func() { reviewFixExcludedWarn.retain(active) }()
for _, x := range plan.FixExclusions {
level := slog.LevelWarn
key := reviewFixExcludedWarnKey(x)
active[key] = struct{}{}
level := reviewFixExcludedWarn.level(key)
if x.Reason == review.FixDispatchExcludedNotHiveAuthored || x.Reason == review.FixDispatchExcludedNotHiveAuthoredDCO {
// Policy skip (the hive never pushes to PRs it did not author), not a fault.
level = slog.LevelInfo
if level == slog.LevelWarn {
level = slog.LevelInfo
}
}
logger.Log(context.Background(), level, "review fix dispatch excluded",
"repo", x.Repo, "pr", x.Number, "head_sha", x.HeadSHA, "author", x.Author, "reason", x.Reason, "attempts", x.Attempts)
Expand All @@ -2853,6 +2860,41 @@
}
}

func reviewFixExcludedWarnKey(x review.FixDispatchExclusion) string {
return prWarnKey(x.Repo, x.Number) + "@" + strings.ToLower(strings.TrimSpace(x.HeadSHA)) + ":" + x.Reason
}

// fixDispatchStatusReader is the automerge engine's view of the review
// fixer's standing on a PR head (hivecommons/hive#15744): the persisted
// dispatch state, re-read per call so a stage pass sees the fixer's latest
// verdict. No state (fresh hive, unreadable file) reads as unknown.
func fixDispatchStatusReader() func(repo string, number int, head string) (review.FixDispatchStatus, bool) {
var (
mu sync.Mutex
state review.DispatchState
modTime time.Time
size int64
loaded bool
)
return func(repo string, number int, head string) (review.FixDispatchStatus, bool) {
mu.Lock()
defer mu.Unlock()
// A stage pass asks once per PR; re-parse only when the file moved.
if fi, err := os.Stat(review.ReviewDispatchStatePath); err == nil && loaded && fi.ModTime().Equal(modTime) && fi.Size() == size {
return review.FixDispatchStatusFor(state, repo, number, head), true
} else if err == nil {
modTime, size = fi.ModTime(), fi.Size()
}
st, err := review.LoadDispatchState("")
if err != nil {
loaded = false
return review.FixDispatchStatus{}, false
}
state, loaded = st, true
return review.FixDispatchStatusFor(state, repo, number, head), true
}
}

// reviewMissingHeads reads the review heads that ran out of retries while
// another head answered (hivecommons/hive#13542), so their perspectives count
// as settled for the decision step. No state is none.
Expand Down
62 changes: 62 additions & 0 deletions src/cmd/hive/review_fix_withheld_audit_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package main

import (
"context"
"io"
"log/slog"
"slices"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -82,3 +84,63 @@ func TestAuditWithheldReviewFixesNotHiveAuthoredExclusionIsNotWarn(t *testing.T)
t.Fatalf("not-hive-authored exclusion must log below WARN, got: %s", out)
}
}

type levelRecorder struct {
levels []slog.Level
}

func (r *levelRecorder) Enabled(context.Context, slog.Level) bool { return true }
func (r *levelRecorder) Handle(_ context.Context, rec slog.Record) error {
if rec.Message == "review fix dispatch excluded" {
r.levels = append(r.levels, rec.Level)
}
return nil
}
func (r *levelRecorder) WithAttrs([]slog.Attr) slog.Handler { return r }
func (r *levelRecorder) WithGroup(string) slog.Handler { return r }

// TestAuditWithheldReviewFixesWarnsOncePerHead: the dispatcher re-derives
// its exclusions every cycle, so the same fix-attempts-exhausted line
// fired every ~5 min for 13h on #15308 (hivecommons/hive#15744). WARN
// once per (pr, head, reason); Debug while it persists; WARN again on a
// new head or after the exclusion cleared and came back.
func TestAuditWithheldReviewFixesWarnsOncePerHead(t *testing.T) {
reviewFixExcludedWarn = prWarnOnce{}
t.Cleanup(func() { reviewFixExcludedWarn = prWarnOnce{} })
rec := &levelRecorder{}
logger := slog.New(rec)
exhausted := review.FixDispatchExclusion{Repo: "hivecommons/hive", Number: 15308, HeadSHA: "5b62304", Author: "hivecommons-hive[bot]", Reason: review.FixDispatchExcludedAttemptsExhausted, Attempts: 6}
plan := review.DispatchPlan{FixExclusions: []review.FixDispatchExclusion{exhausted}}

auditWithheldReviewFixes(plan, nil, logger)
auditWithheldReviewFixes(plan, nil, logger)
auditWithheldReviewFixes(plan, nil, logger)
if want := []slog.Level{slog.LevelWarn, slog.LevelDebug, slog.LevelDebug}; !slices.Equal(rec.levels, want) {
t.Fatalf("levels across three cycles = %v, want %v", rec.levels, want)
}

moved := exhausted
moved.HeadSHA = "9f0e1d2"
rec.levels = nil
auditWithheldReviewFixes(review.DispatchPlan{FixExclusions: []review.FixDispatchExclusion{moved}}, nil, logger)
if want := []slog.Level{slog.LevelWarn}; !slices.Equal(rec.levels, want) {
t.Fatalf("new head levels = %v, want %v", rec.levels, want)
}

// Cleared for a cycle, then back: the old key was retained away.
rec.levels = nil
auditWithheldReviewFixes(review.DispatchPlan{}, nil, logger)
auditWithheldReviewFixes(plan, nil, logger)
if want := []slog.Level{slog.LevelWarn}; !slices.Equal(rec.levels, want) {
t.Fatalf("recurrence levels = %v, want %v", rec.levels, want)
}

// Policy skips stay Info the first time, Debug after.
rec.levels = nil
policy := review.DispatchPlan{FixExclusions: []review.FixDispatchExclusion{{Repo: "acme/x", Number: 1, HeadSHA: "a", Reason: review.FixDispatchExcludedNotHiveAuthored}}}
auditWithheldReviewFixes(policy, nil, logger)
auditWithheldReviewFixes(policy, nil, logger)
if want := []slog.Level{slog.LevelInfo, slog.LevelDebug}; !slices.Equal(rec.levels, want) {
t.Fatalf("policy skip levels = %v, want %v", rec.levels, want)
}
}
5 changes: 5 additions & 0 deletions src/cmd/hive/warn_once_pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@ var (
humanLabelWarn prWarnOnce
reviewExpiredWarn prWarnOnce
reviewPromotedWarn prWarnOnce
// reviewFixExcludedWarn keys on (repo, pr, head, reason): the fix
// dispatcher re-derives its exclusions every cycle, so without it the
// same "fix-attempts-exhausted" line fired every ~5 min for 13h on
// hive's own #15308 (hivecommons/hive#15744).
reviewFixExcludedWarn prWarnOnce
)
6 changes: 5 additions & 1 deletion src/docs/hive-merge.md
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,11 @@ human-authored PR → `stage/071-needs-author`, on a clanker PR →
review or `/hive decision <text>` on a hive-authored PR's current head →
`stage/070-fixing` with reason `human-changes-requested` and one fix kick
carrying the text ([#13041](https://github.com/hivecommons/hive/issues/13041)),
hold / sentinel alert → `stage/085-needs-decision`, untrusted author with an approve verdict at the
hold / sentinel alert → `stage/085-needs-decision`, hive-authored PR whose fix
dispatch is refused with `fix-attempts-exhausted` → `stage/085-needs-decision`
with reason `fixer-exhausted:<N>` and a once-per-head decision comment (re-author /
hand to a person / close as not planned; a stale `decision-answered` cannot pull it
back to 070 while the head is unchanged, [#15744](https://github.com/hivecommons/hive/issues/15744)), untrusted author with an approve verdict at the
current head, green checks, DCO and soak done →
`stage/090-ready-for-human-merge` (only a maintainer's `/lgtm` `/approve` is
missing; the dashboard derives a compact **human-merge reason code** from the
Expand Down
7 changes: 7 additions & 0 deletions src/docs/review-swarm.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,13 @@ The PR review queue (`GET /api/review/queue`) shows this state on unreviewed ite

When an aggregate verdict is `changes_requested`, Hive builds a review-fix kick containing the aggregate findings and sends it to `review.fixer_agent`, the classified PR lane, or `scanner`. Fix dispatches are capped by `escalation.MaxReEngagements`; once exhausted, dispatch state records a `requires_human` hold for the PR head so the automated loop stops.

Once that cap is hit the hive is no longer fixing the PR, and the stage must say so ([#15744](https://github.com/hivecommons/hive/issues/15744)):

- The stage engine moves a hive-authored PR the dispatcher refuses with `fix-attempts-exhausted` from `stage/070-fixing` to `stage/085-needs-decision` with reason `fixer-exhausted:<N>`. The tracker captions it `fixer gave up after N attempts — <first line of the reviewer's last finding>`, and the lead action is **Re-author** (`decide:re-author`); *Hand it to a person* (`/hive decision <text>`) and *Close as not planned* sit in the Decide… submenu. One decision comment per head lists the same three options; it goes through the normal write-back gate.
- A `070-fixing` row never claims `Fixing · @bot` when no fix job is dispatched or running. If the dispatcher excludes the head (attempts exhausted, no enabled fixer, budget), the caption reads `Fixing paused — <why>; no fix job is dispatched` (plus `conflicting with the base branch` when the PR is dirty) and the stage actor is *nobody*.
- A stale answered decision (`decision-answered`) does not clear `stage/stalled` or move the PR back to 070 while the fixer is excluded and the head has not changed; the 085 park is preserved.
- The `review fix dispatch excluded … reason=fix-attempts-exhausted` WARN is logged once per (PR, head, reason); later cycles log it at debug.

### Who may be pushed to: `all_authors` and the retired `fix_human_prs` push

A review-fix kick tells the fixer agent to check out the PR branch and push a commit to it. That is fine on a PR one of the hive's own agents opened; on a contributor's fork (reachable through GitHub's "allow edits by maintainers") or a maintainer's branch it is a bot rewriting someone else's work before any person has looked at it. Reviewing and pushing are therefore separate:
Expand Down
4 changes: 4 additions & 0 deletions src/pkg/dashboard/stage_tracker_build.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dashboard

import (
Expand Down Expand Up @@ -437,8 +437,12 @@
it.Caption = joinClause(it.Caption, clause)
}
}
if n, ok := stageTrackerFixerExhaustedAttempts(it.Reason); ok && it.Stage == trackerNumberNeedsDecision {
it.Caption, it.Actor = stageTrackerFixerExhaustedCaption(n, stageTrackerFixerExhaustedSummary(agg)), "maintainer"
}
it.DecisionNeeded = stageTrackerDecisionNeededWith(it, agg, sentinelLabel, now, bctx)
it.StageActor = stageTrackerStageActor(it, workers, now)
stageTrackerApplyFixerStatus(&it, review.FixDispatchStatusFor(dispatchState, qualifyRepo(repoName), pr.Number, pr.HeadSHA), workers)
if stageTrackerClaimantStage(it.Kind, it.Stage) {
var worker *stageTrackerWorker
if w, ok := stageTrackerWorkerOn(workers, repoName, pr.Number); ok {
Expand Down
59 changes: 59 additions & 0 deletions src/pkg/dashboard/stage_tracker_decision_pr.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dashboard

import (
Expand Down Expand Up @@ -38,6 +38,9 @@
// supersedes) after the fixer's two rebase-resolve attempts failed.
rebaseFailedTwice := lower == stagelabels.LaneReasonRebaseFailedTwice || (adoptionStalled && adoptionLane == stagelabels.LaneReasonRebaseFailedTwice)
reviewerDeferred := lower == stageengine.StageReasonVerdictRequiresHuman || lower == stageengine.StageReasonDecisionRequested
// hivecommons/hive#15744: the hive's own PR after its fixer spent the
// re-engagement cap; nobody is fixing it any more.
fixerAttempts, fixerExhausted := stagelabels.ParseFixerExhausted(base)
hiveSupersederStop := stagelabels.HiveSupersederHardStopReason(base)

// WHAT it is waiting on: the question, most specific source first. A
Expand Down Expand Up @@ -82,6 +85,13 @@
}
d.Blocker = "The hive set `hold` on its own: " + decisionHoldReason(selfHold) + ". It does nothing more until the hold is released."
d.BlockerReason = decisionBlockerHoldHive
case fixerExhausted:
d.AskedBy = decisionAskedByReviewer
d.Question = "The hive's fixer gave up on this PR after " + strconv.Itoa(fixerAttempts) + " attempts"
if finding := decisionFixerExhaustedFinding(it, verdict); finding != "" {
d.Question += ": " + finding
}
d.Question += ". Re-author it from scratch, hand it to a person, or close it as not planned?"
case verdict != nil && decisionFirstNonEmpty(verdict.HumanSummaries) != "":
d.AskedBy = decisionAskedByReviewer
d.Question = "A reviewer handed this to a person: " + decisionFirstNonEmpty(verdict.HumanSummaries)
Expand Down Expand Up @@ -141,6 +151,9 @@
d.Blocker = "The hive never merges this by itself. After approval, a maintainer merges."
case forkGuarded:
d.Blocker = "Neither the author nor the hive can make CI run for this fork PR."
case fixerExhausted:
d.Blocker = "The fix dispatcher refuses another fix for this head (" + strconv.Itoa(fixerAttempts) + " attempts spent). No agent is on it until a person decides."
approveOK, approveWhy = false, "The head still carries the reviewer's unresolved findings; approving does not fix them."
case reviewerDeferred:
d.Blocker = "The hive will not merge until a person decides."
if verdict != nil && strings.TrimSpace(verdict.DecisionFinding) != "" {
Expand Down Expand Up @@ -176,6 +189,9 @@
// for merge-now (rebaseMergeFailureOptions).
d.Options = slices.Insert(d.Options, 0, decisionOption(decisionActionAdopt, rebasemerge.OptionAdoptFreshLabel, true, ""))
}
if fixerExhausted {
d.Options = decisionLeadWithReauthor(d.Options)
}
if selfHold != nil {
// Release leads: it is the one action that answers the question.
d.Options = append([]StageTrackerDecisionOption{decisionHoldOption(true)}, d.Options[:len(d.Options)-1]...)
Expand Down Expand Up @@ -207,6 +223,49 @@
return out
}

// decisionLeadWithReauthor puts "Re-author" at the front of opts (the lead
// action for a fixer-exhausted PR, hivecommons/hive#15744) and relabels the
// won't-fix close as "Close as not planned" so it stays in the Decide…
// submenu rather than leading a destructive answer.
func decisionLeadWithReauthor(opts []StageTrackerDecisionOption) []StageTrackerDecisionOption {
lead := decisionOption(decisionActionReauthor, "Re-author", true, "")
lead.Consequence = "The hive opens a fresh PR for the same issue from the current base and closes this one as superseded."
lead.Lead = true
out := make([]StageTrackerDecisionOption, 0, len(opts)+1)
out = append(out, lead)
for _, o := range opts {
switch o.Action {
case decisionActionReauthor:
continue
case decisionActionCloseWontfix:
o.Label = "Close as not planned"
o.Consequence = "Closes this PR as not planned; the issue stays open for someone else."
case decisionActionDirection:
o.Consequence = "Hands the PR to a person: say who takes it or what to change; the hive steps back."
}
out = append(out, o)
}
return out
}

// decisionFixerExhaustedFinding is the reviewer's last finding in one line
// for the fixer-exhausted question: the verdict's human summary or
// question, else the caption's dash clause.
func decisionFixerExhaustedFinding(it StageTrackerItem, verdict *review.Aggregate) string {
if verdict != nil {
if s := decisionFirstNonEmpty(verdict.HumanSummaries); s != "" {
return stageTrackerFirstLine(s)
}
if q := strings.TrimSpace(verdict.DecisionQuestion); q != "" {
return stageTrackerFirstLine(q)
}
}
if _, after, ok := strings.Cut(it.Caption, " — "); ok {
return strings.TrimSpace(after)
}
return ""
}

// decisionHoldReason is the hold's plain-words reason for the popover.
func decisionHoldReason(h *StageTrackerHold) string {
if h != nil {
Expand Down
Loading
Loading