56 lines
1.7 KiB
Go
56 lines
1.7 KiB
Go
package cli_test
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.a-wan.net/alan/pipelines/internal/pipeline"
|
|
"git.a-wan.net/alan/pipelines/internal/runinspect"
|
|
)
|
|
|
|
func TestDebugIncludesPinnedDefinitionAndRecordedFailure(t *testing.T) {
|
|
run, store, _ := setup(t)
|
|
ctx := context.Background()
|
|
source := pipeline.Template([]string{"original-worker"}, true)
|
|
if _, err := store.Submit(ctx, "workflow", source); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
items, err := store.List(ctx)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
definition, err := store.Get(ctx, items[0].ID, 1)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
id, _, err := store.CreateRun(ctx, definition, "debug-check", t.TempDir(), false, nil, map[string]any{"prompt": "original task for diagnosis"})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err = store.FinishRun(ctx, id, "failed", "error", "recorded provider failure", nil); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err = store.Submit(ctx, "workflow", pipeline.Template([]string{"new-worker"}, true)); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
output, err := run("debug", fmt.Sprint(id), "--json")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var debug runinspect.Debug
|
|
if err = json.Unmarshal([]byte(output), &debug); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, expected := range []string{"original task for diagnosis", "recorded provider failure", "original-worker", "Exact immutable pipeline definition", "Read-only retained OpenCode evidence retrieved on the execution computer"} {
|
|
if !strings.Contains(debug.Prompt, expected) {
|
|
t.Fatal("missing debug context", expected, debug.Prompt)
|
|
}
|
|
}
|
|
if strings.Contains(debug.Prompt, "new-worker") {
|
|
t.Fatal("debug used latest definition instead of pinned version")
|
|
}
|
|
}
|