fix(workflow): deliver the feasibility PRD to the forge issue
The deliver stage's notify() returned early when [notify].webhook was unset, so a parked feasibility PRD left the process nowhere while both its doc comments promised an issue comment that was never posted. A default deployment sets no webhook: the PRD reached only the operator who went looking. notify now posts a one-way delivery notice on the task's forge issue before the webhook, for a forge-backed task. The issue is the channel a default deployment always has; the webhook remains an additional push. Neither is a reply channel -- the decision surfaces stay chat and the Web UI, so the notice carries the PRD and names where to decide rather than inviting a reply, and no reply cursor is recorded (WatchCommentID stays 0). Both stale doc comments now describe what the code does.
This commit is contained in:
1 parent
9c0ac87ecf
commit
a7f17e4e55
2 files changed
+80
-9
No files matched your search
@@ -13,11 +13,12 @@ import (
|
||||
|
||||
// Feasibility is the feature-request workflow: assess the request
|
||||
// against the project's direction, close it with reasons when it
|
||||
// doesn't fit, otherwise produce a PRD, deliver it to Sam (issue
|
||||
// comment + notify webhook), and hand the task to waiting_human. The
|
||||
// daemon watches for Sam's reply and -- LLM-judged, not keyword-matched --
|
||||
// requeues approved features under the implement workflow or closes
|
||||
// rejected ones. Routed via the "feature" label.
|
||||
// doesn't fit, otherwise produce a PRD, post a one-way delivery notice
|
||||
// on the issue (plus the notify webhook when configured), and hand the
|
||||
// task to waiting_human. The operator answers in chat or on the
|
||||
// dashboard -- the decision surfaces -- and the approval requeues the
|
||||
// feature under the implement workflow or closes it. Routed via the
|
||||
// "feature" label.
|
||||
func Feasibility() Workflow {
|
||||
return Workflow{
|
||||
Name: "feasibility",
|
||||
@@ -93,7 +94,9 @@ func Feasibility() Workflow {
|
||||
}.Stage(),
|
||||
|
||||
// Persist the PRD and block on Sam. Messaging and the Web UI are
|
||||
// the decision surfaces; the forge issue is not a chat log.
|
||||
// the decision surfaces, so the issue gets a one-way delivery
|
||||
// notice (notify) rather than a reply channel: the wait is
|
||||
// channel-neutral, and the forge issue is not a chat log.
|
||||
{Name: "deliver", Run: func(ctx context.Context, tc *TaskContext) error {
|
||||
notify(ctx, tc, "feasibility_prd")
|
||||
// The approval handoff is a workflow change, not a payload
|
||||
@@ -136,10 +139,24 @@ func decideCaptureTools(*TaskContext) []agentexec.CaptureTool {
|
||||
}}
|
||||
}
|
||||
|
||||
// notify POSTs a JSON payload to the configured webhook (n8n turns it
|
||||
// into an email). Best-effort: failures log, the issue comment is the
|
||||
// authoritative channel.
|
||||
// notify delivers a human-facing event to the channels a default deployment
|
||||
// has. A forge-backed task gets a one-way notice on its issue -- the channel
|
||||
// that always exists when [notify].webhook is unset -- and the webhook is an
|
||||
// additional push (n8n turns it into an email). Both are best-effort and log
|
||||
// on failure: the PRD is persisted on the task and rendered by the Web UI, so
|
||||
// a transport error must not mask the delivery decision or re-run the agent
|
||||
// stages that produced it.
|
||||
//
|
||||
// The issue notice is one-way. Messaging and the Web UI are the decision
|
||||
// surfaces; the issue is not a chat log, and notify records no reply cursor
|
||||
// on it.
|
||||
func notify(ctx context.Context, tc *TaskContext, kind string) {
|
||||
if tc.Task.IsForgeBacked() {
|
||||
if _, err := tc.Forge.Comment(ctx, tc.Task.Owner, tc.Task.Repo, tc.Task.IssueNumber, deliveryNotice(tc, kind)); err != nil {
|
||||
tc.Log.Warn("delivery notice not posted",
|
||||
"kind", kind, "issue", tc.Task.IssueNumber, "err", err)
|
||||
}
|
||||
}
|
||||
url := tc.Cfg.Notify.Webhook
|
||||
if url == "" {
|
||||
return
|
||||
@@ -172,3 +189,15 @@ func notify(ctx context.Context, tc *TaskContext, kind string) {
|
||||
tc.Log.Warn("close notify webhook response", "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
// deliveryNotice is the body of the one-way notice notify posts on a
|
||||
// forge-backed task's issue. It carries the PRD because the issue is the
|
||||
// durable record of the request, and points at the decision surfaces so the
|
||||
// notice is not read as an invitation to reply there.
|
||||
func deliveryNotice(tc *TaskContext, kind string) string {
|
||||
subject := "archie finished a run that needs you"
|
||||
if kind == "feasibility_prd" {
|
||||
subject = "archie's PRD is ready -- awaiting your go/no-go"
|
||||
}
|
||||
return fmt.Sprintf("**%s.**\n\n%s\n\n_Decide in chat or on the dashboard._", subject, tc.Task.Plan)
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package workflow
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestFeasibilityDeliverNotifiesTheIssueWithoutAWebhook pins archie-core-y1kh.
|
||||
// notify returned early when [notify].webhook was unset, so a parked PRD left
|
||||
// the process nowhere and the issue comment both doc comments promised was
|
||||
// never posted. The deliver stage must post the PRD to the forge issue -- the
|
||||
// one notification channel a default deployment has -- with no webhook set.
|
||||
func TestFeasibilityDeliverNotifiesTheIssueWithoutAWebhook(t *testing.T) {
|
||||
forgeClient := &fakeForge{}
|
||||
tc := &TaskContext{
|
||||
Task: &Task{
|
||||
ID: 7, Owner: "acme", Repo: "widget", IssueNumber: 42,
|
||||
Title: "Add CSV export", Plan: "PRD: export the task list as CSV.", Source: SourceForge,
|
||||
},
|
||||
Forge: forgeClient,
|
||||
Log: slog.New(slog.DiscardHandler),
|
||||
// Cfg.Notify.Webhook is deliberately empty: the default deployment.
|
||||
}
|
||||
|
||||
if err := Feasibility().Stages[3].Run(context.Background(), tc); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(forgeClient.commented) != 1 {
|
||||
t.Fatalf("issue comments = %d, want exactly 1 delivery notice with no webhook configured", len(forgeClient.commented))
|
||||
}
|
||||
if !strings.Contains(forgeClient.commented[0], tc.Task.Plan) {
|
||||
t.Errorf("delivery notice does not carry the PRD:\n%s", forgeClient.commented[0])
|
||||
}
|
||||
if tc.Task.WatchCommentID != 0 {
|
||||
t.Errorf("delivery notice recorded a reply cursor (WatchCommentID = %d): the issue is a delivery channel, not a reply channel", tc.Task.WatchCommentID)
|
||||
}
|
||||
if tc.Outcome.Status != StatusWaitingHuman {
|
||||
t.Errorf("outcome = %q, want %q", tc.Outcome.Status, StatusWaitingHuman)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user