Remove legacy manifest provenance decoding
All checks were successful
ci/woodpecker/push/verify Pipeline was successful

This commit is contained in:
2026-09-25 19:45:19 +00:00
parent 73c4986f3d
commit b750c42ad6
7 changed files with 73 additions and 39 deletions

View File

@@ -1,7 +1,6 @@
package manifest
import (
"encoding/json"
"strings"
"time"
@@ -76,18 +75,6 @@ type EffectiveConfigProvenance struct {
EffectiveConfigDigest string `json:"effective_config_digest,omitempty"`
}
// UnmarshalJSON accepts unknown informational provenance from older manifests.
// The enclosing manifest and its execution state remain strictly decoded.
func (p *EffectiveConfigProvenance) UnmarshalJSON(data []byte) error {
type provenance EffectiveConfigProvenance
var decoded provenance
if err := json.Unmarshal(data, &decoded); err != nil {
return err
}
*p = EffectiveConfigProvenance(decoded)
return nil
}
// SelectedOverlayProvenance identifies an explicitly or default-selected
// pipeline overlay without recording overlay content.
type SelectedOverlayProvenance struct {

View File

@@ -75,18 +75,19 @@ func TestLocalStoreCreateSaveLoadRoundTrip(t *testing.T) {
}
}
func TestLocalStoreLoadsManifestWithHistoricalSelectionProvenance(t *testing.T) {
path := filepath.Join(t.TempDir(), "manifest.json")
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":{"selected_profile":{"name":"testing","source":"explicit"},"effective_config_digest":"001122"},"stages":{}}`
if err := os.WriteFile(path, []byte(data), 0o600); err != nil {
t.Fatal(err)
}
loaded, err := (&LocalStore{}).Load(context.Background(), path)
if err != nil {
t.Fatal(err)
}
if loaded.EffectiveConfig == nil || loaded.EffectiveConfig.EffectiveConfigDigest != "001122" || loaded.EffectiveConfig.SelectedOverlay != nil {
t.Fatalf("historical informational provenance = %#v", loaded.EffectiveConfig)
func TestLocalStoreRejectsUnknownProvenanceFields(t *testing.T) {
for _, tc := range []struct{ name, provenance, field string }{
{"retired selection", `{"selected_profile":{"name":"testing","source":"explicit"}}`, "selected_profile"},
{"unknown provenance", `{"unexpected":true}`, "unexpected"},
{"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":{}}`
_, 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)
}
})
}
}