Files
pipelines/internal/server/turn_failure_test.go
T
alan c2b992542b Tell the next stage what failed when an error edge leads onward
A failed visit was recorded on its step only, so a landing gate that sent
the run back to implement gave the implementer nothing about which checks
failed. The diagnostic (bounded) is now the next stage's previous output
and a memory entry.
2026-11-11 00:39:36 +00:00

42 lines
1.5 KiB
Go

package server
import (
"strings"
"testing"
"git.a-wan.net/alan/pipelines/internal/protocol"
)
// A failed stage whose error edge leads to another stage (a landing gate that
// sends the run back to implement) must tell that stage what failed.
func TestRecordFailureCarriesTheDiagnosticToTheNextStage(t *testing.T) {
state := &runState{prompt: "Do the task", visits: map[string]int{"land": 1}}
state.recordFailure(protocol.RunStep{
Stage: "land",
Outcome: "error",
Status: "failed",
Diagnostic: "delivery check \"tool/test\" failed: exit status 1: FAILED test/a_test.dart: reads the row",
})
if len(state.turns) != 1 || state.turns[0].Stage != "land" || state.turns[0].Outcome != "error" || state.turns[0].Visit != 1 {
t.Fatalf("turns = %+v", state.turns)
}
input := state.turnInput()
for _, want := range []string{"Do the task", "The land stage failed", "FAILED test/a_test.dart: reads the row"} {
if !strings.Contains(input, want) {
t.Errorf("next input lacks %q:\n%s", want, input)
}
}
}
func TestRecordFailureBoundsTheDiagnostic(t *testing.T) {
state := &runState{visits: map[string]int{}}
state.recordFailure(protocol.RunStep{Stage: "land", Outcome: "error", Diagnostic: "first failure\n" + strings.Repeat("x", 3*maxFailureDetail)})
output := state.turns[0].Output
if len(output) > maxFailureDetail+400 {
t.Fatalf("output is %d bytes", len(output))
}
if !strings.Contains(output, "first failure") || !strings.Contains(output, "[truncated]") {
t.Fatalf("output = %.200s", output)
}
}