fix(workflow): don't require a PR number for archie's own PRs
stagePRIntake's new missing-PR-number error (7fb1ccd2) fired even when
this stage runs embedded inside StagePRReviewAndOpenPR (archie's own
PRs, Task.Workflow == "implement"), where no PR exists yet and
localPRSource deliberately ignores the number. Scope the error to the
standalone pr-review workflow, which always needs a real, externally-
fetchable pull request.
Caught before this reached main: the existing StagePRReviewAndOpenPR
tests substitute a fake decision-stage list (by design, so they don't
have to script all nine phases' agent calls), so they never exercised
the real stagePRIntake and would not have caught this. Added a test
that calls stagePRIntake directly with Workflow: "implement" and no
PR number, which does.
This commit is contained in:
2 files changed
+25
-1
No files matched your search
@@ -200,10 +200,16 @@ func stagePRIntake() Stage {
|
||||
// not PRNumber directly; the daemon's container-acquisition path
|
||||
// already resolves this before dispatch, but an in-process or
|
||||
// subprocess run that bypasses it still needs it resolved here.
|
||||
// Archie's own PRs (Task.Workflow == "implement", embedding this
|
||||
// stage through StagePRReviewAndOpenPR) legitimately has no PR
|
||||
// number at all -- localPRSource ignores it, since the PR does not
|
||||
// exist yet -- so the missing-number error only applies to the
|
||||
// standalone pr-review workflow, which always needs a real,
|
||||
// externally-fetchable pull request to review.
|
||||
if tc.Task.PRNumber == 0 {
|
||||
tc.Task.PRNumber = tc.Task.EffectivePRNumber()
|
||||
}
|
||||
if tc.Task.PRNumber == 0 {
|
||||
if tc.Task.PRNumber == 0 && tc.Task.Workflow == "pr-review" {
|
||||
return fmt.Errorf("pr-review: no pull request number (set directly or via the pr_number input)")
|
||||
}
|
||||
meta, err := tc.PRSource.Metadata(ctx, tc.Task.Owner, tc.Task.Repo, tc.Task.PRNumber)
|
||||
|
||||
@@ -196,6 +196,24 @@ func TestStagePRIntakeFailsWithNoPRNumberAnywhere(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestStagePRIntakeAllowsNoPRNumberWhenEmbeddedInAnotherWorkflow(t *testing.T) {
|
||||
// Archie's own PRs (StagePRReviewAndOpenPR) embeds this stage inside the
|
||||
// implement workflow, reviewing a change with no PR number yet --
|
||||
// localPRSource ignores the number entirely. The missing-number error
|
||||
// must not fire here, only for the standalone pr-review workflow.
|
||||
tc := baseTaskContext(t)
|
||||
tc.Task.Workflow = "implement"
|
||||
tc.Task.PRNumber = 0
|
||||
tc.PRSource = &fakePRSource{metadata: PRMetadata{Title: "t", Body: "b"}, diff: smallDiff}
|
||||
tc.Agent = &concurrentAgentRunner{byStage: func(string) (agentexec.Result, error) {
|
||||
return captureResult("score_ai_generated", map[string]any{"confidence": 0.1}), nil
|
||||
}}
|
||||
|
||||
if err := stagePRIntake().Run(context.Background(), tc); err != nil {
|
||||
t.Fatalf("intake: %v (archie's own PRs must not require a PR number)", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStagePRAnatomyBuildsSnapshotBlastRadiusAndNarrative(t *testing.T) {
|
||||
tc := baseTaskContext(t)
|
||||
tc.prReview = &prReviewState{
|
||||
|
||||
Reference in new issue
Block a user