From 4271e15c935a085c5a2d28b01a25702db5319bf8 Mon Sep 17 00:00:00 2001 From: James Reilly Date: Fri, 6 Nov 2026 02:16:02 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20keep=20a=20contributor=20?= =?UTF-8?q?PR's=20security=20hold=20when=20a=20sibling=20perspective=20ask?= =?UTF-8?q?s=20for=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On a PR the hive did not author, a security finding is the one early exit to a person while the PR is in CI/Review (hivecommons/hive#15640), and the decision-marker path already keeps a security-backed hold beside a change request. The bare requires_human path did not: any perspective's changes_requested folded the security perspective's requires_human into the fix cycle, so the PR went back to its author. projectbluefin/utah-packages#890 (2026-11-05 21:55): security returned requires_human on a new Mergeraptor App credential, intent-alignment asked to change `Closes #874` to `Refs #874`; the aggregate became changes_requested and the PR sat at stage/072-returned-to-contributor instead of stage/085-needs-decision. The aggregate now stays requires_human with the finding recorded when the contributor rule applies and securityFindingAcross backs the hold; an unbacked requires_human and hive-authored PRs keep the fix cycle. Signed-off-by: James Reilly --- changelog.d/fixed-stage-drift-on-park.md | 1 + src/docs/review-swarm.md | 9 +++++- src/pkg/review/review.go | 15 ++++++++++ src/pkg/review/review_test.go | 37 ++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 changelog.d/fixed-stage-drift-on-park.md 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) + } +}