Add campaign and session glossary selections

This commit is contained in:
2026-11-27 16:19:11 +00:00
parent 5d44b41e74
commit 1cc37ef980
17 changed files with 244 additions and 39 deletions

View File

@@ -175,7 +175,14 @@ extra all-configuration cache invalidation key.
## Stage 4. Implement campaign/session glossary authoring and field selection ## Stage 4. Implement campaign/session glossary authoring and field selection
Status: Pending Status: Complete
Campaign and session acquisition now retain independent glossary selections,
inline contributions, nullable/empty overrides, source-relative file paths,
and authored snapshot values. Unknown selected catalog IDs fail during combined
acquisition. Verified focused configuration, stage, application and documentation
tests, including imported defaults, replacement, nulls, and rendering. Vocabulary
composition and the preparation cutover remain in subsequent stages.
Start with `document_configkit.go`, `config.go`, `document_render.go`, Start with `document_configkit.go`, `config.go`, `document_render.go`,
`resource_base.go`, and their session-default/presence tests. Implement the `resource_base.go`, and their session-default/presence tests. Implement the

View File

@@ -1439,7 +1439,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: "./glossary.yml", GlossaryFile: new("./glossary.yml"),
}, },
}, },
} }

View File

@@ -108,9 +108,12 @@ type CampaignConfig struct {
// CampaignInputsConfig contains stable campaign-level input file references. // CampaignInputsConfig contains stable campaign-level input file references.
type CampaignInputsConfig struct { 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"` SpeakersFile string `yaml:"speakers_file" json:"speakers_file"`
AutocorrectFile string `yaml:"autocorrect_file" json:"autocorrect_file"` AutocorrectFile string `yaml:"autocorrect_file" json:"autocorrect_file"`
GlossaryFile string `yaml:"glossary_file" json:"glossary_file"` GlossaryFile *string `yaml:"glossary_file" json:"glossary_file"`
PartyFile string `yaml:"party_file" json:"party_file"` PartyFile string `yaml:"party_file" json:"party_file"`
SpellCatalogFile string `yaml:"spell_catalog_file" json:"spell_catalog_file"` SpellCatalogFile string `yaml:"spell_catalog_file" json:"spell_catalog_file"`
} }
@@ -379,12 +382,15 @@ type NotificationConfig struct {
// SessionInputsConfig contains per-session input references. // SessionInputsConfig contains per-session input references.
type SessionInputsConfig struct { 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"` AudioDir string `yaml:"audio_dir" json:"audio_dir"`
AudioFiles []string `yaml:"audio_files" json:"audio_files"` AudioFiles []string `yaml:"audio_files" json:"audio_files"`
AudioS3 *SessionAudioS3Input `yaml:"audio_s3" json:"audio_s3"` AudioS3 *SessionAudioS3Input `yaml:"audio_s3" json:"audio_s3"`
SpeakersFile string `yaml:"speakers_file" json:"speakers_file"` SpeakersFile string `yaml:"speakers_file" json:"speakers_file"`
AutocorrectFile string `yaml:"autocorrect_file" json:"autocorrect_file"` AutocorrectFile string `yaml:"autocorrect_file" json:"autocorrect_file"`
GlossaryFile string `yaml:"glossary_file" json:"glossary_file"` GlossaryFile *string `yaml:"glossary_file" json:"glossary_file"`
SpellCatalogFile string `yaml:"spell_catalog_file" json:"spell_catalog_file"` SpellCatalogFile string `yaml:"spell_catalog_file" json:"spell_catalog_file"`
} }
@@ -435,3 +441,11 @@ type SessionSource struct {
S3Size int64 S3Size int64
S3ETag string S3ETag string
} }
// OptionalString returns the selected text, or an empty value for null or omission.
func OptionalString(value *string) string {
if value == nil {
return ""
}
return *value
}

View File

