Use canonical source identities in publication reports
This commit is contained in:
@@ -326,6 +326,12 @@ publication protocol to obtain this improvement.
|
|||||||
|
|
||||||
## 8. P2: Use canonical publication sources in session reports
|
## 8. P2: Use canonical publication sources in session reports
|
||||||
|
|
||||||
|
Status: Completed. Inspection canonicalizes each source once for the report and
|
||||||
|
all evidence lookups, preserving the authored configuration. A regression using
|
||||||
|
real loading, validation, and publication planning failed for an accepted spaced
|
||||||
|
source before the fix and now passes alongside its unspaced control. Carried-key,
|
||||||
|
lock/outcome, partial-failure, and read-only inspection tests pass.
|
||||||
|
|
||||||
Stage: 12; assembled correctness verification in Stage 21.
|
Stage: 12; assembled correctness verification in Stage 21.
|
||||||
|
|
||||||
Location: `internal/app/session_state_command.go:256–270`.
|
Location: `internal/app/session_state_command.go:256–270`.
|
||||||
|
|||||||
@@ -14,6 +14,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"
|
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
|
||||||
|
"gitea.maximumdirect.net/eric/narratio/internal/stage"
|
||||||
"go.maximumdirect.net/commandkit"
|
"go.maximumdirect.net/commandkit"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
@@ -224,3 +225,43 @@ func TestSessionStateCommandsLeaveManifestUnchanged(t *testing.T) {
|
|||||||
t.Fatal("inspection mutated remote state or downloaded payloads")
|
t.Fatal("inspection mutated remote state or downloaded payloads")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPublishedOutputInspectionNormalizesAcceptedSources(t *testing.T) {
|
||||||
|
const canonical = "narratio.transcript.final_trimmed"
|
||||||
|
for _, source := range []string{canonical, " " + canonical + " "} {
|
||||||
|
t.Run(source, func(t *testing.T) {
|
||||||
|
pipeline, campaign, session := writeValidConfigFiles(t, t.TempDir())
|
||||||
|
addPublishOutputsToPipeline(t, pipeline, " outputs:\n - source: \""+source+"\"\n dest: transcripts/full.json\n")
|
||||||
|
cfg, err := config.LoadWithSessionOptions(pipeline, campaign, session, config.SessionLoadOptions{})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := config.Validate(cfg); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
actions, err := stage.PlanPublicationOutputs(nil, cfg.PublicationOutputs(), nil)
|
||||||
|
if err != nil || len(actions) != 1 || actions[0].Source != canonical {
|
||||||
|
t.Fatalf("publication actions=%#v err=%v", actions, err)
|
||||||
|
}
|
||||||
|
fake := &storage.FakeBackend{}
|
||||||
|
current := seedCommittedRestoreSnapshot(t, cfg, fake, "20260519T010203Z-a1b2c3d4", map[string][]byte{"transcripts/full.json": []byte("published\n")})
|
||||||
|
declaration := ¤t.Commit.Artifacts[1]
|
||||||
|
declaration.Source = canonical
|
||||||
|
current.Manifest.Stages["publish"] = &manifest.StageRecord{
|
||||||
|
Name: "publish", Status: manifest.StatusSucceeded,
|
||||||
|
Metadata: map[string]any{"publish_output_outcomes": []any{map[string]any{"source": canonical, "status": "carried_locked"}}},
|
||||||
|
}
|
||||||
|
outputs, err := inspectPublishedOutputs(context.Background(), cfg, fake, nil, current, []artifacts.RemoteLock{{Source: canonical}}, true, "current")
|
||||||
|
if err != nil || len(outputs) != 1 {
|
||||||
|
t.Fatalf("outputs=%#v err=%v", outputs, err)
|
||||||
|
}
|
||||||
|
output := outputs[0]
|
||||||
|
if output.Source != canonical || output.State != "published" || output.LockState != "locked" || output.Outcome != "carried_locked" || output.DeclaredKey != declaration.DestinationKey || output.OriginRun != current.RunID {
|
||||||
|
t.Fatalf("accepted source lost publication evidence: %#v", output)
|
||||||
|
}
|
||||||
|
if cfg.PublicationOutputs()[0].Source != source {
|
||||||
|
t.Fatal("inspection mutated the source declaration")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -261,9 +261,10 @@ func inspectPublishedOutputs(ctx context.Context, cfg *config.Config, store stor
|
|||||||
}
|
}
|
||||||
var resultErr error
|
var resultErr error
|
||||||
for _, rule := range rules {
|
for _, rule := range rules {
|
||||||
destination, err := artifactpolicy.ResolvePublishedDestinationWithExtractions(strings.TrimSpace(rule.Source), rule.Dest, configuredOutputs, extractionOutputs)
|
source := strings.TrimSpace(rule.Source)
|
||||||
_, isLocked := locked[rule.Source]
|
destination, err := artifactpolicy.ResolvePublishedDestinationWithExtractions(source, rule.Dest, configuredOutputs, extractionOutputs)
|
||||||
output := sessionPublishedOutput{Source: rule.Source, Destination: destination, Required: rule.Required == nil || *rule.Required, LockState: "unknown", State: "missing", Outcome: outcomes[rule.Source]}
|
_, isLocked := locked[source]
|
||||||
|
output := sessionPublishedOutput{Source: source, Destination: destination, Required: rule.Required == nil || *rule.Required, LockState: "unknown", State: "missing", Outcome: outcomes[source]}
|
||||||
if locksKnown {
|
if locksKnown {
|
||||||
output.LockState = "unlocked"
|
output.LockState = "unlocked"
|
||||||
if isLocked {
|
if isLocked {
|
||||||
@@ -274,7 +275,7 @@ func inspectPublishedOutputs(ctx context.Context, cfg *config.Config, store stor
|
|||||||
output.State = "error"
|
output.State = "error"
|
||||||
}
|
}
|
||||||
if err == nil && current != nil && current.Commit != nil {
|
if err == nil && current != nil && current.Commit != nil {
|
||||||
if declaration, ok := declarations[rule.Source]; ok {
|
if declaration, ok := declarations[source]; ok {
|
||||||
identity, identityErr := artifacts.ParsePublishedOutputObjectKey(current.SessionPrefix, declaration.DestinationKey)
|
identity, identityErr := artifacts.ParsePublishedOutputObjectKey(current.SessionPrefix, declaration.DestinationKey)
|
||||||
if identityErr != nil {
|
if identityErr != nil {
|
||||||
err = identityErr
|
err = identityErr
|
||||||
|
|||||||
Reference in New Issue
Block a user