* refactor(workflow,store): relocate Task/Status/Source and define workflow.Store Move store.Task, store.Status*/store.Source*, and the 3-method workflow store interface out of internal/store into internal/domain/workflow as workflow.Task/workflow.Status/workflow.Source plus a consumer-owned workflow.Store, superseding store.WorkflowStore. internal/domain/workflow now imports zero internal/store symbols; internal/store persists the domain type instead (infrastructure depends on domain), and its Store satisfies workflow.Store. Updates every production and test caller of the relocated symbols across daemon, webui, gateway, agentworker, agenttransport/nats, storerpc, taskrun, and worktreerpc, and removes TestRecordDispatchViaExplicitTx per docs/prds/state-store-contract.md (rev. 2c) sections 4 and 12 step 2. Two workflow-package integration tests that exercise the real *store.Store move to an external workflow_test package (store_integration_test.go) to avoid a workflow(test)->store->workflow(prod) import cycle now that store depends on workflow. * no-mistakes(document): docs(state-store): mark §4.8 relocation done in state-store-contract
82 lines
2.5 KiB
Go
82 lines
2.5 KiB
Go
package store
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/samcharles93/archie-core/internal/domain/workflow"
|
|
)
|
|
|
|
// Tasks() is what the dashboard's task list is built from, and the UI reads
|
|
// two fields the query never selected: Plan, which gates the "Decision
|
|
// required" panel on a waiting_human task, and Source, which decides whether
|
|
// to render a forge issue link at all.
|
|
//
|
|
// Both came back as the zero value, so the panel could never appear and a
|
|
// chat-sourced task -- whose issue_number is synthetic -- rendered a link to
|
|
// an issue that does not exist. Neither failed loudly; the features were
|
|
// simply dead.
|
|
func TestTasksSelectsFieldsTheUIReads(t *testing.T) {
|
|
ctx := context.Background()
|
|
s := OpenTest(t)
|
|
t.Cleanup(func() { _ = s.Close() })
|
|
|
|
if _, err := s.EnqueueIssue(ctx, "o", "r", 7, "forge task", "body", "", ""); err != nil {
|
|
t.Fatalf("EnqueueIssue: %v", err)
|
|
}
|
|
forgeTaskRow, err := s.TaskByIssue(ctx, "o", "r", 7)
|
|
if err != nil || forgeTaskRow == nil {
|
|
t.Fatalf("TaskByIssue: %v", err)
|
|
}
|
|
forgeID := forgeTaskRow.ID
|
|
|
|
chatTaskRow, err := s.EnqueueChatTask(ctx, "o", "r", "chat task", "body", "", "")
|
|
if err != nil {
|
|
t.Fatalf("EnqueueChatTask: %v", err)
|
|
}
|
|
chatID := chatTaskRow.ID
|
|
|
|
// A plan is what an operator approves or rejects, so it has to survive
|
|
// the read the approval UI is built on.
|
|
const plan = "1. add the thing\n2. test the thing"
|
|
forgeTaskRow.Plan = plan
|
|
if err := s.Update(ctx, forgeTaskRow); err != nil {
|
|
t.Fatalf("Update: %v", err)
|
|
}
|
|
|
|
tasks, err := s.Tasks(ctx, 50)
|
|
if err != nil {
|
|
t.Fatalf("Tasks: %v", err)
|
|
}
|
|
|
|
byID := make(map[int64]workflow.Task, len(tasks))
|
|
for _, task := range tasks {
|
|
byID[task.ID] = task
|
|
}
|
|
|
|
forgeTask, ok := byID[forgeID]
|
|
if !ok {
|
|
t.Fatalf("forge task %d missing from Tasks()", forgeID)
|
|
}
|
|
if forgeTask.Plan != plan {
|
|
t.Errorf("Plan = %q, want %q: the approval panel is gated on this and "+
|
|
"can never render while it is empty", forgeTask.Plan, plan)
|
|
}
|
|
if forgeTask.Source != workflow.SourceForge {
|
|
t.Errorf("Source = %q, want %q", forgeTask.Source, workflow.SourceForge)
|
|
}
|
|
|
|
chatTask, ok := byID[chatID]
|
|
if !ok {
|
|
t.Fatalf("chat task %d missing from Tasks()", chatID)
|
|
}
|
|
if chatTask.Source != workflow.SourceChat {
|
|
t.Errorf("Source = %q, want %q: without it the UI links a synthetic "+
|
|
"issue number to a forge issue that does not exist",
|
|
chatTask.Source, workflow.SourceChat)
|
|
}
|
|
if chatTask.IsForgeBacked() {
|
|
t.Error("IsForgeBacked() is true for a chat task read through Tasks()")
|
|
}
|
|
}
|