Update examples and tests for shared glossaries

This commit is contained in:
2026-11-27 17:00:16 +00:00
parent 410a4109ad
commit cfcb55e28c
38 changed files with 273 additions and 59 deletions

View File

@@ -137,6 +137,7 @@ func TestRunArtifactsWithSucceededAnalyzeSkipsUnlessForced(t *testing.T) {
seed.MarkStageSucceeded(stageName, time.Date(2026, 5, 3, 10, 1, 0, 0, time.UTC), nil)
}
seed.MarkStageSkipped("extract", time.Date(2026, 5, 3, 10, 1, 0, 0, time.UTC), "notarius_disabled")
seedPolishGlossaryEvidence(t, workspaceRoot, seed)
seedCurrentSemanticEvidence(t, loadConfigForSemanticEvidence(t, pipelinePath, campaignPath, sessionPath), seed, "prepare", "transcribe", "merge", "polish", "normalize", "trim", "render")
if err := store.Save(context.Background(), manifestPath, seed); err != nil {
t.Fatalf("save manifest: %v", err)

View File

@@ -10,6 +10,7 @@ import (
"testing"
"time"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/audita"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/scriptorium"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
@@ -20,6 +21,7 @@ import (
func TestAssembledFullRunUsesCanonicalOrder(t *testing.T) {
cfg := testConfig(t)
seedGlossaryManifest(t, cfg)
canonical := []string{
"prepare", "transcribe", "merge", "polish", "normalize", "trim",
"render", "extract", "analyze", "publish", "notify", "cleanup",
@@ -29,7 +31,7 @@ func TestAssembledFullRunUsesCanonicalOrder(t *testing.T) {
for _, name := range canonical {
stages = append(stages, resultStage{name: name, result: &stage.StageResult{}, order: &order})
}
summary, err := executeStages(context.Background(), cfg, stages, RunOptions{})
summary, err := executeStages(context.Background(), cfg, stages, RunOptions{Env: &Env{Audita: &audita.FakeRunner{}}})
if err != nil {
t.Fatalf("executeStages() error = %v", err)
}
@@ -323,6 +325,7 @@ func TestAssembledSplitBundleProfileSwitchRecordsProvenanceAndLimitsReuse(t *tes
providers := make([]stage.SemanticConfigFingerprinter, len(names))
seed := manifest.New(production.Session.SessionID, time.Now().UTC())
seed.Campaign = production.Session.Campaign
seedGlossaryRecords(t, workspace, seed)
for _, candidate := range stage.All() {
seed.MarkStageSucceeded(candidate.Name(), time.Now().UTC(), nil)
}
@@ -352,7 +355,7 @@ func TestAssembledSplitBundleProfileSwitchRecordsProvenanceAndLimitsReuse(t *tes
testingRuns := make([]int, len(names))
testingStages := assembledSemanticStages(names, providers, testingRuns)
testingSummary, err := executeStages(context.Background(), testingCfg, testingStages, RunOptions{Env: &Env{Scriptorium: &scriptorium.FakeRunner{}}})
testingSummary, err := executeStages(context.Background(), testingCfg, testingStages, RunOptions{Env: &Env{Audita: &audita.FakeRunner{}, Scriptorium: &scriptorium.FakeRunner{}}})
if err != nil {
t.Fatalf("switch to testing profile: %v", err)
}

View File

@@ -472,7 +472,7 @@ inputs:
mustWriteTestFile(t, filepath.Join(campaignDir, "speakers.yml"), "match:\n - speaker: Alice\n match: [\"alice\"]\n")
mustWriteTestFile(t, filepath.Join(campaignDir, "autocorrect.yml"), "[]\n")
mustWriteTestFile(t, filepath.Join(campaignDir, "glossary.yml"), "[]\n")
mustWriteTestFile(t, filepath.Join(campaignDir, "glossary.yml"), "campaign: {entries: []}\n")
mustWriteTestFile(t, filepath.Join(campaignDir, "party.yml"), "schema_version: narratio.party.v1\ncharacters:\n arannis:\n player: {name: Eric}\n character:\n name: Arannis\n classes: [{name: wizard}]\n")
mustWriteTestFile(t, filepath.Join(dir, "audio", "alice.flac"), "audio-bytes")
@@ -702,12 +702,15 @@ func TestAuditaAppHelper(t *testing.T) {
os.Exit(2)
}
processArgs := args[start:]
if len(processArgs) < 2 || processArgs[0] != "process" {
_, _ = os.Stderr.WriteString("expected Audita v2 process invocation\n")
if len(processArgs) < 2 || (processArgs[0] != "process" && processArgs[0] != "preflight") {
_, _ = os.Stderr.WriteString("expected Audita process or preflight invocation\n")
os.Exit(2)
}
if processArgs[0] == "preflight" {
os.Exit(0)
}
for _, arg := range processArgs {
if arg == "--report-json" || arg == "--work-dir" || arg == "--debug" || arg == "--reporting=false" {
if arg == "--report-json" || arg == "--debug" || arg == "--reporting=false" {
_, _ = os.Stderr.WriteString("retired or unwanted Audita flag\n")
os.Exit(2)
}
@@ -726,8 +729,12 @@ func TestAuditaAppHelper(t *testing.T) {
_, _ = os.Stderr.WriteString(fmt.Sprintf("write output: %v\n", err))
os.Exit(2)
}
reportDir := appSeriatimFlagValue(processArgs, "--report-dir")
if err := os.MkdirAll(reportDir, 0o755); err != nil {
os.Exit(2)
}
for _, name := range []string{"errors.yml", "recoveries.yml", "report.md"} {
if err := os.WriteFile(filepath.Join(filepath.Dir(outputPath), name), []byte("status: completed\n"), 0o644); err != nil {
if err := os.WriteFile(filepath.Join(reportDir, name), []byte("status: completed\n"), 0o644); err != nil {
_, _ = os.Stderr.WriteString(fmt.Sprintf("write %s: %v\n", name, err))
os.Exit(2)
}

View File

@@ -170,7 +170,7 @@ func TestExtractLifecyclePrepareBindsVerifiedReferenceSnapshots(t *testing.T) {
sourceID string
filename string
}{
{selector: "glossary", sourceID: artifactpolicy.SourceInputGlossary, filename: "glossary.yml"},
{selector: "glossary", sourceID: artifactpolicy.SourceInputGlossaryCampaign, filename: "campaign.yml"},
{selector: "party", sourceID: artifactpolicy.SourceInputParty, filename: "party.yml"},
{selector: "players", sourceID: artifactpolicy.SourceInputPlayers, filename: "players.yml"},
{selector: "spells", sourceID: artifactpolicy.SourceInputSpellCatalog, filename: "spell_catalog.json"},
@@ -182,11 +182,11 @@ func TestExtractLifecyclePrepareBindsVerifiedReferenceSnapshots(t *testing.T) {
loaded := loadLifecycleManifest(t, cfg)
for index, expected := range want {
binding := request.References[index]
canonical := filepath.Join(paths.InputsDir, expected.filename)
descriptor, ok := artifactpolicy.DescribePreparedInputSource(expected.sourceID)
if !ok {
t.Fatalf("DescribePreparedInputSource(%q) ok = false", expected.sourceID)
}
canonical := filepath.Join(paths.InputsDir, descriptor.Filename)
snapshot, err := artifacts.SessionNotariusReferenceSnapshotPath(
paths, lifecycleInputChecksum(t, loaded, descriptor.ManifestKind), expected.filename,
)
@@ -1085,7 +1085,7 @@ func configureLifecycleReferences(t *testing.T, cfg *config.Config) map[string]s
cfg.Pipeline.Notarius.References = map[string]string{
"party": artifactpolicy.SourceInputParty,
"players": artifactpolicy.SourceInputPlayers,
"glossary": artifactpolicy.SourceInputGlossary,
"glossary": artifactpolicy.SourceInputGlossaryCampaign,
"spells": artifactpolicy.SourceInputSpellCatalog,
}
spellPath := filepath.Join(filepath.Dir(cfg.CampaignPath), "spells.json")
@@ -1098,10 +1098,10 @@ func configureLifecycleReferences(t *testing.T, cfg *config.Config) map[string]s
cfg.Session.Inputs.SpellCatalogFile = "./spells.json"
return map[string]string{
artifactpolicy.SourceInputParty: filepath.Join(filepath.Dir(cfg.CampaignPath), "party.yml"),
artifactpolicy.SourceInputPlayers: filepath.Join(filepath.Dir(cfg.CampaignPath), "players.yml"),
artifactpolicy.SourceInputGlossary: filepath.Join(filepath.Dir(cfg.CampaignPath), "glossary.yml"),
artifactpolicy.SourceInputSpellCatalog: spellPath,
artifactpolicy.SourceInputParty: filepath.Join(filepath.Dir(cfg.CampaignPath), "party.yml"),
artifactpolicy.SourceInputPlayers: filepath.Join(filepath.Dir(cfg.CampaignPath), "players.yml"),
artifactpolicy.SourceInputGlossaryCampaign: filepath.Join(filepath.Dir(cfg.CampaignPath), "glossary.yml"),
artifactpolicy.SourceInputSpellCatalog: spellPath,
}
}

View File

@@ -6,13 +6,17 @@ import (
"encoding/json"
"fmt"
"io"
"path/filepath"
"strings"
"testing"
"time"
"gitea.maximumdirect.net/eric/narratio/internal/artifactpolicy"
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
"gitea.maximumdirect.net/eric/narratio/internal/config"
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
"gitea.maximumdirect.net/eric/narratio/internal/stage"
"go.maximumdirect.net/commandkit"
)
@@ -81,11 +85,62 @@ func seedInvocationPrerequisites(t *testing.T, root, selected string) {
m.Campaign = "sample-campaign"
}
markFixturePrerequisites(t, m, selected)
if selected == "polish" {
seedGlossaryRecords(t, root, m)
}
if err := store.Save(context.Background(), path, m); err != nil {
t.Fatal(err)
}
}
func seedGlossaryRecords(t *testing.T, root string, m *manifest.Manifest) {
t.Helper()
store := artifacts.NewLocalStore(root)
paths, err := store.EnsureLayoutFor("sample-campaign", "2026-05-03")
if err != nil {
t.Fatal(err)
}
for _, descriptor := range artifactpolicy.GlossaryInputSources() {
found := false
for _, input := range m.Inputs {
if input.Kind == descriptor.ManifestKind {
found = true
break
}
}
if found {
continue
}
path := filepath.Join(paths.InputsDir, descriptor.Filename)
mustWriteTestFile(t, path, "synthetic: {entries: []}\n")
checksum, err := store.Checksum(path)
if err != nil {
t.Fatal(err)
}
m.Inputs = append(m.Inputs, manifest.InputRecord{Kind: descriptor.ManifestKind, Path: path, Checksum: checksum})
}
}
func seedPolishGlossaryEvidence(t *testing.T, root string, m *manifest.Manifest) {
t.Helper()
paths := artifacts.NewLocalStore(root).SessionPathsFor("sample-campaign", "2026-05-03")
_, evidence, err := stage.BuildPolishRequest(paths, m, "", filepath.Join(paths.Root, "scratch", "polished.json"), filepath.Join(paths.Root, "scratch", "logs"), filepath.Join(paths.Root, "scratch", "debug"))
if err != nil {
t.Fatal(err)
}
m.Stages["polish"].Metadata = map[string]any{"glossary_evidence": evidence}
}
func seedGlossaryManifest(t *testing.T, cfg *config.Config) {
t.Helper()
m := manifest.New(cfg.Session.SessionID, time.Now().UTC())
m.Campaign = cfg.Session.Campaign
seedGlossaryRecords(t, cfg.Pipeline.Workspace.Root, m)
if err := (&manifest.LocalStore{}).Save(context.Background(), manifestPathFor(cfg), m); err != nil {
t.Fatal(err)
}
}
func findingMatches(findings []finding, severity, category, message string) bool {
for _, item := range findings {
if (severity == "" || item.Severity == severity) && item.Category == category && strings.Contains(item.Message, message) {

View File

@@ -11,6 +11,7 @@ import (
"testing"
"time"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/audita"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/scriptorium"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
"gitea.maximumdirect.net/eric/narratio/internal/artifactmodel"
@@ -441,11 +442,12 @@ inputs:
`), 0o644); err != nil {
t.Fatalf("write session: %v", err)
}
seedValidationPrepared(t, &config.Config{Pipeline: &config.PipelineConfig{Workspace: config.WorkspaceConfig{Root: workspaceRoot}}, Session: &config.SessionConfig{Campaign: "sample-campaign", SessionID: "2026-05-03"}})
fake := &storage.FakeBackend{}
audioKey := artifacts.S3PublishedOutputKey(artifacts.S3AudioPrefix(artifacts.S3SessionPrefix("dnd", "sample-campaign", "2026-05-03"), "audio/"), "alice.flac")
fake.SeedObject(storage.FakeObject{Key: audioKey, Data: []byte("audio")})
deps := commandDependencies{newScriptorium: func() scriptorium.Runner { return &scriptorium.FakeRunner{} }, newObjectStore: func(context.Context, *config.Config) (storage.ObjectStore, error) {
deps := commandDependencies{newAudita: func(*config.Config) (audita.Runner, error) { return &audita.FakeRunner{}, nil }, newScriptorium: func() scriptorium.Runner { return &scriptorium.FakeRunner{} }, newObjectStore: func(context.Context, *config.Config) (storage.ObjectStore, error) {
if os.Getenv(accessKeyEnv) != "test-key-id" || os.Getenv(secretKeyEnv) != "test-secret" {
return nil, fmt.Errorf("secrets were not loaded before object store init")
}
@@ -479,6 +481,7 @@ func TestOperatorCommandsReportConfiguredSpellCatalog(t *testing.T) {
}
spellPath := filepath.Join(filepath.Dir(campaignPath), "spells.json")
mustWriteTestFile(t, spellPath, "{\"spells\":[]}\n")
seedValidationPrepared(t, loadConfigForSemanticEvidence(t, pipelinePath, campaignPath, sessionPath))
fake := &storage.FakeBackend{}
var storeInitCalls int

View File

@@ -234,11 +234,14 @@ func TestProviderCredentialProcessFixture(t *testing.T) {
os.Exit(0)
}
switch args[0] {
case "process":
case "process", "preflight":
if os.Getenv(auditaOnlyName) != auditaOnlyKey {
_, _ = os.Stderr.WriteString("Audita-only credential not forwarded\n")
os.Exit(2)
}
if args[0] == "preflight" {
os.Exit(0)
}
output := appSeriatimFlagValue(args, "--output")
if output == "" {
os.Exit(2)
@@ -249,8 +252,12 @@ func TestProviderCredentialProcessFixture(t *testing.T) {
if err := os.WriteFile(output, []byte(`{"schema":"audita.processed.v1","segments":[]}`), 0o644); err != nil {
os.Exit(2)
}
reportDir := appSeriatimFlagValue(args, "--report-dir")
if err := os.MkdirAll(reportDir, 0o755); err != nil {
os.Exit(2)
}
for _, name := range []string{"errors.yml", "recoveries.yml", "report.md"} {
if err := os.WriteFile(filepath.Join(filepath.Dir(output), name), []byte("status: completed\n"), 0o644); err != nil {
if err := os.WriteFile(filepath.Join(reportDir, name), []byte("status: completed\n"), 0o644); err != nil {
os.Exit(2)
}
}

View File

@@ -10,6 +10,7 @@ import (
"strings"
"testing"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/audita"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/scriptorium"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
@@ -451,7 +452,7 @@ func remoteSessionLoaderDependencies(fake *storage.FakeBackend) (commandDependen
}
func fakeCommandDependencies(fake *storage.FakeBackend, storeInitCalls *int) commandDependencies {
return commandDependencies{newScriptorium: func() scriptorium.Runner { return &scriptorium.FakeRunner{} }, newObjectStore: func(context.Context, *config.Config) (storage.ObjectStore, error) {
return commandDependencies{newAudita: func(*config.Config) (audita.Runner, error) { return &audita.FakeRunner{}, nil }, newScriptorium: func() scriptorium.Runner { return &scriptorium.FakeRunner{} }, newObjectStore: func(context.Context, *config.Config) (storage.ObjectStore, error) {
if storeInitCalls != nil {
*storeInitCalls++
}

View File

@@ -66,6 +66,7 @@ func TestRunNoRemainingStagesRecordsSkippedStages(t *testing.T) {
m.MarkStageSucceeded(name, time.Date(2026, 5, 3, 10, 1, 0, 0, time.UTC), nil)
}
m.MarkStageSkipped("extract", time.Date(2026, 5, 3, 10, 1, 0, 0, time.UTC), "notarius_disabled")
seedPolishGlossaryEvidence(t, workspaceRoot, m)
seedCurrentSemanticEvidence(t, loadConfigForSemanticEvidence(t, pipelinePath, campaignPath, sessionPath), m, "prepare", "transcribe", "merge", "polish", "normalize", "trim", "render", "publish", "notify")
if err := store.Save(context.Background(), manifestPath, m); err != nil {
t.Fatalf("save manifest: %v", err)
@@ -187,6 +188,8 @@ func TestRunSingleStageSkipAndForce(t *testing.T) {
m := manifest.New("2026-05-03", time.Date(2026, 5, 3, 10, 0, 0, 0, time.UTC))
setCurrentBuiltInEvidence(t, m, "merge", artifacts.TranscriptOutputKindBase, artifacts.ArtifactTranscriptBase, basePath)
m.MarkStageSucceeded("polish", time.Date(2026, 5, 3, 10, 1, 0, 0, time.UTC), nil)
seedGlossaryRecords(t, workspaceRoot, m)
seedPolishGlossaryEvidence(t, workspaceRoot, m)
seedCurrentSemanticEvidence(t, loadConfigForSemanticEvidence(t, pipelinePath, campaignPath, sessionPath), m, "polish")
if err := store.Save(context.Background(), manifestPath, m); err != nil {
t.Fatalf("save manifest: %v", err)

View File

@@ -60,10 +60,8 @@ func TestPartialRunRetainsAllFailureCausesAndDurableSuccess(t *testing.T) {
t.Fatalf("summary=%#v", summary)
}
if compositionFailure {
for _, result := range summary.StageResults {
if result.Attempted || result.Outcome != "not_attempted" {
t.Fatalf("composition scheduled work: %#v", summary)
}
if firstRuns != 1 || summary.StageResults[0].Outcome != "completed" || summary.StageResults[1].Attempted || summary.StageResults[1].Outcome != "failed" || summary.StageResults[2].Outcome != "not_attempted" {
t.Fatalf("composition results: %#v", summary)
}
return
}

View File

@@ -10,6 +10,9 @@ import (
)
func inspectInvocationRequirements(runtime *invocationRuntime, start int) error {
if !stagesContainAny(runtime.stages[start:], "polish", "trim", "analyze") {
return nil
}
remaining := runtime.plan
remaining.stages = append([]stage.Stage(nil), runtime.stages[start:]...)
projection, err := projectSelectedWork(runtime.ctx, runtime.cfg, remaining, runtime.opts.Force, runtime.opts.SelectedArtifacts, runtime.effectiveArtifacts, runtime.artifactStore, runtime.manifest)

View File

@@ -7,6 +7,7 @@ import (
"testing"
"time"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/audita"
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
"gitea.maximumdirect.net/eric/narratio/internal/stage"
)
@@ -147,6 +148,7 @@ func TestExecuteStagesResumeValidationFailureRecordsSessionFailure(t *testing.T)
func TestExecuteStagesSuccessfulSaveFailureMarksStageFailedAndInvalidatesDependents(t *testing.T) {
cfg := testConfig(t)
seedGlossaryManifest(t, cfg)
store := &successfulStageSaveFailingStore{
delegate: &manifest.LocalStore{},
stageName: "polish",
@@ -155,7 +157,7 @@ func TestExecuteStagesSuccessfulSaveFailureMarksStageFailedAndInvalidatesDepende
_, err := executeStages(context.Background(), cfg, []stage.Stage{
countingStage{name: "polish", runs: new(int)},
}, RunOptions{Env: &Env{ManifestStore: store}})
}, RunOptions{Env: &Env{ManifestStore: store, Audita: &audita.FakeRunner{}}})
if err == nil || !strings.Contains(err.Error(), "save manifest after stage \"polish\"") {
t.Fatalf("executeStages() error = %v, want successful-stage save failure", err)
}
@@ -174,8 +176,9 @@ func TestExecuteStagesSuccessfulSaveFailureMarksStageFailedAndInvalidatesDepende
func TestExecuteStagesSelfSkipSaveFailureIsNotReportedComplete(t *testing.T) {
cfg := testConfig(t)
seedGlossaryManifest(t, cfg)
store := &successfulStageSaveFailingStore{delegate: &manifest.LocalStore{}, stageName: "polish", dependent: "normalize", failStatus: manifest.StatusSkipped}
summary, err := executeStages(context.Background(), cfg, []stage.Stage{resultStage{name: "polish", result: &stage.StageResult{Disposition: stage.StageDispositionSkipped, SkipReason: "disabled"}}}, RunOptions{Env: &Env{ManifestStore: store}})
summary, err := executeStages(context.Background(), cfg, []stage.Stage{resultStage{name: "polish", result: &stage.StageResult{Disposition: stage.StageDispositionSkipped, SkipReason: "disabled"}}}, RunOptions{Env: &Env{ManifestStore: store, Audita: &audita.FakeRunner{}}})
if err == nil || summary == nil || summary.Complete || len(summary.Skipped) != 0 || summary.StageResults[0].Outcome != "failed" {
t.Fatalf("summary=%#v error=%v", summary, err)
}

View File

@@ -804,6 +804,7 @@ func TestExecuteStagesForceSuccessInvalidatesDownstreamSucceededStages(t *testin
store := &manifest.LocalStore{}
existing := manifest.New(cfg.Session.SessionID, time.Date(2026, 5, 3, 1, 0, 0, 0, time.UTC))
seedGlossaryRecords(t, cfg.Pipeline.Workspace.Root, existing)
for _, stageName := range []string{"prepare", "transcribe", "merge", "polish", "normalize", "trim", "extract", "render", "publish", "notify"} {
existing.MarkStageSucceeded(stageName, time.Date(2026, 5, 3, 1, 1, 0, 0, time.UTC), nil)
}
@@ -817,7 +818,7 @@ func TestExecuteStagesForceSuccessInvalidatesDownstreamSucceededStages(t *testin
runs := 0
stageToRun := countingStage{name: "polish", runs: &runs}
summary, err := executeStages(context.Background(), cfg, []stage.Stage{stageToRun}, RunOptions{Force: true})
summary, err := executeStages(context.Background(), cfg, []stage.Stage{stageToRun}, RunOptions{Force: true, Env: &Env{Audita: &audita.FakeRunner{}}})
if err != nil {
t.Fatalf("executeStages() error = %v", err)
}
@@ -1238,7 +1239,7 @@ func TestExecuteStagesRunLocalArtifactsAndCanonicalSync(t *testing.T) {
runLocalChecks := []string{
filepath.Join(runRoot, "transcribe", "outputs", "transcripts", "raw", "alice.json"),
filepath.Join(runRoot, "merge", "logs", "seriatim.stdout.log"),
filepath.Join(runRoot, "polish", "config", "audita.generated.yml"),
filepath.Join(runRoot, "polish", "outputs", "transcripts", "polished.json"),
filepath.Join(runRoot, "normalize", "logs", "seriatim.normalize.stdout.log"),
filepath.Join(runRoot, "trim", "outputs", "transcripts", "final.trimmed.json"),
}
@@ -1333,6 +1334,7 @@ func TestExecuteStagesSkippedStagePreservesExistingOutputsProvenance(t *testing.
func TestAdapterFailureMarksManifestFailed(t *testing.T) {
cfg := testConfig(t)
seedGlossaryManifest(t, cfg)
selected, err := stage.Select("polish")
if err != nil {
t.Fatalf("Select() error = %v", err)
@@ -1352,9 +1354,6 @@ func TestAdapterFailureMarksManifestFailed(t *testing.T) {
if err := os.WriteFile(filepath.Join(paths.TranscriptsDir, "base.json"), []byte(`{"segments":[]}`), 0o644); err != nil {
t.Fatalf("write merged transcript: %v", err)
}
if err := os.WriteFile(filepath.Join(paths.InputsDir, "glossary.yml"), []byte("terms: []\n"), 0o644); err != nil {
t.Fatalf("write glossary: %v", err)
}
_, runErr := executeStages(context.Background(), cfg, []stage.Stage{selected}, RunOptions{Env: env})
if runErr == nil {
@@ -1388,7 +1387,7 @@ func testConfig(t *testing.T) *config.Config {
mustWriteFile(t, sessionPath, "session_id: 2026-05-03\ncampaign: sample-campaign\ninputs:\n audio_dir: ./audio\n")
mustWriteFile(t, filepath.Join(cfgDir, "speakers.yml"), "alice: alice.flac\n")
mustWriteFile(t, filepath.Join(cfgDir, "autocorrect.yml"), "[]\n")
mustWriteFile(t, filepath.Join(cfgDir, "glossary.yml"), "[]\n")
mustWriteFile(t, filepath.Join(cfgDir, "glossary.yml"), "campaign: {entries: []}\n")
mustWriteFile(t, filepath.Join(cfgDir, "party.yml"), "schema_version: narratio.party.v1\ncharacters:\n arannis:\n player: {name: Eric}\n character:\n name: Arannis\n classes: [{name: wizard}]\n")
mustWriteFile(t, filepath.Join(cfgDir, "audio", "alice.flac"), "audio")
partyDocument, err := config.ParseParty([]byte("schema_version: narratio.party.v1\ncharacters:\n arannis:\n player: {name: Eric}\n character:\n name: Arannis\n classes: [{name: wizard}]\n"))
@@ -1439,7 +1438,7 @@ func testConfig(t *testing.T) *config.Config {
AudioDir: "./audio",
SpeakersFile: "./speakers.yml",
AutocorrectFile: "./autocorrect.yml",
GlossaryFile: new("./glossary.yml"),
GlossaryFile: new(filepath.Join(cfgDir, "glossary.yml")),
},
},
}

View File

@@ -10,6 +10,7 @@ import (
"testing"
"time"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/audita"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/scriptorium"
"gitea.maximumdirect.net/eric/narratio/internal/config"
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
@@ -388,6 +389,7 @@ func TestRefinementSemanticChangesRespectDependencyBranches(t *testing.T) {
cfg := testConfig(t)
providers := make([]stage.SemanticConfigFingerprinter, len(names))
seed := manifest.New(cfg.Session.SessionID, time.Now().UTC())
seedGlossaryRecords(t, cfg.Pipeline.Workspace.Root, seed)
for _, candidate := range stage.All() {
seed.MarkStageSucceeded(candidate.Name(), time.Now().UTC(), nil)
}
@@ -410,7 +412,7 @@ func TestRefinementSemanticChangesRespectDependencyBranches(t *testing.T) {
for index, name := range names {
selected = append(selected, semanticContractRunStub{name: name, provider: providers[index], runs: &runs[index]})
}
if _, err := executeStages(context.Background(), cfg, selected, RunOptions{Env: &Env{Scriptorium: &scriptorium.FakeRunner{}}}); err != nil {
if _, err := executeStages(context.Background(), cfg, selected, RunOptions{Env: &Env{Audita: &audita.FakeRunner{}, Scriptorium: &scriptorium.FakeRunner{}}}); err != nil {
t.Fatal(err)
}
if runs != test.wantRuns {
@@ -431,6 +433,7 @@ func TestOldPolishSemanticEvidenceIsReconsideredOnlyWhenSelected(t *testing.T) {
cfg := testConfig(t)
names := []string{"prepare", "transcribe", "merge", "polish", "normalize", "trim", "render"}
seed := manifest.New(cfg.Session.SessionID, time.Now().UTC())
seedGlossaryRecords(t, cfg.Pipeline.Workspace.Root, seed)
for _, candidate := range stage.All() {
seed.MarkStageSucceeded(candidate.Name(), time.Now().UTC(), nil)
}
@@ -466,7 +469,7 @@ func TestOldPolishSemanticEvidenceIsReconsideredOnlyWhenSelected(t *testing.T) {
if loaded.Stages["polish"].SemanticConfig.Version != seed.Stages["polish"].SemanticConfig.Version {
t.Fatal("downstream-only execution rewrote unselected polish evidence")
}
if _, err := executeStages(context.Background(), cfg, selected, RunOptions{}); err != nil {
if _, err := executeStages(context.Background(), cfg, selected, RunOptions{Env: &Env{Audita: &audita.FakeRunner{}}}); err != nil {
t.Fatal(err)
}
if want := []int{0, 0, 0, 1, 1, 1, 1}; !reflect.DeepEqual(runs, want) {
@@ -476,7 +479,11 @@ func TestOldPolishSemanticEvidenceIsReconsideredOnlyWhenSelected(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if loaded.Stages["polish"].SemanticConfig.Version != 2 || loaded.Stages["extract"].Status != manifest.StatusStale {
currentFingerprint, err := providers[3].SemanticConfigFingerprint(&stage.Env{Config: cfg})
if err != nil {
t.Fatal(err)
}
if loaded.Stages["polish"].SemanticConfig.Version != currentFingerprint.Version || loaded.Stages["extract"].Status != manifest.StatusStale {
t.Fatalf("old evidence was not replaced with normal dependent invalidation: polish=%#v extract=%#v", loaded.Stages["polish"], loaded.Stages["extract"])
}
for index := range runs {

View File

@@ -190,6 +190,7 @@ func TestExecuteWorkflowCommandsAcceptPositionalSessionID(t *testing.T) {
func TestExecuteSessionSubcommandsAcceptPositionalSessionID(t *testing.T) {
workspaceRoot := t.TempDir()
pipelinePath, campaignPath, sessionPath := writeValidConfigFiles(t, workspaceRoot)
seedValidationPrepared(t, loadConfigForSemanticEvidence(t, pipelinePath, campaignPath, sessionPath))
fake := &storage.FakeBackend{}
seedOperatorCommittedOutputs(t, fake, nil)
var storeInitCalls int