feat(prreview): the operator-approval gate is PRReview's own stage-list entry
prReviewDecisionStages loses the withOperatorApproval flag: the shared list the implement workflow splices (archie-core-afbk.7) never carries the gate, and the standalone pipeline inserts it itself, immediately before its merge gate (docs/prds/pr-review-operator-response.md, "The gate is not reachable from archie's own PRs"). A structural test pins both directions so a future edit cannot re-share the gate.
This commit is contained in:
1 parent
678bf82961
commit
97a81dcc63
4 files changed
+64
-23
No files matched your search
@@ -29,7 +29,7 @@ func ReviewPullRequest(ctx context.Context, tc *TaskContext) (PRReviewDecision,
|
||||
_ = os.RemoveAll(tc.prReview.snapshotDir)
|
||||
}
|
||||
}()
|
||||
for _, stage := range prReviewDecisionStages(false) {
|
||||
for _, stage := range prReviewDecisionStages() {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return PRReviewDecision{}, err
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ func renderBlockingFindingsDetail(findings []prreview.ScoredFinding) string {
|
||||
// spliced in as their own preceding stages -- OpenPR's own doc comment names
|
||||
// this exact pattern ("call this and then do so in the same stage").
|
||||
func StagePRReviewAndOpenPR(body func(*TaskContext) string) Stage {
|
||||
return stagePRReviewAndOpenPR(prReviewDecisionStages(false), body)
|
||||
return stagePRReviewAndOpenPR(prReviewDecisionStages(), body)
|
||||
}
|
||||
|
||||
// stagePRReviewAndOpenPR is StagePRReviewAndOpenPR's implementation, taking
|
||||
|
||||
@@ -148,6 +148,11 @@ const prReviewConcurrency = 8
|
||||
// archie-core-afbk.8 adds the precision dial (between review and
|
||||
// verification) and the operator-approval gate (between synthesis and the
|
||||
// merge gate), both off by default and each gated by its own config flag.
|
||||
//
|
||||
// The operator-approval gate is this workflow's OWN stage-list entry, not a
|
||||
// shared one (docs/prds/pr-review-operator-response.md): the implement
|
||||
// workflow splices the shared decision stages, and a gate there would end an
|
||||
// implement run before its PR exists.
|
||||
func PRReview() Workflow {
|
||||
return Workflow{
|
||||
Name: "pr-review",
|
||||
@@ -163,28 +168,40 @@ func PRReview() Workflow {
|
||||
"depth": {Type: "string"},
|
||||
},
|
||||
},
|
||||
Stages: append(prReviewDecisionStages(true), stagePROutput()),
|
||||
Stages: prReviewStandaloneStages(),
|
||||
}
|
||||
}
|
||||
|
||||
// prReviewDecisionStages is phases 1 through 8: everything up to and
|
||||
// including the merge gate's blocking/advisory verdict, but before phase 9
|
||||
// posts anything. Split out from PRReview so the implement workflow can
|
||||
// splice it in before StageOpenPR (archie-core-afbk.7's "archie's own PRs"
|
||||
// trigger): the decision of whether an unchallenged blocking finding parks
|
||||
// the task must happen before a PR exists to post to, while phase 9's
|
||||
// posting must happen after, once a PR number exists to anchor comments to.
|
||||
//
|
||||
// withOperatorApproval splices the operator-approval gate in between
|
||||
// synthesis and the merge gate. Only the standalone pr-review workflow passes
|
||||
// true: there the operator's response re-reviews the pull request, and the
|
||||
// run is re-entered from the start anyway, which is safe because that
|
||||
// pipeline has no write-then-close stage. Archie's own PRs has no PR to give
|
||||
// the operator a posting decision about yet, and a park there would end the
|
||||
// implement run before it opened one (archie-core-7nst), so the splice drops
|
||||
// the gate instead.
|
||||
func prReviewDecisionStages(withOperatorApproval bool) []Stage {
|
||||
stages := []Stage{
|
||||
// posts anything, and WITHOUT the operator-approval gate. Split out from
|
||||
// PRReview so the implement workflow can splice it in before StageOpenPR
|
||||
// (archie-core-afbk.7's "archie's own PRs" trigger) -- and so the operator
|
||||
// gate can never ride along on that splice
|
||||
// (docs/prds/pr-review-operator-response.md, "The gate is not reachable from
|
||||
// archie's own PRs"): there the gate's question (which findings to post) has
|
||||
// no pull request to post to yet, and a park would end the implement run
|
||||
// before it opened one (archie-core-7nst).
|
||||
func prReviewDecisionStages() []Stage {
|
||||
return append(prReviewPipelineStages(), stagePRMergeGate())
|
||||
}
|
||||
|
||||
// prReviewStandaloneStages is the standalone pr-review workflow's full stage
|
||||
// list: the shared decision phases with the operator-approval gate inserted
|
||||
// between synthesis and the merge gate -- the gate runs before the merge
|
||||
// gate's verdict, so an operator's re-review never has to undo one computed
|
||||
// on a since-changed finding set -- followed by phase 9's posting.
|
||||
func prReviewStandaloneStages() []Stage {
|
||||
pipeline := prReviewPipelineStages()
|
||||
stages := make([]Stage, 0, len(pipeline)+3)
|
||||
stages = append(stages, pipeline...)
|
||||
return append(stages, stagePROperatorApproval(), stagePRMergeGate(), stagePROutput())
|
||||
}
|
||||
|
||||
// prReviewPipelineStages is phases 1 through 7: intake through synthesis, the
|
||||
// stages every pr-review trigger shares.
|
||||
func prReviewPipelineStages() []Stage {
|
||||
return []Stage{
|
||||
stagePRIntake(),
|
||||
stagePRAnatomy(),
|
||||
stagePRLenses(),
|
||||
@@ -194,10 +211,6 @@ func prReviewDecisionStages(withOperatorApproval bool) []Stage {
|
||||
stagePRCoverageConsistency(),
|
||||
stagePRSynthesis(),
|
||||
}
|
||||
if withOperatorApproval {
|
||||
stages = append(stages, stagePROperatorApproval())
|
||||
}
|
||||
return append(stages, stagePRMergeGate())
|
||||
}
|
||||
|
||||
// stagePRIntake is pipeline phase 1: PR metadata and diff statistics, the
|
||||
|
||||
@@ -2,6 +2,7 @@ package workflow
|
||||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/agentexec"
|
||||
@@ -90,6 +91,33 @@ func TestStagePRPrecisionGateRunsNoAgentCallWhenNoFindings(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestOperatorApprovalGateLeavesTheSharedDecisionStages pins the PRD's
|
||||
// structural guarantee (docs/prds/pr-review-operator-response.md, "The gate
|
||||
// is not reachable from archie's own PRs"): the shared decision-stage list
|
||||
// the implement workflow's splice takes never carries the gate, and the
|
||||
// standalone pipeline adds it itself, immediately before its merge gate.
|
||||
// A future edit that re-shares the gate would let an approval re-enter the
|
||||
// implement workflow against a worktree that already carries the change,
|
||||
// whose no-changes build closes the issue with no PR ever opened.
|
||||
func TestOperatorApprovalGateLeavesTheSharedDecisionStages(t *testing.T) {
|
||||
names := func(stages []Stage) []string {
|
||||
out := make([]string, len(stages))
|
||||
for i, s := range stages {
|
||||
out[i] = s.Name
|
||||
}
|
||||
return out
|
||||
}
|
||||
shared := names(prReviewDecisionStages())
|
||||
if slices.Contains(shared, "operator-approval") {
|
||||
t.Fatalf("shared decision stages = %v: the gate belongs in PRReview()'s own stage list, not in the list the implement workflow splices", shared)
|
||||
}
|
||||
standalone := names(PRReview().Stages)
|
||||
gate, mergeGate := slices.Index(standalone, "operator-approval"), slices.Index(standalone, "merge-gate")
|
||||
if gate < 0 || mergeGate < 0 || gate+1 != mergeGate {
|
||||
t.Fatalf("pr-review stages = %v, want operator-approval immediately before merge-gate", standalone)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStagePROperatorApprovalWaitsWhenConfiguredAndFindingsExist(t *testing.T) {
|
||||
tc := baseTaskContext(t)
|
||||
tc.Cfg.Review.ApproveBeforePost = true
|
||||
|
||||
Reference in new issue
Block a user