@@ -54,6 +54,27 @@ func documentResource(resolution *configkit.Resolution, path configkit.Path, val
resolveHostResource(resolution, path, value, invocationDir) resolveHostResource(resolution, path, value, invocationDir)
} }
func documentOptionalResource(resolution *configkit.Resolution, path configkit.Path, value **string, invocationDir string, sources map[string]string) {
if info, ok := resolution.EntryInfo(path); ok && len(info.Origin.Locations) == 1 {
if source, ok := resolution.Source(info.Origin.Locations[0].SourceID); ok {
name := source.Path
if name == "" {
name = source.Label
}
sources[path.String()] = name
}
}
if *value == nil {
return
}
trimmed := strings.TrimSpace(**value)
if trimmed == "" || filepath.IsAbs(trimmed) {
return
}
resolved := filepath.Join(resourceBase(resolution, path, invocationDir), trimmed)
configkit.Normalize(resolution, path, value, &resolved, "resolved relative resource from its source")
}
func campaignDefinition(invocationDir string, sources map[string]string, expected string) configkit.Definition[CampaignConfig] { func campaignDefinition(invocationDir string, sources map[string]string, expected string) configkit.Definition[CampaignConfig] {
return configkit.Definition[CampaignConfig]{Resolve: func(cfg *CampaignConfig, resolution *configkit.Resolution) error { return configkit.Definition[CampaignConfig]{Resolve: func(cfg *CampaignConfig, resolution *configkit.Resolution) error {
documentResource(resolution, configkit.Keys("session_template_file"), &cfg.SessionTemplateFile, invocationDir, sources) documentResource(resolution, configkit.Keys("session_template_file"), &cfg.SessionTemplateFile, invocationDir, sources)
@@ -63,11 +84,14 @@ func campaignDefinition(invocationDir string, sources map[string]string, expecte
value *string value *string
}{ }{
{"speakers_file", &cfg.Inputs.SpeakersFile}, {"autocorrect_file", &cfg.Inputs.AutocorrectFile}, {"speakers_file", &cfg.Inputs.SpeakersFile}, {"autocorrect_file", &cfg.Inputs.AutocorrectFile},
{"glossary_file", &cfg.Inputs.GlossaryFile}, {"party_file", &cfg.Inputs.PartyFile}, {"party_file", &cfg.Inputs.PartyFile},
{"spell_catalog_file", &cfg.Inputs.SpellCatalogFile}, {"spell_catalog_file", &cfg.Inputs.SpellCatalogFile},
} { } {
documentResource(resolution, inputs.Key(field.name), field.value, invocationDir, sources) documentResource(resolution, inputs.Key(field.name), field.value, invocationDir, sources)
} }
if cfg.Inputs.GlossaryFile != nil {
documentOptionalResource(resolution, inputs.Key("glossary_file"), &cfg.Inputs.GlossaryFile, invocationDir, sources)
}
return nil return nil
}, Validate: func(cfg *CampaignConfig, v *configkit.Validation) { }, Validate: func(cfg *CampaignConfig, v *configkit.Validation) {
validateCampaignConfigKit(cfg, v) validateCampaignConfigKit(cfg, v)
@@ -89,11 +113,14 @@ func sessionDefinition(invocationDir string, sources map[string]string, label st
value *string value *string
}{ }{
{"audio_dir", &cfg.Inputs.AudioDir}, {"speakers_file", &cfg.Inputs.SpeakersFile}, {"audio_dir", &cfg.Inputs.AudioDir}, {"speakers_file", &cfg.Inputs.SpeakersFile},
{"autocorrect_file", &cfg.Inputs.AutocorrectFile}, {"glossary_file", &cfg.Inputs.GlossaryFile}, {"autocorrect_file", &cfg.Inputs.AutocorrectFile},
{"spell_catalog_file", &cfg.Inputs.SpellCatalogFile}, {"spell_catalog_file", &cfg.Inputs.SpellCatalogFile},
} { } {
documentResource(resolution, inputs.Key(field.name), field.value, invocationDir, sources) documentResource(resolution, inputs.Key(field.name), field.value, invocationDir, sources)
} }
if cfg.Inputs.GlossaryFile != nil {
documentOptionalResource(resolution, inputs.Key("glossary_file"), &cfg.Inputs.GlossaryFile, invocationDir, sources)
}
for index := range cfg.Inputs.AudioFiles { for index := range cfg.Inputs.AudioFiles {
documentResource(resolution, inputs.Key("audio_files").Index(index), &cfg.Inputs.AudioFiles[index], invocationDir, sources) documentResource(resolution, inputs.Key("audio_files").Index(index), &cfg.Inputs.AudioFiles[index], invocationDir, sources)
} }
@@ -139,13 +166,28 @@ func applyCampaignSessionDefaults(cfg *SessionConfig, resolution *configkit.Reso
}{ }{
{"speakers_file", campaign.Inputs.SpeakersFile, &cfg.Inputs.SpeakersFile}, {"speakers_file", campaign.Inputs.SpeakersFile, &cfg.Inputs.SpeakersFile},
{"autocorrect_file", campaign.Inputs.AutocorrectFile, &cfg.Inputs.AutocorrectFile}, {"autocorrect_file", campaign.Inputs.AutocorrectFile, &cfg.Inputs.AutocorrectFile},
{"glossary_file", campaign.Inputs.GlossaryFile, &cfg.Inputs.GlossaryFile},
{"spell_catalog_file", campaign.Inputs.SpellCatalogFile, &cfg.Inputs.SpellCatalogFile}, {"spell_catalog_file", campaign.Inputs.SpellCatalogFile, &cfg.Inputs.SpellCatalogFile},
} { } {
if field.value != "" { if field.value != "" {
configkit.Default(resolution, configkit.Keys("inputs", field.name), field.target, field.value, reason) configkit.Default(resolution, configkit.Keys("inputs", field.name), field.target, field.value, reason)
} }
} }
for _, field := range []struct {
name string
value *string
target **string
}{
{"glossary_file", campaign.Inputs.GlossaryFile, &cfg.Inputs.GlossaryFile},
{"setting", campaign.Inputs.Setting, &cfg.Inputs.Setting},
{"system", campaign.Inputs.System, &cfg.Inputs.System},
} {
if field.value != nil {
configkit.Default(resolution, configkit.Keys("inputs", field.name), field.target, field.value, reason)
}
}
if campaign.Inputs.Glossary != nil {
configkit.Default(resolution, configkit.Keys("inputs", "glossary"), &cfg.Inputs.Glossary, campaign.Inputs.Glossary, reason)
}
} }
// LoadCampaignWithIdentity validates an optional asserted identity within the native load. // LoadCampaignWithIdentity validates an optional asserted identity within the native load.

View File

@@ -42,10 +42,10 @@ inputs:
t.Fatalf("audio[%d] = %q", i, got) t.Fatalf("audio[%d] = %q", i, got)
} }
} }
if cfg.SessionDocument.Inputs.GlossaryFile != filepath.Join(dir, "campaign/glossary.yml") || cfg.SessionDocument.Inputs.SpeakersFile != filepath.Join(dir, "session/override.yml") { if OptionalString(cfg.SessionDocument.Inputs.GlossaryFile) != filepath.Join(dir, "campaign/glossary.yml") || cfg.SessionDocument.Inputs.SpeakersFile != filepath.Join(dir, "session/override.yml") {
t.Fatalf("completed session = %#v", cfg.SessionDocument) t.Fatalf("completed session = %#v", cfg.SessionDocument)
} }
if cfg.CampaignDocument.Inputs.GlossaryFile != filepath.Join(dir, "campaign/glossary.yml") { if OptionalString(cfg.CampaignDocument.Inputs.GlossaryFile) != filepath.Join(dir, "campaign/glossary.yml") {
t.Fatalf("completed campaign = %#v", cfg.CampaignDocument) t.Fatalf("completed campaign = %#v", cfg.CampaignDocument)
} }
} }

