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-superseder-signoff-park.md
Original file line number Diff line number Diff line change
@@ -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".
19 changes: 19 additions & 0 deletions src/pkg/dashboard/stage_tracker_activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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
}
20 changes: 20 additions & 0 deletions src/pkg/dashboard/stage_tracker_activity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
83 changes: 81 additions & 2 deletions src/pkg/review/hive_superseding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,98 @@ 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
r.DecisionQuestion = "Should we accept this public-facing auth behavior change?"
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.
Expand Down
39 changes: 36 additions & 3 deletions src/pkg/review/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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") {
Expand All @@ -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 {
Expand Down
20 changes: 20 additions & 0 deletions src/pkg/stagelabels/hive_superseder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
9 changes: 7 additions & 2 deletions src/pkg/stagelabels/human.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
Loading