Add campaign and session glossary selections
This commit is contained in:
@@ -108,11 +108,14 @@ type CampaignConfig struct {
|
||||
|
||||
// CampaignInputsConfig contains stable campaign-level input file references.
|
||||
type CampaignInputsConfig struct {
|
||||
SpeakersFile string `yaml:"speakers_file" json:"speakers_file"`
|
||||
AutocorrectFile string `yaml:"autocorrect_file" json:"autocorrect_file"`
|
||||
GlossaryFile string `yaml:"glossary_file" json:"glossary_file"`
|
||||
PartyFile string `yaml:"party_file" json:"party_file"`
|
||||
SpellCatalogFile string `yaml:"spell_catalog_file" json:"spell_catalog_file"`
|
||||
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:"autocorrect_file" json:"autocorrect_file"`
|
||||
GlossaryFile *string `yaml:"glossary_file" json:"glossary_file"`
|
||||
PartyFile string `yaml:"party_file" json:"party_file"`
|
||||
SpellCatalogFile string `yaml:"spell_catalog_file" json:"spell_catalog_file"`
|
||||
}
|
||||
|
||||
// SessionConfig contains per-session inputs and metadata.
|
||||
@@ -379,12 +382,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:"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"`
|
||||
}
|
||||
|
||||
@@ -435,3 +441,11 @@ type SessionSource struct {
|
||||
S3Size int64
|
||||
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
|
||||
}
|
||||
|
||||
@@ -54,6 +54,27 @@ func documentResource(resolution *configkit.Resolution, path configkit.Path, val
|
||||
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] {
|
||||
return configkit.Definition[CampaignConfig]{Resolve: func(cfg *CampaignConfig, resolution *configkit.Resolution) error {
|
||||
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
|
||||
}{
|
||||
{"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},
|
||||
} {
|
||||
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
|
||||
}, Validate: func(cfg *CampaignConfig, v *configkit.Validation) {
|
||||
validateCampaignConfigKit(cfg, v)
|
||||
@@ -89,11 +113,14 @@ func sessionDefinition(invocationDir string, sources map[string]string, label st
|
||||
value *string
|
||||
}{
|
||||
{"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},
|
||||
} {
|
||||
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 {
|
||||
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},
|
||||
{"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},
|
||||
} {
|
||||
if field.value != "" {
|
||||
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.
|
||||
|
||||
@@ -42,10 +42,10 @@ inputs:
|
||||
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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
)
|
||||
|
||||
type renderedCampaignInputs struct {
|
||||
SpeakersFile string `yaml:"speakers_file,omitempty"`
|
||||
AutocorrectFile string `yaml:"autocorrect_file,omitempty"`
|
||||
GlossaryFile string `yaml:"glossary_file,omitempty"`
|
||||
PartyFile string `yaml:"party_file,omitempty"`
|
||||
SpellCatalogFile string `yaml:"spell_catalog_file,omitempty"`
|
||||
SpeakersFile string `yaml:"speakers_file,omitempty"`
|
||||
AutocorrectFile string `yaml:"autocorrect_file,omitempty"`
|
||||
PartyFile string `yaml:"party_file,omitempty"`
|
||||
SpellCatalogFile string `yaml:"spell_catalog_file,omitempty"`
|
||||
Extra map[string]any `yaml:",inline"`
|
||||
}
|
||||
|
||||
// RenderCampaignDocument serializes the loaded effective campaign document.
|
||||
@@ -32,7 +32,7 @@ func RenderCampaignDocument(cfg *Config) ([]byte, error) {
|
||||
SessionTemplateFile string `yaml:"session_template_file,omitempty"`
|
||||
Inputs renderedCampaignInputs `yaml:"inputs"`
|
||||
}{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)
|
||||
}
|
||||
@@ -72,13 +72,12 @@ func RenderSessionDocument(cfg *Config, sessionID string) ([]byte, error) {
|
||||
AudioS3 *SessionAudioS3Input `yaml:"audio_s3,omitempty"`
|
||||
SpeakersFile *string `yaml:"speakers_file,omitempty"`
|
||||
AutocorrectFile *string `yaml:"autocorrect_file,omitempty"`
|
||||
GlossaryFile *string `yaml:"glossary_file,omitempty"`
|
||||
SpellCatalogFile *string `yaml:"spell_catalog_file,omitempty"`
|
||||
Extra map[string]any `yaml:",inline"`
|
||||
}{doc.Inputs.AudioDir, doc.Inputs.AudioFiles, doc.Inputs.AudioS3,
|
||||
inputValue("speakers_file", doc.Inputs.SpeakersFile),
|
||||
inputValue("autocorrect_file", doc.Inputs.AutocorrectFile),
|
||||
inputValue("glossary_file", doc.Inputs.GlossaryFile),
|
||||
inputValue("spell_catalog_file", doc.Inputs.SpellCatalogFile)}
|
||||
inputValue("spell_catalog_file", doc.Inputs.SpellCatalogFile), glossaryFields(result != nil, metadata, doc.Inputs.Setting, doc.Inputs.System, doc.Inputs.GlossaryFile, doc.Inputs.Glossary, true)}
|
||||
value := struct {
|
||||
SessionID string `yaml:"session_id"`
|
||||
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}
|
||||
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
|
||||
}
|
||||
|
||||
107
internal/config/glossary_authoring_test.go
Normal file
107
internal/config/glossary_authoring_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
@@ -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: "glossary.yml", PartyFile: "party.yml",
|
||||
SpeakersFile: "speakers.yml", AutocorrectFile: "autocorrect.yml", GlossaryFile: new("glossary.yml"), PartyFile: "party.yml",
|
||||
}}
|
||||
if err := validateCampaign(cfg); err == nil {
|
||||
t.Fatalf("validateCampaign(%q) error = nil, want rejection", value)
|
||||
|
||||
@@ -239,6 +239,12 @@ func ResolveLoadedPipelineCampaign(loaded LoadedPipelineCampaign, sessionPath st
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -299,7 +305,7 @@ func deriveStableInputs(campaignCfg *CampaignConfig, sessionCfg *SessionConfig,
|
||||
}{
|
||||
{"speakers_file", sessionCfg.Inputs.SpeakersFile, &stable.SpeakersFile, 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},
|
||||
{"spell_catalog_file", sessionCfg.Inputs.SpellCatalogFile, &stable.SpellCatalogFile, false},
|
||||
} {
|
||||
|
||||
@@ -98,7 +98,7 @@ func TestNativeCampaignResultValidatesConfigurationWithoutReadingResources(t *te
|
||||
if err := yaml.Unmarshal(output.Bytes(), &shown); err != nil {
|
||||
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")
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ 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" || 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)
|
||||
}
|
||||
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 {
|
||||
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)
|
||||
}
|
||||
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"}
|
||||
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\ninputs: null\n",
|
||||
} {
|
||||
|
||||
@@ -38,9 +38,6 @@ func campaignConfigurationError(cfg *CampaignConfig) (configkit.Path, error) {
|
||||
if strings.TrimSpace(cfg.Inputs.AutocorrectFile) == "" {
|
||||
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) == "" {
|
||||
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) == "" {
|
||||
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) == "" {
|
||||
return configkit.Keys("inputs", "spell_catalog_file"), fmt.Errorf("session.inputs.spell_catalog_file must be non-empty when provided")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user