Require explicit manifest schemas

This commit is contained in:
2026-09-02 11:45:40 +00:00
parent 9679117e94
commit 2cfca710ec
17 changed files with 307 additions and 123 deletions

View File

@@ -11,7 +11,7 @@ import (
const testSemanticDigest = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
func TestSemanticConfigFingerprintRoundTripsAndLegacyRecordsRemainReadable(t *testing.T) {
func TestSemanticConfigFingerprintRoundTripsAndRemainsOptional(t *testing.T) {
ctx := context.Background()
store := &LocalStore{}
dir := t.TempDir()
@@ -47,17 +47,17 @@ func TestSemanticConfigFingerprintRoundTripsAndLegacyRecordsRemainReadable(t *te
t.Fatalf("run fingerprint = %#v", loadedRun.Stages["prepare"].SemanticConfig)
}
legacyPath := filepath.Join(dir, "legacy.json")
legacy := `{"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(legacyPath, []byte(legacy), 0o644); err != nil {
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"}}}`
if err := os.WriteFile(path, []byte(data), 0o644); err != nil {
t.Fatal(err)
}
legacyManifest, err := store.Load(ctx, legacyPath)
loadedWithoutFingerprint, err := store.Load(ctx, path)
if err != nil {
t.Fatal(err)
}
if legacyManifest.Stages["prepare"].SemanticConfig != nil {
t.Fatalf("legacy fingerprint = %#v, want nil", legacyManifest.Stages["prepare"].SemanticConfig)
if loadedWithoutFingerprint.Stages["prepare"].SemanticConfig != nil {
t.Fatalf("fingerprint = %#v, want nil", loadedWithoutFingerprint.Stages["prepare"].SemanticConfig)
}
}