Reconcile reuse and inspection with native extraction
This commit is contained in:
@@ -40,7 +40,7 @@ characters:
|
||||
for_each: party.characters
|
||||
prompt_id: dnd.character_items
|
||||
profile_id: production
|
||||
output_path_pattern: artifacts/characters/{character_id}/items.md
|
||||
output_path_pattern: artifacts/{character_id}-items.md
|
||||
inputs:
|
||||
transcript: {source: narratio.transcript.final_trimmed, required: true}
|
||||
member_vars:
|
||||
@@ -56,7 +56,7 @@ characters:
|
||||
for_each: party.characters
|
||||
prompt_id: dnd.character_meta
|
||||
profile_id: production
|
||||
output_path_pattern: artifacts/characters/{character_id}/meta.md
|
||||
output_path_pattern: artifacts/{character_id}-meta.md
|
||||
inputs:
|
||||
transcript: {source: narratio.transcript.final_trimmed, required: true}
|
||||
`))
|
||||
@@ -77,7 +77,7 @@ characters:
|
||||
t.Fatalf("artifact keys = %#v, want %#v", keys, wantKeys)
|
||||
}
|
||||
alpha := cfg.ArtifactCatalog.Artifacts["character_items_alpha"]
|
||||
if alpha.Enabled || alpha.OutputPath != "artifacts/characters/alpha/items.md" {
|
||||
if alpha.Enabled || alpha.OutputPath != "artifacts/alpha-items.md" {
|
||||
t.Fatalf("alpha artifact = %#v", alpha)
|
||||
}
|
||||
if !reflect.DeepEqual(alpha.Vars, map[string]any{
|
||||
@@ -138,7 +138,7 @@ func TestArtifactFamiliesRejectInvalidExpansionDeclarations(t *testing.T) {
|
||||
{name: "repeated token", party: canonicalPartyFixture, families: strings.Replace(validFamilyYAML, "meta.md", "{character_id}.md", 1), wantError: "must contain exactly one"},
|
||||
{name: "member selector", party: canonicalPartyFixture, families: strings.Replace(validFamilyYAML, "character.name", "character.unknown", 1), wantError: "selector"},
|
||||
{name: "static variable collision", party: canonicalPartyFixture, families: strings.Replace(validFamilyYAML, "member_vars:\n character_name", "vars:\n character_name: static\n member_vars:\n character_name", 1), wantError: "conflicts with static vars"},
|
||||
{name: "unsafe output", party: canonicalPartyFixture, families: strings.Replace(validFamilyYAML, "artifacts/characters/{character_id}/meta.md", "../{character_id}.md", 1), wantError: "must not contain path traversal"},
|
||||
{name: "unsafe output", party: canonicalPartyFixture, families: strings.Replace(validFamilyYAML, "artifacts/{character_id}-meta.md", "../{character_id}.md", 1), wantError: "must not contain path traversal"},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
@@ -169,7 +169,7 @@ func TestArtifactFamiliesRejectGeneratedKeyAndOutputCollisions(t *testing.T) {
|
||||
}
|
||||
base := ScriptoriumArtifactFamilyConfig{
|
||||
ForEach: partyCharactersFamilySource, PromptID: "dnd.character_meta",
|
||||
OutputPathPattern: "artifacts/characters/{character_id}/meta.md",
|
||||
OutputPathPattern: "artifacts/{character_id}-meta.md",
|
||||
}
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
@@ -183,7 +183,7 @@ func TestArtifactFamiliesRejectGeneratedKeyAndOutputCollisions(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "generated output", artifacts: map[string]ScriptoriumArtifactConfig{
|
||||
"existing": {OutputPath: "artifacts/characters/arannis/meta.md"},
|
||||
"existing": {OutputPath: "artifacts/arannis-meta.md"},
|
||||
}, wantError: "generates output path",
|
||||
},
|
||||
} {
|
||||
@@ -215,12 +215,12 @@ characters:
|
||||
enabled: true
|
||||
for_each: party.characters
|
||||
prompt_id: dnd.character_meta
|
||||
output_path_pattern: artifacts/characters/{character_id}/meta.md
|
||||
output_path_pattern: artifacts/{character_id}-meta.md
|
||||
character_items:
|
||||
enabled: true
|
||||
for_each: party.characters
|
||||
prompt_id: dnd.character_items
|
||||
output_path_pattern: artifacts/characters/{character_id}/items.md
|
||||
output_path_pattern: artifacts/{character_id}-items.md
|
||||
depends_on: [session_recap]
|
||||
inputs:
|
||||
transcript: {source: narratio.transcript.final_trimmed, required: true}
|
||||
@@ -589,7 +589,7 @@ const validFamilyYAML = `
|
||||
for_each: party.characters
|
||||
prompt_id: dnd.character_meta
|
||||
profile_id: production
|
||||
output_path_pattern: artifacts/characters/{character_id}/meta.md
|
||||
output_path_pattern: artifacts/{character_id}-meta.md
|
||||
member_vars:
|
||||
character_name: character.name
|
||||
`
|
||||
|
||||
@@ -35,9 +35,9 @@ notification:
|
||||
}
|
||||
}
|
||||
|
||||
func TestCampaignStrictDecodeAcceptsCampaignID(t *testing.T) {
|
||||
func TestCampaignStrictDecodeAcceptsSharedID(t *testing.T) {
|
||||
pipelinePath, campaignPath, sessionPath := writeCampaignConfigTestFiles(t,
|
||||
"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",
|
||||
"schema_version: maximumdirect.rpg.campaign.v1\nid: sample-campaign\nreferences: {party: ./party.yml}\nnarratio:\n inputs:\n speakers_file: ./speakers.yml\n glossary_file: ./glossary.yml\n",
|
||||
"session_id: 2026-05-03\ninputs:\n audio_dir: ./audio\n",
|
||||
)
|
||||
|
||||
@@ -60,14 +60,14 @@ func TestCampaignStrictDecodeRejectsLegacyCampaignField(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Fatal("expected load error, got nil")
|
||||
}
|
||||
if !strings.Contains(configurationErrorText(err), "load campaign config") || !strings.Contains(configurationErrorText(err), "decode.unknown_field") {
|
||||
t.Fatalf("error = %q, want campaign strict decode context", configurationErrorText(err))
|
||||
if !strings.Contains(configurationErrorText(err), "load campaign config") || !strings.Contains(configurationErrorText(err), "retired campaign field") {
|
||||
t.Fatalf("error = %q, want retired field context", configurationErrorText(err))
|
||||
}
|
||||
}
|
||||
|
||||
func TestCampaignStrictDecodeRejectsUnknownFields(t *testing.T) {
|
||||
pipelinePath, campaignPath, sessionPath := writeCampaignConfigTestFiles(t,
|
||||
"campaign_id: sample-campaign\nunknown: true\ninputs:\n speakers_file: ./speakers.yml\n autocorrect_file: ./autocorrect.yml\n glossary_file: ./glossary.yml\n party_file: ./party.yml\n",
|
||||
"schema_version: maximumdirect.rpg.campaign.v1\nid: sample-campaign\nreferences: {party: ./party.yml}\nnarratio:\n unknown: true\n inputs: {speakers_file: ./speakers.yml}\n",
|
||||
"session_id: 2026-05-03\ninputs:\n audio_dir: ./audio\n",
|
||||
)
|
||||
|
||||
@@ -82,7 +82,7 @@ func TestCampaignStrictDecodeRejectsUnknownFields(t *testing.T) {
|
||||
|
||||
func TestCampaignStrictDecodeAcceptsSessionTemplateFile(t *testing.T) {
|
||||
pipelinePath, campaignPath, sessionPath := writeCampaignConfigTestFiles(t,
|
||||
"campaign_id: sample-campaign\nsession_template_file: ./session.template.yml\ninputs:\n speakers_file: ./speakers.yml\n autocorrect_file: ./autocorrect.yml\n glossary_file: ./glossary.yml\n party_file: ./party.yml\n",
|
||||
"schema_version: maximumdirect.rpg.campaign.v1\nid: sample-campaign\nreferences: {party: ./party.yml}\nnarratio:\n session_template_file: ./session.template.yml\n inputs:\n speakers_file: ./speakers.yml\n glossary_file: ./glossary.yml\n",
|
||||
"session_id: 2026-05-03\ninputs:\n audio_dir: ./audio\n",
|
||||
)
|
||||
|
||||
@@ -97,7 +97,7 @@ func TestCampaignStrictDecodeAcceptsSessionTemplateFile(t *testing.T) {
|
||||
|
||||
func TestCampaignSessionMergeFillsStableInputs(t *testing.T) {
|
||||
pipelinePath, campaignPath, sessionPath := writeCampaignConfigTestFiles(t,
|
||||
"campaign_id: sample-campaign\ninputs:\n speakers_file: ./campaign-speakers.yml\n autocorrect_file: ./campaign-autocorrect.yml\n glossary_file: ./campaign-glossary.yml\n party_file: ./campaign-party.yml\n",
|
||||
"schema_version: maximumdirect.rpg.campaign.v1\nid: sample-campaign\nreferences: {party: ./campaign-party.yml}\nnarratio:\n inputs:\n speakers_file: ./campaign-speakers.yml\n glossary_file: ./campaign-glossary.yml\n",
|
||||
"session_id: 2026-05-03\ninputs:\n audio_dir: ./audio\n",
|
||||
)
|
||||
|
||||
@@ -112,14 +112,13 @@ func TestCampaignSessionMergeFillsStableInputs(t *testing.T) {
|
||||
t.Fatalf("session campaign = %q, want campaign config value", cfg.Session.Campaign)
|
||||
}
|
||||
assertResolvedStableInput(t, cfg.StableInputs.SpeakersFile, "./campaign-speakers.yml", campaignPath, "campaign_config")
|
||||
assertResolvedStableInput(t, cfg.StableInputs.AutocorrectFile, "./campaign-autocorrect.yml", campaignPath, "campaign_config")
|
||||
assertResolvedStableInput(t, cfg.StableInputs.GlossaryFile, "./campaign-glossary.yml", campaignPath, "campaign_config")
|
||||
assertResolvedStableInput(t, cfg.StableInputs.PartyFile, "./campaign-party.yml", campaignPath, "campaign_config")
|
||||
}
|
||||
|
||||
func TestCampaignSessionMergeSessionOverridesStableInputs(t *testing.T) {
|
||||
pipelinePath, campaignPath, sessionPath := writeCampaignConfigTestFiles(t,
|
||||
"campaign_id: sample-campaign\ninputs:\n speakers_file: ./campaign-speakers.yml\n autocorrect_file: ./campaign-autocorrect.yml\n glossary_file: ./campaign-glossary.yml\n party_file: ./campaign-party.yml\n",
|
||||
"schema_version: maximumdirect.rpg.campaign.v1\nid: sample-campaign\nreferences: {party: ./campaign-party.yml}\nnarratio:\n inputs:\n speakers_file: ./campaign-speakers.yml\n glossary_file: ./campaign-glossary.yml\n",
|
||||
"session_id: 2026-05-03\ncampaign: sample-campaign\ninputs:\n audio_dir: ./audio\n speakers_file: ./session-speakers.yml\n",
|
||||
)
|
||||
|
||||
@@ -131,82 +130,13 @@ func TestCampaignSessionMergeSessionOverridesStableInputs(t *testing.T) {
|
||||
t.Fatalf("Validate() error = %v", err)
|
||||
}
|
||||
assertResolvedStableInput(t, cfg.StableInputs.SpeakersFile, "./session-speakers.yml", sessionPath, "session_config")
|
||||
assertResolvedStableInput(t, cfg.StableInputs.AutocorrectFile, "./campaign-autocorrect.yml", campaignPath, "campaign_config")
|
||||
assertResolvedStableInput(t, cfg.StableInputs.GlossaryFile, "./campaign-glossary.yml", campaignPath, "campaign_config")
|
||||
assertResolvedStableInput(t, cfg.StableInputs.PartyFile, "./campaign-party.yml", campaignPath, "campaign_config")
|
||||
}
|
||||
|
||||
func TestCampaignSessionMergeSpellCatalog(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
campaignValue string
|
||||
sessionValue string
|
||||
wantPath string
|
||||
wantSource string
|
||||
}{
|
||||
{name: "omitted", wantPath: "", wantSource: "campaign_config"},
|
||||
{name: "campaign inherited", campaignValue: "./campaign-spells.json", wantPath: "./campaign-spells.json", wantSource: "campaign_config"},
|
||||
{name: "session override", campaignValue: "./campaign-spells.json", sessionValue: "./session-spells.json", wantPath: "./session-spells.json", wantSource: "session_config"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
campaignSpell := ""
|
||||
if tt.campaignValue != "" {
|
||||
campaignSpell = " spell_catalog_file: " + tt.campaignValue + "\n"
|
||||
}
|
||||
sessionSpell := ""
|
||||
if tt.sessionValue != "" {
|
||||
sessionSpell = " spell_catalog_file: " + tt.sessionValue + "\n"
|
||||
}
|
||||
pipelinePath, campaignPath, sessionPath := writeCampaignConfigTestFiles(t,
|
||||
"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"+campaignSpell,
|
||||
"session_id: 2026-05-03\ninputs:\n audio_dir: ./audio\n"+sessionSpell,
|
||||
)
|
||||
|
||||
cfg, err := LoadWithSessionOptions(pipelinePath, campaignPath, sessionPath, SessionLoadOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("LoadWithSessionOptions() error = %v", err)
|
||||
}
|
||||
wantConfigPath := campaignPath
|
||||
if tt.wantSource == "session_config" {
|
||||
wantConfigPath = sessionPath
|
||||
}
|
||||
assertResolvedStableInput(t, cfg.StableInputs.SpellCatalogFile, tt.wantPath, wantConfigPath, tt.wantSource)
|
||||
if cfg.Session.Inputs.SpellCatalogFile != cfg.StableInputs.SpellCatalogFile.Path {
|
||||
t.Fatalf("session spell_catalog_file = %q, want %q", cfg.Session.Inputs.SpellCatalogFile, cfg.StableInputs.SpellCatalogFile.Path)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCampaignSessionMergeRejectsWhitespaceSpellCatalog(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
campaignLine string
|
||||
sessionLine string
|
||||
wantErr string
|
||||
}{
|
||||
{name: "campaign", campaignLine: " spell_catalog_file: ' '\n", wantErr: "campaign.inputs.spell_catalog_file"},
|
||||
{name: "session", sessionLine: " spell_catalog_file: ' '\n", wantErr: "session.inputs.spell_catalog_file"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
pipelinePath, campaignPath, sessionPath := writeCampaignConfigTestFiles(t,
|
||||
"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"+tt.campaignLine,
|
||||
"session_id: 2026-05-03\ninputs:\n audio_dir: ./audio\n"+tt.sessionLine,
|
||||
)
|
||||
_, err := LoadWithSessionOptions(pipelinePath, campaignPath, sessionPath, SessionLoadOptions{})
|
||||
if err == nil || !strings.Contains(configurationErrorText(err), tt.wantErr) {
|
||||
t.Fatalf("LoadWithSessionOptions() error = %v, want containing %q", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCampaignWithCanonicalPartyDoesNotRequirePlayersInput(t *testing.T) {
|
||||
pipelinePath, campaignPath, sessionPath := writeCampaignConfigTestFiles(t,
|
||||
"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",
|
||||
"schema_version: maximumdirect.rpg.campaign.v1\nid: sample-campaign\nreferences: {party: ./party.yml}\nnarratio:\n inputs:\n speakers_file: ./speakers.yml\n glossary_file: ./glossary.yml\n",
|
||||
"session_id: 2026-05-03\ninputs:\n audio_dir: ./audio\n",
|
||||
)
|
||||
|
||||
@@ -217,7 +147,7 @@ func TestCampaignWithCanonicalPartyDoesNotRequirePlayersInput(t *testing.T) {
|
||||
|
||||
func TestCampaignSessionMismatchFails(t *testing.T) {
|
||||
pipelinePath, campaignPath, sessionPath := writeCampaignConfigTestFiles(t,
|
||||
"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",
|
||||
"schema_version: maximumdirect.rpg.campaign.v1\nid: sample-campaign\nreferences: {party: ./party.yml}\nnarratio:\n inputs:\n speakers_file: ./speakers.yml\n glossary_file: ./glossary.yml\n",
|
||||
"session_id: 2026-05-03\ncampaign: other-campaign\ninputs:\n audio_dir: ./audio\n",
|
||||
)
|
||||
|
||||
@@ -232,7 +162,7 @@ func TestCampaignSessionMismatchFails(t *testing.T) {
|
||||
|
||||
func TestLoadMissingCampaignFileFails(t *testing.T) {
|
||||
pipelinePath, _, sessionPath := writeCampaignConfigTestFiles(t,
|
||||
"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",
|
||||
"schema_version: maximumdirect.rpg.campaign.v1\nid: sample-campaign\nreferences: {party: ./party.yml}\nnarratio:\n inputs:\n speakers_file: ./speakers.yml\n glossary_file: ./glossary.yml\n",
|
||||
"session_id: 2026-05-03\ninputs:\n audio_dir: ./audio\n",
|
||||
)
|
||||
missingCampaignPath := filepath.Join(filepath.Dir(sessionPath), "missing-campaign.yml")
|
||||
|
||||
@@ -106,7 +106,7 @@ characters:
|
||||
|
||||
func TestExplicitPartySelectionNeverFallsBack(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
campaignPath := writePipelineFixture(t, dir, "campaign.yml", "campaign_id: campaign\ninputs: {speakers_file: speakers.yml, autocorrect_file: autocorrect.yml, glossary_file: glossary.yml, party_file: party.yml}\n")
|
||||
campaignPath := writePipelineFixture(t, dir, "campaign.yml", "schema_version: maximumdirect.rpg.campaign.v1\nid: campaign\nreferences: {party: party.yml}\nnarratio: {inputs: {speakers_file: speakers.yml, glossary_file: glossary.yml}}\n")
|
||||
writePipelineFixture(t, dir, "party.yml", canonicalPartyFixture)
|
||||
campaign, err := LoadCampaign(campaignPath)
|
||||
if err != nil {
|
||||
|
||||
@@ -132,15 +132,13 @@ type AutocorrectionRule struct {
|
||||
|
||||
// CampaignInputsConfig contains stable campaign-level input file references.
|
||||
type CampaignInputsConfig struct {
|
||||
Setting *string `yaml:"setting" json:"setting"`
|
||||
System *string `yaml:"system" json:"system"`
|
||||
Glossary map[string]any `yaml:"glossary" json:"glossary"`
|
||||
SpeakersFile string `yaml:"speakers_file" json:"speakers_file"`
|
||||
AutocorrectFile string `yaml:"-" json:"-"`
|
||||
GlossaryFile *string `yaml:"glossary_file" json:"glossary_file"`
|
||||
PartyFile string `yaml:"party_file" json:"party_file"`
|
||||
SpellCatalogFile string `yaml:"-" json:"-"`
|
||||
Autocorrect []AutocorrectionRule `yaml:"autocorrect" json:"autocorrect"`
|
||||
Setting *string `yaml:"setting" json:"setting"`
|
||||
System *string `yaml:"system" json:"system"`
|
||||
Glossary map[string]any `yaml:"glossary" json:"glossary"`
|
||||
SpeakersFile string `yaml:"speakers_file" json:"speakers_file"`
|
||||
GlossaryFile *string `yaml:"glossary_file" json:"glossary_file"`
|
||||
PartyFile string `yaml:"party_file" json:"party_file"`
|
||||
Autocorrect []AutocorrectionRule `yaml:"autocorrect" json:"autocorrect"`
|
||||
}
|
||||
|
||||
// SessionConfig contains per-session inputs and metadata.
|
||||
@@ -371,8 +369,6 @@ type NotariusConfig struct {
|
||||
ConfigOverlay *string `yaml:"config_overlay,omitempty" json:"config_overlay,omitempty"`
|
||||
Cache *string `yaml:"cache,omitempty" json:"cache,omitempty"`
|
||||
Debug bool `yaml:"debug,omitempty" json:"debug,omitempty"`
|
||||
Resume bool `yaml:"-" json:"-"`
|
||||
ChunkCache string `yaml:"-" json:"-"`
|
||||
ConfigPath string `yaml:"config_path" json:"config_path"`
|
||||
PipelineID string `yaml:"pipeline_id" json:"pipeline_id"`
|
||||
Timeout string `yaml:"timeout" json:"timeout"`
|
||||
@@ -381,14 +377,10 @@ type NotariusConfig struct {
|
||||
Outputs map[string]NotariusOutputConfig `yaml:"outputs" json:"outputs"`
|
||||
}
|
||||
|
||||
// NotariusOutputConfig declares one required extraction lane contract.
|
||||
// NotariusOutputConfig declares one required extraction lane and destination.
|
||||
type NotariusOutputConfig struct {
|
||||
LaneID string `yaml:"lane_id" json:"lane_id"`
|
||||
Filename string `yaml:"filename,omitempty" json:"filename,omitempty"`
|
||||
MediaType string `yaml:"-" json:"-"`
|
||||
SchemaID string `yaml:"-" json:"-"`
|
||||
SchemaVersion string `yaml:"-" json:"-"`
|
||||
ModuleKey string `yaml:"-" json:"-"`
|
||||
LaneID string `yaml:"lane_id" json:"lane_id"`
|
||||
Filename string `yaml:"filename,omitempty" json:"filename,omitempty"`
|
||||
}
|
||||
|
||||
// NotificationConfig configures the supported notification behavior.
|
||||
@@ -398,17 +390,15 @@ type NotificationConfig struct {
|
||||
|
||||
// SessionInputsConfig contains per-session input references.
|
||||
type SessionInputsConfig struct {
|
||||
Setting *string `yaml:"setting" json:"setting"`
|
||||
System *string `yaml:"system" json:"system"`
|
||||
Glossary map[string]any `yaml:"glossary" json:"glossary"`
|
||||
AudioDir string `yaml:"audio_dir" json:"audio_dir"`
|
||||
AudioFiles []string `yaml:"audio_files" json:"audio_files"`
|
||||
AudioS3 *SessionAudioS3Input `yaml:"audio_s3" json:"audio_s3"`
|
||||
SpeakersFile string `yaml:"speakers_file" json:"speakers_file"`
|
||||
AutocorrectFile string `yaml:"-" json:"-"`
|
||||
Autocorrect []AutocorrectionRule `yaml:"autocorrect" json:"autocorrect"`
|
||||
GlossaryFile *string `yaml:"glossary_file" json:"glossary_file"`
|
||||
SpellCatalogFile string `yaml:"-" json:"-"`
|
||||
Setting *string `yaml:"setting" json:"setting"`
|
||||
System *string `yaml:"system" json:"system"`
|
||||
Glossary map[string]any `yaml:"glossary" json:"glossary"`
|
||||
AudioDir string `yaml:"audio_dir" json:"audio_dir"`
|
||||
AudioFiles []string `yaml:"audio_files" json:"audio_files"`
|
||||
AudioS3 *SessionAudioS3Input `yaml:"audio_s3" json:"audio_s3"`
|
||||
SpeakersFile string `yaml:"speakers_file" json:"speakers_file"`
|
||||
Autocorrect []AutocorrectionRule `yaml:"autocorrect" json:"autocorrect"`
|
||||
GlossaryFile *string `yaml:"glossary_file" json:"glossary_file"`
|
||||
}
|
||||
|
||||
// SessionAudioS3Input configures S3 session-audio input discovery.
|
||||
@@ -418,11 +408,9 @@ type SessionAudioS3Input struct {
|
||||
|
||||
// ResolvedStableInputs records the origins of completed stable input paths.
|
||||
type ResolvedStableInputs struct {
|
||||
SpeakersFile ResolvedInputFile
|
||||
AutocorrectFile ResolvedInputFile
|
||||
GlossaryFile ResolvedInputFile
|
||||
PartyFile ResolvedInputFile
|
||||
SpellCatalogFile ResolvedInputFile
|
||||
SpeakersFile ResolvedInputFile
|
||||
GlossaryFile ResolvedInputFile
|
||||
PartyFile ResolvedInputFile
|
||||
}
|
||||
|
||||
// ResolvedInputFile records one effective input path and its declaring source.
|
||||
|
||||
@@ -10,13 +10,14 @@ import (
|
||||
func TestImportedCampaignAndSessionResourcesRetainTheirSources(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
pipeline := writePipelineFixture(t, dir, "pipeline.yml", testTranscriptionConfig+"workspace: {root: /tmp/narratio}\n")
|
||||
campaign := writePipelineFixture(t, dir, "campaign.yml", "config:\n imports:\n - path: campaign/shared.yml\ncampaign_id: sample\n")
|
||||
fragment := writePipelineFixture(t, dir, "campaign/shared.yml", `session_template_file: templates/session.yml
|
||||
inputs:
|
||||
speakers_file: speakers.yml
|
||||
autocorrect_file: autocorrect.yml
|
||||
glossary_file: glossary.yml
|
||||
party_file: party.yml
|
||||
campaign := writePipelineFixture(t, dir, "campaign.yml", "config:\n imports:\n - path: campaign/shared.yml\nschema_version: maximumdirect.rpg.campaign.v1\nid: sample\n")
|
||||
fragment := writePipelineFixture(t, dir, "campaign/shared.yml", `references:
|
||||
party: party.yml
|
||||
narratio:
|
||||
session_template_file: templates/session.yml
|
||||
inputs:
|
||||
speakers_file: speakers.yml
|
||||
glossary_file: glossary.yml
|
||||
`)
|
||||
writePipelineFixture(t, dir, "campaign/party.yml", canonicalPartyFixture)
|
||||
session := writePipelineFixture(t, dir, "session.yml", "config:\n imports:\n - path: session/inputs.yml\nsession_id: sample-session\n")
|
||||
@@ -98,9 +99,9 @@ func TestRemoteSessionResourceBaseIgnoresDiagnosticLabel(t *testing.T) {
|
||||
|
||||
func TestEquivalentDocumentLayoutsRenderIdentically(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
firstCampaign := writePipelineFixture(t, dir, "first-campaign.yml", "campaign_id: sample\ninputs: {speakers_file: shared/speakers.yml, autocorrect_file: shared/autocorrect.yml, glossary_file: shared/glossary.yml, party_file: shared/party.yml}\n")
|
||||
secondCampaign := writePipelineFixture(t, dir, "second-campaign.yml", "config:\n imports:\n - path: shared/campaign.yml\ncampaign_id: sample\n")
|
||||
writePipelineFixture(t, dir, "shared/campaign.yml", "inputs: {speakers_file: speakers.yml, autocorrect_file: autocorrect.yml, glossary_file: glossary.yml, party_file: party.yml}\n")
|
||||
firstCampaign := writePipelineFixture(t, dir, "first-campaign.yml", "schema_version: maximumdirect.rpg.campaign.v1\nid: sample\nreferences: {party: shared/party.yml}\nnarratio: {inputs: {speakers_file: shared/speakers.yml, glossary_file: shared/glossary.yml}}\n")
|
||||
secondCampaign := writePipelineFixture(t, dir, "second-campaign.yml", "config:\n imports:\n - path: shared/campaign.yml\nschema_version: maximumdirect.rpg.campaign.v1\nid: sample\n")
|
||||
writePipelineFixture(t, dir, "shared/campaign.yml", "references: {party: party.yml}\nnarratio: {inputs: {speakers_file: speakers.yml, glossary_file: glossary.yml}}\n")
|
||||
firstSession := writePipelineFixture(t, dir, "first-session.yml", "session_id: sample\ninputs: {audio_dir: shared/audio}\n")
|
||||
secondSession := writePipelineFixture(t, dir, "second-session.yml", "config:\n imports:\n - path: shared/session.yml\nsession_id: sample\n")
|
||||
writePipelineFixture(t, dir, "shared/session.yml", "inputs: {audio_dir: audio}\n")
|
||||
|
||||
@@ -12,21 +12,22 @@ func TestGlossarySelectionsInheritIndependently(t *testing.T) {
|
||||
campaignPath := writePipelineFixture(t, dir, "campaign.yml", `config:
|
||||
imports:
|
||||
- path: config/inputs.yml
|
||||
campaign_id: campaign
|
||||
schema_version: maximumdirect.rpg.campaign.v1
|
||||
id: campaign
|
||||
`)
|
||||
writePipelineFixture(t, dir, "config/inputs.yml", `inputs:
|
||||
speakers_file: speakers.yml
|
||||
autocorrect_file: autocorrect.yml
|
||||
party_file: party.yml
|
||||
setting: coast
|
||||
system: magic
|
||||
glossary_file: vocabulary.yml
|
||||
glossary:
|
||||
entries: [{id: watch, name: Silver Watch, category: organization}]
|
||||
writePipelineFixture(t, dir, "config/inputs.yml", `setting: coast
|
||||
system: magic
|
||||
references: {party: party.yml}
|
||||
narratio:
|
||||
inputs:
|
||||
speakers_file: speakers.yml
|
||||
glossary_file: vocabulary.yml
|
||||
glossary:
|
||||
entries: [{id: watch, name: Silver Watch, category: organization}]
|
||||
`)
|
||||
campaign, err := LoadCampaign(campaignPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
t.Fatal(configurationErrorText(err))
|
||||
}
|
||||
if OptionalString(campaign.Inputs.GlossaryFile) != filepath.Join(dir, "config/vocabulary.yml") {
|
||||
t.Fatal(campaign.Inputs.GlossaryFile)
|
||||
@@ -84,7 +85,7 @@ campaign_id: campaign
|
||||
|
||||
func TestGlossarySelectionsRejectInvalidTypesAndUnknownIDs(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
campaignPath := writePipelineFixture(t, dir, "campaign.yml", "campaign_id: campaign\ninputs: {speakers_file: s, autocorrect_file: a, party_file: p}\n")
|
||||
campaignPath := writePipelineFixture(t, dir, "campaign.yml", "schema_version: maximumdirect.rpg.campaign.v1\nid: campaign\nreferences: {party: p}\nnarratio: {inputs: {speakers_file: s}}\n")
|
||||
campaign, err := LoadCampaign(campaignPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -10,7 +10,7 @@ func TestIdentityValidationRejectsUnsafeSegments(t *testing.T) {
|
||||
for _, value := range unsafe {
|
||||
t.Run("campaign/"+strings.ReplaceAll(value, "/", "_"), func(t *testing.T) {
|
||||
cfg := &CampaignConfig{CampaignID: value, Inputs: CampaignInputsConfig{
|
||||
SpeakersFile: "speakers.yml", AutocorrectFile: "autocorrect.yml", GlossaryFile: new("glossary.yml"), PartyFile: "party.yml",
|
||||
SpeakersFile: "speakers.yml", GlossaryFile: new("glossary.yml"), PartyFile: "party.yml",
|
||||
}}
|
||||
if err := validateCampaign(cfg); err == nil {
|
||||
t.Fatalf("validateCampaign(%q) error = nil, want rejection", value)
|
||||
|
||||
@@ -539,16 +539,16 @@ func TestMaintainedExtractionExamplesPreservePublishedContracts(t *testing.T) {
|
||||
t.Fatalf("load full example error = %v", err)
|
||||
}
|
||||
want := map[string]NotariusOutputConfig{
|
||||
"item_registry": {LaneID: "item-registry", MediaType: "application/json", SchemaID: "notarius.dnd.item_registry", SchemaVersion: "v1", ModuleKey: "dnd/item-registry"},
|
||||
"npc_registry": {LaneID: "npc-registry", MediaType: "application/json", SchemaID: "notarius.dnd.npc_registry", SchemaVersion: "v1", ModuleKey: "dnd/npc-registry"},
|
||||
"location_registry": {LaneID: "location-registry", MediaType: "application/json", SchemaID: "notarius.dnd.location_registry", SchemaVersion: "v1", ModuleKey: "dnd/location-registry"},
|
||||
"scene_descriptions": {LaneID: "scene-descriptions", MediaType: "application/json", SchemaID: "notarius.dnd.scene_descriptions", SchemaVersion: "v1", ModuleKey: "dnd/scene-descriptions"},
|
||||
"item_occurrences": {LaneID: "item-occurrences", MediaType: "application/json", SchemaID: "notarius.dnd.item_occurrences", SchemaVersion: "v1", ModuleKey: "dnd/item-occurrences"},
|
||||
"spells": {LaneID: "spells", MediaType: "application/json", SchemaID: "notarius.dnd.spells", SchemaVersion: "v1", ModuleKey: "dnd/spells"},
|
||||
"combat_turns": {LaneID: "combat-turns", MediaType: "application/json", SchemaID: "notarius.dnd.combat_turns", SchemaVersion: "v1", ModuleKey: "dnd/combat-turns"},
|
||||
"npc_occurrences": {LaneID: "npc-occurrences", MediaType: "application/json", SchemaID: "notarius.dnd.npc_occurrences", SchemaVersion: "v1", ModuleKey: "dnd/npc-occurrences"},
|
||||
"location_occurrences": {LaneID: "location-occurrences", MediaType: "application/json", SchemaID: "notarius.dnd.location_occurrences", SchemaVersion: "v1", ModuleKey: "dnd/location-occurrences"},
|
||||
"enemy_events": {LaneID: "enemy-events", MediaType: "application/json", SchemaID: "notarius.dnd.enemy_events", SchemaVersion: "v1", ModuleKey: "dnd/enemy-events"},
|
||||
"item_registry": {LaneID: "item-registry"},
|
||||
"npc_registry": {LaneID: "npc-registry"},
|
||||
"location_registry": {LaneID: "location-registry"},
|
||||
"scene_descriptions": {LaneID: "scene-descriptions"},
|
||||
"item_occurrences": {LaneID: "item-occurrences"},
|
||||
"spells": {LaneID: "spells"},
|
||||
"combat_turns": {LaneID: "combat-turns"},
|
||||
"npc_occurrences": {LaneID: "npc-occurrences"},
|
||||
"location_occurrences": {LaneID: "location-occurrences"},
|
||||
"enemy_events": {LaneID: "enemy-events"},
|
||||
}
|
||||
if full.Notarius == nil || !reflect.DeepEqual(full.Notarius.Outputs, want) {
|
||||
t.Fatalf("full example outputs = %#v, want %#v", full.Notarius, want)
|
||||
@@ -596,12 +596,13 @@ func writeConfigFiles(t *testing.T, pipelineYAML, sessionYAML string) (string, s
|
||||
if err := os.WriteFile(pipelinePath, []byte(pipelineYAML), 0o644); err != nil {
|
||||
t.Fatalf("write pipeline.yml: %v", err)
|
||||
}
|
||||
campaignYAML := `campaign_id: ` + campaignNameFromSessionYAML(sessionYAML) + `
|
||||
inputs:
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
party_file: ./party.yml
|
||||
campaignYAML := `schema_version: maximumdirect.rpg.campaign.v1
|
||||
id: ` + campaignNameFromSessionYAML(sessionYAML) + `
|
||||
references: {party: ./party.yml}
|
||||
narratio:
|
||||
inputs:
|
||||
speakers_file: ./speakers.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`
|
||||
if err := os.WriteFile(campaignPath, []byte(campaignYAML), 0o644); err != nil {
|
||||
t.Fatalf("write campaign.yml: %v", err)
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func TestNotariusOmittedAndDisabledBehavior(t *testing.T) {
|
||||
@@ -48,9 +45,6 @@ notarius:
|
||||
if disabled.Notarius.Binary != DefaultNotariusBinary || disabled.Notarius.Timeout != DefaultNotariusTimeout {
|
||||
t.Fatalf("disabled defaults = %#v", disabled.Notarius)
|
||||
}
|
||||
if disabled.Notarius.Resume || disabled.Notarius.ChunkCache != "" {
|
||||
t.Fatalf("disabled cache-control defaults = %#v", disabled.Notarius)
|
||||
}
|
||||
if disabled.Notarius.ConfigPath != filepath.Join(dir, "relative/notarius.yml") || disabled.Notarius.WorkingDirectory != "" {
|
||||
t.Fatalf("disabled resource paths = %#v", disabled.Notarius)
|
||||
}
|
||||
@@ -154,9 +148,6 @@ notarius:
|
||||
outputs:
|
||||
npc_registry:
|
||||
lane_id: npc-registry
|
||||
media_type: application/json
|
||||
schema_id: notarius.dnd.npc_registry
|
||||
schema_version: v1
|
||||
`
|
||||
if err := os.WriteFile(pipelinePath, []byte(pipelineYAML), 0o644); err != nil {
|
||||
t.Fatalf("write pipeline: %v", err)
|
||||
@@ -207,84 +198,27 @@ notarius:
|
||||
}
|
||||
|
||||
func TestNotariusCacheControlNormalizationAndValidation(t *testing.T) {
|
||||
for _, mode := range []string{"", "auto", "bypass", "refresh"} {
|
||||
t.Run("mode "+mode, func(t *testing.T) {
|
||||
for _, value := range []string{"auto", "bypass", "refresh"} {
|
||||
t.Run(value, func(t *testing.T) {
|
||||
cfg := validNotariusConfig()
|
||||
cfg.Resume = true
|
||||
if mode != "" {
|
||||
cfg.ChunkCache = " " + mode + " "
|
||||
}
|
||||
original := " " + value + " "
|
||||
cfg.Cache = &original
|
||||
if err := NormalizePipelineConfig(&PipelineConfig{Notarius: cfg}); err != nil {
|
||||
t.Fatalf("NormalizePipelineConfig() error = %v", err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cfg.ChunkCache != mode {
|
||||
t.Fatalf("ChunkCache = %q, want %q", cfg.ChunkCache, mode)
|
||||
}
|
||||
if !cfg.Resume {
|
||||
t.Fatal("Resume = false, want true")
|
||||
if cfg.Cache == nil || *cfg.Cache != value {
|
||||
t.Fatalf("cache = %v", cfg.Cache)
|
||||
}
|
||||
if err := validateNotarius(cfg, nil); err != nil {
|
||||
t.Fatalf("validateNotarius() error = %v", err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
for _, mode := range []string{"AUTO", "invalid"} {
|
||||
t.Run("invalid "+mode, func(t *testing.T) {
|
||||
cfg := validNotariusConfig()
|
||||
cfg.ChunkCache = mode
|
||||
err := validateNotarius(cfg, nil)
|
||||
if err == nil || !strings.Contains(configurationErrorText(err), "pipeline.notarius.chunk_cache") {
|
||||
t.Fatalf("validateNotarius() error = %v, want chunk_cache error", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
disabled := &NotariusConfig{Enabled: false, Resume: true, ChunkCache: " INVALID "}
|
||||
if err := NormalizePipelineConfig(&PipelineConfig{Notarius: disabled}); err != nil {
|
||||
t.Fatalf("NormalizePipelineConfig(disabled) error = %v", err)
|
||||
}
|
||||
if disabled.ChunkCache != " INVALID " {
|
||||
t.Fatalf("disabled ChunkCache = %q, want unchanged", disabled.ChunkCache)
|
||||
}
|
||||
if err := validateNotarius(disabled, nil); err != nil {
|
||||
t.Fatalf("validateNotarius(disabled) error = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotariusCacheControlsSafeSerialization(t *testing.T) {
|
||||
cfg := validNotariusConfig()
|
||||
cfg.Resume = true
|
||||
cfg.ChunkCache = "refresh"
|
||||
|
||||
yamlData, err := yaml.Marshal(cfg)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
jsonData, err := json.Marshal(cfg)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(string(yamlData), "resume: true") || !strings.Contains(string(yamlData), "chunk_cache: refresh") {
|
||||
t.Fatalf("YAML omitted cache controls: %s", yamlData)
|
||||
}
|
||||
if !strings.Contains(string(jsonData), `"resume":true`) || !strings.Contains(string(jsonData), `"chunk_cache":"refresh"`) {
|
||||
t.Fatalf("JSON omitted cache controls: %s", jsonData)
|
||||
}
|
||||
|
||||
cfg.Resume = false
|
||||
cfg.ChunkCache = ""
|
||||
yamlData, err = yaml.Marshal(cfg)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
jsonData, err = json.Marshal(cfg)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, serialized := range []string{string(yamlData), string(jsonData)} {
|
||||
if strings.Contains(serialized, "resume") || strings.Contains(serialized, "chunk_cache") {
|
||||
t.Fatalf("zero-value cache controls were serialized: %s", serialized)
|
||||
for _, value := range []string{"", "AUTO", "invalid"} {
|
||||
cfg := validNotariusConfig()
|
||||
cfg.Cache = &value
|
||||
if err := validateNotarius(cfg, nil); err == nil {
|
||||
t.Fatalf("accepted cache %q", value)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -298,9 +232,6 @@ notarius:
|
||||
outputs:
|
||||
npc_registry:
|
||||
lane_id: npc-registry
|
||||
media_type: application/json
|
||||
schema_id: notarius.dnd.npc_registry
|
||||
schema_version: v1
|
||||
`
|
||||
paths := make([]string, 2)
|
||||
configs := make([]*PipelineConfig, 2)
|
||||
@@ -360,7 +291,7 @@ func TestNotariusReferenceValidationAndNormalization(t *testing.T) {
|
||||
" party ": " narratio.input.party ",
|
||||
" chunk . players ": "narratio.input.players",
|
||||
" npc-registry . extract . glossary ": "narratio.input.glossary.campaign",
|
||||
"spells": "narratio.input.spell_catalog",
|
||||
"spells": "narratio.input.glossary.combined",
|
||||
}
|
||||
|
||||
if err := NormalizePipelineConfig(&PipelineConfig{Notarius: cfg}); err != nil {
|
||||
@@ -373,7 +304,7 @@ func TestNotariusReferenceValidationAndNormalization(t *testing.T) {
|
||||
"party": "narratio.input.party",
|
||||
"chunk.players": "narratio.input.players",
|
||||
"npc-registry.extract.glossary": "narratio.input.glossary.campaign",
|
||||
"spells": "narratio.input.spell_catalog",
|
||||
"spells": "narratio.input.glossary.combined",
|
||||
}
|
||||
if len(cfg.References) != len(want) {
|
||||
t.Fatalf("normalized references = %#v, want %#v", cfg.References, want)
|
||||
@@ -500,12 +431,10 @@ func TestNotariusNormalizationProducesCanonicalValues(t *testing.T) {
|
||||
}
|
||||
cfg.Outputs = map[string]NotariusOutputConfig{
|
||||
" npc_registry ": {
|
||||
LaneID: " npc-registry ", MediaType: " application/json ",
|
||||
SchemaID: " notarius.dnd.npc_registry ", SchemaVersion: " v1 ",
|
||||
LaneID: " npc-registry ",
|
||||
},
|
||||
"spells": {
|
||||
LaneID: " spells ", MediaType: " application/json ",
|
||||
SchemaID: " notarius.dnd.spells ", SchemaVersion: " v1 ",
|
||||
LaneID: " spells ",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -525,7 +454,7 @@ func TestNotariusNormalizationProducesCanonicalValues(t *testing.T) {
|
||||
if _, ok := cfg.Outputs[" npc_registry "]; ok {
|
||||
t.Fatal("outputs retain unnormalized key")
|
||||
}
|
||||
if got := cfg.Outputs["npc_registry"]; got.LaneID != "npc-registry" || got.MediaType != "application/json" || got.SchemaID != "notarius.dnd.npc_registry" || got.SchemaVersion != "v1" {
|
||||
if got := cfg.Outputs["npc_registry"]; got.LaneID != "npc-registry" {
|
||||
t.Fatalf("normalized npc_registry output = %#v", got)
|
||||
}
|
||||
beforeSecondPass := cloneNotariusConfigForTest(cfg)
|
||||
@@ -570,10 +499,10 @@ func TestNotariusDiagnosticsUseSortedMapKeys(t *testing.T) {
|
||||
cfg.References = nil
|
||||
cfg.Outputs = make(map[string]NotariusOutputConfig, len(keys))
|
||||
for _, key := range keys {
|
||||
cfg.Outputs[key] = NotariusOutputConfig{LaneID: key}
|
||||
cfg.Outputs[key] = NotariusOutputConfig{}
|
||||
}
|
||||
},
|
||||
wantField: "pipeline.notarius.outputs.alpha.media_type",
|
||||
wantField: "pipeline.notarius.outputs.alpha.lane_id",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -614,25 +543,6 @@ func cloneNotariusConfigForTest(cfg *NotariusConfig) *NotariusConfig {
|
||||
return &clone
|
||||
}
|
||||
|
||||
func TestNotariusSpellCatalogReferenceRequiresEffectiveInput(t *testing.T) {
|
||||
cfg := loadedValidConfig(t)
|
||||
cfg.Pipeline.Notarius = validNotariusConfig()
|
||||
cfg.Pipeline.Notarius.References = map[string]string{
|
||||
"zeta": "narratio.input.spell_catalog",
|
||||
"alpha": "narratio.input.spell_catalog",
|
||||
}
|
||||
|
||||
err := Validate(cfg)
|
||||
if err == nil || !strings.Contains(configurationErrorText(err), "pipeline.notarius.references.alpha") || !strings.Contains(configurationErrorText(err), "requires campaign.inputs.spell_catalog_file or session.inputs.spell_catalog_file") {
|
||||
t.Fatalf("Validate() error = %v, want sorted selector and missing spell catalog input", err)
|
||||
}
|
||||
|
||||
cfg.StableInputs.SpellCatalogFile = ResolvedInputFile{Path: "./spells.json", Source: "campaign_config"}
|
||||
if err := Validate(cfg); err != nil {
|
||||
t.Fatalf("Validate() with spell catalog error = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func validNotariusConfig() *NotariusConfig {
|
||||
return &NotariusConfig{
|
||||
Enabled: true,
|
||||
@@ -643,10 +553,7 @@ func validNotariusConfig() *NotariusConfig {
|
||||
WorkingDirectory: ".",
|
||||
Outputs: map[string]NotariusOutputConfig{
|
||||
"npc_registry": {
|
||||
LaneID: "npc-registry",
|
||||
MediaType: "application/json",
|
||||
SchemaID: "notarius.dnd.npc_registry",
|
||||
SchemaVersion: "v1",
|
||||
LaneID: "npc-registry",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -659,88 +566,28 @@ func TestNotariusEnabledValidation(t *testing.T) {
|
||||
pipeline_id: dnd-session
|
||||
timeout: 45m
|
||||
outputs:
|
||||
npc_registry:
|
||||
lane_id: npc-registry
|
||||
media_type: application/json
|
||||
schema_id: notarius.dnd.npc_registry
|
||||
schema_version: v1
|
||||
module_key: dnd/npc-registry
|
||||
npc_registry: {lane_id: npc-registry}
|
||||
`
|
||||
tests := []struct {
|
||||
name string
|
||||
section string
|
||||
wantErr []string
|
||||
}{
|
||||
{name: "valid", section: valid},
|
||||
{name: "blank binary", section: strings.Replace(valid, " enabled: true\n", " enabled: true\n binary: \" \"\n", 1), wantErr: []string{"pipeline.notarius.binary", "required"}},
|
||||
{name: "missing config path", section: strings.Replace(valid, " config_path: ./notarius.yml\n", "", 1), wantErr: []string{"pipeline.notarius.config_path", "required"}},
|
||||
{name: "missing pipeline id", section: strings.Replace(valid, " pipeline_id: dnd-session\n", "", 1), wantErr: []string{"pipeline.notarius.pipeline_id", "required"}},
|
||||
{name: "missing outputs", section: strings.Split(valid, " outputs:\n")[0], wantErr: []string{"pipeline.notarius.outputs", "at least one"}},
|
||||
{name: "zero timeout", section: strings.Replace(valid, " timeout: 45m", " timeout: 0s", 1), wantErr: []string{"pipeline.notarius.timeout", "positive"}},
|
||||
{name: "negative timeout", section: strings.Replace(valid, " timeout: 45m", " timeout: -1s", 1), wantErr: []string{"pipeline.notarius.timeout", "positive"}},
|
||||
{name: "invalid timeout", section: strings.Replace(valid, " timeout: 45m", " timeout: later", 1), wantErr: []string{"pipeline.notarius.timeout", "valid duration"}},
|
||||
{name: "invalid output key", section: strings.Replace(valid, " npc_registry:", " npc-registry:", 1), wantErr: []string{"pipeline.notarius.outputs keys", "must match"}},
|
||||
{name: "missing lane", section: strings.Replace(valid, " lane_id: npc-registry\n", "", 1), wantErr: []string{"pipeline.notarius.outputs.npc_registry.lane_id", "required"}},
|
||||
{name: "missing media type", section: strings.Replace(valid, " media_type: application/json\n", "", 1), wantErr: []string{"pipeline.notarius.outputs.npc_registry.media_type", "required"}},
|
||||
{name: "missing schema id", section: strings.Replace(valid, " schema_id: notarius.dnd.npc_registry\n", "", 1), wantErr: []string{"pipeline.notarius.outputs.npc_registry.schema_id", "required"}},
|
||||
{name: "missing schema version", section: strings.Replace(valid, " schema_version: v1\n", "", 1), wantErr: []string{"pipeline.notarius.outputs.npc_registry.schema_version", "required"}},
|
||||
{
|
||||
name: "normalized key collision",
|
||||
section: strings.Replace(valid, " module_key: dnd/npc-registry\n", ` module_key: dnd/npc-registry
|
||||
" npc_registry ":
|
||||
lane_id: npc-registry-two
|
||||
media_type: application/json
|
||||
schema_id: two
|
||||
schema_version: v1
|
||||
`, 1),
|
||||
wantErr: []string{"pipeline.notarius.outputs keys", "duplicate source"},
|
||||
},
|
||||
{
|
||||
name: "duplicate normalized lane",
|
||||
section: strings.Replace(valid, " module_key: dnd/npc-registry\n", ` module_key: dnd/npc-registry
|
||||
spells:
|
||||
lane_id: " npc-registry "
|
||||
media_type: application/json
|
||||
schema_id: two
|
||||
schema_version: v1
|
||||
`, 1),
|
||||
wantErr: []string{"pipeline.notarius.outputs.spells.lane_id", "duplicates"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
pipelinePath, sessionPath := writeConfigFiles(t, testPipelineBaseYAML+"\n"+tt.section, testSessionBaseYAML)
|
||||
cfg, err := Load(pipelinePath, sessionPath)
|
||||
if err != nil {
|
||||
if len(tt.wantErr) > 0 {
|
||||
for _, fragment := range tt.wantErr {
|
||||
if !strings.Contains(configurationErrorText(err), fragment) {
|
||||
t.Fatalf("Load() error = %v, want containing %q", err, fragment)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
t.Fatalf("Load() error = %v", err)
|
||||
}
|
||||
err = Validate(cfg)
|
||||
if len(tt.wantErr) == 0 {
|
||||
if err != nil {
|
||||
t.Fatalf("Validate() error = %v", err)
|
||||
}
|
||||
output := cfg.Pipeline.Notarius.Outputs["npc_registry"]
|
||||
if output.LaneID != "npc-registry" || output.ModuleKey != "dnd/npc-registry" {
|
||||
t.Fatalf("normalized output = %#v", output)
|
||||
}
|
||||
return
|
||||
}
|
||||
for _, test := range []struct{ name, section, want string }{
|
||||
{"valid", valid, ""},
|
||||
{"blank binary", strings.Replace(valid, " enabled: true\n", " enabled: true\n binary: ' ' \n", 1), "binary"},
|
||||
{"missing config", strings.Replace(valid, " config_path: ./notarius.yml\n", "", 1), "config_path"},
|
||||
{"missing pipeline", strings.Replace(valid, " pipeline_id: dnd-session\n", "", 1), "pipeline_id"},
|
||||
{"missing outputs", strings.Split(valid, " outputs:\n")[0], "outputs"},
|
||||
{"bad timeout", strings.Replace(valid, " timeout: 45m", " timeout: 0s", 1), "timeout"},
|
||||
{"invalid lane", strings.Replace(valid, "lane_id: npc-registry", "lane_id: ''", 1), "lane_id"},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
pipeline, session := writeConfigFiles(t, testPipelineBaseYAML+"\n"+test.section, testSessionBaseYAML)
|
||||
cfg, err := Load(pipeline, session)
|
||||
if err == nil {
|
||||
t.Fatalf("Validate() error = nil, want containing %q", tt.wantErr)
|
||||
err = Validate(cfg)
|
||||
}
|
||||
for _, fragment := range tt.wantErr {
|
||||
if !strings.Contains(configurationErrorText(err), fragment) {
|
||||
t.Fatalf("Validate() error = %v, want containing %q", err, fragment)
|
||||
}
|
||||
if test.want == "" && err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if test.want != "" && (err == nil || !strings.Contains(configurationErrorText(err), test.want)) {
|
||||
t.Fatalf("error=%v want %q", err, test.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -24,12 +24,13 @@ characters:
|
||||
if err := os.WriteFile(partyPath, partyYAML, 0o644); err != nil {
|
||||
t.Fatalf("write party: %v", err)
|
||||
}
|
||||
pipelinePath, campaignPath, sessionPath := writePartyResolutionConfig(t, dir, `campaign_id: campaign
|
||||
inputs:
|
||||
speakers_file: speakers.yml
|
||||
autocorrect_file: autocorrect.yml
|
||||
glossary_file: glossary.yml
|
||||
party_file: roster/party.yml
|
||||
pipelinePath, campaignPath, sessionPath := writePartyResolutionConfig(t, dir, `schema_version: maximumdirect.rpg.campaign.v1
|
||||
id: campaign
|
||||
references: {party: roster/party.yml}
|
||||
narratio:
|
||||
inputs:
|
||||
speakers_file: speakers.yml
|
||||
glossary_file: glossary.yml
|
||||
`, `session_id: session
|
||||
campaign: campaign
|
||||
inputs:
|
||||
@@ -68,7 +69,7 @@ func TestCanonicalPartyRejectsSeparatePlayersAndSessionPartyOverrides(t *testing
|
||||
sessionExtra string
|
||||
want string
|
||||
}{
|
||||
{name: "campaign players", campaignExtra: " players_file: players.yml\n", want: "/inputs/players_file"},
|
||||
{name: "campaign players", campaignExtra: " players_file: players.yml\n", want: "/narratio/inputs/players_file"},
|
||||
{name: "session players", sessionExtra: " players_file: players.yml\n", want: "/inputs/players_file"},
|
||||
{name: "session party", sessionExtra: " party_file: party-override.yml\n", want: "/inputs/party_file"},
|
||||
}
|
||||
@@ -76,7 +77,7 @@ func TestCanonicalPartyRejectsSeparatePlayersAndSessionPartyOverrides(t *testing
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writePartyResolutionFile(t, filepath.Join(dir, "party.yml"), canonicalPartyFixture)
|
||||
pipelinePath, campaignPath, sessionPath := writePartyResolutionConfig(t, dir, "campaign_id: campaign\ninputs:\n speakers_file: speakers.yml\n autocorrect_file: autocorrect.yml\n glossary_file: glossary.yml\n party_file: party.yml\n"+test.campaignExtra, "session_id: session\ncampaign: campaign\ninputs:\n audio_dir: audio\n"+test.sessionExtra)
|
||||
pipelinePath, campaignPath, sessionPath := writePartyResolutionConfig(t, dir, "schema_version: maximumdirect.rpg.campaign.v1\nid: campaign\nreferences: {party: party.yml}\nnarratio:\n inputs:\n speakers_file: speakers.yml\n glossary_file: glossary.yml\n"+test.campaignExtra, "session_id: session\ncampaign: campaign\ninputs:\n audio_dir: audio\n"+test.sessionExtra)
|
||||
_, err := LoadWithSessionOptions(pipelinePath, campaignPath, sessionPath, SessionLoadOptions{})
|
||||
if err == nil || !strings.Contains(configurationErrorText(err), test.want) {
|
||||
t.Fatalf("LoadWithSessionOptions() error = %v, want %q", err, test.want)
|
||||
@@ -88,12 +89,13 @@ func TestCanonicalPartyRejectsSeparatePlayersAndSessionPartyOverrides(t *testing
|
||||
func TestUnversionedPartyIsRejectedBeforeResolution(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writePartyResolutionFile(t, filepath.Join(dir, "party.yml"), "legacy: campaign\n")
|
||||
pipelinePath, campaignPath, sessionPath := writePartyResolutionConfig(t, dir, `campaign_id: campaign
|
||||
inputs:
|
||||
speakers_file: speakers.yml
|
||||
autocorrect_file: autocorrect.yml
|
||||
glossary_file: glossary.yml
|
||||
party_file: party.yml
|
||||
pipelinePath, campaignPath, sessionPath := writePartyResolutionConfig(t, dir, `schema_version: maximumdirect.rpg.campaign.v1
|
||||
id: campaign
|
||||
references: {party: party.yml}
|
||||
narratio:
|
||||
inputs:
|
||||
speakers_file: speakers.yml
|
||||
glossary_file: glossary.yml
|
||||
`, `session_id: session
|
||||
campaign: campaign
|
||||
inputs:
|
||||
@@ -108,7 +110,7 @@ inputs:
|
||||
func TestResolveAndLoadedCampaignShareCanonicalPartyResolution(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writePartyResolutionFile(t, filepath.Join(dir, "party.yml"), canonicalPartyFixture)
|
||||
pipelinePath, campaignPath, sessionPath := writePartyResolutionConfig(t, dir, "campaign_id: campaign\ninputs:\n speakers_file: speakers.yml\n autocorrect_file: autocorrect.yml\n glossary_file: glossary.yml\n party_file: party.yml\n", "session_id: session\ncampaign: campaign\ninputs:\n audio_dir: audio\n")
|
||||
pipelinePath, campaignPath, sessionPath := writePartyResolutionConfig(t, dir, "schema_version: maximumdirect.rpg.campaign.v1\nid: campaign\nreferences: {party: party.yml}\nnarratio:\n inputs:\n speakers_file: speakers.yml\n glossary_file: glossary.yml\n", "session_id: session\ncampaign: campaign\ninputs:\n audio_dir: audio\n")
|
||||
pipeline, err := LoadPipeline(pipelinePath)
|
||||
if err != nil {
|
||||
t.Fatalf("LoadPipeline() error = %v", err)
|
||||
|
||||
@@ -360,9 +360,6 @@ notarius:
|
||||
outputs:
|
||||
npc_registry:
|
||||
lane_id: npc-registry
|
||||
media_type: application/json
|
||||
schema_id: notarius.dnd.npc_registry
|
||||
schema_version: v1
|
||||
`)
|
||||
|
||||
cfg, err := LoadPipeline(pipelinePath)
|
||||
@@ -568,41 +565,31 @@ func TestNotariusCredentialRootProvenance(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNotariusCacheControlProfileReplacementAndNullReset(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
overlay string
|
||||
wantResume bool
|
||||
wantMode string
|
||||
wantSource bool
|
||||
wantNil bool
|
||||
for _, test := range []struct {
|
||||
name, overlay string
|
||||
reset bool
|
||||
}{
|
||||
{name: "replacement", overlay: "notarius:\n resume: true\n chunk_cache: refresh\n", wantResume: true, wantMode: "refresh", wantSource: true},
|
||||
{name: "null reset", overlay: "notarius: null\n", wantNil: true},
|
||||
}
|
||||
for _, test := range tests {
|
||||
{"replacement", "notarius:\n cache: refresh\n", false}, {"null reset", "notarius: null\n", true},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
root := writePipelineFixture(t, dir, "pipeline.yml", "whisperx:\n transcribe_url: https://transcription.example.test/transcribe\nnotarius:\n enabled: false\n resume: false\n chunk_cache: bypass\n")
|
||||
root := writePipelineFixture(t, dir, "pipeline.yml", "whisperx:\n transcribe_url: https://transcription.example.test/transcribe\nnotarius:\n enabled: false\n cache: bypass\n")
|
||||
overlay := writePipelineFixture(t, dir, "overlays/testing.yml", test.overlay)
|
||||
profile := "testing"
|
||||
cfg, err := LoadPipelineWithOptions(root, PipelineLoadOptions{Overlay: &profile})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if test.wantNil {
|
||||
if test.reset {
|
||||
if cfg.Notarius != nil {
|
||||
t.Fatalf("Notarius = %#v, want null reset", cfg.Notarius)
|
||||
t.Fatalf("Notarius = %#v", cfg.Notarius)
|
||||
}
|
||||
return
|
||||
}
|
||||
if cfg.Notarius == nil || cfg.Notarius.Resume != test.wantResume || cfg.Notarius.ChunkCache != test.wantMode {
|
||||
t.Fatalf("cache controls = resume %v, mode %q; want resume %v, mode %q", cfg.Notarius.Resume, cfg.Notarius.ChunkCache, test.wantResume, test.wantMode)
|
||||
if cfg.Notarius == nil || cfg.Notarius.Cache == nil || *cfg.Notarius.Cache != "refresh" {
|
||||
t.Fatalf("Notarius = %#v", cfg.Notarius)
|
||||
}
|
||||
if !test.wantSource {
|
||||
return
|
||||
}
|
||||
assertNativePipelineSource(t, cfg, configkit.Keys("notarius", "resume"), overlay)
|
||||
assertNativePipelineSource(t, cfg, configkit.Keys("notarius", "chunk_cache"), overlay)
|
||||
assertNativePipelineSource(t, cfg, configkit.Keys("notarius", "cache"), overlay)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ notarius:
|
||||
enabled: true
|
||||
pipeline_id: dnd-session
|
||||
outputs:
|
||||
recap: {lane_id: recap, media_type: application/json, schema_id: recap, schema_version: "1"}
|
||||
recap: {lane_id: recap}
|
||||
`)
|
||||
writePipelineFixture(t, dir, "overlays/testing.yml", "audita:\n config_path: custom.yml\n")
|
||||
base, err := LoadPipeline(root)
|
||||
|
||||
@@ -84,7 +84,7 @@ func TestScriptoriumLoadAndValidate(t *testing.T) {
|
||||
enabled: true
|
||||
prompt_id: dnd.session_recap
|
||||
`,
|
||||
wantValidateErr: []string{"pipeline.scriptorium.artifacts.session_recap.output_path", "required"},
|
||||
wantValidateErr: []string{"pipeline.scriptorium.artifacts.session_recap", "required"},
|
||||
},
|
||||
{
|
||||
name: "invalid timeout fails",
|
||||
@@ -392,7 +392,7 @@ func TestScriptoriumLoadAndValidate(t *testing.T) {
|
||||
prompt_id: dnd.session_recap
|
||||
output_path: transcripts/session_recap.md
|
||||
`,
|
||||
wantValidateErr: []string{"pipeline.scriptorium.artifacts.session_recap.output_path", "under artifacts/"},
|
||||
wantValidateErr: []string{"pipeline.scriptorium.artifacts.session_recap", "under artifacts/"},
|
||||
},
|
||||
{
|
||||
name: "artifact source infers dependency",
|
||||
@@ -536,7 +536,7 @@ func TestScriptoriumLoadAndValidate(t *testing.T) {
|
||||
source: narratio.artifact.session_recap
|
||||
required: true
|
||||
`,
|
||||
wantValidateErr: []string{"pipeline.scriptorium.artifacts.session_recap.output_path", "referenced"},
|
||||
wantValidateErr: []string{"pipeline.scriptorium.artifacts.session_recap", "referenced"},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -641,6 +641,5 @@ campaign: test-campaign
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`
|
||||
|
||||
@@ -15,17 +15,15 @@ import (
|
||||
func TestSessionDefaultsCompleteBeforeNativeHandoff(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
pipeline := writePipelineFixture(t, dir, "pipeline.yml", testTranscriptionConfig+"workspace: {root: work}\n")
|
||||
campaign := writePipelineFixture(t, dir, "campaign.yml", "config:\n imports:\n - path: campaign/resources.yml\ncampaign_id: campaign\n")
|
||||
fragment := writePipelineFixture(t, dir, "campaign/resources.yml", `inputs:
|
||||
speakers_file: speakers.yml
|
||||
autocorrect_file: autocorrect.yml
|
||||
glossary_file: glossary.yml
|
||||
party_file: party.yml
|
||||
spell_catalog_file: spells.yml
|
||||
campaign := writePipelineFixture(t, dir, "campaign.yml", "config:\n imports:\n - path: campaign/resources.yml\nschema_version: maximumdirect.rpg.campaign.v1\nid: campaign\nreferences: {party: campaign/party.yml}\n")
|
||||
fragment := writePipelineFixture(t, dir, "campaign/resources.yml", `narratio:
|
||||
inputs:
|
||||
speakers_file: speakers.yml
|
||||
glossary_file: glossary.yml
|
||||
`)
|
||||
writePipelineFixture(t, dir, "campaign/party.yml", canonicalPartyFixture)
|
||||
session := writePipelineFixture(t, dir, "session.yml", "config:\n imports:\n - path: session/resources.yml\nsession_id: session\n")
|
||||
sessionFragment := writePipelineFixture(t, dir, "session/resources.yml", "inputs:\n audio_dir: audio\n speakers_file: override.yml\n spell_catalog_file: ''\n")
|
||||
sessionFragment := writePipelineFixture(t, dir, "session/resources.yml", "inputs:\n audio_dir: audio\n speakers_file: override.yml\n")
|
||||
cfg, err := LoadWithSessionOptions(pipeline, campaign, session, SessionLoadOptions{SessionID: "session"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -37,10 +35,10 @@ func TestSessionDefaultsCompleteBeforeNativeHandoff(t *testing.T) {
|
||||
if len(result.Sources()) != 2 {
|
||||
t.Fatalf("session sources include unrelated campaign inputs: %+v", result.Sources())
|
||||
}
|
||||
if cfg.Session.Campaign != "campaign" || OptionalString(cfg.Session.Inputs.GlossaryFile) != filepath.Join(dir, "campaign/glossary.yml") || cfg.Session.Inputs.SpellCatalogFile != "" {
|
||||
if cfg.Session.Campaign != "campaign" || OptionalString(cfg.Session.Inputs.GlossaryFile) != filepath.Join(dir, "campaign/glossary.yml") {
|
||||
t.Fatalf("session defaults/explicit clearing: %+v", cfg.Session)
|
||||
}
|
||||
if cfg.StableInputs.GlossaryFile.Source != "campaign_config" || cfg.StableInputs.GlossaryFile.ConfigPath != fragment || cfg.StableInputs.SpeakersFile.ConfigPath != sessionFragment || cfg.StableInputs.SpellCatalogFile.Source != "session_config" {
|
||||
if cfg.StableInputs.GlossaryFile.Source != "campaign_config" || cfg.StableInputs.GlossaryFile.ConfigPath != fragment || cfg.StableInputs.SpeakersFile.ConfigPath != sessionFragment {
|
||||
t.Fatalf("stable input references: %+v", cfg.StableInputs)
|
||||
}
|
||||
explanation, ok := result.Explain(configkit.Keys("inputs", "glossary_file"))
|
||||
@@ -89,12 +87,10 @@ func TestSessionDefaultsCompleteBeforeNativeHandoff(t *testing.T) {
|
||||
if !reflect.DeepEqual(reloaded.Inputs, cfg.Session.Inputs) {
|
||||
t.Fatalf("standalone rendering lost effective values or explicit clearing: %s", materialized)
|
||||
}
|
||||
writePipelineFixture(t, dir, "campaign/resources.yml", `inputs:
|
||||
speakers_file: replacement-speakers.yml
|
||||
autocorrect_file: replacement-autocorrect.yml
|
||||
glossary_file: replacement-glossary.yml
|
||||
party_file: party.yml
|
||||
spell_catalog_file: replacement-spells.yml
|
||||
writePipelineFixture(t, dir, "campaign/resources.yml", `narratio:
|
||||
inputs:
|
||||
speakers_file: replacement-speakers.yml
|
||||
glossary_file: replacement-glossary.yml
|
||||
`)
|
||||
receiving, err := LoadCampaign(campaign)
|
||||
if err != nil {
|
||||
@@ -104,37 +100,17 @@ func TestSessionDefaultsCompleteBeforeNativeHandoff(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if OptionalString(reloaded.Inputs.GlossaryFile) != OptionalString(receiving.Inputs.GlossaryFile) || reloaded.Inputs.AutocorrectFile != receiving.Inputs.AutocorrectFile {
|
||||
t.Fatalf("materialization froze inherited inputs: %+v", reloaded.Inputs)
|
||||
if OptionalString(reloaded.Inputs.GlossaryFile) != OptionalString(cfg.Session.Inputs.GlossaryFile) {
|
||||
t.Fatalf("materialization lost resolved glossary: %+v", reloaded.Inputs)
|
||||
}
|
||||
if reloaded.Inputs.SpeakersFile != cfg.Session.Inputs.SpeakersFile || reloaded.Inputs.SpellCatalogFile != "" {
|
||||
if reloaded.Inputs.SpeakersFile != cfg.Session.Inputs.SpeakersFile {
|
||||
t.Fatalf("materialization lost explicit override or clearing: %+v", reloaded.Inputs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMaterializedSessionOmitsInheritedSpellCatalog(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
campaignPath := writePipelineFixture(t, dir, "campaign.yml", "campaign_id: campaign\ninputs: {speakers_file: speakers.yml, autocorrect_file: autocorrect.yml, glossary_file: glossary.yml, party_file: party.yml, spell_catalog_file: spells.yml}\n")
|
||||
campaign, err := LoadCampaign(campaignPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
session, err := LoadSessionBytesWithOptions("session.yml", []byte("session_id: session\ninputs: {audio_dir: audio}\n"), SessionLoadOptions{Campaign: campaign, CampaignPath: campaignPath})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
data, err := RenderSessionDocument(&Config{Session: session}, "session")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if strings.Contains(string(data), "spell_catalog_file") || strings.Contains(string(data), "speakers_file") {
|
||||
t.Fatalf("materialized inherited fields: %s", data)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionDefaultsRespectExplicitEmptyInputsAndIdentity(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
campaignPath := writePipelineFixture(t, dir, "campaign.yml", "campaign_id: campaign\ninputs: {speakers_file: speakers.yml, autocorrect_file: autocorrect.yml, glossary_file: glossary.yml, party_file: party.yml}\n")
|
||||
campaignPath := writePipelineFixture(t, dir, "campaign.yml", "schema_version: maximumdirect.rpg.campaign.v1\nid: campaign\nreferences: {party: party.yml}\nnarratio: {inputs: {speakers_file: speakers.yml, glossary_file: glossary.yml}}\n")
|
||||
campaign, err := LoadCampaign(campaignPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -15,7 +15,6 @@ campaign: sample-campaign
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`
|
||||
if err := os.WriteFile(sessionPath, []byte(sessionYAML), 0o644); err != nil {
|
||||
@@ -38,7 +37,6 @@ campaign: sample-campaign
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`
|
||||
if err := os.WriteFile(sessionPath, []byte(sessionYAML), 0o644); err != nil {
|
||||
@@ -63,7 +61,6 @@ campaign: sample-campaign
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`
|
||||
if err := os.WriteFile(sessionPath, []byte(sessionYAML), 0o644); err != nil {
|
||||
@@ -91,7 +88,6 @@ campaign: sample-campaign
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`
|
||||
if err := os.WriteFile(sessionPath, []byte(sessionYAML), 0o644); err != nil {
|
||||
@@ -136,7 +132,6 @@ unknown_field: true
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`
|
||||
if err := os.WriteFile(sessionPath, []byte(sessionYAML), 0o644); err != nil {
|
||||
@@ -160,7 +155,6 @@ campaign: sample-campaign
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`
|
||||
if err := os.WriteFile(sessionPath, []byte(sessionYAML), 0o644); err != nil {
|
||||
@@ -251,6 +245,5 @@ const standaloneSessionFields = `campaign: sample-campaign
|
||||
inputs:
|
||||
audio_dir: audio
|
||||
speakers_file: speakers.yml
|
||||
autocorrect_file: autocorrect.yml
|
||||
glossary_file: glossary.yml
|
||||
`
|
||||
|
||||
@@ -636,7 +636,6 @@ inputs:
|
||||
audio_s3:
|
||||
prefix: audio/
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`,
|
||||
},
|
||||
@@ -648,7 +647,6 @@ inputs:
|
||||
audio_s3:
|
||||
prefix: /audio/
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`,
|
||||
wantErr: "session.inputs.audio_s3.prefix must be a relative path",
|
||||
@@ -661,7 +659,6 @@ inputs:
|
||||
audio_s3:
|
||||
prefix: ../audio/
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`,
|
||||
wantErr: "session.inputs.audio_s3.prefix must not contain path traversal",
|
||||
@@ -675,7 +672,6 @@ inputs:
|
||||
audio_s3:
|
||||
prefix: audio/
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`,
|
||||
wantErr: "mutually exclusive",
|
||||
@@ -721,7 +717,6 @@ inputs:
|
||||
audio_s3:
|
||||
prefix: audio/
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`
|
||||
pipelinePath, sessionPath := writeConfigFiles(t, pipelineYAML, sessionYAML)
|
||||
|
||||
@@ -79,10 +79,7 @@ func TestValidateNotariusTimeoutRequiresPositiveValue(t *testing.T) {
|
||||
WorkingDirectory: "/tmp",
|
||||
Outputs: map[string]NotariusOutputConfig{
|
||||
"npc_registry": {
|
||||
LaneID: "npc-registry",
|
||||
MediaType: "application/json",
|
||||
SchemaID: "notarius.dnd.npc_registry",
|
||||
SchemaVersion: "v1",
|
||||
LaneID: "npc-registry",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user