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

@@ -575,7 +575,13 @@ stage transition, or latest-view rotation occurs.
## Stage 16. Cut maintained consumer bindings and examples over explicitly ## 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 Update maintained pipelines, campaign/session examples, and synthetic fixtures
to the new fields and source IDs. Replace the old Notarius text `glossary` to the new fields and source IDs. Replace the old Notarius text `glossary`

View File

@@ -9,6 +9,10 @@ in the [configuration reference](../docs/config.md).
- [Minimal pipeline](pipeline.minimal.yml): campaign discovery plus the required - [Minimal pipeline](pipeline.minimal.yml): campaign discovery plus the required
WhisperX URL. 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, - [Production-shaped pipeline](pipeline.production.yml): S3 storage, publish,
external tools, and configured Scriptorium artifacts. external tools, and configured Scriptorium artifacts.
- [Production-base/testing-overlay bundle](production-testing/pipeline.yml): - [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 demonstrate the narrow placeholder syntax consumed by `session init`; they
are templates, not runtime session files. 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 ## Input Fixtures
- [Speakers](speakers.yml), [autocorrect](autocorrect.yml), and - [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 example domains. The Audita and Notarius names are example references, not
implicit aliases: external backend/profile configurations must use those exact implicit aliases: external backend/profile configurations must use those exact
names, or the Narratio credential lists must be changed to match. See the 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 maintained downstream configuration examples.
For a deployed bundle, keep credential files out of source control. Select a For a deployed bundle, keep credential files out of source control. Select a

View File

@@ -1 +1,3 @@
[] campaign:
entries:
- {id: lantern_watch, name: Lantern Watch, category: organization}

View File

@@ -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}

View File

@@ -0,0 +1,3 @@
# Campaign inputs fragment; select the adjacent sample file when importing this fragment.
inputs:
glossary_file: ../glossary.yml

View File

@@ -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}

View File

@@ -1,2 +1,3 @@
[] campaign:
entries:
- {id: lantern_watch, name: Lantern Watch, category: organization}

View File

@@ -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

View File

@@ -15,7 +15,7 @@ notarius:
pipeline_id: dnd-session pipeline_id: dnd-session
timeout: 3h timeout: 3h
references: references:
glossary: narratio.input.glossary glossary: narratio.input.glossary.campaign
party: narratio.input.party party: narratio.input.party
players: narratio.input.players players: narratio.input.players
spell_catalog: narratio.input.spell_catalog spell_catalog: narratio.input.spell_catalog

View File

@@ -95,9 +95,9 @@ audita:
# Optional overrides. Audita owns its own configuration and profiles. # Optional overrides. Audita owns its own configuration and profiles.
binary: audita binary: audita
timeout: 3h 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] credentials: [AUDITA_LLM_API_KEY]
# Omit modules for Audita's default sequence; modules: [] disables corrections. # Configure processing order in Audita configuration.
overlay: "" overlay: ""
proposal_profile: "" proposal_profile: ""
validation_profile: "" validation_profile: ""
@@ -149,7 +149,7 @@ notarius:
# External campaign references use prepared Narratio source IDs. Omit an # External campaign references use prepared Narratio source IDs. Omit an
# optional binding when the selected Notarius pipeline does not need it. # optional binding when the selected Notarius pipeline does not need it.
references: references:
glossary: narratio.input.glossary glossary: narratio.input.glossary.campaign
party: narratio.input.party party: narratio.input.party
players: narratio.input.players players: narratio.input.players
spell_catalog: narratio.input.spell_catalog spell_catalog: narratio.input.spell_catalog
@@ -247,7 +247,7 @@ scriptorium:
source: narratio.input.party source: narratio.input.party
required: true required: true
glossary: glossary:
source: narratio.input.glossary source: narratio.input.glossary.campaign
required: false required: false
vars: vars:
session_id: true session_id: true

View File

