diff options
Diffstat (limited to 'internal/task/currentattempt_test.go')
| -rw-r--r-- | internal/task/currentattempt_test.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/internal/task/currentattempt_test.go b/internal/task/currentattempt_test.go index 76661d8..58f7b08 100644 --- a/internal/task/currentattempt_test.go +++ b/internal/task/currentattempt_test.go @@ -122,6 +122,45 @@ func TestCurrentAttempt_DependentWithMultipleDependsOn_NotTreatedAsFixAttempt(t } } +// TestCurrentAttempt_DependentWithDifferentRole_NotTreatedAsFixAttempt proves +// a top-level evaluator task depending on a top-level builder task (both with +// ParentTaskID=="") is not mistaken for the builder's fix attempt, because its +// role differs from the builder's. This is the story-orchestrator scenario: +// builder (role="builder") has evaluator dependents (role="evaluator_quality" +// etc.) and later a fix-attempt (role="builder") -- only the fix-attempt must +// be resolved as "next", not the evaluators. +func TestCurrentAttempt_DependentWithDifferentRole_NotTreatedAsFixAttempt(t *testing.T) { + lookup := newFakeLookup() + lookup.tasks["builder"] = &Task{ID: "builder", ParentTaskID: "", Agent: AgentConfig{Role: "builder"}} + lookup.tasks["evaluator"] = &Task{ID: "evaluator", ParentTaskID: "", Agent: AgentConfig{Role: "evaluator_quality"}, DependsOn: []string{"builder"}} + + got, err := CurrentAttempt(lookup, "builder") + if err != nil { + t.Fatalf("CurrentAttempt: %v", err) + } + if got.ID != "builder" { + t.Errorf("got %q, want builder (evaluator with different role must not be treated as a fix attempt)", got.ID) + } +} + +// TestCurrentAttempt_FixAttemptWithSameRole_ResolvedCorrectly proves that a +// fix-attempt task with the same role as the anchor IS resolved as "next", +// even when evaluators with different roles also depend on the anchor. +func TestCurrentAttempt_FixAttemptWithSameRole_ResolvedCorrectly(t *testing.T) { + lookup := newFakeLookup() + lookup.tasks["builder"] = &Task{ID: "builder", ParentTaskID: "", Agent: AgentConfig{Role: "builder"}} + lookup.tasks["evaluator"] = &Task{ID: "evaluator", ParentTaskID: "", Agent: AgentConfig{Role: "evaluator_quality"}, DependsOn: []string{"builder"}} + lookup.tasks["fix1"] = &Task{ID: "fix1", ParentTaskID: "", Agent: AgentConfig{Role: "builder"}, DependsOn: []string{"builder"}} + + got, err := CurrentAttempt(lookup, "builder") + if err != nil { + t.Fatalf("CurrentAttempt: %v", err) + } + if got.ID != "fix1" { + t.Errorf("got %q, want fix1 (same-role fix attempt must be resolved as current)", got.ID) + } +} + func TestCurrentAttempt_UnknownAnchor_ReturnsError(t *testing.T) { lookup := newFakeLookup() if _, err := CurrentAttempt(lookup, "does-not-exist"); err == nil { |