View File

@@ -10,9 +10,9 @@ import (
type renderedCampaignInputs struct { type renderedCampaignInputs struct {
SpeakersFile string `yaml:"speakers_file,omitempty"` SpeakersFile string `yaml:"speakers_file,omitempty"`
AutocorrectFile string `yaml:"autocorrect_file,omitempty"` AutocorrectFile string `yaml:"autocorrect_file,omitempty"`
GlossaryFile string `yaml:"glossary_file,omitempty"`
PartyFile string `yaml:"party_file,omitempty"` PartyFile string `yaml:"party_file,omitempty"`
SpellCatalogFile string `yaml:"spell_catalog_file,omitempty"` SpellCatalogFile string `yaml:"spell_catalog_file,omitempty"`
Extra map[string]any `yaml:",inline"`
} }
// RenderCampaignDocument serializes the loaded effective campaign document. // RenderCampaignDocument serializes the loaded effective campaign document.
@@ -32,7 +32,7 @@ func RenderCampaignDocument(cfg *Config) ([]byte, error) {
SessionTemplateFile string `yaml:"session_template_file,omitempty"` SessionTemplateFile string `yaml:"session_template_file,omitempty"`
Inputs renderedCampaignInputs `yaml:"inputs"` Inputs renderedCampaignInputs `yaml:"inputs"`
}{doc.CampaignID, doc.SessionTemplateFile, renderedCampaignInputs{ }{doc.CampaignID, doc.SessionTemplateFile, renderedCampaignInputs{
doc.Inputs.SpeakersFile, doc.Inputs.AutocorrectFile, doc.Inputs.GlossaryFile, doc.Inputs.PartyFile, doc.Inputs.SpellCatalogFile, doc.Inputs.SpeakersFile, doc.Inputs.AutocorrectFile, doc.Inputs.PartyFile, doc.Inputs.SpellCatalogFile, glossaryFields(doc.ConfigKitResult() != nil, campaignMetadata(doc), doc.Inputs.Setting, doc.Inputs.System, doc.Inputs.GlossaryFile, doc.Inputs.Glossary, false),
}} }}
return yaml.Marshal(value) return yaml.Marshal(value)
} }
@@ -72,13 +72,12 @@ func RenderSessionDocument(cfg *Config, sessionID string) ([]byte, error) {
AudioS3 *SessionAudioS3Input `yaml:"audio_s3,omitempty"` AudioS3 *SessionAudioS3Input `yaml:"audio_s3,omitempty"`
SpeakersFile *string `yaml:"speakers_file,omitempty"` SpeakersFile *string `yaml:"speakers_file,omitempty"`
AutocorrectFile *string `yaml:"autocorrect_file,omitempty"` AutocorrectFile *string `yaml:"autocorrect_file,omitempty"`
GlossaryFile *string `yaml:"glossary_file,omitempty"`
SpellCatalogFile *string `yaml:"spell_catalog_file,omitempty"` SpellCatalogFile *string `yaml:"spell_catalog_file,omitempty"`
Extra map[string]any `yaml:",inline"`
}{doc.Inputs.AudioDir, doc.Inputs.AudioFiles, doc.Inputs.AudioS3, }{doc.Inputs.AudioDir, doc.Inputs.AudioFiles, doc.Inputs.AudioS3,
inputValue("speakers_file", doc.Inputs.SpeakersFile), inputValue("speakers_file", doc.Inputs.SpeakersFile),
inputValue("autocorrect_file", doc.Inputs.AutocorrectFile), inputValue("autocorrect_file", doc.Inputs.AutocorrectFile),
inputValue("glossary_file", doc.Inputs.GlossaryFile), inputValue("spell_catalog_file", doc.Inputs.SpellCatalogFile), glossaryFields(result != nil, metadata, doc.Inputs.Setting, doc.Inputs.System, doc.Inputs.GlossaryFile, doc.Inputs.Glossary, true)}
inputValue("spell_catalog_file", doc.Inputs.SpellCatalogFile)}
value := struct { value := struct {
SessionID string `yaml:"session_id"` SessionID string `yaml:"session_id"`
PreviousSessionID string `yaml:"previous_session_id,omitempty"` PreviousSessionID string `yaml:"previous_session_id,omitempty"`
@@ -89,3 +88,40 @@ func RenderSessionDocument(cfg *Config, sessionID string) ([]byte, error) {
}{id, cfg.Session.PreviousSessionID, cfg.Session.Campaign, doc.Date, doc.Title, inputs} }{id, cfg.Session.PreviousSessionID, cfg.Session.Campaign, doc.Date, doc.Title, inputs}
return yaml.Marshal(value) return yaml.Marshal(value)
} }
func campaignMetadata(cfg *CampaignConfig) configkit.Metadata {
if r := cfg.ConfigKitResult(); r != nil {
return r.Metadata()
}
return configkit.Metadata{}
}
func glossaryFields(hasResult bool, metadata configkit.Metadata, setting, system, file *string, glossary map[string]any, authoredOnly bool) map[string]any {
result := map[string]any{}
for _, field := range []struct {
name string
value *string
}{{"setting", setting}, {"system", system}, {"glossary_file", file}} {
path := configkit.Keys("inputs", field.name)
info, found := metadata.Lookup(path)
explicit := hasResult && metadata.IsExplicit(path)
if (authoredOnly && hasResult && !explicit) || (!explicit && field.value == nil) {
continue
}
if found && info.Null {
result[field.name] = nil
} else {
result[field.name] = OptionalString(field.value)
}
}
path := configkit.Keys("inputs", "glossary")
explicit := hasResult && metadata.IsExplicit(path)
if !(authoredOnly && hasResult && !explicit) && (explicit || glossary != nil) {
if glossary == nil {
result["glossary"] = nil
} else {
result["glossary"] = glossary
}
}
return result
}

