Keep source provenance out of prepare reuse decisions
This commit is contained in:
@@ -141,6 +141,13 @@ materialization in finding 1.
|
|||||||
|
|
||||||
## 4. P2: Keep party-selection provenance out of prepare resume identity
|
## 4. P2: Keep party-selection provenance out of prepare resume identity
|
||||||
|
|
||||||
|
Status: Completed. Prepare's versioned semantic projection excludes stable-input
|
||||||
|
ownership labels; provenance remains available in source records. Native planning
|
||||||
|
and execution regressions retain identical prepared checksums and downstream
|
||||||
|
success for default/explicit selection of the same roster, and invalidate work
|
||||||
|
for changed roster contents. Focused resume and semantic tests pass under race
|
||||||
|
detection.
|
||||||
|
|
||||||
Stages: 4–7, 10–11, and 21.
|
Stages: 4–7, 10–11, and 21.
|
||||||
|
|
||||||
Locations: `internal/config/party_resolution.go:70–81`,
|
Locations: `internal/config/party_resolution.go:70–81`,
|
||||||
|
|||||||
90
internal/app/party_selection_resume_test.go
Normal file
90
internal/app/party_selection_resume_test.go
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
package app
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"reflect"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
|
||||||
|
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
|
||||||
|
"go.maximumdirect.net/commandkit"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestEquivalentPartySelectionPreservesPreparedWork(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
root := t.TempDir()
|
||||||
|
pipeline, campaign, session := writeValidConfigFiles(t, root)
|
||||||
|
selection := []string{"--stage", "prepare", "--config", pipeline, "--campaign-file", campaign, "--session-file", session, "--format", "json"}
|
||||||
|
invoke := func(command []string, result any) {
|
||||||
|
t.Helper()
|
||||||
|
var out, diagnostic bytes.Buffer
|
||||||
|
outcome := Execute(ctx, command, commandkit.Streams{Out: &out, Err: &diagnostic})
|
||||||
|
if outcome.Status != 0 {
|
||||||
|
t.Fatalf("%v: status=%d diagnostics=%s", command, outcome.Status, &diagnostic)
|
||||||
|
}
|
||||||
|
if err := json.Unmarshal(out.Bytes(), result); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var run runReport
|
||||||
|
invoke(append([]string{"run", "2026-05-03"}, selection...), &run)
|
||||||
|
path := artifacts.SessionManifestPathForCampaign(root, "sample-campaign", "2026-05-03")
|
||||||
|
store := &manifest.LocalStore{}
|
||||||
|
before, err := store.Load(ctx, path)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
before.MarkStageSucceeded("transcribe", time.Now().UTC(), nil)
|
||||||
|
if err := store.Save(ctx, path, before); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
checksums := func(m *manifest.Manifest) map[string]string {
|
||||||
|
result := map[string]string{}
|
||||||
|
for _, input := range m.Inputs {
|
||||||
|
result[input.Kind+"\x00"+input.Path] = input.Checksum
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
partyPath := filepath.Join(filepath.Dir(campaign), "party.yml")
|
||||||
|
selection = append(selection, "--party-file", partyPath)
|
||||||
|
var plan sessionPlanReport
|
||||||
|
invoke(append([]string{"session", "plan", "2026-05-03"}, selection...), &plan)
|
||||||
|
if len(plan.Stages) != 1 || plan.Stages[0].Action != string(stageActionSkip) {
|
||||||
|
t.Fatalf("equivalent roster plan=%#v", plan)
|
||||||
|
}
|
||||||
|
invoke(append([]string{"run", "2026-05-03"}, selection...), &run)
|
||||||
|
after, err := store.Load(ctx, path)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(run.Executed) != 0 || after.Stages["transcribe"].Status != manifest.StatusSucceeded || !reflect.DeepEqual(checksums(before), checksums(after)) {
|
||||||
|
t.Fatalf("equivalent selection reran work: report=%#v transcription=%v", run, after.Stages["transcribe"].Status)
|
||||||
|
}
|
||||||
|
party, err := os.ReadFile(partyPath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
changed := strings.Replace(string(party), "Arannis", "Arannis Changed", 1)
|
||||||
|
if changed == string(party) {
|
||||||
|
t.Fatal("fixture did not contain the expected character")
|
||||||
|
}
|
||||||
|
mustWriteTestFile(t, partyPath, changed)
|
||||||
|
invoke(append([]string{"session", "plan", "2026-05-03"}, selection...), &plan)
|
||||||
|
if len(plan.Stages) != 1 || plan.Stages[0].Action != string(stageActionRun) {
|
||||||
|
t.Fatalf("changed roster plan=%#v", plan)
|
||||||
|
}
|
||||||
|
invoke(append([]string{"run", "2026-05-03"}, selection...), &run)
|
||||||
|
after, err = store.Load(ctx, path)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(run.Executed) != 1 || after.Stages["transcribe"].Status != manifest.StatusStale || reflect.DeepEqual(checksums(before), checksums(after)) {
|
||||||
|
t.Fatalf("changed roster retained old work: report=%#v transcription=%v", run, after.Stages["transcribe"].Status)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
prepareSemanticConfigVersion = 2
|
prepareSemanticConfigVersion = 3
|
||||||
transcribeSemanticConfigVersion = 1
|
transcribeSemanticConfigVersion = 1
|
||||||
mergeSemanticConfigVersion = 1
|
mergeSemanticConfigVersion = 1
|
||||||
)
|
)
|
||||||
@@ -36,7 +36,6 @@ type prepareAudioSelection struct {
|
|||||||
|
|
||||||
type prepareStableInputSelection struct {
|
type prepareStableInputSelection struct {
|
||||||
Kind string `json:"kind"`
|
Kind string `json:"kind"`
|
||||||
Source string `json:"source"`
|
|
||||||
Present bool `json:"present"`
|
Present bool `json:"present"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,15 +159,12 @@ func prepareStableInputSemantics(cfg *config.Config) []prepareStableInputSelecti
|
|||||||
}
|
}
|
||||||
|
|
||||||
func prepareStableInput(kind string, resolved config.ResolvedInputFile, fallback string) prepareStableInputSelection {
|
func prepareStableInput(kind string, resolved config.ResolvedInputFile, fallback string) prepareStableInputSelection {
|
||||||
source := strings.TrimSpace(resolved.Source)
|
|
||||||
if source == "" {
|
|
||||||
source = "session_config"
|
|
||||||
}
|
|
||||||
path := resolved.Path
|
path := resolved.Path
|
||||||
if strings.TrimSpace(path) == "" {
|
if strings.TrimSpace(path) == "" {
|
||||||
path = fallback
|
path = fallback
|
||||||
}
|
}
|
||||||
return prepareStableInputSelection{Kind: kind, Source: source, Present: strings.TrimSpace(path) != ""}
|
// Source ownership remains provenance; resume validates the selected payloads.
|
||||||
|
return prepareStableInputSelection{Kind: kind, Present: strings.TrimSpace(path) != ""}
|
||||||
}
|
}
|
||||||
|
|
||||||
func cloneFloat64(value *float64) *float64 {
|
func cloneFloat64(value *float64) *float64 {
|
||||||
|
|||||||
@@ -23,9 +23,6 @@ func TestPrepareSemanticConfigSensitivity(t *testing.T) {
|
|||||||
{name: "previous session", mutate: func(env *Env) {
|
{name: "previous session", mutate: func(env *Env) {
|
||||||
env.Config.Session.PreviousSessionID = "2026-04-26"
|
env.Config.Session.PreviousSessionID = "2026-04-26"
|
||||||
}},
|
}},
|
||||||
{name: "stable input owner", mutate: func(env *Env) {
|
|
||||||
env.Config.StableInputs.PartyFile.Source = "campaign_config"
|
|
||||||
}},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
assertSemanticFingerprintUnchanged(t, prepareStage{}, initialSemanticEnv(), []struct {
|
assertSemanticFingerprintUnchanged(t, prepareStage{}, initialSemanticEnv(), []struct {
|
||||||
@@ -37,6 +34,10 @@ func TestPrepareSemanticConfigSensitivity(t *testing.T) {
|
|||||||
env.Config.Pipeline.Spool.Root = "/different/spool"
|
env.Config.Pipeline.Spool.Root = "/different/spool"
|
||||||
env.Config.Pipeline.Cache.Root = "/different/cache"
|
env.Config.Pipeline.Cache.Root = "/different/cache"
|
||||||
}},
|
}},
|
||||||
|
{name: "stable input owner", mutate: func(env *Env) {
|
||||||
|
env.Config.StableInputs.PartyFile.Source = "party_file"
|
||||||
|
env.Config.StableInputs.SpeakersFile.Source = "campaign_config"
|
||||||
|
}},
|
||||||
{name: "absolute stable source path", mutate: func(env *Env) {
|
{name: "absolute stable source path", mutate: func(env *Env) {
|
||||||
env.Config.StableInputs.PartyFile.Path = "/relocated/party.yml"
|
env.Config.StableInputs.PartyFile.Path = "/relocated/party.yml"
|
||||||
env.Config.StableInputs.PartyFile.ConfigPath = "/relocated/campaign.yml"
|
env.Config.StableInputs.PartyFile.ConfigPath = "/relocated/campaign.yml"
|
||||||
|
|||||||
Reference in New Issue
Block a user