Update pipeline defaults so trim is enabled when omitted
This commit is contained in:
@@ -188,7 +188,7 @@ type NormalizeConfig struct {
|
||||
|
||||
// TrimConfig configures trim-stage transcript boundary behavior.
|
||||
type TrimConfig struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Enabled *bool `yaml:"enabled"`
|
||||
OutputPath string `yaml:"output_path"`
|
||||
Bounds TrimBoundsConfig `yaml:"bounds"`
|
||||
Seriatim TrimSeriatimConfig `yaml:"seriatim"`
|
||||
|
||||
@@ -38,14 +38,19 @@ const (
|
||||
DefaultScriptoriumTimeout = "10m"
|
||||
DefaultScriptoriumArtifactOutputRoot = "artifacts"
|
||||
|
||||
DefaultTrimBoundsTimeout = "10m"
|
||||
DefaultTrimSeriatimReport = false
|
||||
DefaultRenderEnabled = true
|
||||
DefaultRenderFormat = "markdown"
|
||||
DefaultRenderTitle = ""
|
||||
DefaultRenderTimestamps = true
|
||||
DefaultRenderSegmentIDs = true
|
||||
DefaultRenderMetadata = false
|
||||
DefaultTrimEnabled = true
|
||||
DefaultTrimOutputPath = artifactmodel.TranscriptPathFinalTrimmed
|
||||
DefaultTrimBoundsPromptID = "dnd.session_bounds"
|
||||
DefaultTrimBoundsTranscriptInputName = "transcript"
|
||||
DefaultTrimBoundsOutputPath = "artifacts/session_bounds.json"
|
||||
DefaultTrimBoundsTimeout = "10m"
|
||||
DefaultTrimSeriatimReport = false
|
||||
DefaultRenderEnabled = true
|
||||
DefaultRenderFormat = "markdown"
|
||||
DefaultRenderTitle = ""
|
||||
DefaultRenderTimestamps = true
|
||||
DefaultRenderSegmentIDs = true
|
||||
DefaultRenderMetadata = false
|
||||
|
||||
DefaultNormalizeOutputPath = artifactmodel.TranscriptPathFinal
|
||||
DefaultNormalizeOutputSchema = "seriatim-intermediate"
|
||||
|
||||
@@ -336,7 +336,13 @@ func applyPipelineDefaults(cfg *PipelineConfig) {
|
||||
cfg.Normalize = &NormalizeConfig{}
|
||||
}
|
||||
applyNormalizeDefaults(cfg.Normalize)
|
||||
if cfg.Trim == nil {
|
||||
cfg.Trim = &TrimConfig{}
|
||||
}
|
||||
applyTrimDefaults(cfg.Trim)
|
||||
if trimEnabled(cfg.Trim) && cfg.Scriptorium == nil {
|
||||
cfg.Scriptorium = &ScriptoriumConfig{}
|
||||
}
|
||||
applyRenderDefaults(&cfg.Render)
|
||||
applyScriptoriumDefaults(cfg.Scriptorium)
|
||||
}
|
||||
@@ -500,6 +506,21 @@ func applyTrimDefaults(cfg *TrimConfig) {
|
||||
if cfg == nil {
|
||||
return
|
||||
}
|
||||
if cfg.Enabled == nil {
|
||||
cfg.Enabled = boolPtr(DefaultTrimEnabled)
|
||||
}
|
||||
if strings.TrimSpace(cfg.OutputPath) == "" {
|
||||
cfg.OutputPath = DefaultTrimOutputPath
|
||||
}
|
||||
if strings.TrimSpace(cfg.Bounds.PromptID) == "" {
|
||||
cfg.Bounds.PromptID = DefaultTrimBoundsPromptID
|
||||
}
|
||||
if strings.TrimSpace(cfg.Bounds.TranscriptInputName) == "" {
|
||||
cfg.Bounds.TranscriptInputName = DefaultTrimBoundsTranscriptInputName
|
||||
}
|
||||
if strings.TrimSpace(cfg.Bounds.OutputPath) == "" {
|
||||
cfg.Bounds.OutputPath = DefaultTrimBoundsOutputPath
|
||||
}
|
||||
if cfg.Bounds.Timeout == "" {
|
||||
cfg.Bounds.Timeout = DefaultTrimBoundsTimeout
|
||||
}
|
||||
@@ -508,6 +529,10 @@ func applyTrimDefaults(cfg *TrimConfig) {
|
||||
}
|
||||
}
|
||||
|
||||
func trimEnabled(cfg *TrimConfig) bool {
|
||||
return cfg != nil && cfg.Enabled != nil && *cfg.Enabled
|
||||
}
|
||||
|
||||
func applyRenderDefaults(cfg **RenderConfig) {
|
||||
if cfg == nil {
|
||||
return
|
||||
|
||||
@@ -13,6 +13,20 @@ func TestTrimLoadAndValidate(t *testing.T) {
|
||||
wantValidateErr string
|
||||
assert func(t *testing.T, cfg *Config)
|
||||
}{
|
||||
{
|
||||
name: "trim defaults when omitted",
|
||||
trimYAML: "",
|
||||
assert: func(t *testing.T, cfg *Config) {
|
||||
t.Helper()
|
||||
assertDefaultTrimConfig(t, cfg)
|
||||
if cfg.Pipeline.Scriptorium == nil {
|
||||
t.Fatal("scriptorium config should be defaulted when trim is enabled by default")
|
||||
}
|
||||
if cfg.Pipeline.Scriptorium.Binary != DefaultScriptoriumBinary {
|
||||
t.Fatalf("scriptorium.binary = %q, want %q", cfg.Pipeline.Scriptorium.Binary, DefaultScriptoriumBinary)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "valid trim config",
|
||||
trimYAML: `trim:
|
||||
@@ -34,8 +48,8 @@ func TestTrimLoadAndValidate(t *testing.T) {
|
||||
if cfg.Pipeline.Trim == nil {
|
||||
t.Fatal("trim config should be present")
|
||||
}
|
||||
if cfg.Pipeline.Trim.Enabled != true {
|
||||
t.Fatalf("trim.enabled = %t, want true", cfg.Pipeline.Trim.Enabled)
|
||||
if cfg.Pipeline.Trim.Enabled == nil || !*cfg.Pipeline.Trim.Enabled {
|
||||
t.Fatalf("trim.enabled = %#v, want true", cfg.Pipeline.Trim.Enabled)
|
||||
}
|
||||
if cfg.Pipeline.Trim.Bounds.ProfileID != "" {
|
||||
t.Fatalf("trim.bounds.profile_id = %q, want empty", cfg.Pipeline.Trim.Bounds.ProfileID)
|
||||
@@ -43,67 +57,25 @@ func TestTrimLoadAndValidate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "enabled omitted defaults disabled",
|
||||
name: "enabled omitted defaults enabled",
|
||||
trimYAML: `trim:
|
||||
output_path: transcripts/final.trimmed.json
|
||||
bounds:
|
||||
prompt_id: dnd_session.bounds
|
||||
transcript_input_name: transcript
|
||||
output_path: artifacts/session_bounds.json
|
||||
`,
|
||||
assert: func(t *testing.T, cfg *Config) {
|
||||
t.Helper()
|
||||
if cfg.Pipeline.Trim == nil {
|
||||
t.Fatal("trim config should be present")
|
||||
}
|
||||
if cfg.Pipeline.Trim.Enabled {
|
||||
t.Fatal("trim.enabled should default to false when omitted")
|
||||
}
|
||||
assertDefaultTrimConfig(t, cfg)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "missing prompt id fails when enabled",
|
||||
name: "explicit disabled remains disabled",
|
||||
trimYAML: `trim:
|
||||
enabled: true
|
||||
output_path: transcripts/final.trimmed.json
|
||||
bounds:
|
||||
transcript_input_name: transcript
|
||||
output_path: artifacts/session_bounds.json
|
||||
enabled: false
|
||||
`,
|
||||
wantValidateErr: "pipeline.trim.bounds.prompt_id is required when pipeline.trim.enabled is true",
|
||||
},
|
||||
{
|
||||
name: "missing transcript input name fails when enabled",
|
||||
trimYAML: `trim:
|
||||
enabled: true
|
||||
output_path: transcripts/final.trimmed.json
|
||||
bounds:
|
||||
prompt_id: dnd_session.bounds
|
||||
output_path: artifacts/session_bounds.json
|
||||
`,
|
||||
wantValidateErr: "pipeline.trim.bounds.transcript_input_name is required when pipeline.trim.enabled is true",
|
||||
},
|
||||
{
|
||||
name: "missing bounds output path fails when enabled",
|
||||
trimYAML: `trim:
|
||||
enabled: true
|
||||
output_path: transcripts/final.trimmed.json
|
||||
bounds:
|
||||
prompt_id: dnd_session.bounds
|
||||
transcript_input_name: transcript
|
||||
`,
|
||||
wantValidateErr: "pipeline.trim.bounds.output_path is required when pipeline.trim.enabled is true",
|
||||
},
|
||||
{
|
||||
name: "missing trimmed output path fails when enabled",
|
||||
trimYAML: `trim:
|
||||
enabled: true
|
||||
bounds:
|
||||
prompt_id: dnd_session.bounds
|
||||
transcript_input_name: transcript
|
||||
output_path: artifacts/session_bounds.json
|
||||
`,
|
||||
wantValidateErr: "pipeline.trim.output_path is required when pipeline.trim.enabled is true",
|
||||
assert: func(t *testing.T, cfg *Config) {
|
||||
t.Helper()
|
||||
if cfg.Pipeline.Trim == nil || cfg.Pipeline.Trim.Enabled == nil || *cfg.Pipeline.Trim.Enabled {
|
||||
t.Fatalf("trim.enabled = %#v, want false", cfg.Pipeline.Trim)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "invalid timeout fails",
|
||||
@@ -185,3 +157,31 @@ func TestTrimLoadAndValidate(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func assertDefaultTrimConfig(t *testing.T, cfg *Config) {
|
||||
t.Helper()
|
||||
if cfg.Pipeline.Trim == nil {
|
||||
t.Fatal("trim config should be present")
|
||||
}
|
||||
if cfg.Pipeline.Trim.Enabled == nil || !*cfg.Pipeline.Trim.Enabled {
|
||||
t.Fatalf("trim.enabled = %#v, want true", cfg.Pipeline.Trim.Enabled)
|
||||
}
|
||||
if cfg.Pipeline.Trim.OutputPath != DefaultTrimOutputPath {
|
||||
t.Fatalf("trim.output_path = %q, want %q", cfg.Pipeline.Trim.OutputPath, DefaultTrimOutputPath)
|
||||
}
|
||||
if cfg.Pipeline.Trim.Bounds.PromptID != DefaultTrimBoundsPromptID {
|
||||
t.Fatalf("trim.bounds.prompt_id = %q, want %q", cfg.Pipeline.Trim.Bounds.PromptID, DefaultTrimBoundsPromptID)
|
||||
}
|
||||
if cfg.Pipeline.Trim.Bounds.TranscriptInputName != DefaultTrimBoundsTranscriptInputName {
|
||||
t.Fatalf("trim.bounds.transcript_input_name = %q, want %q", cfg.Pipeline.Trim.Bounds.TranscriptInputName, DefaultTrimBoundsTranscriptInputName)
|
||||
}
|
||||
if cfg.Pipeline.Trim.Bounds.OutputPath != DefaultTrimBoundsOutputPath {
|
||||
t.Fatalf("trim.bounds.output_path = %q, want %q", cfg.Pipeline.Trim.Bounds.OutputPath, DefaultTrimBoundsOutputPath)
|
||||
}
|
||||
if cfg.Pipeline.Trim.Bounds.Timeout != DefaultTrimBoundsTimeout {
|
||||
t.Fatalf("trim.bounds.timeout = %q, want %q", cfg.Pipeline.Trim.Bounds.Timeout, DefaultTrimBoundsTimeout)
|
||||
}
|
||||
if cfg.Pipeline.Trim.Seriatim.Report == nil || *cfg.Pipeline.Trim.Seriatim.Report != DefaultTrimSeriatimReport {
|
||||
t.Fatalf("trim.seriatim.report = %#v, want %t", cfg.Pipeline.Trim.Seriatim.Report, DefaultTrimSeriatimReport)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +276,10 @@ func validateTrim(cfg *TrimConfig) error {
|
||||
if cfg == nil {
|
||||
return nil
|
||||
}
|
||||
if !cfg.Enabled {
|
||||
if cfg.Enabled == nil {
|
||||
return fmt.Errorf("pipeline.trim.enabled must be set (defaults should populate this)")
|
||||
}
|
||||
if !*cfg.Enabled {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user