From cfcb55e28ce40ca8b80a1fb228423374ac82ec63 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Fri, 27 Nov 2026 17:00:16 +0000 Subject: [PATCH] Update examples and tests for shared glossaries --- docs/roadmap/implementation.md | 8 ++- examples/README.md | 12 +++- .../campaigns/sample-campaign/glossary.yml | 4 +- examples/glossary-authoring/combined.yml | 7 +++ examples/glossary-authoring/file-only.yml | 3 + examples/glossary-authoring/inline-only.yml | 5 ++ examples/glossary.yml | 5 +- examples/pipeline.catalog.yml | 10 ++++ examples/pipeline.extraction-subset.yml | 2 +- examples/pipeline.full.annotated.yml | 8 +-- examples/pipeline.production.yml | 11 +++- .../production-testing/conf.d/transcript.yml | 1 - examples/reference-catalog/catalog.yml | 5 ++ .../reference-catalog/fragments/places.yml | 3 + examples/reference-catalog/setting.yml | 8 +++ examples/reference-catalog/spells.yml | 3 + .../app/analyze_artifacts_commands_test.go | 1 + internal/app/assembled_workflow_test.go | 7 ++- internal/app/commands_test.go | 17 ++++-- internal/app/extract_lifecycle_test.go | 14 ++--- internal/app/native_invocation_test.go | 55 +++++++++++++++++++ internal/app/operator_helpers_test.go | 5 +- .../provider_credentials_integration_test.go | 11 +++- internal/app/remote_session_test.go | 3 +- internal/app/run_selection_test.go | 3 + internal/app/runner_partial_result_test.go | 6 +- internal/app/runner_preflight.go | 3 + internal/app/runner_terminal_failure_test.go | 7 ++- internal/app/runner_test.go | 13 ++--- internal/app/semantic_resume_test.go | 13 ++++- internal/app/session_oriented_cli_test.go | 1 + internal/config/load_validate_test.go | 52 ++++++++++++++++++ internal/config/notarius_test.go | 4 +- internal/config/scriptorium_test.go | 2 +- internal/stage/analyze_test.go | 6 +- internal/stage/extract_test.go | 8 ++- internal/stage/prepare_test.go | 2 +- internal/stage/transcribe_test.go | 4 +- 38 files changed, 273 insertions(+), 59 deletions(-) create mode 100644 examples/glossary-authoring/combined.yml create mode 100644 examples/glossary-authoring/file-only.yml create mode 100644 examples/glossary-authoring/inline-only.yml create mode 100644 examples/pipeline.catalog.yml create mode 100644 examples/reference-catalog/catalog.yml create mode 100644 examples/reference-catalog/fragments/places.yml create mode 100644 examples/reference-catalog/setting.yml create mode 100644 examples/reference-catalog/spells.yml diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index 114fdd3..7356e91 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -575,7 +575,13 @@ stage transition, or latest-view rotation occurs. ## Stage 16. Cut maintained consumer bindings and examples over explicitly -Status: Pending +Status: Complete + +Updated maintained bindings, native glossary examples, and offline test +fixtures, including a synthetic catalog with relative imports and campaign +authoring variants. Verified example acquisition and glossary resolution, +extract/analyze/preflight coverage, documentation links, and `go test ./...`. +Real catalog and Audita compatibility checks remain for Stage 17. Update maintained pipelines, campaign/session examples, and synthetic fixtures to the new fields and source IDs. Replace the old Notarius text `glossary` diff --git a/examples/README.md b/examples/README.md index 22ba8d5..91226ed 100644 --- a/examples/README.md +++ b/examples/README.md @@ -9,6 +9,10 @@ in the [configuration reference](../docs/config.md). - [Minimal pipeline](pipeline.minimal.yml): campaign discovery plus the required WhisperX URL. +- [Synthetic catalog pipeline](pipeline.catalog.yml): imports the small + [example catalog](reference-catalog/catalog.yml), whose setting imports a + relative fragment. Install an operator-selected catalog separately for a + production deployment. - [Production-shaped pipeline](pipeline.production.yml): S3 storage, publish, external tools, and configured Scriptorium artifacts. - [Production-base/testing-overlay bundle](production-testing/pipeline.yml): @@ -61,6 +65,12 @@ with the sample campaign and a compatible local- or S3-audio session. demonstrate the narrow placeholder syntax consumed by `session init`; they are templates, not runtime session files. +The [inline-only](glossary-authoring/inline-only.yml), +[file-only](glossary-authoring/file-only.yml), and +[combined](glossary-authoring/combined.yml) inputs fragments illustrate campaign +vocabulary selection. They omit optional setting and system selections; add +those IDs only when the pipeline imports a matching catalog. + ## Input Fixtures - [Speakers](speakers.yml), [autocorrect](autocorrect.yml), and @@ -84,7 +94,7 @@ examples that reference them. They use fictional campaign content and reserved example domains. The Audita and Notarius names are example references, not implicit aliases: external backend/profile configurations must use those exact names, or the Narratio credential lists must be changed to match. See the -[Audita v2 migration guide](https://gitea.maximumdirect.net/eric/audita/src/tag/v2.0.0/docs/migrations/v2.md) +[Audita v4.2 configuration guide](https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/config.md) for maintained downstream configuration examples. For a deployed bundle, keep credential files out of source control. Select a diff --git a/examples/campaigns/sample-campaign/glossary.yml b/examples/campaigns/sample-campaign/glossary.yml index fe51488..13364df 100644 --- a/examples/campaigns/sample-campaign/glossary.yml +++ b/examples/campaigns/sample-campaign/glossary.yml @@ -1 +1,3 @@ -[] +campaign: + entries: + - {id: lantern_watch, name: Lantern Watch, category: organization} diff --git a/examples/glossary-authoring/combined.yml b/examples/glossary-authoring/combined.yml new file mode 100644 index 0000000..59c7430 --- /dev/null +++ b/examples/glossary-authoring/combined.yml @@ -0,0 +1,7 @@ +# Inline records compose above the file using ConfigKit entry identities. +inputs: + glossary_file: ../glossary.yml + glossary: + instruction: Use established campaign terminology. + entries: + - {id: lantern_watch, name: Silver Watch, category: organization} diff --git a/examples/glossary-authoring/file-only.yml b/examples/glossary-authoring/file-only.yml new file mode 100644 index 0000000..1940553 --- /dev/null +++ b/examples/glossary-authoring/file-only.yml @@ -0,0 +1,3 @@ +# Campaign inputs fragment; select the adjacent sample file when importing this fragment. +inputs: + glossary_file: ../glossary.yml diff --git a/examples/glossary-authoring/inline-only.yml b/examples/glossary-authoring/inline-only.yml new file mode 100644 index 0000000..cea9e0d --- /dev/null +++ b/examples/glossary-authoring/inline-only.yml @@ -0,0 +1,5 @@ +# Campaign inputs fragment; include the required roster and other inputs separately. +inputs: + glossary: + entries: + - {id: watch, name: Silver Watch, category: organization} diff --git a/examples/glossary.yml b/examples/glossary.yml index 7dd4387..13364df 100644 --- a/examples/glossary.yml +++ b/examples/glossary.yml @@ -1,2 +1,3 @@ -[] - +campaign: + entries: + - {id: lantern_watch, name: Lantern Watch, category: organization} diff --git a/examples/pipeline.catalog.yml b/examples/pipeline.catalog.yml new file mode 100644 index 0000000..62a11b1 --- /dev/null +++ b/examples/pipeline.catalog.yml @@ -0,0 +1,10 @@ +# Synthetic catalog example; production installations select their own local catalog. +config: + imports: + - path: reference-catalog/catalog.yml + required: true +campaigns: + root: /usr/local/share/narratio/campaigns + default_campaign_id: sample-campaign +whisperx: + transcribe_url: https://transcription.example.com/transcribe diff --git a/examples/pipeline.extraction-subset.yml b/examples/pipeline.extraction-subset.yml index feeb28c..0c93119 100644 --- a/examples/pipeline.extraction-subset.yml +++ b/examples/pipeline.extraction-subset.yml @@ -15,7 +15,7 @@ notarius: pipeline_id: dnd-session timeout: 3h references: - glossary: narratio.input.glossary + glossary: narratio.input.glossary.campaign party: narratio.input.party players: narratio.input.players spell_catalog: narratio.input.spell_catalog diff --git a/examples/pipeline.full.annotated.yml b/examples/pipeline.full.annotated.yml index 277f986..68b51d1 100644 --- a/examples/pipeline.full.annotated.yml +++ b/examples/pipeline.full.annotated.yml @@ -95,9 +95,9 @@ audita: # Optional overrides. Audita owns its own configuration and profiles. binary: audita timeout: 3h - # Names must match credentials on every backend in the Audita v2 config. + # Names must match credentials on the configured Audita backends. credentials: [AUDITA_LLM_API_KEY] - # Omit modules for Audita's default sequence; modules: [] disables corrections. + # Configure processing order in Audita configuration. overlay: "" proposal_profile: "" validation_profile: "" @@ -149,7 +149,7 @@ notarius: # External campaign references use prepared Narratio source IDs. Omit an # optional binding when the selected Notarius pipeline does not need it. references: - glossary: narratio.input.glossary + glossary: narratio.input.glossary.campaign party: narratio.input.party players: narratio.input.players spell_catalog: narratio.input.spell_catalog @@ -247,7 +247,7 @@ scriptorium: source: narratio.input.party required: true glossary: - source: narratio.input.glossary + source: narratio.input.glossary.campaign required: false vars: session_id: true diff --git a/examples/pipeline.production.yml b/examples/pipeline.production.yml index 4d50ade..ffef358 100644 --- a/examples/pipeline.production.yml +++ b/examples/pipeline.production.yml @@ -1,3 +1,10 @@ +# If this file is installed under /etc/narratio, install the selected catalog +# at /etc/narratio/reference-catalog and enable its root-relative import: +# config: +# imports: +# - path: reference-catalog/catalog.yml +# required: true + workspace: root: /var/lib/narratio/workspace cleanup_after_publish: true @@ -58,7 +65,7 @@ audita: binary: audita timeout: 3h credentials: [AUDITA_LLM_API_KEY] - # Omit modules to use Audita defaults; modules: [] disables corrections. + # Configure processing order in Audita configuration. output_schema: audita-v1 normalize: @@ -93,7 +100,7 @@ scriptorium: source: narratio.input.party required: true glossary: - source: narratio.input.glossary + source: narratio.input.glossary.campaign required: false vars: session_id: true diff --git a/examples/production-testing/conf.d/transcript.yml b/examples/production-testing/conf.d/transcript.yml index 260221f..014dbf6 100644 --- a/examples/production-testing/conf.d/transcript.yml +++ b/examples/production-testing/conf.d/transcript.yml @@ -8,7 +8,6 @@ seriatim: audita: binary: audita - modules: [glossary, grammar] output_schema: audita-v1 proposal_profile: narratio-production-model-placeholder validation_profile: narratio-production-validator-placeholder diff --git a/examples/reference-catalog/catalog.yml b/examples/reference-catalog/catalog.yml new file mode 100644 index 0000000..1990f4d --- /dev/null +++ b/examples/reference-catalog/catalog.yml @@ -0,0 +1,5 @@ +reference_catalog: + settings: + lantern_coast: ./setting.yml + systems: + sample_magic: ./spells.yml diff --git a/examples/reference-catalog/fragments/places.yml b/examples/reference-catalog/fragments/places.yml new file mode 100644 index 0000000..b65c643 --- /dev/null +++ b/examples/reference-catalog/fragments/places.yml @@ -0,0 +1,3 @@ +setting: + entries: + - {id: harbor, name: North Harbor, category: place} diff --git a/examples/reference-catalog/setting.yml b/examples/reference-catalog/setting.yml new file mode 100644 index 0000000..10ee76f --- /dev/null +++ b/examples/reference-catalog/setting.yml @@ -0,0 +1,8 @@ +config: + imports: + - path: fragments/places.yml + required: true +setting: + instruction: Use the established place names. + entries: + - {id: coast, name: Lantern Coast, category: place} diff --git a/examples/reference-catalog/spells.yml b/examples/reference-catalog/spells.yml new file mode 100644 index 0000000..ece048d --- /dev/null +++ b/examples/reference-catalog/spells.yml @@ -0,0 +1,3 @@ +spells: + entries: + - {id: glow, name: Lantern Glow, category: spell} diff --git a/internal/app/analyze_artifacts_commands_test.go b/internal/app/analyze_artifacts_commands_test.go index 92ebe0f..2e02cf7 100644 --- a/internal/app/analyze_artifacts_commands_test.go +++ b/internal/app/analyze_artifacts_commands_test.go @@ -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) diff --git a/internal/app/assembled_workflow_test.go b/internal/app/assembled_workflow_test.go index caa3924..a31f2dd 100644 --- a/internal/app/assembled_workflow_test.go +++ b/internal/app/assembled_workflow_test.go @@ -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) } diff --git a/internal/app/commands_test.go b/internal/app/commands_test.go index c973b88..6ad3c26 100644 --- a/internal/app/commands_test.go +++ b/internal/app/commands_test.go @@ -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) } diff --git a/internal/app/extract_lifecycle_test.go b/internal/app/extract_lifecycle_test.go index 399c74f..0dd76f8 100644 --- a/internal/app/extract_lifecycle_test.go +++ b/internal/app/extract_lifecycle_test.go @@ -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, } } diff --git a/internal/app/native_invocation_test.go b/internal/app/native_invocation_test.go index 169b803..e9f8902 100644 --- a/internal/app/native_invocation_test.go +++ b/internal/app/native_invocation_test.go @@ -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) { diff --git a/internal/app/operator_helpers_test.go b/internal/app/operator_helpers_test.go index 19bb21d..72f0d23 100644 --- a/internal/app/operator_helpers_test.go +++ b/internal/app/operator_helpers_test.go @@ -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 diff --git a/internal/app/provider_credentials_integration_test.go b/internal/app/provider_credentials_integration_test.go index f524268..a7e5752 100644 --- a/internal/app/provider_credentials_integration_test.go +++ b/internal/app/provider_credentials_integration_test.go @@ -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) } } diff --git a/internal/app/remote_session_test.go b/internal/app/remote_session_test.go index d059d12..379472d 100644 --- a/internal/app/remote_session_test.go +++ b/internal/app/remote_session_test.go @@ -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++ } diff --git a/internal/app/run_selection_test.go b/internal/app/run_selection_test.go index cf0f6ae..3903ad8 100644 --- a/internal/app/run_selection_test.go +++ b/internal/app/run_selection_test.go @@ -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) diff --git a/internal/app/runner_partial_result_test.go b/internal/app/runner_partial_result_test.go index 225686c..c3be984 100644 --- a/internal/app/runner_partial_result_test.go +++ b/internal/app/runner_partial_result_test.go @@ -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 } diff --git a/internal/app/runner_preflight.go b/internal/app/runner_preflight.go index 4cc43b3..fae971e 100644 --- a/internal/app/runner_preflight.go +++ b/internal/app/runner_preflight.go @@ -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) diff --git a/internal/app/runner_terminal_failure_test.go b/internal/app/runner_terminal_failure_test.go index 8b9cf57..07c3d5d 100644 --- a/internal/app/runner_terminal_failure_test.go +++ b/internal/app/runner_terminal_failure_test.go @@ -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) } diff --git a/internal/app/runner_test.go b/internal/app/runner_test.go index dc259ad..2e16379 100644 --- a/internal/app/runner_test.go +++ b/internal/app/runner_test.go @@ -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")), }, }, } diff --git a/internal/app/semantic_resume_test.go b/internal/app/semantic_resume_test.go index ccd88a8..e3507bc 100644 --- a/internal/app/semantic_resume_test.go +++ b/internal/app/semantic_resume_test.go @@ -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 { diff --git a/internal/app/session_oriented_cli_test.go b/internal/app/session_oriented_cli_test.go index 4a5ef4a..59b239f 100644 --- a/internal/app/session_oriented_cli_test.go +++ b/internal/app/session_oriented_cli_test.go @@ -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 diff --git a/internal/config/load_validate_test.go b/internal/config/load_validate_test.go index edb9391..4d81d1e 100644 --- a/internal/config/load_validate_test.go +++ b/internal/config/load_validate_test.go @@ -2,6 +2,7 @@ package config import ( "encoding/json" + "fmt" "io/fs" "os" "path/filepath" @@ -13,6 +14,55 @@ import ( "gopkg.in/yaml.v3" ) +func TestGlossaryAuthoringExamplesResolve(t *testing.T) { + examples, err := filepath.Abs(filepath.Join("..", "..", "examples")) + if err != nil { + t.Fatal(err) + } + for _, tc := range []struct { + name, fragment, selectors, campaign, setting, spells string + }{ + {name: "inline", fragment: "inline-only.yml", campaign: "Silver Watch", setting: "entries: []", spells: "entries: []"}, + {name: "file", fragment: "file-only.yml", campaign: "Lantern Watch", setting: "entries: []", spells: "entries: []"}, + {name: "combined with catalog", fragment: "combined.yml", selectors: " setting: lantern_coast\n system: sample_magic\n", campaign: "Silver Watch", setting: "North Harbor", spells: "Lantern Glow"}, + } { + t.Run(tc.name, func(t *testing.T) { + dir := t.TempDir() + fragment := filepath.Join("glossary-authoring", tc.fragment) + for _, name := range []string{fragment, "glossary.yml"} { + data, err := os.ReadFile(filepath.Join(examples, name)) + if err != nil { + t.Fatal(err) + } + writePipelineFixture(t, dir, name, string(data)) + } + campaign := writePipelineFixture(t, dir, "campaign.yml", fmt.Sprintf(`config: + imports: + - path: %q +campaign_id: sample-campaign +inputs: + speakers_file: %q + autocorrect_file: %q + party_file: %q +%s`, fragment, filepath.Join(examples, "campaigns", "sample-campaign", "speakers.yml"), filepath.Join(examples, "campaigns", "sample-campaign", "autocorrect.yml"), filepath.Join(examples, "campaigns", "sample-campaign", "party.yml"), tc.selectors)) + session := writePipelineFixture(t, dir, "session.yml", "session_id: session\ninputs: {audio_dir: audio}\n") + cfg, err := LoadWithSessionOptions(filepath.Join(examples, "pipeline.catalog.yml"), campaign, session, SessionLoadOptions{}) + if err != nil { + t.Fatal(err) + } + docs, err := ResolveGlossaries(cfg) + if err != nil { + t.Fatal(err) + } + for role, want := range map[string]string{"campaign": tc.campaign, "setting": tc.setting, "spells": tc.spells} { + if !strings.Contains(string(docs[role]), want) { + t.Fatalf("%s = %s; want %q", role, docs[role], want) + } + } + }) + } +} + func TestRepresentativeLoadDefaultsAndValidation(t *testing.T) { pipelinePath, sessionPath := writeConfigFiles(t, `whisperx: transcribe_url: https://transcription.example.com/transcribe @@ -261,6 +311,7 @@ func TestExamplesLoadAndValidate(t *testing.T) { t.Setenv("NOTARIUS_LLM_API_KEY", "synthetic-example-notarius-key") examplesDir := filepath.Join("..", "..", "examples") if got, want := maintainedPipelineRoots(t, examplesDir), []string{ + "pipeline.catalog.yml", "pipeline.extraction-subset.yml", "pipeline.full.annotated.yml", "pipeline.minimal.yml", @@ -274,6 +325,7 @@ func TestExamplesLoadAndValidate(t *testing.T) { pipelineFile string sessionFile string }{ + {name: "catalog pipeline with local audio session", pipelineFile: "pipeline.catalog.yml", sessionFile: "session.local-audio.yml"}, { name: "minimal pipeline with local audio session", pipelineFile: "pipeline.minimal.yml", diff --git a/internal/config/notarius_test.go b/internal/config/notarius_test.go index 26b5a63..2b0ceff 100644 --- a/internal/config/notarius_test.go +++ b/internal/config/notarius_test.go @@ -359,7 +359,7 @@ func TestNotariusReferenceValidationAndNormalization(t *testing.T) { cfg.References = map[string]string{ " party ": " narratio.input.party ", " chunk . players ": "narratio.input.players", - " npc-registry . extract . glossary ": "narratio.input.glossary", + " npc-registry . extract . glossary ": "narratio.input.glossary.campaign", "spells": "narratio.input.spell_catalog", } @@ -372,7 +372,7 @@ func TestNotariusReferenceValidationAndNormalization(t *testing.T) { want := map[string]string{ "party": "narratio.input.party", "chunk.players": "narratio.input.players", - "npc-registry.extract.glossary": "narratio.input.glossary", + "npc-registry.extract.glossary": "narratio.input.glossary.campaign", "spells": "narratio.input.spell_catalog", } if len(cfg.References) != len(want) { diff --git a/internal/config/scriptorium_test.go b/internal/config/scriptorium_test.go index 35da401..60c3ad8 100644 --- a/internal/config/scriptorium_test.go +++ b/internal/config/scriptorium_test.go @@ -247,7 +247,7 @@ func TestScriptoriumLoadAndValidate(t *testing.T) { source: narratio.input.party required: true glossary: - source: narratio.input.glossary + source: narratio.input.glossary.campaign required: false `, }, diff --git a/internal/stage/analyze_test.go b/internal/stage/analyze_test.go index b3e70c7..25f5b64 100644 --- a/internal/stage/analyze_test.go +++ b/internal/stage/analyze_test.go @@ -1148,12 +1148,12 @@ func TestAnalyzeResolvesPreparedStableInputSources(t *testing.T) { writeAnalyzeFile(t, filepath.Join(paths.TranscriptsDir, "final.trimmed.json"), `{"segments":[]}`) playersPath := filepath.Join(paths.InputsDir, "players.yml") partyPath := filepath.Join(paths.InputsDir, "party.yml") - glossaryPath := filepath.Join(paths.InputsDir, "glossary.yml") + glossaryPath := filepath.Join(paths.InputsDir, "glossaries", "campaign.yml") spellCatalogPath := filepath.Join(paths.InputsDir, "spell_catalog.json") recordPreparedAnalyzeInput(t, m, artifactpolicy.SourceInputPlayers, playersPath, "- Eric\n") m.Inputs[len(m.Inputs)-1].Source = "derived_from_party" recordPreparedAnalyzeInput(t, m, artifactpolicy.SourceInputParty, partyPath, "- Arannis\n") - recordPreparedAnalyzeInput(t, m, artifactpolicy.SourceInputGlossary, glossaryPath, "- term: Ten Towns\n") + recordPreparedAnalyzeInput(t, m, artifactpolicy.SourceInputGlossaryCampaign, glossaryPath, "campaign: {entries: [{id: ten_towns, name: Ten Towns}]}\n") recordPreparedAnalyzeInput(t, m, artifactpolicy.SourceInputSpellCatalog, spellCatalogPath, "{\"spells\":[]}\n") artifact := env.Config.ArtifactCatalog.Artifacts["session_recap"] @@ -1166,7 +1166,7 @@ func TestAnalyzeResolvesPreparedStableInputSources(t *testing.T) { Required: true, } artifact.Inputs["glossary"] = config.ScriptoriumInputConfig{ - Source: "narratio.input.glossary", + Source: "narratio.input.glossary.campaign", Required: true, } artifact.Inputs["spells"] = config.ScriptoriumInputConfig{ diff --git a/internal/stage/extract_test.go b/internal/stage/extract_test.go index d451999..c9f9a9e 100644 --- a/internal/stage/extract_test.go +++ b/internal/stage/extract_test.go @@ -173,7 +173,7 @@ func TestExtractStageResolvesAllPreparedReferencesInSelectorOrder(t *testing.T) }{ {selector: " players ", sourceID: artifactpolicy.SourceInputPlayers, contents: "players-secret\n"}, {selector: "spells.spell_catalog", sourceID: artifactpolicy.SourceInputSpellCatalog, contents: "spell-secret\n"}, - {selector: "glossary", sourceID: artifactpolicy.SourceInputGlossary, contents: "glossary-secret\n"}, + {selector: "glossary", sourceID: artifactpolicy.SourceInputGlossaryCampaign, contents: "glossary-secret\n"}, {selector: "party", sourceID: artifactpolicy.SourceInputParty, contents: "party-secret\n"}, } env.Config.Pipeline.Notarius.References = make(map[string]string, len(configured)) @@ -433,7 +433,7 @@ func TestExtractReferenceSnapshotsDeduplicateEquivalentDestinations(t *testing.T Bindings: []notarius.ReferenceBinding{{Selector: "party"}, {Selector: "alternate"}}, Identities: []extractReferenceIdentity{ identity, - {Selector: "alternate", SourceID: artifactpolicy.SourceInputGlossary, Path: identity.Path, Checksum: checksum, SizeBytes: identity.SizeBytes}, + {Selector: "alternate", SourceID: artifactpolicy.SourceInputGlossaryCampaign, Path: identity.Path, Checksum: checksum, SizeBytes: identity.SizeBytes}, }, } bindings, err := materializeExtractReferenceSnapshots(sessionPathsForEnv(env, m.SessionID), references) @@ -964,7 +964,9 @@ func TestExtractionFingerprintIsIndependentOfOutputMapOrder(t *testing.T) { mutate func(*extractReferenceIdentity) }{ {name: "selector", mutate: func(identity *extractReferenceIdentity) { identity.Selector = "changed" }}, - {name: "source", mutate: func(identity *extractReferenceIdentity) { identity.SourceID = artifactpolicy.SourceInputGlossary }}, + {name: "source", mutate: func(identity *extractReferenceIdentity) { + identity.SourceID = artifactpolicy.SourceInputGlossaryCampaign + }}, {name: "path", mutate: func(identity *extractReferenceIdentity) { identity.Path = "inputs/changed.yml" }}, {name: "checksum", mutate: func(identity *extractReferenceIdentity) { identity.Checksum = "changed-checksum" }}, {name: "size", mutate: func(identity *extractReferenceIdentity) { identity.SizeBytes++ }}, diff --git a/internal/stage/prepare_test.go b/internal/stage/prepare_test.go index ae6e096..098035a 100644 --- a/internal/stage/prepare_test.go +++ b/internal/stage/prepare_test.go @@ -876,7 +876,7 @@ inputs: writeFile(t, sessionPath, "session_id: 2026-05-03\n") writeFile(t, filepath.Join(cfgDir, "speakers.yml"), "alice: alice.flac\n") writeFile(t, filepath.Join(cfgDir, "autocorrect.yml"), "[]\n") - writeFile(t, filepath.Join(cfgDir, "glossary.yml"), "[]\n") + writeFile(t, filepath.Join(cfgDir, "glossary.yml"), "campaign: {entries: []}\n") partyBytes := []byte("schema_version: narratio.party.v1\ncharacters:\n arannis:\n player: {name: Eric}\n character:\n name: Arannis\n classes: [{name: wizard}]\n") writeFile(t, filepath.Join(cfgDir, "party.yml"), string(partyBytes)) party, err := config.ParseParty(partyBytes) diff --git a/internal/stage/transcribe_test.go b/internal/stage/transcribe_test.go index 9b6f257..3fa4dd8 100644 --- a/internal/stage/transcribe_test.go +++ b/internal/stage/transcribe_test.go @@ -426,7 +426,7 @@ func setupTranscribeEnv(t *testing.T, audioFiles []string) (*Env, *manifest.Mani writeFile(t, campaignPath, "campaign_id: sample-campaign\ninputs:\n speakers_file: ./speakers.yml\n autocorrect_file: ./autocorrect.yml\n glossary_file: ./glossary.yml\n party_file: ./party.yml\n") writeFile(t, filepath.Join(cfgDir, "speakers.yml"), "alice: alice.flac\n") writeFile(t, filepath.Join(cfgDir, "autocorrect.yml"), "[]\n") - writeFile(t, filepath.Join(cfgDir, "glossary.yml"), "[]\n") + writeFile(t, filepath.Join(cfgDir, "glossary.yml"), "campaign: {entries: []}\n") partyBytes := []byte("schema_version: narratio.party.v1\ncharacters:\n arannis:\n player: {name: Eric}\n character:\n name: Arannis\n classes: [{name: wizard}]\n") writeFile(t, filepath.Join(cfgDir, "party.yml"), string(partyBytes)) party, err := config.ParseParty(partyBytes) @@ -462,7 +462,7 @@ func setupTranscribeEnv(t *testing.T, audioFiles []string) (*Env, *manifest.Mani AudioDir: "./audio", SpeakersFile: "./speakers.yml", AutocorrectFile: "./autocorrect.yml", - GlossaryFile: new("./glossary.yml"), + GlossaryFile: new(filepath.Join(cfgDir, "glossary.yml")), }, }, StableInputs: config.ResolvedStableInputs{