diff --git a/changelog.d/fixed-stage-drift-on-park.md b/changelog.d/fixed-stage-drift-on-park.md new file mode 100644 index 0000000000..a4d4c6f680 --- /dev/null +++ b/changelog.d/fixed-stage-drift-on-park.md @@ -0,0 +1 @@ +- On a PR the hive did not author, the security review's `requires_human` now stays a hold for a person (`stage/085-needs-decision`, with the finding named) when another perspective also asks for changes. Before, the sibling `changes_requested` folded the security hold into the fix cycle and the PR went back to its author at `stage/072-returned-to-contributor`, although a security finding is the contributor rule's one early exit to a person ([#15640](https://github.com/hivecommons/hive/issues/15640)). projectbluefin/utah-packages#890 was sent to its author for a PR-body edit while the security review's question about a new App credential waited on a maintainer. diff --git a/src/docs/review-swarm.md b/src/docs/review-swarm.md index e78cf33d06..7b47bc4a78 100644 --- a/src/docs/review-swarm.md +++ b/src/docs/review-swarm.md @@ -366,7 +366,14 @@ tests-removed lane rule and a reporter-trust hold are the lane-side equivalents and park the PR the same way. The finding is recorded as `decision_finding` and the 085 comment and tracker popover print it as `the review found: …` next to the reviewer's question, so the operator is -told WHAT was found. +told WHAT was found. Another perspective's `changes_requested` on the same +head does not fold that exit into the fix cycle: the aggregate stays +`requires_human` with the finding, and the change requests wait in the +review for the person who decides +([projectbluefin/utah-packages#890](https://github.com/projectbluefin/utah-packages/pull/890) +went to its author at `stage/072-returned-to-contributor` for a PR-body +edit while the security review's App-credential question waited on a +maintainer). Everything else the review raises — ordinary nits and findings, a duplicate, naming, scope, sequencing, licensing, a failing optional check, a conflict diff --git a/src/pkg/review/review.go b/src/pkg/review/review.go index 132c15a406..b5fbe714f1 100644 --- a/src/pkg/review/review.go +++ b/src/pkg/review/review.go @@ -625,6 +625,21 @@ func aggregateReports(reports []PerspectiveReport, opts AggregateOptions) Aggreg agg.Reasons = []string{fmt.Sprintf("fix cycle cap reached (%d/%d)", opts.FixAttempts, maxFix)} return agg } + if seenVerdicts[VerdictRequiresHuman] && contributorHandsFree(agg, opts) { + // A security finding is the contributor rule's one early exit + // to a person (hivecommons/hive#15640), and a sibling + // perspective's change request does not fold it into the fix + // cycle: the decision-marker path above already keeps it. + // projectbluefin/utah-packages#890 went back to its author at + // 072 for a PR-body edit while the security review's question + // about a new App credential waited on a maintainer. + if finding, backed := securityFindingAcross(reports, sensitivePaths); backed { + agg.DecisionFinding = finding + agg.Verdict = VerdictRequiresHuman + agg.RequiresHuman = true + return agg + } + } agg.Verdict = VerdictChangesRequested agg.FixCycle = true markRequiresHumanPerspectivesAsChangesRequested(&agg) diff --git a/src/pkg/review/review_test.go b/src/pkg/review/review_test.go index 414d90b666..717eb7a407 100644 --- a/src/pkg/review/review_test.go +++ b/src/pkg/review/review_test.go @@ -807,3 +807,40 @@ func TestAggregateReportsContributorUnbackedDecisionWithChangesRoutesToFixer(t * t.Fatalf("aggregate = %+v, want the sibling change request to route to the fixer, question advisory", got) } } + +// projectbluefin/utah-packages#890: the security review withheld approval on +// a new App credential while intent-alignment asked for a PR-body edit. The +// security hold is the contributor rule's one early exit to a person +// (hivecommons/hive#15640); the sibling change request folded it into the +// fix cycle and the PR went back to its author at 072 instead of 085. +func TestAggregateReportsContributorSecurityHoldSurvivesSiblingChangeRequest(t *testing.T) { + sec := baseReport(PerspectiveSecurity, VerdictRequiresHuman) + sec.Summary = "New App credential minted in a scheduled workflow; a maintainer must confirm the credential choice." + intent := baseReport(PerspectiveIntentAlignment, VerdictChangesRequested, outputschema.Finding{Title: "`Closes #874` contradicts the issue's own handoff", Severity: outputschema.SeverityMedium, ReviewScope: "in-scope"}) + got := AggregateReports([]PerspectiveReport{sec, intent}, AggregateOptions{}) + if got.Verdict != VerdictRequiresHuman || !got.RequiresHuman || got.FixCycle || got.MergeEligible { + t.Fatalf("aggregate = %+v, want the security hold kept for a person", got) + } + if !strings.Contains(got.DecisionFinding, "security review withheld approval") { + t.Fatalf("DecisionFinding = %q, want the security hold named", got.DecisionFinding) + } + if got.Perspectives[PerspectiveSecurity] != VerdictRequiresHuman { + t.Fatalf("perspectives = %v, want the security perspective left as requires_human", got.Perspectives) + } + + // An unbacked requires_human beside a change request still goes to the fixer. + plain := baseReport(PerspectiveIntentAlignment, VerdictRequiresHuman) + plain.Summary = "Unclear whether the groundwork should land before its consumer." + changes := baseReport(PerspectiveCorrectness, VerdictChangesRequested, outputschema.Finding{Title: "nil deref", Severity: outputschema.SeverityMedium, ReviewScope: "in-scope"}) + got = AggregateReports([]PerspectiveReport{plain, changes}, AggregateOptions{}) + if got.Verdict != VerdictChangesRequested || !got.FixCycle || got.RequiresHuman { + t.Fatalf("unbacked aggregate = %+v, want the fixer lane", got) + } + + // The hive's own PR is not under the contributor rule: its fix cycle runs first. + sec.HiveAuthored, intent.HiveAuthored = true, true + got = AggregateReports([]PerspectiveReport{sec, intent}, AggregateOptions{}) + if got.Verdict != VerdictChangesRequested || !got.FixCycle || got.RequiresHuman { + t.Fatalf("hive-authored aggregate = %+v, want the fixer lane", got) + } +}