@@ -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: workspace:
root: /var/lib/narratio/workspace root: /var/lib/narratio/workspace
cleanup_after_publish: true cleanup_after_publish: true
@@ -58,7 +65,7 @@ audita:
binary: audita binary: audita
timeout: 3h timeout: 3h
credentials: [AUDITA_LLM_API_KEY] credentials: [AUDITA_LLM_API_KEY]
# Omit modules to use Audita defaults; modules: [] disables corrections. # Configure processing order in Audita configuration.
output_schema: audita-v1 output_schema: audita-v1
normalize: normalize:
@@ -93,7 +100,7 @@ scriptorium:
source: narratio.input.party source: narratio.input.party
required: true required: true
glossary: glossary:
source: narratio.input.glossary source: narratio.input.glossary.campaign
required: false required: false
vars: vars:
session_id: true session_id: true

View File

@@ -8,7 +8,6 @@ seriatim:
audita: audita:
binary: audita binary: audita
modules: [glossary, grammar]
output_schema: audita-v1 output_schema: audita-v1
proposal_profile: narratio-production-model-placeholder proposal_profile: narratio-production-model-placeholder
validation_profile: narratio-production-validator-placeholder validation_profile: narratio-production-validator-placeholder

View File

@@ -0,0 +1,5 @@
reference_catalog:
settings:
lantern_coast: ./setting.yml
systems:
sample_magic: ./spells.yml

View File

@@ -0,0 +1,3 @@
setting:
entries:
- {id: harbor, name: North Harbor, category: place}

View File

@@ -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}

View File