View File

@@ -0,0 +1,107 @@
package config
import (
"path/filepath"
"reflect"
"strings"
"testing"
)
func TestGlossarySelectionsInheritIndependently(t *testing.T) {
dir := t.TempDir()
campaignPath := writePipelineFixture(t, dir, "campaign.yml", `config:
imports:
- path: config/inputs.yml
campaign_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}]
`)
campaign, err := LoadCampaign(campaignPath)
if err != nil {
t.Fatal(err)
}
if OptionalString(campaign.Inputs.GlossaryFile) != filepath.Join(dir, "config/vocabulary.yml") {
t.Fatal(campaign.Inputs.GlossaryFile)
}
campaignDoc, err := RenderCampaignDocument(&Config{Campaign: campaign})
if err != nil {
t.Fatal(err)
}
if !strings.Contains(string(campaignDoc), "Silver Watch") || !strings.Contains(string(campaignDoc), "setting: coast") {
t.Fatalf("campaign snapshot: %s", campaignDoc)
}
opts := SessionLoadOptions{Campaign: campaign, CampaignPath: campaignPath}
for _, tc := range []struct {
name, input, file, setting, system string
glossary map[string]any
}{
{"omitted", "", OptionalString(campaign.Inputs.GlossaryFile), "coast", "magic", campaign.Inputs.Glossary},
{"inline only", "glossary: {instruction: Session context.}", OptionalString(campaign.Inputs.GlossaryFile), "coast", "magic", map[string]any{"instruction": "Session context."}},
{"file only", "glossary_file: replacement.yml", filepath.Join(dir, "replacement.yml"), "coast", "magic", campaign.Inputs.Glossary},
{"explicit empty", "setting: ''\n system: null\n glossary_file: ''\n glossary: {}", "", "", "", map[string]any{}},
{"explicit null", "glossary: null", OptionalString(campaign.Inputs.GlossaryFile), "coast", "magic", nil},
{"null file", "glossary_file: null", "", "coast", "magic", campaign.Inputs.Glossary},
} {
t.Run(tc.name, func(t *testing.T) {
input := "session_id: session\ninputs:\n audio_dir: audio\n"
if tc.input != "" {
input += " " + tc.input + "\n"
}
path := writePipelineFixture(t, dir, "session.yml", input)
session, err := LoadSessionWithOptions(path, opts)
if err != nil {
t.Fatal(configurationErrorText(err))
}
got := session.Inputs
if OptionalString(got.GlossaryFile) != tc.file || OptionalString(got.Setting) != tc.setting || OptionalString(got.System) != tc.system || !reflect.DeepEqual(got.Glossary, tc.glossary) {
t.Fatalf("unexpected selections: %+v", got)
}
rendered, err := RenderSessionDocument(&Config{Session: session}, "session")
if err != nil {
t.Fatal(err)
}
reloaded, err := LoadSessionBytesWithOptions("materialized", rendered, opts)
if err != nil {
t.Fatalf("%s: %v", rendered, err)
}
if !reflect.DeepEqual(reloaded.Inputs.Glossary, got.Glossary) || !reflect.DeepEqual(reloaded.Inputs.Setting, got.Setting) || !reflect.DeepEqual(reloaded.Inputs.System, got.System) || !reflect.DeepEqual(reloaded.Inputs.GlossaryFile, got.GlossaryFile) {
t.Fatalf("round trip: %s -> %+v", rendered, reloaded.Inputs)
}
if tc.name == "explicit null" && !strings.Contains(string(rendered), "glossary: null") {
t.Fatalf("lost null: %s", rendered)
}
})
}
}
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")
campaign, err := LoadCampaign(campaignPath)
if err != nil {
t.Fatal(err)
}
opts := SessionLoadOptions{Campaign: campaign, CampaignPath: campaignPath}
for _, input := range []string{"glossary: [wrong]", "setting: [wrong]", "glossary_file: [wrong]"} {
_, err := LoadSessionBytesWithOptions("session", []byte("session_id: session\ninputs:\n audio_dir: audio\n "+input+"\n"), opts)
if err == nil {
t.Fatalf("accepted %s", input)
}
}
session, err := LoadSessionBytesWithOptions("session", []byte("session_id: session\ninputs: {audio_dir: audio, setting: missing}\n"), opts)
if err != nil {
t.Fatal(err)
}
loaded := LoadedPipelineCampaign{Pipeline: &PipelineConfig{}, Campaign: campaign, Party: ResolvedParty{Canonical: &CanonicalParty{}}}
if _, err := ResolveLoadedPipelineCampaign(loaded, "session", session, SessionSource{}); err == nil || !strings.Contains(err.Error(), "missing") {
t.Fatalf("unknown selection: %v", err)
}
}

