Reject unsupported session state before execution and restore

This commit is contained in:
2026-11-29 23:57:16 +00:00
parent 8bc3ae56cb
commit 816453b444
16 changed files with 172 additions and 49 deletions

View File

@@ -178,7 +178,7 @@ Artifacts package owns shared remote current-state loading mechanics used by
restore, status and validation checks, and previous-cache planning. restore, status and validation checks, and previous-cache planning.
The selected session manifest is accepted only with The selected session manifest is accepted only with
`schema_version: narratio.session-manifest.v1` and complete stage identity. `schema_version: narratio.session-manifest.v2` and complete stage identity.
An unsupported local or downloaded manifest must be replaced by regeneration, An unsupported local or downloaded manifest must be replaced by regeneration,
verified restore, or republication; artifact resolution never fills in missing verified restore, or republication; artifact resolution never fills in missing
authority markers. authority markers.

View File

@@ -10,7 +10,7 @@ manifest placement belongs in
`manifest.Manifest` records: `manifest.Manifest` records:
- required `schema_version: narratio.session-manifest.v1` - required `schema_version: narratio.session-manifest.v2`
- identity (`session_id`, `campaign`, `run_id`) - identity (`session_id`, `campaign`, `run_id`)
- local path metadata (`local_workdir`, `local_spool_dir`) - local path metadata (`local_workdir`, `local_spool_dir`)
- remote identity metadata (`s3_bucket`, `s3_session_prefix`, `s3_run_prefix`) - remote identity metadata (`s3_bucket`, `s3_session_prefix`, `s3_run_prefix`)
@@ -24,17 +24,17 @@ guidance rather than being normalized into a different workspace or remote
namespace. namespace.
Decoding rejects unknown typed fields, including informational fields inside Decoding rejects unknown typed fields, including informational fields inside
`effective_config` and its nested selection. The schema version remains `effective_config` and its nested selection. The schema version is
`narratio.session-manifest.v1`; there is no compatibility reader that silently `narratio.session-manifest.v2`; there is no compatibility reader that silently
drops retired fields. See [overlay migration](../operations.md#migrating-manifest-overlay-provenance) drops retired fields. See [overlay provenance](../operations.md#migrating-manifest-overlay-provenance)
for deliberate migration of retired selection provenance. Cleanup progress uses for handling retired selection provenance. Cleanup progress uses only the
only the cleanup entry in `stages`. cleanup entry in `stages`.
Every persisted session manifest has a non-nil `stages` map. Each entry is Every persisted session manifest has a non-nil `stages` map. Each entry is
non-nil and its embedded `name` exactly matches its map key; loading never non-nil and its embedded `name` exactly matches its map key; loading never
invents either marker. A missing or unsupported schema version, or incomplete invents either marker. A missing or unsupported schema version, or incomplete
stage identity, is unsupported local state: move it aside and regenerate it, stage identity, is unsupported local state: move it aside before regenerating it
or restore a verified current committed snapshot when that is authoritative. or restoring a supported committed snapshot when that is authoritative.
Prepare records independent `party` and `players` input checksums. In canonical Prepare records independent `party` and `players` input checksums. In canonical
party mode, the party record retains its campaign source identity while the party mode, the party record retains its campaign source identity while the
@@ -86,10 +86,8 @@ from reviving pre-force results.
Older aggregate-only transcribe success is conservatively regenerated once Older aggregate-only transcribe success is conservatively regenerated once
when transcribe is selected because it does not bind individual outputs to the when transcribe is selected because it does not bind individual outputs to the
audio bytes used. The session-manifest schema identifier remains audio bytes used. The transcribe subcollection has its own version independent
`narratio.session-manifest.v1`; this additive state is accepted by current of the session-manifest marker.
Narratio, but older strict-decoding binaries may reject manifests after these
fields have been written.
### Analyze-owned artifact state ### Analyze-owned artifact state

View File

@@ -465,27 +465,10 @@ later extraction actually runs.
## Migrating Manifest Overlay Provenance ## Migrating Manifest Overlay Provenance
The pipeline-selection rename is a clean cutover. Manifests containing Manifests containing `effective_config.selected_profile` are rejected by strict
`effective_config.selected_profile` are rejected by strict decoding; Narratio decoding. Historical session state is not converted in place; move it aside and
does not silently discard or translate that retired field. regenerate the session using the supported format. Do not edit immutable remote
snapshots.
Before using an affected local session with the new version:
1. Stop Narratio activity for the session and back up its manifest.
2. Rename only `effective_config.selected_profile` to `selected_overlay`, keeping
its `name` and `source`, or remove the retired informational member. If a
current `selected_overlay` member already exists, retain it and remove the
retired member rather than creating duplicate keys.
3. Preserve the schema version, digest, stage records, checkpoint evidence,
output references, and other session state. Retry the intended command.
This metadata is informational, not resume authority. Do not delete session
progress or force all stages merely to perform this migration. Other unknown
fields still require investigation rather than blanket removal.
Do not edit immutable remote committed snapshots. Restoring an older snapshot
with retired provenance requires a compatible previous Narratio version, followed
by migration of the restored local manifest before using the new version.
## Migrating Audita and Provider Credentials ## Migrating Audita and Provider Credentials
@@ -732,10 +715,10 @@ Durable session paths:
- `cache/notarius/references/<sha256>/<prepared-basename>` - `cache/notarius/references/<sha256>/<prepared-basename>`
`manifest.json` is the versioned session-progress document. Narratio accepts `manifest.json` is the versioned session-progress document. Narratio accepts
only `narratio.session-manifest.v1`. Do not edit unsupported session state to only `narratio.session-manifest.v2`. Do not edit unsupported session state to
add missing markers. Move it aside and regenerate it, restore a verified add missing markers. Move unsupported local state aside before regenerating it
current committed snapshot, or republish healthy regenerated state as the or restoring a supported committed snapshot. Republish regenerated state when
relevant workflow requires. the remote snapshot is unsupported.
Validated Notarius bundles live below `artifacts/notarius/{run_id}/`; receipt, Validated Notarius bundles live below `artifacts/notarius/{run_id}/`; receipt,
stderr, and pre-promotion output remain in the producing run's `extract` stderr, and pre-promotion output remain in the producing run's `extract`

View File

@@ -120,6 +120,12 @@ Use local synthetic fixtures; no sibling checkout is needed by default tests.
## Stage 2 — Establish the supported-state boundary ## Stage 2 — Establish the supported-state boundary
**Complete.** Commit: `Reject unsupported session state before execution and restore`.
Verification: `go test ./internal/app ./internal/manifest ./internal/artifacts
./internal/doccheck` with Go 1.27.4 passed, including forced local and remote
rejection without session-file mutation. Remote discovery uses the existing
strict manifest loader before planning.
**Read:** roadmap “One cutover and durable-state boundary”; **Read:** roadmap “One cutover and durable-state boundary”;
[Manifest Internals](../internal/manifest.md) and [Manifest Internals](../internal/manifest.md) and
[Restore Internals](../internal/command-restore.md). Entry points: [Restore Internals](../internal/command-restore.md). Entry points:

View File

@@ -7,6 +7,7 @@ import (
"gitea.maximumdirect.net/eric/narratio/internal/artifacts" "gitea.maximumdirect.net/eric/narratio/internal/artifacts"
"gitea.maximumdirect.net/eric/narratio/internal/config" "gitea.maximumdirect.net/eric/narratio/internal/config"
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
"go.maximumdirect.net/commandkit" "go.maximumdirect.net/commandkit"
) )
@@ -59,6 +60,10 @@ func restoreSessionState(ctx context.Context, cfg *config.Config, opts RestorePl
if err != nil { if err != nil {
return diagnostic, fmt.Errorf("restore: %w", err) return diagnostic, fmt.Errorf("restore: %w", err)
} }
manifestPath := artifacts.SessionManifestPathForCampaign(cfg.Pipeline.Workspace.Root, cfg.Session.Campaign, cfg.Session.SessionID)
if _, _, err := loadManifestAtPathIfPresent(ctx, &manifest.LocalStore{}, manifestPath); err != nil {
return diagnostic, fmt.Errorf("restore: %w", err)
}
if opts.DryRun { if opts.DryRun {
plan, err := deps.buildRestorePlan(ctx, cfg, current, objectStore, RestorePlanOptions{ plan, err := deps.buildRestorePlan(ctx, cfg, current, objectStore, RestorePlanOptions{
IncludeAudio: opts.IncludeAudio, IncludeAudio: opts.IncludeAudio,
@@ -97,6 +102,9 @@ func restoreSessionState(ctx context.Context, cfg *config.Config, opts RestorePl
} }
} }
}() }()
if _, _, err := loadManifestAtPathIfPresent(ctx, &manifest.LocalStore{}, manifestPath); err != nil {
return diagnostic, fmt.Errorf("restore: %w", err)
}
// Classification and installation share the same transition lock as a // Classification and installation share the same transition lock as a
// runner. This prevents a runner from making reuse decisions against state // runner. This prevents a runner from making reuse decisions against state

View File

@@ -21,7 +21,7 @@ func TestDiscoverRemoteCurrentStateRequiresCommittedPointer(t *testing.T) {
func restoreManifestJSON(t *testing.T, sessionID, campaign string) []byte { func restoreManifestJSON(t *testing.T, sessionID, campaign string) []byte {
t.Helper() t.Helper()
now := time.Date(2026, 5, 19, 23, 0, 0, 0, time.UTC).Format(time.RFC3339Nano) now := time.Date(2026, 5, 19, 23, 0, 0, 0, time.UTC).Format(time.RFC3339Nano)
data, err := json.Marshal(map[string]any{"schema_version": "narratio.session-manifest.v1", "session_id": sessionID, "campaign": campaign, "run_id": "20260519T010203Z-a1b2c3d4", "created_at": now, "updated_at": now, "stages": map[string]any{}}) data, err := json.Marshal(map[string]any{"schema_version": "narratio.session-manifest.v2", "session_id": sessionID, "campaign": campaign, "run_id": "20260519T010203Z-a1b2c3d4", "created_at": now, "updated_at": now, "stages": map[string]any{}})
if err != nil { if err != nil {
t.Fatalf("marshal manifest: %v", err) t.Fatalf("marshal manifest: %v", err)
} }

View File

@@ -18,6 +18,91 @@ import (
"gitea.maximumdirect.net/eric/narratio/internal/manifest" "gitea.maximumdirect.net/eric/narratio/internal/manifest"
) )
func TestExecuteRestoreRejectsUnsupportedRemoteState(t *testing.T) {
for _, marker := range []string{"narratio.session-manifest.v1", "", "narratio.session-manifest.v99"} {
t.Run(marker, func(t *testing.T) {
root := t.TempDir()
pipeline, campaign, session := writeValidConfigFiles(t, root)
fake := &storage.FakeBackend{}
cfg, _, _, _ := seedRestoreCommittedState(t, fake, pipeline, campaign, session)
current := seedCommittedRestoreSnapshot(t, cfg, fake, "20260519T010203Z-a1b2c3d4", nil)
old := fake.Objects[current.CurrentManifestKey].Data
data := bytes.Replace(old, []byte("narratio.session-manifest.v2"), []byte(marker), 1)
if marker == "" {
data = bytes.Replace(data, []byte(`"schema_version":"",`), nil, 1)
}
fake.SeedObject(storage.FakeObject{Key: current.CurrentManifestKey, Data: data})
for i := range current.Commit.Artifacts {
if current.Commit.Artifacts[i].Type == artifacts.RemoteArtifactTypeSessionManifest {
current.Commit.Artifacts[i] = remoteRestoreArtifact(fake, artifacts.RemoteArtifactTypeSessionManifest, "session.manifest", current.CurrentManifestKey)
}
}
commitData, err := artifacts.EncodeRemoteCommitManifest(*current.Commit)
if err != nil {
t.Fatal(err)
}
commitKey := artifacts.S3RunCommitKey(current.SessionPrefix, current.RunID)
fake.SeedObject(storage.FakeObject{Key: commitKey, Data: commitData})
pointerData, err := artifacts.EncodeCurrentCommitPointer(artifacts.CurrentCommitPointer{FormatVersion: artifacts.RemoteCommitFormatVersion, Campaign: cfg.Session.Campaign, SessionID: cfg.Session.SessionID, RunID: current.RunID, CommitKey: commitKey, CommitSHA256: restoreCommitSHA256(commitData), CommitSize: int64(len(commitData)), CommitGeneration: fake.Objects[commitKey].ETag})
if err != nil {
t.Fatal(err)
}
fake.SeedObject(storage.FakeObject{Key: artifacts.S3CurrentCommitPointerKey(current.SessionPrefix), Data: pointerData})
var stdout, stderr bytes.Buffer
code := restoreCommandExecutor(fake)([]string{"session", "restore", cfg.Session.SessionID, "--config", pipeline, "--campaign-file", campaign, "--session-file", session, "--force"}, &stdout, &stderr)
if code == 0 || !strings.Contains(stderr.String(), "schema_version") {
t.Fatalf("exit %d, stderr %q", code, stderr.String())
}
path := artifacts.SessionWorkDirForCampaign(root, cfg.Session.Campaign, cfg.Session.SessionID)
if _, err := os.Stat(path); !os.IsNotExist(err) {
t.Fatalf("session root exists after failed discovery: %v", err)
}
})
}
}
func TestExecuteRestoreRejectsUnsupportedLocalStateEvenWithForce(t *testing.T) {
for _, marker := range []string{"narratio.session-manifest.v1", "", "narratio.session-manifest.v99"} {
t.Run(marker, func(t *testing.T) {
root := t.TempDir()
pipeline, campaign, session := writeValidConfigFiles(t, root)
fake := &storage.FakeBackend{}
cfg, _, _, _ := seedRestoreCommittedState(t, fake, pipeline, campaign, session)
seedCommittedRestoreSnapshot(t, cfg, fake, "20260519T010203Z-a1b2c3d4", nil)
path := artifacts.SessionManifestPathForCampaign(root, cfg.Session.Campaign, cfg.Session.SessionID)
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
t.Fatal(err)
}
data := bytes.Replace(restoreManifestJSON(t, cfg.Session.SessionID, cfg.Session.Campaign), []byte("narratio.session-manifest.v2"), []byte(marker), 1)
if marker == "" {
data = bytes.Replace(data, []byte(`,"schema_version":""`), nil, 1)
}
if err := os.WriteFile(path, data, 0o644); err != nil {
t.Fatal(err)
}
var stdout, stderr bytes.Buffer
code := restoreCommandExecutor(fake)([]string{"session", "restore", cfg.Session.SessionID, "--config", pipeline, "--campaign-file", campaign, "--session-file", session, "--force"}, &stdout, &stderr)
if code == 0 {
t.Fatal("expected restore failure")
}
after, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(after, data) {
t.Fatal("manifest changed")
}
entries, err := os.ReadDir(filepath.Dir(path))
if err != nil {
t.Fatal(err)
}
if len(entries) != 1 || entries[0].Name() != "manifest.json" {
t.Fatalf("session files changed: %v", entries)
}
})
}
}
func TestExecuteRestoreNonDryRunRestoresDurableFiles(t *testing.T) { func TestExecuteRestoreNonDryRunRestoresDurableFiles(t *testing.T) {
workspaceRoot := t.TempDir() workspaceRoot := t.TempDir()
pipelinePath, campaignPath, sessionPath := writeValidConfigFiles(t, workspaceRoot) pipelinePath, campaignPath, sessionPath := writeValidConfigFiles(t, workspaceRoot)

View File

@@ -51,6 +51,11 @@ func executePlanWithDependencies(ctx context.Context, cfg *config.Config, plan B
if err != nil { if err != nil {
return nil, err return nil, err
} }
// Reject unsupported existing state before creating or normalizing layout.
// The locked initialization reads it again to protect against concurrent work.
if _, _, err := loadManifestAtPathIfPresent(ctx, &manifest.LocalStore{}, runtime.manifestPath); err != nil {
return nil, err
}
if err := prepareInvocationLayout(runtime); err != nil { if err := prepareInvocationLayout(runtime); err != nil {
return nil, err return nil, err
} }

View File

@@ -1,6 +1,7 @@
package app package app
import ( import (
"bytes"
"context" "context"
"encoding/json" "encoding/json"
"errors" "errors"
@@ -887,6 +888,43 @@ func TestExecuteStagesFailureUpdatesManifest(t *testing.T) {
} }
} }
func TestExecuteStagesRejectsUnsupportedSessionWithoutMutation(t *testing.T) {
for _, marker := range []string{"narratio.session-manifest.v1", "", "narratio.session-manifest.v99"} {
t.Run(marker, func(t *testing.T) {
cfg := testConfig(t)
path := manifestPathFor(cfg)
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
t.Fatal(err)
}
data := []byte(fmt.Sprintf(`{"schema_version":%q,"session_id":"%s","created_at":"2026-05-03T10:00:00Z","updated_at":"2026-05-03T10:00:00Z","stages":{}}`, marker, cfg.Session.SessionID))
if marker == "" {
data = bytes.Replace(data, []byte(`"schema_version":"",`), nil, 1)
}
if err := os.WriteFile(path, data, 0o644); err != nil {
t.Fatal(err)
}
_, err := executeStages(context.Background(), cfg, []stage.Stage{BuildFullPlan()[0]}, RunOptions{Force: true})
if err == nil {
t.Fatal("expected unsupported state error")
}
after, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(after, data) {
t.Fatal("manifest changed")
}
entries, err := os.ReadDir(filepath.Dir(path))
if err != nil {
t.Fatal(err)
}
if len(entries) != 1 || entries[0].Name() != "manifest.json" {
t.Fatalf("session files changed: %v", entries)
}
})
}
}
func TestExecuteStagesLoadsExistingManifest(t *testing.T) { func TestExecuteStagesLoadsExistingManifest(t *testing.T) {
cfg := testConfig(t) cfg := testConfig(t)
manifestPath := manifestPathFor(cfg) manifestPath := manifestPathFor(cfg)

View File

@@ -31,7 +31,7 @@ func testManifestJSON(t *testing.T, sessionID, campaign, runID string) []byte {
t.Helper() t.Helper()
now := time.Date(2026, 5, 19, 23, 0, 0, 0, time.UTC).Format(time.RFC3339Nano) now := time.Date(2026, 5, 19, 23, 0, 0, 0, time.UTC).Format(time.RFC3339Nano)
data, err := json.Marshal(map[string]any{ data, err := json.Marshal(map[string]any{
"schema_version": "narratio.session-manifest.v1", "session_id": sessionID, "schema_version": "narratio.session-manifest.v2", "session_id": sessionID,
"campaign": campaign, "run_id": runID, "created_at": now, "updated_at": now, "campaign": campaign, "run_id": runID, "created_at": now, "updated_at": now,
"stages": map[string]any{}, "stages": map[string]any{},
}) })

View File

@@ -153,7 +153,7 @@ func TestAnalyzeStageRequiresCurrentPerArtifactAuthority(t *testing.T) {
now := time.Date(2026, 5, 3, 10, 0, 0, 0, time.UTC) now := time.Date(2026, 5, 3, 10, 0, 0, 0, time.UTC)
store := &LocalStore{} store := &LocalStore{}
aggregateOnly := `{ aggregateOnly := `{
"schema_version": "narratio.session-manifest.v1", "schema_version": "narratio.session-manifest.v2",
"session_id": "session", "session_id": "session",
"created_at": "2026-05-03T10:00:00Z", "created_at": "2026-05-03T10:00:00Z",
"updated_at": "2026-05-03T10:01:00Z", "updated_at": "2026-05-03T10:01:00Z",

View File

@@ -12,7 +12,7 @@ import (
func TestLocalStoreRejectsUnsafeLegacyIdentity(t *testing.T) { func TestLocalStoreRejectsUnsafeLegacyIdentity(t *testing.T) {
now := time.Now().UTC() now := time.Now().UTC()
path := filepath.Join(t.TempDir(), "manifest.json") path := filepath.Join(t.TempDir(), "manifest.json")
data := []byte(`{"schema_version":"narratio.session-manifest.v1","session_id":"../escape","campaign":"campaign","created_at":"` + now.Format(time.RFC3339Nano) + `","updated_at":"` + now.Format(time.RFC3339Nano) + `","stages":{}}`) data := []byte(`{"schema_version":"narratio.session-manifest.v2","session_id":"../escape","campaign":"campaign","created_at":"` + now.Format(time.RFC3339Nano) + `","updated_at":"` + now.Format(time.RFC3339Nano) + `","stages":{}}`)
if err := os.WriteFile(path, data, 0o600); err != nil { if err := os.WriteFile(path, data, 0o600); err != nil {
t.Fatalf("WriteFile() error = %v", err) t.Fatalf("WriteFile() error = %v", err)
} }

View File

@@ -10,7 +10,7 @@ import (
const ( const (
// SessionManifestSchemaVersion identifies the only supported durable session // SessionManifestSchemaVersion identifies the only supported durable session
// manifest representation. // manifest representation.
SessionManifestSchemaVersion = "narratio.session-manifest.v1" SessionManifestSchemaVersion = "narratio.session-manifest.v2"
) )
// ErrorRecord captures structured error metadata at run or stage scope. // ErrorRecord captures structured error metadata at run or stage scope.

View File

@@ -33,7 +33,7 @@ func TestSemanticConfigFingerprintRoundTripsAndRemainsOptional(t *testing.T) {
} }
path := filepath.Join(dir, "without-fingerprint.json") path := filepath.Join(dir, "without-fingerprint.json")
data := `{"schema_version":"narratio.session-manifest.v1","session_id":"session","created_at":"2026-01-01T00:00:00Z","updated_at":"2026-01-01T00:00:00Z","stages":{"prepare":{"name":"prepare","status":"succeeded","created_at":"2026-01-01T00:00:00Z","updated_at":"2026-01-01T00:00:00Z"}}}` data := `{"schema_version":"narratio.session-manifest.v2","session_id":"session","created_at":"2026-01-01T00:00:00Z","updated_at":"2026-01-01T00:00:00Z","stages":{"prepare":{"name":"prepare","status":"succeeded","created_at":"2026-01-01T00:00:00Z","updated_at":"2026-01-01T00:00:00Z"}}}`
if err := os.WriteFile(path, []byte(data), 0o644); err != nil { if err := os.WriteFile(path, []byte(data), 0o644); err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@@ -82,7 +82,7 @@ func TestLocalStoreRejectsUnknownProvenanceFields(t *testing.T) {
{"unknown selection field", `{"selected_overlay":{"name":"testing","source":"explicit","unexpected":true}}`, "unexpected"}, {"unknown selection field", `{"selected_overlay":{"name":"testing","source":"explicit","unexpected":true}}`, "unexpected"},
} { } {
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
data := `{"schema_version":"narratio.session-manifest.v1","session_id":"2026-05-03","created_at":"2026-05-03T10:00:00Z","updated_at":"2026-05-03T10:00:00Z","effective_config":` + tc.provenance + `,"stages":{}}` data := `{"schema_version":"narratio.session-manifest.v2","session_id":"2026-05-03","created_at":"2026-05-03T10:00:00Z","updated_at":"2026-05-03T10:00:00Z","effective_config":` + tc.provenance + `,"stages":{}}`
_, err := (&LocalStore{}).LoadReader(context.Background(), strings.NewReader(data)) _, err := (&LocalStore{}).LoadReader(context.Background(), strings.NewReader(data))
if err == nil || !strings.Contains(err.Error(), tc.field) { if err == nil || !strings.Contains(err.Error(), tc.field) {
t.Fatalf("expected rejection identifying %q, got %v", tc.field, err) t.Fatalf("expected rejection identifying %q, got %v", tc.field, err)
@@ -97,7 +97,7 @@ func TestLocalStorePreservesOptionalArtifactMetadata(t *testing.T) {
dir := t.TempDir() dir := t.TempDir()
path := filepath.Join(dir, "manifest.json") path := filepath.Join(dir, "manifest.json")
data := `{ data := `{
"schema_version": "narratio.session-manifest.v1", "schema_version": "narratio.session-manifest.v2",
"session_id": "2026-05-03", "session_id": "2026-05-03",
"created_at": "2026-05-03T10:00:00Z", "created_at": "2026-05-03T10:00:00Z",
"updated_at": "2026-05-03T10:01:00Z", "updated_at": "2026-05-03T10:01:00Z",
@@ -260,7 +260,7 @@ func TestLoadRejectsInvalidManifest(t *testing.T) {
ctx := context.Background() ctx := context.Background()
path := filepath.Join(t.TempDir(), "manifest.json") path := filepath.Join(t.TempDir(), "manifest.json")
if err := os.WriteFile(path, []byte(`{"schema_version":"narratio.session-manifest.v1","updated_at":"2026-05-03T10:00:00Z","stages":{}}`), 0o644); err != nil { if err := os.WriteFile(path, []byte(`{"schema_version":"narratio.session-manifest.v2","updated_at":"2026-05-03T10:00:00Z","stages":{}}`), 0o644); err != nil {
t.Fatalf("WriteFile() error = %v", err) t.Fatalf("WriteFile() error = %v", err)
} }
@@ -275,7 +275,7 @@ func TestLoadRejectsInvalidManifest(t *testing.T) {
func TestLocalStoreRejectsRetiredCleanupFieldAndRoundTripsCanonicalV1(t *testing.T) { func TestLocalStoreRejectsRetiredCleanupFieldAndRoundTripsCanonicalV1(t *testing.T) {
store := &LocalStore{} store := &LocalStore{}
canonical := `{"schema_version":"narratio.session-manifest.v1","session_id":"2026-05-03","created_at":"2026-05-03T10:00:00Z","updated_at":"2026-05-03T10:01:00Z","stages":{}}` canonical := `{"schema_version":"narratio.session-manifest.v2","session_id":"2026-05-03","created_at":"2026-05-03T10:00:00Z","updated_at":"2026-05-03T10:01:00Z","stages":{}}`
loaded, err := store.LoadReader(context.Background(), strings.NewReader(canonical)) loaded, err := store.LoadReader(context.Background(), strings.NewReader(canonical))
if err != nil { if err != nil {

View File

@@ -65,7 +65,7 @@ func TestTranscribeSpeakerStateRoundTripsPopulatedAndVersionedEmptyCollections(t
func TestTranscribeSpeakerStateAllowsLegacyAggregateOnlyManifest(t *testing.T) { func TestTranscribeSpeakerStateAllowsLegacyAggregateOnlyManifest(t *testing.T) {
legacy := `{ legacy := `{
"schema_version": "narratio.session-manifest.v1", "schema_version": "narratio.session-manifest.v2",
"session_id": "session", "session_id": "session",
"created_at": "2026-09-21T12:00:00Z", "created_at": "2026-09-21T12:00:00Z",
"updated_at": "2026-09-21T12:01:00Z", "updated_at": "2026-09-21T12:01:00Z",