package server import ( "testing" "git.a-wan.net/alan/pipelines/internal/protocol" "git.a-wan.net/alan/pipelines/internal/stage" ) // TestResumedRunStatePublishesPersistedCapturedPaths proves the field is rebuilt // from every persisted completed step's captured paths (rebuildRunState → // recordChanges), deduplicated and first-seen-ordered, so a resumed run keeps the // same server evidence available to any stage that still asks for it. func TestResumedRunStatePublishesPersistedCapturedPaths(t *testing.T) { detail := &protocol.RunDetail{Input: map[string]any{"prompt": "task"}} detail.Steps = []protocol.RunStep{ {Sequence: 1, Stage: "implementer", Status: "completed", Output: stage.Values{"changed_files": []any{"a.go"}}, FileChanges: &protocol.StageFileChanges{Files: []protocol.FileChange{{Path: "a.go"}, {Path: "a.go"}, {Path: "b.go"}}}}, {Sequence: 2, Stage: "reviewer", Status: "completed", Output: stage.Values{}, FileChanges: &protocol.StageFileChanges{Files: []protocol.FileChange{{Path: "b.go"}, {Path: "c.go"}}}}, } state := rebuildRunState(detail, protocol.RunStep{Target: "committer", Output: stage.Values{}}) state.publishServerChangedFiles() got, ok := state.memory["input"].output[serverChangedFilesField].([]string) if !ok { t.Fatalf("resumed input memory has no %s list: %v", serverChangedFilesField, state.memory["input"].output) } want := []string{"a.go", "b.go", "c.go"} if len(got) != len(want) { t.Fatalf("captured paths = %v, want %v", got, want) } for i := range want { if got[i] != want[i] { t.Fatalf("captured paths = %v, want first-seen %v", got, want) } } }