From b34f870aa4678fd7a6850717360e6af58c508c5f Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Wed, 4 Nov 2026 19:24:39 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20review:=20superseding=20PR=20wit?= =?UTF-8?q?h=20unanimous=20sign-off=20requires=5Fhuman=20parks=20for=20a?= =?UTF-8?q?=20decision,=20not=20the=20fixer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A hive-superseding PR whose every reviewer perspective returned requires_human as a pure approver question (decision requested, no finding above info) was routed to the fixer by the superseder rule. The fixer had nothing to push, the cycle hit its cap, fixer-exhausted re-authored the change, and the next PR repeated it (#16398 -> #16456 -> #16607) while no operator was ever asked. Aggregation now keeps such a head requires_human with its decision question, RouteHuman parks it at 085 needs-decision with approve / request-changes actions, and the tracker's review chevron says the head is verified and waiting on sign-off. Fixes #16675 Signed-off-by: Andrew Anderson --- changelog.d/fixed-superseder-signoff-park.md | 1 + src/pkg/dashboard/stage_tracker_activity.go | 19 +++++ .../dashboard/stage_tracker_activity_test.go | 20 +++++ src/pkg/review/hive_superseding_test.go | 83 ++++++++++++++++++- src/pkg/review/review.go | 39 ++++++++- src/pkg/stagelabels/hive_superseder_test.go | 20 +++++ src/pkg/stagelabels/human.go | 9 +- 7 files changed, 184 insertions(+), 7 deletions(-) create mode 100644 changelog.d/fixed-superseder-signoff-park.md diff --git a/changelog.d/fixed-superseder-signoff-park.md b/changelog.d/fixed-superseder-signoff-park.md new file mode 100644 index 0000000000..90c1ab9a5b --- /dev/null +++ b/changelog.d/fixed-superseder-signoff-park.md @@ -0,0 +1 @@ +- Review aggregation no longer routes a hive-superseding PR to the fixer when every perspective's `requires_human` is a pure approver question with nothing above an informational finding. That route dispatched no-op fix kicks until the cycle was exhausted, then re-authored the same change (#16398 → #16456 → #16607) while the approver the reviewer asked never saw a decision. Such a head keeps its decision question, parks at `stage/085-needs-decision` with approve / request-changes actions, and the tracker's review chevron reads "waiting on a human approver · reviewer verified, needs sign-off". diff --git a/src/pkg/dashboard/stage_tracker_activity.go b/src/pkg/dashboard/stage_tracker_activity.go index 98a7be52a0..1a89343b02 100644 --- a/src/pkg/dashboard/stage_tracker_activity.go +++ b/src/pkg/dashboard/stage_tracker_activity.go @@ -701,6 +701,9 @@ func stageTrackerReviewActivity(pr github.PullRequest, bundle *evidence.Bundle, out.Blocker = stageTrackerFixerExhaustedSummary(agg) case "requires_human": out.State, out.Caption = "human_decision", "Review findings · needs owner sign-off" + if trackerAggregateSignOffOnly(*agg) { + out.Caption = "Waiting on a human approver · reviewer verified, needs sign-off" + } out.Blocker = agg.DecisionQuestion } } @@ -909,3 +912,19 @@ func stageTrackerApplyCodeActivity(it *StageTrackerItem, dispatch review.Dispatc } } } + +// trackerAggregateSignOffOnly reports a requires_human aggregate whose +// perspectives asked an approver a question and none found code to change: +// the review verified the head and only a person's sign-off is owed +// (hivecommons/hive#16607). +func trackerAggregateSignOffOnly(agg review.Aggregate) bool { + if !agg.DecisionRequested || strings.TrimSpace(agg.DecisionQuestion) == "" { + return false + } + for _, v := range agg.Perspectives { + if v == review.VerdictChangesRequested || v == review.VerdictReject { + return false + } + } + return true +} diff --git a/src/pkg/dashboard/stage_tracker_activity_test.go b/src/pkg/dashboard/stage_tracker_activity_test.go index f2cf9e9de7..56f729e835 100644 --- a/src/pkg/dashboard/stage_tracker_activity_test.go +++ b/src/pkg/dashboard/stage_tracker_activity_test.go @@ -671,3 +671,23 @@ func TestStageTrackerActivityCIRunningWhileChecksPending(t *testing.T) { } } } + +// A requires_human aggregate whose perspectives only asked an approver a +// question (no changes_requested) is a verified head waiting on sign-off, +// not "findings" (hivecommons/hive#16607); one requesting changes is not. +func TestTrackerAggregateSignOffOnly(t *testing.T) { + signOff := review.Aggregate{Verdict: review.VerdictRequiresHuman, DecisionRequested: true, DecisionQuestion: "@owner confirm?", + Perspectives: map[review.Perspective]review.Verdict{review.PerspectiveSecurity: review.VerdictRequiresHuman, review.PerspectiveStyle: review.VerdictRequiresHuman}} + if !trackerAggregateSignOffOnly(signOff) { + t.Fatalf("sign-off aggregate not recognised: %+v", signOff) + } + withFix := signOff + withFix.Perspectives = map[review.Perspective]review.Verdict{review.PerspectiveSecurity: review.VerdictRequiresHuman, review.PerspectiveCorrectness: review.VerdictChangesRequested} + noQuestion := signOff + noQuestion.DecisionRequested, noQuestion.DecisionQuestion = false, "" + for name, agg := range map[string]review.Aggregate{"changes requested sibling": withFix, "no question": noQuestion} { + if trackerAggregateSignOffOnly(agg) { + t.Errorf("%s: wrongly recognised as sign-off only", name) + } + } +} diff --git a/src/pkg/review/hive_superseding_test.go b/src/pkg/review/hive_superseding_test.go index 13bd8d76d9..dc7068d4ae 100644 --- a/src/pkg/review/hive_superseding_test.go +++ b/src/pkg/review/hive_superseding_test.go @@ -3,12 +3,17 @@ package review import ( "strings" "testing" + + "github.com/hivecommons/hive/pkg/outputschema" ) // hiveSupersederSecurityReport is a security-sensitive requires_human on a -// PR the hive created to supersede another PR. +// PR the hive created to supersede another PR, with a finding the fixer +// can act on. func hiveSupersederSecurityReport() PerspectiveReport { - r := baseReport(PerspectiveSecurity, VerdictRequiresHuman) + r := baseReport(PerspectiveSecurity, VerdictRequiresHuman, outputschema.Finding{ + Title: "token logged at debug level", Severity: outputschema.SeverityMedium, File: "auth.go", Line: 12, + }) r.HiveAuthored = true r.HiveSuperseding = true r.DecisionRequested = true @@ -16,6 +21,80 @@ func hiveSupersederSecurityReport() PerspectiveReport { return r } +// hiveSupersederSignOffReport is the hivecommons/hive#16607 shape: every +// perspective requires_human, each only asking an approver to confirm a +// trust-boundary change, with at most an informational finding. +func hiveSupersederSignOffReport(p Perspective) PerspectiveReport { + r := baseReport(p, VerdictRequiresHuman) + r.HiveAuthored = true + r.HiveSuperseding = true + r.DecisionRequested = true + r.DecisionRiskHigh = true + r.DecisionQuestion = "@hanthor should confirm that the relay may now App-merge trusted-author pin-only PRs." + if p == PerspectiveSecurity { + r.Findings = []outputschema.Finding{{ + Title: "relay now lifts the human-merge-path hold", Severity: outputschema.SeverityInfo, + Summary: "Needs approver sign-off, not a code fix.", File: "src/pkg/github/human_merge_paths.go", Line: 269, + }} + } + return r +} + +// TestAggregateHiveSupersedingSignOffOnlyParksForDecision: when every +// perspective's requires_human is a pure approver question with nothing +// above an informational finding, the superseder rule has no fix to route. +// The aggregate keeps the decision request so the stage engine parks the PR +// at 085 needs-decision instead of kicking a fixer that has nothing to fix +// until the cycle is exhausted and the PR is re-authored (#16398 → #16456 +// → #16607). +func TestAggregateHiveSupersedingSignOffOnlyParksForDecision(t *testing.T) { + reports := []PerspectiveReport{ + hiveSupersederSignOffReport(PerspectiveCorrectness), + hiveSupersederSignOffReport(PerspectiveSecurity), + hiveSupersederSignOffReport(PerspectiveStyle), + } + got := AggregateReports(reports, AggregateOptions{}) + + if got.Verdict != VerdictRequiresHuman || !got.RequiresHuman || got.FixCycle || got.MergeEligible { + t.Fatalf("aggregate = %+v, want requires_human park", got) + } + if !got.DecisionRequested || got.DecisionQuestion == "" { + t.Fatalf("aggregate = %+v, want the decision question preserved", got) + } + if hasReason(got.Reasons, HiveSupersedingFixRouteReason) { + t.Fatalf("reasons = %v, must not carry the fix-route reason", got.Reasons) + } + for p, v := range got.Perspectives { + if v != VerdictRequiresHuman { + t.Fatalf("perspective %s = %s, want requires_human kept", p, v) + } + } + if got.Normalize().Verdict != VerdictRequiresHuman { + t.Fatalf("Normalize() = %+v, must not re-route a decision request to the fixer", got.Normalize()) + } +} + +// TestAggregateHiveSupersedingSignOffWithActionableFindingRoutesToFixer: +// a sibling perspective that found code to change keeps the owner's fixer +// route; the sign-off park is only for a swarm with nothing to fix. +func TestAggregateHiveSupersedingSignOffWithActionableFindingRoutesToFixer(t *testing.T) { + for name, extra := range map[string]PerspectiveReport{ + "changes_requested sibling": func() PerspectiveReport { + r := baseReport(PerspectiveCorrectness, VerdictChangesRequested) + r.HiveAuthored, r.HiveSuperseding = true, true + return r + }(), + "requires_human with medium finding": hiveSupersederSecurityReport(), + } { + t.Run(name, func(t *testing.T) { + got := AggregateReports([]PerspectiveReport{hiveSupersederSignOffReport(PerspectiveStyle), extra}, AggregateOptions{}) + if got.Verdict != VerdictChangesRequested || !got.FixCycle || got.DecisionRequested { + t.Fatalf("aggregate = %+v, want changes_requested fixer route", got) + } + }) + } +} + // TestAggregateHiveSupersedingRiskRequiresHumanRoutesToFixer: the owner's // rule — a security/risk requires_human on the hive's superseding PR is a // fix request, not an 085 park. diff --git a/src/pkg/review/review.go b/src/pkg/review/review.go index c3bad61c2a..132c15a406 100644 --- a/src/pkg/review/review.go +++ b/src/pkg/review/review.go @@ -454,6 +454,7 @@ func aggregateReports(reports []PerspectiveReport, opts AggregateOptions) Aggreg var decisionQuestions []string var hasReject, hasChanges, unresolvedRequiresHuman, riskEscalation bool var selfAuthoredHumanWithConcreteRemediation, selfAuthoredHumanWithoutRemediation bool + var signOffAsk, requiresHumanBeyondSignOff bool for i, r := range reports { effective := effectiveReports[i] if agg.Repo == "" { @@ -490,6 +491,11 @@ func aggregateReports(reports []PerspectiveReport, opts AggregateOptions) Aggreg case VerdictChangesRequested: hasChanges = true case VerdictRequiresHuman: + if reportAsksForSignOff(r) { + signOffAsk = true + } else { + requiresHumanBeyondSignOff = true + } if selfAuthoredRequiresHumanReportIsResolvable(r, opts) { if reportHasConcreteRemediation(r) { selfAuthoredHumanWithConcreteRemediation = true @@ -530,7 +536,8 @@ func aggregateReports(reports []PerspectiveReport, opts AggregateOptions) Aggreg sortReasons(agg.Reasons) sort.Strings(agg.HumanSummaries) - if hiveSupersedingFixRoute(agg, opts, hasReject, decisionRequested, riskEscalation, unresolvedRequiresHuman) { + signOffOnly := signOffAsk && !requiresHumanBeyondSignOff && !hasReject && !hasChanges + if hiveSupersedingFixRoute(agg, opts, hasReject, decisionRequested, riskEscalation, unresolvedRequiresHuman, signOffOnly) { // Owner rule: a PR the hive created to supersede another PR auto- // merges with no operator decision. A reviewer's requires_human — // a risk-class question, a security-sensitive finding — is a @@ -945,8 +952,17 @@ const HiveSupersedingFixRouteReason = "hive-authored superseding PR: reviewer re // reject stays a reject: it is an emergent problem with the PR, not a // finding to fix. Everything the self-authored path already resolves on // its own (non-risk questions, concrete remediation) keeps that path. -func hiveSupersedingFixRoute(agg Aggregate, opts AggregateOptions, hasReject, decisionRequested, riskEscalation, unresolvedRequiresHuman bool) bool { - if !agg.HiveSuperseding || !agg.HiveAuthored || opts.HiveSupersedingAutoMergeOff || hasReject { +// +// signOffOnly is the one requires_human the fixer cannot answer: every +// perspective explicitly deferred a maintainer decision and none raised a +// finding above informational severity (reportAsksForSignOff). Routing that +// to the fixer dispatched six no-op fix kicks, exhausted the cycle, and +// re-authored the same change three times (#16398 → #16456 → #16607) while +// the approver who was asked never saw a decision pill. It stays a +// decision-requested requires_human, which the stage engine parks at 085 +// needs-decision with approve / request-changes options. +func hiveSupersedingFixRoute(agg Aggregate, opts AggregateOptions, hasReject, decisionRequested, riskEscalation, unresolvedRequiresHuman, signOffOnly bool) bool { + if !agg.HiveSuperseding || !agg.HiveAuthored || opts.HiveSupersedingAutoMergeOff || hasReject || signOffOnly { return false } if strings.EqualFold(strings.TrimSpace(opts.SelfAuthoredDecisionPolicy), "escalate") { @@ -955,6 +971,23 @@ func hiveSupersedingFixRoute(agg Aggregate, opts AggregateOptions, hasReject, de return unresolvedRequiresHuman || (decisionRequested && riskEscalation) } +// reportAsksForSignOff reports whether a requires_human report (the caller +// has already established the effective verdict) is a pure approver +// question: it explicitly requested a maintainer decision and carries no +// in-scope finding above informational severity, so there is no code change +// an agent could make to clear it. +func reportAsksForSignOff(r PerspectiveReport) bool { + if !r.DecisionRequested { + return false + } + for _, f := range r.Findings { + if InScopeFinding(f) && severityRank(f.Severity) > severityRank(outputschema.SeverityInfo) { + return false + } + } + return true +} + func reportsHiveSuperseding(reports []PerspectiveReport) bool { for _, r := range reports { if r.HiveSuperseding { diff --git a/src/pkg/stagelabels/hive_superseder_test.go b/src/pkg/stagelabels/hive_superseder_test.go index d71717f9e2..7f46dc11bb 100644 --- a/src/pkg/stagelabels/hive_superseder_test.go +++ b/src/pkg/stagelabels/hive_superseder_test.go @@ -81,3 +81,23 @@ func TestHiveSupersederHardStopReasonRejectsOtherReasons(t *testing.T) { t.Fatal("unknown token must have no prose") } } + +// TestRouteHumanHiveSupersederSignOffQuestionParksAt085: a requires_human +// that still carries its decision question is the aggregate's pure +// approver sign-off (nothing for the fixer, hivecommons/hive#16607). It is +// a decision with approve / request-changes actions, not a 070 row nobody +// is working. +func TestRouteHumanHiveSupersederSignOffQuestionParksAt085(t *testing.T) { + e := hiveSupersederEvidence() + e.DecisionQuestion = "@hanthor should confirm the relay may App-merge trusted pin-only PRs." + r := RouteHuman(e) + if r.Stage != NeedsDecision || r.LaneReason == LaneReasonHiveSupersederFix { + t.Fatalf("route = %+v, want 085 decision", r) + } + if !strings.Contains(strings.Join(r.Reasons, "\n"), "reviewer question: "+e.DecisionQuestion) { + t.Fatalf("reasons = %v, want the reviewer question", r.Reasons) + } + if DecisionActions(r) == "" { + t.Fatalf("route = %+v, want approve / request-changes actions", r) + } +} diff --git a/src/pkg/stagelabels/human.go b/src/pkg/stagelabels/human.go index 2a53c28a4f..1f44ebeb59 100644 --- a/src/pkg/stagelabels/human.go +++ b/src/pkg/stagelabels/human.go @@ -428,11 +428,16 @@ func RouteHuman(e Evidence) Route { } return Route{Stage: NeedsDecision, Reasons: reasons, LaneReason: LaneReasonHiveSupersederHardStopPrefix + token, Summary: summary, Head: e.Head, SelfAuthored: e.SelfAuthored, Verdict: e.Verdict, HumanApprover: strings.TrimSpace(e.HumanApprover), Hold: e.Hold} } - if e.Verdict == VerdictRequiresHuman && strings.TrimSpace(e.HumanApprover) == "" { + if e.Verdict == VerdictRequiresHuman && strings.TrimSpace(e.HumanApprover) == "" && strings.TrimSpace(e.DecisionQuestion) == "" { // Owner rule: the reviewer's finding — security-sensitive // included — is the fixer's to address, not a person's to rule // on. The aggregate routes it as changes_requested; the stage - // says so rather than "needs your decision". + // says so rather than "needs your decision". A verdict that + // still carries its decision question is the one case the + // aggregate left for a person (a pure approver sign-off with + // nothing to fix, hivecommons/hive#16607): no fixer is + // dispatched for it, so captioning it "goes to the fixer" + // parked it on 070 with nobody on it; it falls through to 085. note(HiveSupersederAutoMergeCaption+": the reviewer's finding @"+ShortSHA(e.Head)+" goes to the fixer", LaneReasonHiveSupersederFix) } }