From 452af37b99651cf15fc4f52fe42f6707dc84d8c2 Mon Sep 17 00:00:00 2001 From: Danathar Date: Sat, 31 Oct 2026 15:27:22 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20review:=20a=20hive-authored=20as?= =?UTF-8?q?k=20on=20a=20sensitive=20path=20stays=20a=20person's=20decision?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Under self_authored_decision_policy: resolve, a hive-authored requires_human or decision-requested perspective whose in-scope finding sits on a sensitive path (sentinel defaults plus security.sensitive_paths) now stays requires_human with a decision_finding naming the file, so no fix is dispatched and the PR parks at stage/085-needs-decision with the reviewer's ask. The sensitive-paths risk class used to read only the question's wording: projectbluefin/bonedigger#106's "apply the pr-validate.yml + BASELINE hunks" named no risk term, was routed to the fixer as changes_requested, and sat at 070 with stage/stalled flapping through six fix attempts that never pushed, nobody asked. Aggregate.Normalize and prstage.NormalizeReviewVerdict leave a requires_human with a recorded decision_finding alone. Asks for changes, asks off the sensitive paths, out-of-scope findings, permissions- tightening-only diffs and the escalate policy are unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar --- .../fixed-self-authored-sensitive-path-ask.md | 1 + .../hive/self_authored_workflow_ask_test.go | 94 +++++++++++ src/docs/review-swarm.md | 17 ++ src/pkg/review/review.go | 61 ++++++- src/pkg/review/security_finding.go | 29 ++-- .../self_authored_sensitive_path_test.go | 155 ++++++++++++++++++ src/pkg/stageengine/prstage/types.go | 2 +- 7 files changed, 345 insertions(+), 14 deletions(-) create mode 100644 changelog.d/fixed-self-authored-sensitive-path-ask.md create mode 100644 src/cmd/hive/self_authored_workflow_ask_test.go create mode 100644 src/pkg/review/self_authored_sensitive_path_test.go diff --git a/changelog.d/fixed-self-authored-sensitive-path-ask.md b/changelog.d/fixed-self-authored-sensitive-path-ask.md new file mode 100644 index 0000000000..bca4831cd7 --- /dev/null +++ b/changelog.d/fixed-self-authored-sensitive-path-ask.md @@ -0,0 +1 @@ +- Review: on a hive-authored PR, a `requires_human` or decision-requested perspective whose in-scope finding sits on a sensitive path (for example `.github/workflows/`) now stays a person's decision under `self_authored_decision_policy: resolve`. It parks at `stage/085-needs-decision`, and the comment names the finding and the reviewer's ask. Before, an ask worded without a risk-class term, such as "apply the `pr-validate.yml` hunk from the PR body", was turned into `changes_requested`. The PR then sat at `stage/070-fixing`, with `stage/stalled` coming and going, through fix attempts that could not land the workflow edit, and nobody was asked. A recorded `decision_finding` also stops the read-time verdict normalizers from turning the hold back into `changes_requested`. Asks for changes, and asks off the sensitive paths, still go to the fixer. diff --git a/src/cmd/hive/self_authored_workflow_ask_test.go b/src/cmd/hive/self_authored_workflow_ask_test.go new file mode 100644 index 0000000000..5f3819cf28 --- /dev/null +++ b/src/cmd/hive/self_authored_workflow_ask_test.go @@ -0,0 +1,94 @@ +package main + +import ( + "testing" + "time" + + "github.com/hivecommons/hive/pkg/outputschema" + "github.com/hivecommons/hive/pkg/review" + "github.com/hivecommons/hive/pkg/stageengine" + "github.com/hivecommons/hive/pkg/stageengine/prstage" + "github.com/hivecommons/hive/pkg/stagelabels" +) + +// projectbluefin/bonedigger#106 end to end: the review of the hive's own PR +// asks a maintainer to commit a hunk in a workflow file. The aggregate the +// review records, read back the way the lanes read it, must classify as +// 085 with the ask, not 070, and 085 has no stalled dwell, so the PR no +// longer flaps stage/stalled while it waits for the person. +func TestSelfAuthoredWorkflowAskParksAt085WithTheAsk(t *testing.T) { + const head = "a3c2a5b431c40c23b34c4dbe968cb52446d10faf" + const ask = "apply the `pr-validate.yml` + `BASELINE` hunks from the PR body on this branch before merging" + report := func(file string) review.PerspectiveReport { + return review.PerspectiveReport{ + AgentReport: outputschema.AgentReport{ + Lane: "review-swarm", Kind: outputschema.KindReview, Summary: "the title is not yet true", + Findings: []outputschema.Finding{{ + Title: "pull-request check still installs the lint tool unpinned", Severity: outputschema.SeverityMedium, + ReviewScope: "in-scope", File: file, Line: 28, + Summary: "update the pipx step to install from .github/requirements-ci.txt", + }}, + PRsOpened: []outputschema.PROpened{}, BeadsFiled: []outputschema.BeadFiled{}, + }, + Perspective: review.PerspectiveIntentAlignment, Verdict: review.VerdictRequiresHuman, + Repo: "projectbluefin/bonedigger", Number: 106, HeadSHA: head, + HiveAuthored: true, DecisionRequested: true, DecisionQuestion: ask, + } + } + classify := func(t *testing.T, file, laneReason string) (prstage.Verdict, review.Aggregate) { + t.Helper() + agg := review.AggregateReports([]review.PerspectiveReport{report(file)}, review.AggregateOptions{}) + agg.RecordedAt = time.Date(2026, 10, 29, 18, 25, 47, 0, time.UTC) + verdict := contributorLaneVerdictFromArtifact(review.Artifact{Items: []review.Aggregate{agg}}, "projectbluefin/bonedigger", 106, head, false) + return stageengine.ClassifyStage(prstage.Observation{ + Lane: prstage.StageLaneSelf, Number: 106, HeadSHA: head, Reason: laneReason, + Detail: prstage.Detail{VerdictKnown: true, Verdict: verdict}, + }), agg + } + + got, agg := classify(t, ".github/workflows/pr-validate.yml", "review-verdict-requires-human") + if got.Stage != stagelabels.NeedsDecision || !got.Human { + t.Fatalf("stage = %+v (aggregate %s), want 085 needs-decision", got, agg.Verdict) + } + if got.Reason != stageengine.StageReasonDecisionRequested { + t.Fatalf("reason = %q, want %q", got.Reason, stageengine.StageReasonDecisionRequested) + } + verdict := contributorLaneVerdictFromArtifact(review.Artifact{Items: []review.Aggregate{agg}}, "projectbluefin/bonedigger", 106, head, false) + if verdict.DecisionQuestion != ask || verdict.DecisionFinding == "" { + t.Fatalf("verdict = %+v, want the ask and the finding for the 085 comment", verdict) + } + + entered := time.Date(2026, 10, 29, 19, 3, 12, 0, time.UTC) + parked := stagelabels.Record{Stage: got.Stage, EnteredAt: entered, LastActivityAt: entered} + if stagelabels.Stalled(parked, nil, entered.Add(40*time.Hour)) { + t.Fatalf("085 marked stalled after 40h; it must wait for the person without the stalled label") + } + + // The ask the hive can make itself still goes to the fixer at 070, + // and 070 still stalls when nobody works it. + fixing, _ := classify(t, "tests/test_python_install_pins.py", "changes-requested") + if fixing.Stage != stagelabels.Fixing { + t.Fatalf("stage = %+v, want 070 fixing for a fix off the sensitive paths", fixing) + } + working := stagelabels.Record{Stage: fixing.Stage, EnteredAt: entered, LastActivityAt: entered} + if !stagelabels.Stalled(working, nil, entered.Add(3*time.Hour)) { + t.Fatalf("070 not stalled after 3h quiet; the fixing dwell must be unchanged") + } +} + +// The stage-side fallback normalizer rewrites a hive-authored requires_human +// with concrete wording to changes_requested. A verdict whose aggregate +// recorded a DecisionFinding is a person's by policy and must stay so. +func TestNormalizeReviewVerdictKeepsARecordedDecisionFinding(t *testing.T) { + v := prstage.ReviewVerdict{ + Configured: true, Verdict: "requires_human", HiveAuthoredKnown: true, HiveAuthored: true, + HumanSummaries: []string{"update the pipx step in pr-validate.yml"}, + } + if got := prstage.NormalizeReviewVerdict(v); got.Verdict != "changes_requested" { + t.Fatalf("without a finding: verdict = %q, want the existing changes_requested rewrite", got.Verdict) + } + v.DecisionFinding = `sensitive path .github/workflows/pr-validate.yml: intent-alignment finding "unpinned"` + if got := prstage.NormalizeReviewVerdict(v); got.Verdict != "requires_human" { + t.Fatalf("with a finding: verdict = %q, want requires_human kept", got.Verdict) + } +} diff --git a/src/docs/review-swarm.md b/src/docs/review-swarm.md index 3456157802..e4bceac5da 100644 --- a/src/docs/review-swarm.md +++ b/src/docs/review-swarm.md @@ -321,6 +321,23 @@ parked for a person.) The risk classes are: | `licensing-legal` | license, copyright, legal, privacy, compliance, trademark, CLA | | `unverifiable` | the reviewer says it could not read, judge or test the change, or the requirement is ambiguous | +The `sensitive-paths` class also covers what the reviewer asks a person +about, not only how the question is worded. A `requires_human` or +decision-requested perspective whose in-scope finding sits on a sensitive +path (the sentinel defaults plus `security.sensitive_paths`) stays a +person's decision. The aggregate keeps `requires_human` with +`decision_finding: sensitive path : …`, no fix is dispatched, and the +PR parks at `stage/085-needs-decision`. The 085 comment prints that finding +and the reviewer's question, so it names the change the maintainer must +commit. Before this, "apply the `pr-validate.yml` hunk from the PR body" +named no risk class, so the ask was routed to the fixer as +`changes_requested`. The PR then sat at `stage/070-fixing`, wearing +`stage/stalled` on and off, through six fix attempts that could not land a +workflow edit (projectbluefin/bonedigger#106). A perspective that asks for +changes on a workflow file still goes to the fixer, which may hold the +Workflows permission. The permissions-tightening carve-out applies as it +does to the question. + Set the policy to `escalate` to preserve the older behavior where every decision marker parks the PR for a person. The reviewer template (`policies/reviewer-queue.md`) also tells the swarm to check the linked diff --git a/src/pkg/review/review.go b/src/pkg/review/review.go index f560251a95..711864f4a8 100644 --- a/src/pkg/review/review.go +++ b/src/pkg/review/review.go @@ -488,7 +488,7 @@ func aggregateReports(reports []PerspectiveReport, opts AggregateOptions) Aggreg unresolvedRequiresHuman = true } } - if reportRequiresRiskEscalation(r) { + if reportRequiresRiskEscalation(r, opts) { riskEscalation = true } if r.RedundantOf > 0 && agg.RedundantOf == 0 { @@ -612,6 +612,13 @@ func aggregateReports(reports []PerspectiveReport, opts AggregateOptions) Aggreg agg.Reasons = []string{"self-authored non-risk requires_human recorded as advisory"} return agg } + if agg.DecisionFinding == "" { + // The 085 comment prints it after "the review found:", and + // Normalize reads it as the reason the hold stays a person's. + if finding, ok := selfAuthoredSensitivePathAskAcross(reports, opts); ok { + agg.DecisionFinding = finding + } + } agg.Verdict = VerdictRequiresHuman agg.RequiresHuman = true return agg @@ -656,6 +663,12 @@ func (a Aggregate) Normalize() Aggregate { if FixCycleCapReached(a) { return a } + if strings.TrimSpace(a.DecisionFinding) != "" { + // The aggregate recorded what makes the hold a person's (a + // sensitive-path ask on the hive's own PR); a re-read must not + // hand it to the fixer. + return a + } if aggregateRequiresRiskEscalation(a) || (!aggregateHasConcreteRemediation(a) && !aggregateHasBlockingPerspective(a)) { return a } @@ -781,7 +794,7 @@ func selfAuthoredRequiresHumanReportIsResolvable(r PerspectiveReport, opts Aggre if !r.HiveAuthored || strings.EqualFold(strings.TrimSpace(opts.SelfAuthoredDecisionPolicy), "escalate") { return false } - if r.Verdict != VerdictRequiresHuman || reportRequiresRiskEscalation(r) { + if r.Verdict != VerdictRequiresHuman || reportRequiresRiskEscalation(r, opts) { return false } if r.DecisionRequested { @@ -819,11 +832,14 @@ func reportHasConcreteRemediation(r PerspectiveReport) bool { return false } -func reportRequiresRiskEscalation(r PerspectiveReport) bool { +func reportRequiresRiskEscalation(r PerspectiveReport, opts AggregateOptions) bool { tightening := r.PermissionsTighteningOnly if _, risk := DecisionQuestionRiskClassFor(r.DecisionQuestion, tightening); risk || r.DecisionRiskHigh { return true } + if _, onPath := selfAuthoredSensitivePathAsk(r, opts); onPath { + return true + } if containsRiskEscalationTermFor(r.Summary, tightening) { return true } @@ -835,6 +851,45 @@ func reportRequiresRiskEscalation(r PerspectiveReport) bool { return false } +// selfAuthoredSensitivePathAsk is the sensitive-paths risk class applied to +// what a hive-authored review asks a person about, not only to how the +// question is worded. A requires_human or decision-requested report whose +// in-scope finding sits on a sensitive path (sentinel.DefaultSensitivePaths +// plus `security.sensitive_paths`) stays a person's decision under the +// resolve policy, as a question naming the path already does. +// +// Seen on projectbluefin/bonedigger#106: the reviewer asked a maintainer to +// "apply the `pr-validate.yml` + `BASELINE` hunks from the PR body", with +// the finding on `.github/workflows/pr-validate.yml`. The wording named no +// risk class, so the ask was resolved to changes_requested and the PR sat at +// stage/070-fixing through six fix attempts that never pushed, then wore +// stage/stalled on and off until a maintainer applied the hunk 38h later; +// nobody was asked. +// +// A report that asks for changes is not covered: the fixer is still the one +// to try it. The permissions-tightening carve-out (hivecommons/hive#13068) +// applies here as it does to the question. +func selfAuthoredSensitivePathAsk(r PerspectiveReport, opts AggregateOptions) (string, bool) { + if !r.HiveAuthored || r.PermissionsTighteningOnly || strings.EqualFold(strings.TrimSpace(opts.SelfAuthoredDecisionPolicy), "escalate") { + return "", false + } + if r.Verdict != VerdictRequiresHuman && !r.DecisionRequested { + return "", false + } + return sensitivePathFinding(r, SecuritySensitivePaths(opts.SensitivePaths)) +} + +// selfAuthoredSensitivePathAskAcross returns the first report's +// selfAuthoredSensitivePathAsk finding. +func selfAuthoredSensitivePathAskAcross(reports []PerspectiveReport, opts AggregateOptions) (string, bool) { + for _, r := range reports { + if finding, ok := selfAuthoredSensitivePathAsk(r, opts); ok { + return finding, true + } + } + return "", false +} + // ConcreteRemediationText reports whether review prose names an actionable // engineering fix instead of merely saying a person should decide. func ConcreteRemediationText(text string) bool { return reviewtext.ConcreteRemediationText(text) } diff --git a/src/pkg/review/security_finding.go b/src/pkg/review/security_finding.go index 45a6b7fa7b..284c75ae53 100644 --- a/src/pkg/review/security_finding.go +++ b/src/pkg/review/security_finding.go @@ -87,29 +87,38 @@ func IsSecuritySensitiveFinding(r PerspectiveReport, sensitivePaths []string) (s if class, risk := DecisionQuestionRiskClassFor(r.DecisionQuestion, r.PermissionsTighteningOnly); risk && securitySensitiveClasses[class] { return class + " question from the " + string(r.Perspective) + " review", true } - paths := sensitivePaths - if paths == nil { - paths = SecuritySensitivePaths(nil) + if finding, ok := sensitivePathFinding(r, sensitivePaths); ok { + return finding, true } for _, f := range r.Findings { if !InScopeFinding(f) { continue } - if file := strings.TrimSpace(f.File); file != "" && intent.PathMatchesAny(file, paths) { - return fmt.Sprintf("sensitive path %s: %s finding %q", file, r.Perspective, strings.TrimSpace(f.Title)), true + if securityTermIn(f.Title, r.PermissionsTighteningOnly) || securityTermIn(f.Summary, r.PermissionsTighteningOnly) { + return fmt.Sprintf("%s finding %q flags insecure behaviour", r.Perspective, strings.TrimSpace(f.Title)), true } } + if securityTermIn(r.Summary, r.PermissionsTighteningOnly) { + return "the " + string(r.Perspective) + " review flags insecure behaviour", true + } + return "", false +} + +// sensitivePathFinding names r's first in-scope finding on a sensitive path +// (nil paths means the defaults). +func sensitivePathFinding(r PerspectiveReport, sensitivePaths []string) (string, bool) { + paths := sensitivePaths + if paths == nil { + paths = SecuritySensitivePaths(nil) + } for _, f := range r.Findings { if !InScopeFinding(f) { continue } - if securityTermIn(f.Title, r.PermissionsTighteningOnly) || securityTermIn(f.Summary, r.PermissionsTighteningOnly) { - return fmt.Sprintf("%s finding %q flags insecure behaviour", r.Perspective, strings.TrimSpace(f.Title)), true + if file := strings.TrimSpace(f.File); file != "" && intent.PathMatchesAny(file, paths) { + return fmt.Sprintf("sensitive path %s: %s finding %q", file, r.Perspective, strings.TrimSpace(f.Title)), true } } - if securityTermIn(r.Summary, r.PermissionsTighteningOnly) { - return "the " + string(r.Perspective) + " review flags insecure behaviour", true - } return "", false } diff --git a/src/pkg/review/self_authored_sensitive_path_test.go b/src/pkg/review/self_authored_sensitive_path_test.go new file mode 100644 index 0000000000..43a62b51ef --- /dev/null +++ b/src/pkg/review/self_authored_sensitive_path_test.go @@ -0,0 +1,155 @@ +package review + +import ( + "strings" + "testing" + + "github.com/hivecommons/hive/pkg/outputschema" +) + +// projectbluefin/bonedigger#106: the hive's own PR pinned the tools its +// checks install, but the pin itself lives in a workflow file. The review +// asked a maintainer to commit that hunk; under the resolve policy the ask +// was turned into changes_requested because its wording named no risk +// class, and the PR sat at 070 while the fixer could not land it. +func bonedigger106Reports(workflowFile string) []PerspectiveReport { + intent := baseReport(PerspectiveIntentAlignment, VerdictRequiresHuman, outputschema.Finding{ + Title: "pull-request check still installs the lint tool unpinned", + Severity: outputschema.SeverityMedium, + ReviewScope: "in-scope", + File: workflowFile, + Line: 28, + Summary: "update the pipx step to install from .github/requirements-ci.txt and remove the BASELINE entry", + }) + intent.HiveAuthored = true + intent.DecisionRequested = true + intent.DecisionQuestion = "apply the `pr-validate.yml` + `BASELINE` hunks from the PR body on this branch before merging" + correctness := baseReport(PerspectiveCorrectness, VerdictChangesRequested, outputschema.Finding{ + Title: "pipx_errors treats a flag value as the package spec", + Severity: outputschema.SeverityLow, + ReviewScope: "in-scope", + File: "tests/test_python_install_pins.py", + Line: 143, + }) + correctness.HiveAuthored = true + return []PerspectiveReport{intent, correctness} +} + +func TestSelfAuthoredWorkflowAskStaysAPersonsDecision(t *testing.T) { + reports := bonedigger106Reports(".github/workflows/pr-validate.yml") + got := AggregateReports(reports, AggregateOptions{}) + if got.Verdict != VerdictRequiresHuman || !got.RequiresHuman || got.FixCycle || got.MergeEligible { + t.Fatalf("aggregate = %+v, want a requires_human hold, not the fixer", got) + } + if !got.DecisionRequested || got.DecisionQuestion != reports[0].DecisionQuestion { + t.Fatalf("decision = %v %q, want the reviewer's ask kept verbatim", got.DecisionRequested, got.DecisionQuestion) + } + if !strings.Contains(got.DecisionFinding, "sensitive path .github/workflows/pr-validate.yml") { + t.Fatalf("DecisionFinding = %q, want it to name the workflow file", got.DecisionFinding) + } + if n := got.Normalize(); n.Verdict != VerdictRequiresHuman || n.FixCycle || !n.DecisionRequested { + t.Fatalf("Normalize = %+v, want the hold kept on re-read", n) + } +} + +// Without a decision marker the reviewer's requires_human alone is the ask. +// The hold carries the finding, and Normalize (run on every artifact read) +// must not hand it to the fixer as concrete remediation. +func TestSelfAuthoredBareRequiresHumanOnWorkflowStaysAPersonsDecision(t *testing.T) { + r := bonedigger106Reports(".github/workflows/pr-validate.yml")[0] + r.DecisionRequested = false + r.DecisionQuestion = "" + r.Summary = "Apply the pr-validate.yml hunk from the PR body; only a maintainer can commit that edit." + got := AggregateReports([]PerspectiveReport{r}, AggregateOptions{}) + if got.Verdict != VerdictRequiresHuman || !got.RequiresHuman || got.FixCycle { + t.Fatalf("aggregate = %+v, want a requires_human hold", got) + } + if !strings.Contains(got.DecisionFinding, "sensitive path .github/workflows/pr-validate.yml") { + t.Fatalf("DecisionFinding = %q, want it to name the workflow file", got.DecisionFinding) + } + if n := got.Normalize(); n.Verdict != VerdictRequiresHuman || n.FixCycle { + t.Fatalf("Normalize = %+v, want the hold kept on re-read", n) + } + // The same aggregate without the recorded finding is what Normalize + // still routes to the fixer, so the guard is the finding, not the shape. + legacy := got + legacy.DecisionFinding = "" + if n := legacy.Normalize(); n.Verdict != VerdictChangesRequested { + t.Fatalf("legacy Normalize = %+v, want the existing concrete-remediation route", n) + } +} + +// Everything the hive can fix keeps its 070 route. +func TestSelfAuthoredAsksOffSensitivePathsStillGoToTheFixer(t *testing.T) { + t.Run("same ask on an ordinary file", func(t *testing.T) { + reports := bonedigger106Reports("tests/fixtures/pr-validate.yml") + got := AggregateReports(reports, AggregateOptions{}) + if got.Verdict != VerdictChangesRequested || !got.FixCycle || got.RequiresHuman || got.DecisionRequested { + t.Fatalf("aggregate = %+v, want changes_requested for the fixer", got) + } + }) + t.Run("changes requested on a workflow file is the fixer's to try", func(t *testing.T) { + r := baseReport(PerspectiveCorrectness, VerdictChangesRequested, outputschema.Finding{ + Title: "job name typo", Severity: outputschema.SeverityLow, ReviewScope: "in-scope", File: ".github/workflows/ci.yml", + }) + r.HiveAuthored = true + got := AggregateReports([]PerspectiveReport{r}, AggregateOptions{}) + if got.Verdict != VerdictChangesRequested || !got.FixCycle || got.DecisionFinding != "" { + t.Fatalf("aggregate = %+v, want changes_requested for the fixer", got) + } + }) + t.Run("decision on an ordinary file beside changes requested on a workflow file", func(t *testing.T) { + // Only what a person is asked about can make it a person's; the + // workflow finding is a changes_requested one, so the fixer tries. + reports := bonedigger106Reports("tests/fixtures/pr-validate.yml") + reports[1].Findings[0].File = ".github/workflows/ci.yml" + got := AggregateReports(reports, AggregateOptions{}) + if got.Verdict != VerdictChangesRequested || !got.FixCycle || got.DecisionRequested { + t.Fatalf("aggregate = %+v, want changes_requested for the fixer", got) + } + }) + t.Run("out-of-scope finding on a workflow file", func(t *testing.T) { + reports := bonedigger106Reports(".github/workflows/pr-validate.yml") + reports[0].Findings[0].ReviewScope = "out-of-scope" + got := AggregateReports(reports, AggregateOptions{}) + if got.Verdict != VerdictChangesRequested || !got.FixCycle { + t.Fatalf("aggregate = %+v, want changes_requested for the fixer", got) + } + }) + t.Run("permissions-tightening carve-out", func(t *testing.T) { + reports := bonedigger106Reports(".github/workflows/pr-validate.yml") + for i := range reports { + reports[i].PermissionsTighteningOnly = true + } + got := AggregateReports(reports, AggregateOptions{}) + if got.Verdict != VerdictChangesRequested || !got.FixCycle { + t.Fatalf("aggregate = %+v, want the tightening-only workflow diff to stay the hive's call", got) + } + }) +} + +func TestSelfAuthoredOperatorSensitivePathAskStaysAPersonsDecision(t *testing.T) { + reports := bonedigger106Reports("internal/proxy/allow.go") + if got := AggregateReports(reports, AggregateOptions{}); got.Verdict != VerdictChangesRequested { + t.Fatalf("aggregate = %+v, want an unlisted path to go to the fixer", got) + } + got := AggregateReports(reports, AggregateOptions{SensitivePaths: []string{"internal/proxy/**"}}) + if got.Verdict != VerdictRequiresHuman || !strings.Contains(got.DecisionFinding, "sensitive path internal/proxy/allow.go") { + t.Fatalf("aggregate = %+v, want security.sensitive_paths honoured", got) + } +} + +// The escalate policy already keeps every question; the new rule adds +// nothing there, including no finding text in the 085 comment. +func TestSelfAuthoredWorkflowAskUnderEscalatePolicyUnchanged(t *testing.T) { + got := AggregateReports(bonedigger106Reports(".github/workflows/pr-validate.yml"), AggregateOptions{SelfAuthoredDecisionPolicy: "escalate"}) + if got.Verdict != VerdictRequiresHuman || !got.DecisionRequested { + t.Fatalf("aggregate = %+v, want the escalate hold", got) + } + r := bonedigger106Reports(".github/workflows/pr-validate.yml")[0] + r.DecisionRequested, r.DecisionQuestion = false, "" + got = AggregateReports([]PerspectiveReport{r}, AggregateOptions{SelfAuthoredDecisionPolicy: "escalate"}) + if got.Verdict != VerdictRequiresHuman || got.DecisionFinding != "" { + t.Fatalf("aggregate = %+v, want the escalate hold with no added finding", got) + } +} diff --git a/src/pkg/stageengine/prstage/types.go b/src/pkg/stageengine/prstage/types.go index 20f4032828..9a6a6a5071 100644 --- a/src/pkg/stageengine/prstage/types.go +++ b/src/pkg/stageengine/prstage/types.go @@ -253,7 +253,7 @@ func (v ReviewVerdict) WithDecisionAnswer(by, head, directive string) ReviewVerd } func NormalizeReviewVerdict(v ReviewVerdict) ReviewVerdict { - if !v.Configured || v.Approved || v.DecisionRequested || (v.HiveAuthoredKnown && !v.HiveAuthored) || v.FixCycleCapReached || strings.ToLower(strings.TrimSpace(v.Verdict)) != "requires_human" { + if !v.Configured || v.Approved || v.DecisionRequested || (v.HiveAuthoredKnown && !v.HiveAuthored) || v.FixCycleCapReached || strings.TrimSpace(v.DecisionFinding) != "" || strings.ToLower(strings.TrimSpace(v.Verdict)) != "requires_human" { return v } text := strings.TrimSpace(v.DecisionQuestion + "\n" + strings.Join(v.HumanSummaries, "\n"))