From 8068dca4641393c03aec12253e7c1195943727f1 Mon Sep 17 00:00:00 2001 From: Claudomator Agent Date: Thu, 9 Jul 2026 03:16:37 +0000 Subject: feat(agentchannel,executor,agentloop): expose acceptance_criteria on spawn_subtask --- internal/executor/channel_test.go | 59 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'internal/executor/channel_test.go') diff --git a/internal/executor/channel_test.go b/internal/executor/channel_test.go index 23f0661..a2e7c70 100644 --- a/internal/executor/channel_test.go +++ b/internal/executor/channel_test.go @@ -338,6 +338,65 @@ func TestStoreChannel_SpawnSubtask_DependsOnDefaultsEmpty(t *testing.T) { } } +// TestStoreChannel_SpawnSubtask_SetsAcceptanceCriteria proves a caller can +// state what a spawned subtask's work must satisfy. +func TestStoreChannel_SpawnSubtask_SetsAcceptanceCriteria(t *testing.T) { + store := &fakeChannelStore{} + ch := newStoreChannel(store, "parent-task-1") + + id, err := ch.SpawnSubtask(context.Background(), agentchannel.SubtaskSpec{ + Name: "step 1", + Instructions: "do the thing", + AcceptanceCriteria: []string{"tests pass", "no new lint warnings"}, + }) + if err != nil { + t.Fatalf("spawn subtask: %v", err) + } + + var got *task.Task + for _, ct := range store.createdTasks { + if ct.ID == id { + got = ct + } + } + if got == nil { + t.Fatal("subtask not found in store.createdTasks") + } + if len(got.AcceptanceCriteria) != 2 || got.AcceptanceCriteria[0] != "tests pass" || got.AcceptanceCriteria[1] != "no new lint warnings" { + t.Errorf("AcceptanceCriteria: want [tests pass, no new lint warnings], got %+v", got.AcceptanceCriteria) + } +} + +// TestStoreChannel_SpawnSubtask_AcceptanceCriteriaDefaultsEmpty proves the +// backward-compatible default: a caller that never sets AcceptanceCriteria +// (every pre-existing caller) gets a child task with none, exactly as before +// this change. +func TestStoreChannel_SpawnSubtask_AcceptanceCriteriaDefaultsEmpty(t *testing.T) { + store := &fakeChannelStore{} + ch := newStoreChannel(store, "parent-task-1") + + id, err := ch.SpawnSubtask(context.Background(), agentchannel.SubtaskSpec{ + Name: "solo step", + Instructions: "do the thing", + }) + if err != nil { + t.Fatalf("spawn subtask: %v", err) + } + + var got *task.Task + for _, ct := range store.createdTasks { + if ct.ID == id { + got = ct + } + } + if got == nil { + t.Fatal("subtask not found in store.createdTasks") + } + if len(got.AcceptanceCriteria) != 0 { + t.Errorf("expected empty AcceptanceCriteria by default, got %v", got.AcceptanceCriteria) + } +} + func TestStoreChannel_RecordProgress_EmitsAgentMessage(t *testing.T) { store := &fakeChannelStore{} ch := newStoreChannel(store, "task-1") -- cgit v1.2.3