Add reporting and debug settings with context-aware CLI selection

This commit is contained in:
2026-09-24 17:27:11 +00:00
parent b98604e5ca
commit 63fcfc487d
8 changed files with 168 additions and 72 deletions

View File

@@ -10,15 +10,10 @@ import (
"gitea.maximumdirect.net/eric/audita/internal/core/outputschema"
)
type WorkDirRetention string
const (
WorkDirRetentionAuto WorkDirRetention = "auto"
WorkDirRetentionAlways WorkDirRetention = "always"
WorkDirRetentionNever WorkDirRetention = "never"
DefaultModulesCSV = "glossary,homophones,glossary,spoken_word,grammar"
DefaultTranscriptDescriptionMaxChars = 500
DefaultValidationMaxPromptTokens = 2048
DefaultModulesCSV = "glossary,homophones,glossary,spoken_word,grammar"
DefaultTranscriptDescriptionMaxChars = 500
DefaultValidationMaxPromptTokens = 2048
)
// Config is the version-2 application configuration. Invocation paths are not settings.
@@ -34,6 +29,7 @@ type Config struct {
Normalization Normalization `yaml:"normalization"`
Thresholds Thresholds `yaml:"thresholds"`
Context Context `yaml:"context"`
Reporting Reporting `yaml:"reporting"`
Diagnostics Diagnostics `yaml:"diagnostics"`
}
@@ -80,8 +76,12 @@ type Context struct {
Description string `yaml:"description"`
}
type Diagnostics struct {
WorkDir string `yaml:"work_dir"`
Retention WorkDirRetention `yaml:"retention"`
Debug bool `yaml:"debug"`
WorkDir string `yaml:"work_dir"`
}
type Reporting struct {
Enabled bool `yaml:"enabled"`
StdoutDir string `yaml:"stdout_dir"`
}
func defaults() Config {
@@ -94,7 +94,8 @@ func defaults() Config {
Chunking: Chunking{MaxSectionTokens: 8192, MinSectionTokens: 2048},
Normalization: Normalization{MaxSegmentGap: 4, EllipsisGap: 3.5, MaxSegmentDuration: 60, MaxSegmentTokens: 2048},
Thresholds: Thresholds{Glossary: .8, Homophones: .8, SpokenWord: .8, Grammar: .8},
Diagnostics: Diagnostics{WorkDir: "/tmp/audita", Retention: WorkDirRetentionAuto},
Reporting: Reporting{Enabled: true, StdoutDir: "."},
Diagnostics: Diagnostics{WorkDir: "/tmp/audita"},
}
}
@@ -170,8 +171,6 @@ func validate(c *Config, v *ck.Validation) {
check(threshold >= 0 && threshold <= 1, ck.Keys("thresholds", name), "confidence threshold must be between zero and one")
}
check(len(strings.TrimSpace(c.Context.Description)) <= DefaultTranscriptDescriptionMaxChars, ck.Keys("context", "description"), fmt.Sprintf("description must be at most %d bytes after trimming", DefaultTranscriptDescriptionMaxChars))
check(strings.TrimSpace(c.Diagnostics.WorkDir) != "", ck.Keys("diagnostics", "work_dir"), "work directory is required")
check(c.Diagnostics.Retention == WorkDirRetentionAuto || c.Diagnostics.Retention == WorkDirRetentionAlways || c.Diagnostics.Retention == WorkDirRetentionNever, ck.Keys("diagnostics", "retention"), "retention must be auto, always, or never")
}
// ParseModulesCSV is used only for an explicitly supplied --modules override.

View File

@@ -56,7 +56,7 @@ func TestStrictInputAndConstraints(t *testing.T) {
{"invalid section relation", base + "chunking:\n min_section_tokens: 10000\n"},
{"string normalization", base + "normalization:\n max_segment_gap: 4s\n"},
{"invalid threshold", base + "thresholds:\n glossary: 1.1\n"},
{"invalid retention", base + "diagnostics:\n retention: sometimes\n"},
{"removed retention", base + "diagnostics:\n retention: always\n"},
} {
t.Run(tc.name, func(t *testing.T) {
if _, err := loadText(tc.text, ""); err == nil {