View File

@@ -10,7 +10,7 @@ func TestIdentityValidationRejectsUnsafeSegments(t *testing.T) {
for _, value := range unsafe { for _, value := range unsafe {
t.Run("campaign/"+strings.ReplaceAll(value, "/", "_"), func(t *testing.T) { t.Run("campaign/"+strings.ReplaceAll(value, "/", "_"), func(t *testing.T) {
cfg := &CampaignConfig{CampaignID: value, Inputs: CampaignInputsConfig{ cfg := &CampaignConfig{CampaignID: value, Inputs: CampaignInputsConfig{
SpeakersFile: "speakers.yml", AutocorrectFile: "autocorrect.yml", GlossaryFile: "glossary.yml", PartyFile: "party.yml", SpeakersFile: "speakers.yml", AutocorrectFile: "autocorrect.yml", GlossaryFile: new("glossary.yml"), PartyFile: "party.yml",
}} }}
if err := validateCampaign(cfg); err == nil { if err := validateCampaign(cfg); err == nil {
t.Fatalf("validateCampaign(%q) error = nil, want rejection", value) t.Fatalf("validateCampaign(%q) error = nil, want rejection", value)

View File

@@ -239,6 +239,12 @@ func ResolveLoadedPipelineCampaign(loaded LoadedPipelineCampaign, sessionPath st
return cfg, nil return cfg, nil
} }
if _, err := loaded.Pipeline.ReferenceCatalog.SelectSetting(OptionalString(sessionCfg.Inputs.Setting)); err != nil {
return nil, err
}
if _, err := loaded.Pipeline.ReferenceCatalog.SelectSystem(OptionalString(sessionCfg.Inputs.System)); err != nil {
return nil, err
}
stableInputs, err := deriveStableInputs(loaded.Campaign, sessionCfg, loaded.CampaignPath, sessionPath) stableInputs, err := deriveStableInputs(loaded.Campaign, sessionCfg, loaded.CampaignPath, sessionPath)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -299,7 +305,7 @@ func deriveStableInputs(campaignCfg *CampaignConfig, sessionCfg *SessionConfig,
}{ }{
{"speakers_file", sessionCfg.Inputs.SpeakersFile, &stable.SpeakersFile, false}, {"speakers_file", sessionCfg.Inputs.SpeakersFile, &stable.SpeakersFile, false},
{"autocorrect_file", sessionCfg.Inputs.AutocorrectFile, &stable.AutocorrectFile, false}, {"autocorrect_file", sessionCfg.Inputs.AutocorrectFile, &stable.AutocorrectFile, false},
{"glossary_file", sessionCfg.Inputs.GlossaryFile, &stable.GlossaryFile, false}, {"glossary_file", OptionalString(sessionCfg.Inputs.GlossaryFile), &stable.GlossaryFile, false},
{"party_file", campaignCfg.Inputs.PartyFile, &stable.PartyFile, true}, {"party_file", campaignCfg.Inputs.PartyFile, &stable.PartyFile, true},
{"spell_catalog_file", sessionCfg.Inputs.SpellCatalogFile, &stable.SpellCatalogFile, false}, {"spell_catalog_file", sessionCfg.Inputs.SpellCatalogFile, &stable.SpellCatalogFile, false},
} { } {

View File

@@ -98,7 +98,7 @@ func TestNativeCampaignResultValidatesConfigurationWithoutReadingResources(t *te
if err := yaml.Unmarshal(output.Bytes(), &shown); err != nil { if err := yaml.Unmarshal(output.Bytes(), &shown); err != nil {
t.Fatal(err) t.Fatal(err)
} }
if shown.CampaignID != cfg.CampaignID || shown.Inputs != cfg.Inputs { if shown.CampaignID != cfg.CampaignID || !reflect.DeepEqual(shown.Inputs, cfg.Inputs) {
t.Fatal("native show lost completed campaign values") t.Fatal("native show lost completed campaign values")
} }

View File

@@ -37,7 +37,7 @@ func TestSessionDefaultsCompleteBeforeNativeHandoff(t *testing.T) {
if len(result.Sources()) != 2 { if len(result.Sources()) != 2 {
t.Fatalf("session sources include unrelated campaign inputs: %+v", result.Sources()) t.Fatalf("session sources include unrelated campaign inputs: %+v", result.Sources())
} }
if cfg.Session.Campaign != "campaign" || 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") || cfg.Session.Inputs.SpellCatalogFile != "" {
t.Fatalf("session defaults/explicit clearing: %+v", cfg.Session) 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 || cfg.StableInputs.SpellCatalogFile.Source != "session_config" {
@@ -104,7 +104,7 @@ func TestSessionDefaultsCompleteBeforeNativeHandoff(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if reloaded.Inputs.GlossaryFile != receiving.Inputs.GlossaryFile || reloaded.Inputs.AutocorrectFile != receiving.Inputs.AutocorrectFile { if OptionalString(reloaded.Inputs.GlossaryFile) != OptionalString(receiving.Inputs.GlossaryFile) || reloaded.Inputs.AutocorrectFile != receiving.Inputs.AutocorrectFile {
t.Fatalf("materialization froze inherited inputs: %+v", reloaded.Inputs) t.Fatalf("materialization froze inherited inputs: %+v", reloaded.Inputs)
} }
if reloaded.Inputs.SpeakersFile != cfg.Session.Inputs.SpeakersFile || reloaded.Inputs.SpellCatalogFile != "" { if reloaded.Inputs.SpeakersFile != cfg.Session.Inputs.SpeakersFile || reloaded.Inputs.SpellCatalogFile != "" {
@@ -141,7 +141,6 @@ func TestSessionDefaultsRespectExplicitEmptyInputsAndIdentity(t *testing.T) {
} }
opts := SessionLoadOptions{Campaign: campaign, CampaignPath: campaignPath, SessionID: "session"} opts := SessionLoadOptions{Campaign: campaign, CampaignPath: campaignPath, SessionID: "session"}
for _, data := range []string{ for _, data := range []string{
"session_id: session\ninputs: {audio_dir: audio, glossary_file: ''}\n",
"session_id: session\ncampaign: ''\ninputs: {audio_dir: audio}\n", "session_id: session\ncampaign: ''\ninputs: {audio_dir: audio}\n",
"session_id: session\ninputs: null\n", "session_id: session\ninputs: null\n",
} { } {

View File

@@ -38,9 +38,6 @@ func campaignConfigurationError(cfg *CampaignConfig) (configkit.Path, error) {
if strings.TrimSpace(cfg.Inputs.AutocorrectFile) == "" { if strings.TrimSpace(cfg.Inputs.AutocorrectFile) == "" {
return configkit.Keys("inputs", "autocorrect_file"), fmt.Errorf("campaign.inputs.autocorrect_file is required") return configkit.Keys("inputs", "autocorrect_file"), fmt.Errorf("campaign.inputs.autocorrect_file is required")
} }
if strings.TrimSpace(cfg.Inputs.GlossaryFile) == "" {
return configkit.Keys("inputs", "glossary_file"), fmt.Errorf("campaign.inputs.glossary_file is required")
}
if strings.TrimSpace(cfg.Inputs.PartyFile) == "" { if strings.TrimSpace(cfg.Inputs.PartyFile) == "" {
return configkit.Keys("inputs", "party_file"), fmt.Errorf("campaign.inputs.party_file is required") return configkit.Keys("inputs", "party_file"), fmt.Errorf("campaign.inputs.party_file is required")
} }
@@ -89,9 +86,6 @@ func sessionConfigurationError(cfg *SessionConfig) (configkit.Path, error) {
if strings.TrimSpace(cfg.Inputs.AutocorrectFile) == "" { if strings.TrimSpace(cfg.Inputs.AutocorrectFile) == "" {
return configkit.Keys("inputs", "autocorrect_file"), fmt.Errorf("session.inputs.autocorrect_file is required") return configkit.Keys("inputs", "autocorrect_file"), fmt.Errorf("session.inputs.autocorrect_file is required")
} }
if strings.TrimSpace(cfg.Inputs.GlossaryFile) == "" {
return configkit.Keys("inputs", "glossary_file"), fmt.Errorf("session.inputs.glossary_file is required")
}
if cfg.Inputs.SpellCatalogFile != "" && strings.TrimSpace(cfg.Inputs.SpellCatalogFile) == "" { if cfg.Inputs.SpellCatalogFile != "" && strings.TrimSpace(cfg.Inputs.SpellCatalogFile) == "" {
return configkit.Keys("inputs", "spell_catalog_file"), fmt.Errorf("session.inputs.spell_catalog_file must be non-empty when provided") return configkit.Keys("inputs", "spell_catalog_file"), fmt.Errorf("session.inputs.spell_catalog_file must be non-empty when provided")
} }

View File

@@ -295,7 +295,7 @@ func setupPolishEnv(t *testing.T) (*Env, *manifest.Manifest) {
Session: &config.SessionConfig{ Session: &config.SessionConfig{
SessionID: "2026-05-03", SessionID: "2026-05-03",
Inputs: config.SessionInputsConfig{ Inputs: config.SessionInputsConfig{
GlossaryFile: "./glossary.yml", GlossaryFile: new("./glossary.yml"),
}, },
}, },
} }

View File

@@ -53,7 +53,7 @@ func (prepareStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*S
speakersInput := stableInputSource(env.Config.StableInputs.SpeakersFile, env.Config.Session.Inputs.SpeakersFile, sessionSrc) speakersInput := stableInputSource(env.Config.StableInputs.SpeakersFile, env.Config.Session.Inputs.SpeakersFile, sessionSrc)
autocorrectInput := stableInputSource(env.Config.StableInputs.AutocorrectFile, env.Config.Session.Inputs.AutocorrectFile, sessionSrc) autocorrectInput := stableInputSource(env.Config.StableInputs.AutocorrectFile, env.Config.Session.Inputs.AutocorrectFile, sessionSrc)
glossaryInput := stableInputSource(env.Config.StableInputs.GlossaryFile, env.Config.Session.Inputs.GlossaryFile, sessionSrc) glossaryInput := stableInputSource(env.Config.StableInputs.GlossaryFile, config.OptionalString(env.Config.Session.Inputs.GlossaryFile), sessionSrc)
spellCatalogInput := stableInputSource(env.Config.StableInputs.SpellCatalogFile, env.Config.Session.Inputs.SpellCatalogFile, sessionSrc) spellCatalogInput := stableInputSource(env.Config.StableInputs.SpellCatalogFile, env.Config.Session.Inputs.SpellCatalogFile, sessionSrc)
speakersSrc, err := resolveConfigRelativePath(speakersInput) speakersSrc, err := resolveConfigRelativePath(speakersInput)

View File

@@ -104,7 +104,7 @@ func currentPrepareSourceInputs(ctx context.Context, env *Env, m *manifest.Manif
if !ok { if !ok {
return nil, fmt.Errorf("glossary prepared-input descriptor is unavailable") return nil, fmt.Errorf("glossary prepared-input descriptor is unavailable")
} }
if err := appendFile(glossary.ManifestKind, cfg.StableInputs.GlossaryFile, cfg.Session.Inputs.GlossaryFile); err != nil { if err := appendFile(glossary.ManifestKind, cfg.StableInputs.GlossaryFile, config.OptionalString(cfg.Session.Inputs.GlossaryFile)); err != nil {
return nil, err return nil, err
} }
spellCatalog, ok := artifactpolicy.DescribePreparedInputSource(artifactpolicy.SourceInputSpellCatalog) spellCatalog, ok := artifactpolicy.DescribePreparedInputSource(artifactpolicy.SourceInputSpellCatalog)

View File

@@ -152,7 +152,7 @@ func prepareStableInputSemantics(cfg *config.Config) []prepareStableInputSelecti
return []prepareStableInputSelection{ return []prepareStableInputSelection{
prepareStableInput("speakers", stable.SpeakersFile, cfg.Session.Inputs.SpeakersFile), prepareStableInput("speakers", stable.SpeakersFile, cfg.Session.Inputs.SpeakersFile),
prepareStableInput("autocorrect", stable.AutocorrectFile, cfg.Session.Inputs.AutocorrectFile), prepareStableInput("autocorrect", stable.AutocorrectFile, cfg.Session.Inputs.AutocorrectFile),
prepareStableInput("glossary", stable.GlossaryFile, cfg.Session.Inputs.GlossaryFile), prepareStableInput("glossary", stable.GlossaryFile, config.OptionalString(cfg.Session.Inputs.GlossaryFile)),
prepareStableInput("party", stable.PartyFile, ""), prepareStableInput("party", stable.PartyFile, ""),
prepareStableInput("spell_catalog", stable.SpellCatalogFile, cfg.Session.Inputs.SpellCatalogFile), prepareStableInput("spell_catalog", stable.SpellCatalogFile, cfg.Session.Inputs.SpellCatalogFile),
} }

View File

@@ -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: "./glossary.yml", GlossaryFile: new("./glossary.yml"),
}, },
}, },
StableInputs: config.ResolvedStableInputs{ StableInputs: config.ResolvedStableInputs{