diff --git a/internal/domain/workflow/implement.go b/internal/domain/workflow/implement.go index 55f005fdd..32e79ef1d 100644 --- a/internal/domain/workflow/implement.go +++ b/internal/domain/workflow/implement.go @@ -202,10 +202,10 @@ func Implement() Workflow { // not full price. When the adversarial review ran, its findings section is // appended so the PR states what the reviewer checked and found (h019.6). func implementPRBody(tc *TaskContext) string { - body := fmt.Sprintf("%s\n\n---\n*workflow: implement · %d iterations · %s*", - tc.BuildSummary, tc.Task.Iterations, formatTokenUsage(tc.Task.TokensUsed, tc.RunUsage)) + summary := tc.BuildSummary if section := renderPRReviewSection(tc.ReviewReport); section != "" { - body += "\n\n" + section + summary += "\n\n" + section } - return body + return fmt.Sprintf("%s\n\n---\n*workflow: implement · %d iterations · %s*", + summary, tc.Task.Iterations, formatTokenUsage(tc.Task.TokensUsed, tc.RunUsage)) } diff --git a/internal/domain/workflow/review_surface_test.go b/internal/domain/workflow/review_surface_test.go index b931b7849..f4ab109a3 100644 --- a/internal/domain/workflow/review_surface_test.go +++ b/internal/domain/workflow/review_surface_test.go @@ -85,3 +85,22 @@ func TestImplementPRBodyCarriesZeroFindingSection(t *testing.T) { t.Fatalf("PR body lost the build summary:\n%s", body) } } + +// TestStageReviewStashesReportForPRBody pins the integration between +// StageReview and implementPRBody: a passing review must land on +// tc.ReviewReport, or the PR body silently omits the findings section +// (renderPRReviewSection returns "" for a zero-value report). +func TestStageReviewStashesReportForPRBody(t *testing.T) { + tc, _ := reviewTaskContext(t, true) + tc.Reviewer = &fakeReviewer{report: NewCompletedReviewReport(nil, "clean")} + + if err := StageReview().Run(t.Context(), tc); err != nil { + t.Fatalf("StageReview().Run() error = %v", err) + } + if !tc.ReviewReport.Ran() { + t.Fatal("ReviewReport not stashed after a passing review; the PR body would omit the findings section") + } + if tc.ReviewReport.Status != ReviewStatusCompleted { + t.Errorf("ReviewReport.Status = %q, want %q", tc.ReviewReport.Status, ReviewStatusCompleted) + } +}