Delete run manifest domain model
This commit is contained in:
@@ -256,83 +256,6 @@ func TestLoadRejectsInvalidManifest(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalStoreCreateSaveLoadRunManifestRoundTrip(t *testing.T) {
|
||||
store := &LocalStore{}
|
||||
ctx := context.Background()
|
||||
|
||||
run, err := store.CreateRun(
|
||||
ctx,
|
||||
"2026-05-03",
|
||||
"forsaken",
|
||||
"20260517T000000Z-abcdef12",
|
||||
true,
|
||||
[]string{"prepare", "transcribe"},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("CreateRun() error = %v", err)
|
||||
}
|
||||
run.SessionManifestPath = "/var/lib/narratio/work/forsaken/2026-05-03/manifest.json"
|
||||
run.EffectiveConfig = &EffectiveConfigProvenance{
|
||||
SelectedProfile: &SelectedProfileProvenance{Name: "testing", Source: "cli"},
|
||||
EffectiveConfigDigest: "aabbcc",
|
||||
}
|
||||
run.MarkStageRunning("prepare", time.Date(2026, 5, 3, 12, 1, 0, 0, time.UTC))
|
||||
run.MarkStageSucceeded("prepare", time.Date(2026, 5, 3, 12, 2, 0, 0, time.UTC), []ArtifactRecord{
|
||||
{Kind: "input", LocalPath: "inputs/session.yml"},
|
||||
})
|
||||
run.MarkSucceeded(time.Date(2026, 5, 3, 12, 3, 0, 0, time.UTC))
|
||||
|
||||
path := filepath.Join(t.TempDir(), "run-manifest.json")
|
||||
if err := store.SaveRun(ctx, path, run); err != nil {
|
||||
t.Fatalf("SaveRun() error = %v", err)
|
||||
}
|
||||
|
||||
loaded, err := store.LoadRun(ctx, path)
|
||||
if err != nil {
|
||||
t.Fatalf("LoadRun() error = %v", err)
|
||||
}
|
||||
|
||||
if loaded.SessionID != "2026-05-03" {
|
||||
t.Fatalf("SessionID = %q, want %q", loaded.SessionID, "2026-05-03")
|
||||
}
|
||||
if loaded.Campaign != "forsaken" {
|
||||
t.Fatalf("Campaign = %q, want %q", loaded.Campaign, "forsaken")
|
||||
}
|
||||
if loaded.RunID != "20260517T000000Z-abcdef12" {
|
||||
t.Fatalf("RunID = %q, want %q", loaded.RunID, "20260517T000000Z-abcdef12")
|
||||
}
|
||||
if loaded.Status != RunManifestStatusSucceeded {
|
||||
t.Fatalf("Status = %q, want %q", loaded.Status, RunManifestStatusSucceeded)
|
||||
}
|
||||
if loaded.Stages["prepare"] == nil || loaded.Stages["prepare"].Status != StatusSucceeded {
|
||||
t.Fatalf("prepare stage = %#v, want succeeded", loaded.Stages["prepare"])
|
||||
}
|
||||
if loaded.Stages["prepare"].Action != RunStageActionRun {
|
||||
t.Fatalf("prepare action = %q, want %q", loaded.Stages["prepare"].Action, RunStageActionRun)
|
||||
}
|
||||
if loaded.EffectiveConfig == nil || loaded.EffectiveConfig.SelectedProfile == nil || loaded.EffectiveConfig.SelectedProfile.Name != "testing" || loaded.EffectiveConfig.EffectiveConfigDigest != "aabbcc" {
|
||||
t.Fatalf("effective config provenance = %#v", loaded.EffectiveConfig)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadRunRejectsInvalidManifest(t *testing.T) {
|
||||
store := &LocalStore{}
|
||||
ctx := context.Background()
|
||||
|
||||
path := filepath.Join(t.TempDir(), "run-manifest.json")
|
||||
if err := os.WriteFile(path, []byte(`{"schema_version":"narratio.run-manifest.v1","session_id":"2026-05-03","stages":{}}`), 0o644); err != nil {
|
||||
t.Fatalf("WriteFile() error = %v", err)
|
||||
}
|
||||
|
||||
_, err := store.LoadRun(ctx, path)
|
||||
if err == nil {
|
||||
t.Fatal("expected error, got nil")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "run_id is required") {
|
||||
t.Fatalf("error = %q, want run_id validation", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalStoreRejectsUnsupportedSchemaVersions(t *testing.T) {
|
||||
store := &LocalStore{}
|
||||
now := time.Date(2026, 5, 3, 10, 0, 0, 0, time.UTC)
|
||||
@@ -370,32 +293,6 @@ func TestLocalStoreRejectsUnsupportedSchemaVersions(t *testing.T) {
|
||||
},
|
||||
want: "unsupported session manifest schema_version",
|
||||
},
|
||||
{
|
||||
name: "missing run schema",
|
||||
schema: `{"session_id":"session","run_id":"run","created_at":"2026-05-03T10:00:00Z","updated_at":"2026-05-03T10:00:00Z","stages":{}}`,
|
||||
load: func(source *strings.Reader) error {
|
||||
_, err := store.LoadRunReader(context.Background(), source)
|
||||
return err
|
||||
},
|
||||
save: func() error {
|
||||
return store.SaveRun(context.Background(), filepath.Join(t.TempDir(), "run.json"), &RunManifest{SessionID: "session", RunID: "run", CreatedAt: now, UpdatedAt: now, Stages: map[string]*RunStageRecord{}})
|
||||
},
|
||||
want: "run manifest schema_version is required",
|
||||
},
|
||||
{
|
||||
name: "unknown run schema",
|
||||
schema: `{"schema_version":"narratio.run-manifest.v99","session_id":"session","run_id":"run","created_at":"2026-05-03T10:00:00Z","updated_at":"2026-05-03T10:00:00Z","stages":{}}`,
|
||||
load: func(source *strings.Reader) error {
|
||||
_, err := store.LoadRunReader(context.Background(), source)
|
||||
return err
|
||||
},
|
||||
save: func() error {
|
||||
m := NewRun("session", "", "run", false, nil, now)
|
||||
m.SchemaVersion = "narratio.run-manifest.v99"
|
||||
return store.SaveRun(context.Background(), filepath.Join(t.TempDir(), "run.json"), m)
|
||||
},
|
||||
want: "unsupported run manifest schema_version",
|
||||
},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
if err := test.load(strings.NewReader(test.schema)); err == nil || !strings.Contains(err.Error(), test.want) {
|
||||
|
||||
Reference in New Issue
Block a user