From 5264d5d85872f05367f0b62264f563aed0aeb420 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Mon, 28 Sep 2026 17:02:18 +1000 Subject: [PATCH] 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. --- internal/domain/workflow/prreview_stages.go | 8 +++++++- .../domain/workflow/prreview_stages_test.go | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/internal/domain/workflow/prreview_stages.go b/internal/domain/workflow/prreview_stages.go index 12f73ff25..b215d46f7 100644 --- a/internal/domain/workflow/prreview_stages.go +++ b/internal/domain/workflow/prreview_stages.go @@ -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) diff --git a/internal/domain/workflow/prreview_stages_test.go b/internal/domain/workflow/prreview_stages_test.go index 0707c0f61..3166bcee5 100644 --- a/internal/domain/workflow/prreview_stages_test.go +++ b/internal/domain/workflow/prreview_stages_test.go @@ -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{