@@ -0,0 +1,3 @@
spells:
entries:
- {id: glow, name: Lantern Glow, category: spell}

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.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") 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") 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 { if err := store.Save(context.Background(), manifestPath, seed); err != nil {
t.Fatalf("save manifest: %v", err) t.Fatalf("save manifest: %v", err)

View File

@@ -10,6 +10,7 @@ import (
"testing" "testing"
"time" "time"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/audita"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/scriptorium" "gitea.maximumdirect.net/eric/narratio/internal/adapters/scriptorium"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage" "gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
"gitea.maximumdirect.net/eric/narratio/internal/artifacts" "gitea.maximumdirect.net/eric/narratio/internal/artifacts"
@@ -20,6 +21,7 @@ import (
func TestAssembledFullRunUsesCanonicalOrder(t *testing.T) { func TestAssembledFullRunUsesCanonicalOrder(t *testing.T) {
cfg := testConfig(t) cfg := testConfig(t)
seedGlossaryManifest(t, cfg)
canonical := []string{ canonical := []string{
"prepare", "transcribe", "merge", "polish", "normalize", "trim", "prepare", "transcribe", "merge", "polish", "normalize", "trim",
"render", "extract", "analyze", "publish", "notify", "cleanup", "render", "extract", "analyze", "publish", "notify", "cleanup",
@@ -29,7 +31,7 @@ func TestAssembledFullRunUsesCanonicalOrder(t *testing.T) {
for _, name := range canonical { for _, name := range canonical {
stages = append(stages, resultStage{name: name, result: &stage.StageResult{}, order: &order}) 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 { if err != nil {
t.Fatalf("executeStages() error = %v", err) t.Fatalf("executeStages() error = %v", err)
} }
@@ -323,6 +325,7 @@ func TestAssembledSplitBundleProfileSwitchRecordsProvenanceAndLimitsReuse(t *tes
providers := make([]stage.SemanticConfigFingerprinter, len(names)) providers := make([]stage.SemanticConfigFingerprinter, len(names))
seed := manifest.New(production.Session.SessionID, time.Now().UTC()) seed := manifest.New(production.Session.SessionID, time.Now().UTC())
seed.Campaign = production.Session.Campaign seed.Campaign = production.Session.Campaign
seedGlossaryRecords(t, workspace, seed)
for _, candidate := range stage.All() { for _, candidate := range stage.All() {
seed.MarkStageSucceeded(candidate.Name(), time.Now().UTC(), nil) seed.MarkStageSucceeded(candidate.Name(), time.Now().UTC(), nil)
} }
@@ -352,7 +355,7 @@ func TestAssembledSplitBundleProfileSwitchRecordsProvenanceAndLimitsReuse(t *tes
testingRuns := make([]int, len(names)) testingRuns := make([]int, len(names))
testingStages := assembledSemanticStages(names, providers, testingRuns) 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 { if err != nil {
t.Fatalf("switch to testing profile: %v", err) 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, "speakers.yml"), "match:\n - speaker: Alice\n match: [\"alice\"]\n")
mustWriteTestFile(t, filepath.Join(campaignDir, "autocorrect.yml"), "[]\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(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") mustWriteTestFile(t, filepath.Join(dir, "audio", "alice.flac"), "audio-bytes")
@@ -702,12 +702,15 @@ func TestAuditaAppHelper(t *testing.T) {
os.Exit(2) os.Exit(2)
} }
processArgs := args[start:] processArgs := args[start:]
if len(processArgs) < 2 || processArgs[0] != "process" { if len(processArgs) < 2 || (processArgs[0] != "process" && processArgs[0] != "preflight") {
_, _ = os.Stderr.WriteString("expected Audita v2 process invocation\n") _, _ = os.Stderr.WriteString("expected Audita process or preflight invocation\n")
os.Exit(2) os.Exit(2)
} }
if processArgs[0] == "preflight" {
os.Exit(0)
}
for _, arg := range processArgs { 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.Stderr.WriteString("retired or unwanted Audita flag\n")
os.Exit(2) os.Exit(2)
} }
@@ -726,8 +729,12 @@ func TestAuditaAppHelper(t *testing.T) {
_, _ = os.Stderr.WriteString(fmt.Sprintf("write output: %v\n", err)) _, _ = os.Stderr.WriteString(fmt.Sprintf("write output: %v\n", err))
os.Exit(2) 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"} { 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.Stderr.WriteString(fmt.Sprintf("write %s: %v\n", name, err))
os.Exit(2) os.Exit(2)
} }

View File

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

View File

@@ -6,13 +6,17 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"path/filepath"
"strings" "strings"
"testing" "testing"
"time" "time"
"gitea.maximumdirect.net/eric/narratio/internal/artifactpolicy"
"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/manifest" "gitea.maximumdirect.net/eric/narratio/internal/manifest"
"gitea.maximumdirect.net/eric/narratio/internal/stage"
"go.maximumdirect.net/commandkit" "go.maximumdirect.net/commandkit"
) )
@@ -81,11 +85,62 @@ func seedInvocationPrerequisites(t *testing.T, root, selected string) {
m.Campaign = "sample-campaign" m.Campaign = "sample-campaign"
} }
markFixturePrerequisites(t, m, selected) markFixturePrerequisites(t, m, selected)
if selected == "polish" {
seedGlossaryRecords(t, root, m)
}
if err := store.Save(context.Background(), path, m); err != nil { if err := store.Save(context.Background(), path, m); err != nil {
t.Fatal(err) 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 { func findingMatches(findings []finding, severity, category, message string) bool {
for _, item := range findings { for _, item := range findings {
if (severity == "" || item.Severity == severity) && item.Category == category && strings.Contains(item.Message, message) { if (severity == "" || item.Severity == severity) && item.Category == category && strings.Contains(item.Message, message) {

View File

@@ -11,6 +11,7 @@ import (
"testing" "testing"
"time" "time"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/audita"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/scriptorium" "gitea.maximumdirect.net/eric/narratio/internal/adapters/scriptorium"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage" "gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
"gitea.maximumdirect.net/eric/narratio/internal/artifactmodel" "gitea.maximumdirect.net/eric/narratio/internal/artifactmodel"
@@ -441,11 +442,12 @@ inputs:
`), 0o644); err != nil { `), 0o644); err != nil {
t.Fatalf("write session: %v", err) 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{} fake := &storage.FakeBackend{}
audioKey := artifacts.S3PublishedOutputKey(artifacts.S3AudioPrefix(artifacts.S3SessionPrefix("dnd", "sample-campaign", "2026-05-03"), "audio/"), "alice.flac") 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")}) 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" { if os.Getenv(accessKeyEnv) != "test-key-id" || os.Getenv(secretKeyEnv) != "test-secret" {
return nil, fmt.Errorf("secrets were not loaded before object store init") 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") spellPath := filepath.Join(filepath.Dir(campaignPath), "spells.json")
mustWriteTestFile(t, spellPath, "{\"spells\":[]}\n") mustWriteTestFile(t, spellPath, "{\"spells\":[]}\n")
seedValidationPrepared(t, loadConfigForSemanticEvidence(t, pipelinePath, campaignPath, sessionPath))
fake := &storage.FakeBackend{} fake := &storage.FakeBackend{}
var storeInitCalls int var storeInitCalls int

View File

@@ -234,11 +234,14 @@ func TestProviderCredentialProcessFixture(t *testing.T) {
os.Exit(0) os.Exit(0)
} }
switch args[0] { switch args[0] {
case "process": case "process", "preflight":
if os.Getenv(auditaOnlyName) != auditaOnlyKey { if os.Getenv(auditaOnlyName) != auditaOnlyKey {
_, _ = os.Stderr.WriteString("Audita-only credential not forwarded\n") _, _ = os.Stderr.WriteString("Audita-only credential not forwarded\n")
os.Exit(2) os.Exit(2)
} }
if args[0] == "preflight" {
os.Exit(0)
}
output := appSeriatimFlagValue(args, "--output") output := appSeriatimFlagValue(args, "--output")
if output == "" { if output == "" {
os.Exit(2) 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 { if err := os.WriteFile(output, []byte(`{"schema":"audita.processed.v1","segments":[]}`), 0o644); err != nil {
os.Exit(2) 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"} { 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) os.Exit(2)
} }
} }

View File

@@ -10,6 +10,7 @@ import (
"strings" "strings"
"testing" "testing"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/audita"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/scriptorium" "gitea.maximumdirect.net/eric/narratio/internal/adapters/scriptorium"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage" "gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
"gitea.maximumdirect.net/eric/narratio/internal/artifacts" "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 { 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 { if storeInitCalls != nil {
*storeInitCalls++ *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.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") 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") 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 { if err := store.Save(context.Background(), manifestPath, m); err != nil {
t.Fatalf("save manifest: %v", err) 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)) 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) setCurrentBuiltInEvidence(t, m, "merge", artifacts.TranscriptOutputKindBase, artifacts.ArtifactTranscriptBase, basePath)
m.MarkStageSucceeded("polish", time.Date(2026, 5, 3, 10, 1, 0, 0, time.UTC), nil) 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") seedCurrentSemanticEvidence(t, loadConfigForSemanticEvidence(t, pipelinePath, campaignPath, sessionPath), m, "polish")
if err := store.Save(context.Background(), manifestPath, m); err != nil { if err := store.Save(context.Background(), manifestPath, m); err != nil {
t.Fatalf("save manifest: %v", err) t.Fatalf("save manifest: %v", err)

View File

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

View File

@@ -10,6 +10,9 @@ import (
) )
func inspectInvocationRequirements(runtime *invocationRuntime, start int) error { func inspectInvocationRequirements(runtime *invocationRuntime, start int) error {
if !stagesContainAny(runtime.stages[start:], "polish", "trim", "analyze") {
return nil
}
remaining := runtime.plan remaining := runtime.plan
remaining.stages = append([]stage.Stage(nil), runtime.stages[start:]...) 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) 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" "testing"
"time" "time"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/audita"
"gitea.maximumdirect.net/eric/narratio/internal/manifest" "gitea.maximumdirect.net/eric/narratio/internal/manifest"
"gitea.maximumdirect.net/eric/narratio/internal/stage" "gitea.maximumdirect.net/eric/narratio/internal/stage"
) )
@@ -147,6 +148,7 @@ func TestExecuteStagesResumeValidationFailureRecordsSessionFailure(t *testing.T)
func TestExecuteStagesSuccessfulSaveFailureMarksStageFailedAndInvalidatesDependents(t *testing.T) { func TestExecuteStagesSuccessfulSaveFailureMarksStageFailedAndInvalidatesDependents(t *testing.T) {
cfg := testConfig(t) cfg := testConfig(t)
seedGlossaryManifest(t, cfg)
store := &successfulStageSaveFailingStore{ store := &successfulStageSaveFailingStore{
delegate: &manifest.LocalStore{}, delegate: &manifest.LocalStore{},
stageName: "polish", stageName: "polish",
@@ -155,7 +157,7 @@ func TestExecuteStagesSuccessfulSaveFailureMarksStageFailedAndInvalidatesDepende
_, err := executeStages(context.Background(), cfg, []stage.Stage{ _, err := executeStages(context.Background(), cfg, []stage.Stage{
countingStage{name: "polish", runs: new(int)}, 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\"") { if err == nil || !strings.Contains(err.Error(), "save manifest after stage \"polish\"") {
t.Fatalf("executeStages() error = %v, want successful-stage save failure", err) t.Fatalf("executeStages() error = %v, want successful-stage save failure", err)
} }
@@ -174,8 +176,9 @@ func TestExecuteStagesSuccessfulSaveFailureMarksStageFailedAndInvalidatesDepende
func TestExecuteStagesSelfSkipSaveFailureIsNotReportedComplete(t *testing.T) { func TestExecuteStagesSelfSkipSaveFailureIsNotReportedComplete(t *testing.T) {
cfg := testConfig(t) cfg := testConfig(t)
seedGlossaryManifest(t, cfg)
store := &successfulStageSaveFailingStore{delegate: &manifest.LocalStore{}, stageName: "polish", dependent: "normalize", failStatus: manifest.StatusSkipped} 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" { if err == nil || summary == nil || summary.Complete || len(summary.Skipped) != 0 || summary.StageResults[0].Outcome != "failed" {
t.Fatalf("summary=%#v error=%v", summary, err) t.Fatalf("summary=%#v error=%v", summary, err)
} }

View File

@@ -804,6 +804,7 @@ func TestExecuteStagesForceSuccessInvalidatesDownstreamSucceededStages(t *testin
store := &manifest.LocalStore{} store := &manifest.LocalStore{}
existing := manifest.New(cfg.Session.SessionID, time.Date(2026, 5, 3, 1, 0, 0, 0, time.UTC)) 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"} { 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) 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 runs := 0
stageToRun := countingStage{name: "polish", runs: &runs} 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 { if err != nil {
t.Fatalf("executeStages() error = %v", err) t.Fatalf("executeStages() error = %v", err)
} }
@@ -1238,7 +1239,7 @@ func TestExecuteStagesRunLocalArtifactsAndCanonicalSync(t *testing.T) {
runLocalChecks := []string{ runLocalChecks := []string{
filepath.Join(runRoot, "transcribe", "outputs", "transcripts", "raw", "alice.json"), filepath.Join(runRoot, "transcribe", "outputs", "transcripts", "raw", "alice.json"),
filepath.Join(runRoot, "merge", "logs", "seriatim.stdout.log"), 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, "normalize", "logs", "seriatim.normalize.stdout.log"),
filepath.Join(runRoot, "trim", "outputs", "transcripts", "final.trimmed.json"), filepath.Join(runRoot, "trim", "outputs", "transcripts", "final.trimmed.json"),
} }
@@ -1333,6 +1334,7 @@ func TestExecuteStagesSkippedStagePreservesExistingOutputsProvenance(t *testing.
func TestAdapterFailureMarksManifestFailed(t *testing.T) { func TestAdapterFailureMarksManifestFailed(t *testing.T) {
cfg := testConfig(t) cfg := testConfig(t)
seedGlossaryManifest(t, cfg)
selected, err := stage.Select("polish") selected, err := stage.Select("polish")
if err != nil { if err != nil {
t.Fatalf("Select() error = %v", err) 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 { if err := os.WriteFile(filepath.Join(paths.TranscriptsDir, "base.json"), []byte(`{"segments":[]}`), 0o644); err != nil {
t.Fatalf("write merged transcript: %v", err) 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}) _, runErr := executeStages(context.Background(), cfg, []stage.Stage{selected}, RunOptions{Env: env})
if runErr == nil { 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, 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, "speakers.yml"), "alice: alice.flac\n")
mustWriteFile(t, filepath.Join(cfgDir, "autocorrect.yml"), "[]\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, "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") 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")) 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", AudioDir: "./audio",
SpeakersFile: "./speakers.yml", SpeakersFile: "./speakers.yml",
AutocorrectFile: "./autocorrect.yml", AutocorrectFile: "./autocorrect.yml",
GlossaryFile: new("./glossary.yml"), GlossaryFile: new(filepath.Join(cfgDir, "glossary.yml")),
}, },
}, },
} }

View File

@@ -10,6 +10,7 @@ import (
"testing" "testing"
"time" "time"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/audita"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/scriptorium" "gitea.maximumdirect.net/eric/narratio/internal/adapters/scriptorium"
"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"
@@ -388,6 +389,7 @@ func TestRefinementSemanticChangesRespectDependencyBranches(t *testing.T) {
cfg := testConfig(t) cfg := testConfig(t)
providers := make([]stage.SemanticConfigFingerprinter, len(names)) providers := make([]stage.SemanticConfigFingerprinter, len(names))
seed := manifest.New(cfg.Session.SessionID, time.Now().UTC()) seed := manifest.New(cfg.Session.SessionID, time.Now().UTC())
seedGlossaryRecords(t, cfg.Pipeline.Workspace.Root, seed)
for _, candidate := range stage.All() { for _, candidate := range stage.All() {
seed.MarkStageSucceeded(candidate.Name(), time.Now().UTC(), nil) seed.MarkStageSucceeded(candidate.Name(), time.Now().UTC(), nil)
} }
@@ -410,7 +412,7 @@ func TestRefinementSemanticChangesRespectDependencyBranches(t *testing.T) {
for index, name := range names { for index, name := range names {
selected = append(selected, semanticContractRunStub{name: name, provider: providers[index], runs: &runs[index]}) 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) t.Fatal(err)
} }
if runs != test.wantRuns { if runs != test.wantRuns {
@@ -431,6 +433,7 @@ func TestOldPolishSemanticEvidenceIsReconsideredOnlyWhenSelected(t *testing.T) {
cfg := testConfig(t) cfg := testConfig(t)
names := []string{"prepare", "transcribe", "merge", "polish", "normalize", "trim", "render"} names := []string{"prepare", "transcribe", "merge", "polish", "normalize", "trim", "render"}
seed := manifest.New(cfg.Session.SessionID, time.Now().UTC()) seed := manifest.New(cfg.Session.SessionID, time.Now().UTC())
seedGlossaryRecords(t, cfg.Pipeline.Workspace.Root, seed)
for _, candidate := range stage.All() { for _, candidate := range stage.All() {
seed.MarkStageSucceeded(candidate.Name(), time.Now().UTC(), nil) 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 { if loaded.Stages["polish"].SemanticConfig.Version != seed.Stages["polish"].SemanticConfig.Version {
t.Fatal("downstream-only execution rewrote unselected polish evidence") 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) t.Fatal(err)
} }
if want := []int{0, 0, 0, 1, 1, 1, 1}; !reflect.DeepEqual(runs, want) { 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 { if err != nil {
t.Fatal(err) 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"]) 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 { for index := range runs {

View File

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

View File

@@ -2,6 +2,7 @@ package config
import ( import (
"encoding/json" "encoding/json"
"fmt"
"io/fs" "io/fs"
"os" "os"
"path/filepath" "path/filepath"
@@ -13,6 +14,55 @@ import (
"gopkg.in/yaml.v3" "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) { func TestRepresentativeLoadDefaultsAndValidation(t *testing.T) {
pipelinePath, sessionPath := writeConfigFiles(t, `whisperx: pipelinePath, sessionPath := writeConfigFiles(t, `whisperx:
transcribe_url: https://transcription.example.com/transcribe 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") t.Setenv("NOTARIUS_LLM_API_KEY", "synthetic-example-notarius-key")
examplesDir := filepath.Join("..", "..", "examples") examplesDir := filepath.Join("..", "..", "examples")
if got, want := maintainedPipelineRoots(t, examplesDir), []string{ if got, want := maintainedPipelineRoots(t, examplesDir), []string{
"pipeline.catalog.yml",
"pipeline.extraction-subset.yml", "pipeline.extraction-subset.yml",
"pipeline.full.annotated.yml", "pipeline.full.annotated.yml",
"pipeline.minimal.yml", "pipeline.minimal.yml",
@@ -274,6 +325,7 @@ func TestExamplesLoadAndValidate(t *testing.T) {
pipelineFile string pipelineFile string
sessionFile 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", name: "minimal pipeline with local audio session",
pipelineFile: "pipeline.minimal.yml", pipelineFile: "pipeline.minimal.yml",

View File

@@ -359,7 +359,7 @@ func TestNotariusReferenceValidationAndNormalization(t *testing.T) {
cfg.References = map[string]string{ cfg.References = map[string]string{
" party ": " narratio.input.party ", " party ": " narratio.input.party ",
" chunk . players ": "narratio.input.players", " 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", "spells": "narratio.input.spell_catalog",
} }
@@ -372,7 +372,7 @@ func TestNotariusReferenceValidationAndNormalization(t *testing.T) {
want := map[string]string{ want := map[string]string{
"party": "narratio.input.party", "party": "narratio.input.party",
"chunk.players": "narratio.input.players", "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", "spells": "narratio.input.spell_catalog",
} }
if len(cfg.References) != len(want) { if len(cfg.References) != len(want) {

View File

@@ -247,7 +247,7 @@ func TestScriptoriumLoadAndValidate(t *testing.T) {
source: narratio.input.party source: narratio.input.party
required: true required: true
glossary: glossary:
source: narratio.input.glossary source: narratio.input.glossary.campaign
required: false required: false
`, `,
}, },

View File

@@ -1148,12 +1148,12 @@ func TestAnalyzeResolvesPreparedStableInputSources(t *testing.T) {
writeAnalyzeFile(t, filepath.Join(paths.TranscriptsDir, "final.trimmed.json"), `{"segments":[]}`) writeAnalyzeFile(t, filepath.Join(paths.TranscriptsDir, "final.trimmed.json"), `{"segments":[]}`)
playersPath := filepath.Join(paths.InputsDir, "players.yml") playersPath := filepath.Join(paths.InputsDir, "players.yml")
partyPath := filepath.Join(paths.InputsDir, "party.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") spellCatalogPath := filepath.Join(paths.InputsDir, "spell_catalog.json")
recordPreparedAnalyzeInput(t, m, artifactpolicy.SourceInputPlayers, playersPath, "- Eric\n") recordPreparedAnalyzeInput(t, m, artifactpolicy.SourceInputPlayers, playersPath, "- Eric\n")
m.Inputs[len(m.Inputs)-1].Source = "derived_from_party" m.Inputs[len(m.Inputs)-1].Source = "derived_from_party"
recordPreparedAnalyzeInput(t, m, artifactpolicy.SourceInputParty, partyPath, "- Arannis\n") 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") recordPreparedAnalyzeInput(t, m, artifactpolicy.SourceInputSpellCatalog, spellCatalogPath, "{\"spells\":[]}\n")
artifact := env.Config.ArtifactCatalog.Artifacts["session_recap"] artifact := env.Config.ArtifactCatalog.Artifacts["session_recap"]
@@ -1166,7 +1166,7 @@ func TestAnalyzeResolvesPreparedStableInputSources(t *testing.T) {
Required: true, Required: true,
} }
artifact.Inputs["glossary"] = config.ScriptoriumInputConfig{ artifact.Inputs["glossary"] = config.ScriptoriumInputConfig{
Source: "narratio.input.glossary", Source: "narratio.input.glossary.campaign",
Required: true, Required: true,
} }
artifact.Inputs["spells"] = config.ScriptoriumInputConfig{ artifact.Inputs["spells"] = config.ScriptoriumInputConfig{

View File

@@ -173,7 +173,7 @@ func TestExtractStageResolvesAllPreparedReferencesInSelectorOrder(t *testing.T)
}{ }{
{selector: " players ", sourceID: artifactpolicy.SourceInputPlayers, contents: "players-secret\n"}, {selector: " players ", sourceID: artifactpolicy.SourceInputPlayers, contents: "players-secret\n"},
{selector: "spells.spell_catalog", sourceID: artifactpolicy.SourceInputSpellCatalog, contents: "spell-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"}, {selector: "party", sourceID: artifactpolicy.SourceInputParty, contents: "party-secret\n"},
} }
env.Config.Pipeline.Notarius.References = make(map[string]string, len(configured)) 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"}}, Bindings: []notarius.ReferenceBinding{{Selector: "party"}, {Selector: "alternate"}},
Identities: []extractReferenceIdentity{ Identities: []extractReferenceIdentity{
identity, 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) bindings, err := materializeExtractReferenceSnapshots(sessionPathsForEnv(env, m.SessionID), references)
@@ -964,7 +964,9 @@ func TestExtractionFingerprintIsIndependentOfOutputMapOrder(t *testing.T) {
mutate func(*extractReferenceIdentity) mutate func(*extractReferenceIdentity)
}{ }{
{name: "selector", mutate: func(identity *extractReferenceIdentity) { identity.Selector = "changed" }}, {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: "path", mutate: func(identity *extractReferenceIdentity) { identity.Path = "inputs/changed.yml" }},
{name: "checksum", mutate: func(identity *extractReferenceIdentity) { identity.Checksum = "changed-checksum" }}, {name: "checksum", mutate: func(identity *extractReferenceIdentity) { identity.Checksum = "changed-checksum" }},
{name: "size", mutate: func(identity *extractReferenceIdentity) { identity.SizeBytes++ }}, {name: "size", mutate: func(identity *extractReferenceIdentity) { identity.SizeBytes++ }},

View File

@@ -876,7 +876,7 @@ inputs:
writeFile(t, sessionPath, "session_id: 2026-05-03\n") 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, "speakers.yml"), "alice: alice.flac\n")
writeFile(t, filepath.Join(cfgDir, "autocorrect.yml"), "[]\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") 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)) writeFile(t, filepath.Join(cfgDir, "party.yml"), string(partyBytes))
party, err := config.ParseParty(partyBytes) party, err := config.ParseParty(partyBytes)

View File

@@ -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, 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, "speakers.yml"), "alice: alice.flac\n")
writeFile(t, filepath.Join(cfgDir, "autocorrect.yml"), "[]\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") 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)) writeFile(t, filepath.Join(cfgDir, "party.yml"), string(partyBytes))
party, err := config.ParseParty(partyBytes) party, err := config.ParseParty(partyBytes)
@@ -462,7 +462,7 @@ func setupTranscribeEnv(t *testing.T, audioFiles []string) (*Env, *manifest.Mani
AudioDir: "./audio", AudioDir: "./audio",
SpeakersFile: "./speakers.yml", SpeakersFile: "./speakers.yml",
AutocorrectFile: "./autocorrect.yml", AutocorrectFile: "./autocorrect.yml",
GlossaryFile: new("./glossary.yml"), GlossaryFile: new(filepath.Join(cfgDir, "glossary.yml")),
}, },
}, },
StableInputs: config.ResolvedStableInputs{ StableInputs: config.ResolvedStableInputs{