Reject unsupported session state before execution and restore
This commit is contained in:
@@ -153,7 +153,7 @@ func TestAnalyzeStageRequiresCurrentPerArtifactAuthority(t *testing.T) {
|
||||
now := time.Date(2026, 5, 3, 10, 0, 0, 0, time.UTC)
|
||||
store := &LocalStore{}
|
||||
aggregateOnly := `{
|
||||
"schema_version": "narratio.session-manifest.v1",
|
||||
"schema_version": "narratio.session-manifest.v2",
|
||||
"session_id": "session",
|
||||
"created_at": "2026-05-03T10:00:00Z",
|
||||
"updated_at": "2026-05-03T10:01:00Z",
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
func TestLocalStoreRejectsUnsafeLegacyIdentity(t *testing.T) {
|
||||
now := time.Now().UTC()
|
||||
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 {
|
||||
t.Fatalf("WriteFile() error = %v", err)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
const (
|
||||
// SessionManifestSchemaVersion identifies the only supported durable session
|
||||
// manifest representation.
|
||||
SessionManifestSchemaVersion = "narratio.session-manifest.v1"
|
||||
SessionManifestSchemaVersion = "narratio.session-manifest.v2"
|
||||
)
|
||||
|
||||
// ErrorRecord captures structured error metadata at run or stage scope.
|
||||
|
||||
@@ -33,7 +33,7 @@ func TestSemanticConfigFingerprintRoundTripsAndRemainsOptional(t *testing.T) {
|
||||
}
|
||||
|
||||
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 {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ func TestLocalStoreRejectsUnknownProvenanceFields(t *testing.T) {
|
||||
{"unknown selection field", `{"selected_overlay":{"name":"testing","source":"explicit","unexpected":true}}`, "unexpected"},
|
||||
} {
|
||||
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))
|
||||
if err == nil || !strings.Contains(err.Error(), tc.field) {
|
||||
t.Fatalf("expected rejection identifying %q, got %v", tc.field, err)
|
||||
@@ -97,7 +97,7 @@ func TestLocalStorePreservesOptionalArtifactMetadata(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "manifest.json")
|
||||
data := `{
|
||||
"schema_version": "narratio.session-manifest.v1",
|
||||
"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",
|
||||
@@ -260,7 +260,7 @@ func TestLoadRejectsInvalidManifest(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ func TestLoadRejectsInvalidManifest(t *testing.T) {
|
||||
|
||||
func TestLocalStoreRejectsRetiredCleanupFieldAndRoundTripsCanonicalV1(t *testing.T) {
|
||||
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))
|
||||
if err != nil {
|
||||
|
||||
@@ -65,7 +65,7 @@ func TestTranscribeSpeakerStateRoundTripsPopulatedAndVersionedEmptyCollections(t
|
||||
|
||||
func TestTranscribeSpeakerStateAllowsLegacyAggregateOnlyManifest(t *testing.T) {
|
||||
legacy := `{
|
||||
"schema_version": "narratio.session-manifest.v1",
|
||||
"schema_version": "narratio.session-manifest.v2",
|
||||
"session_id": "session",
|
||||
"created_at": "2026-09-21T12:00:00Z",
|
||||
"updated_at": "2026-09-21T12:01:00Z",
|
||||
|
||||
Reference in New Issue
Block a user