Adopt Audita native processing arguments
This commit is contained in:
@@ -370,7 +370,13 @@ conflict policy; no new remote protocol is needed.
|
|||||||
|
|
||||||
## Stage 10. Cut the Audita processing adapter over to v4.2
|
## Stage 10. Cut the Audita processing adapter over to v4.2
|
||||||
|
|
||||||
Status: Pending
|
Status: Complete
|
||||||
|
|
||||||
|
The adapter now passes ordered native glossary files, independent destinations,
|
||||||
|
and enable-only debug, with a shared argument builder and updated safe invocation
|
||||||
|
records. Removed module configuration and plumbing. Focused adapter, configuration,
|
||||||
|
and semantic tests pass; all packages compile. Polish still supplies its former
|
||||||
|
input path until Stage 11; examples and wider fixture updates remain scheduled.
|
||||||
|
|
||||||
Read Audita v4.2 CLI/subprocess/output contracts, then `adapters/audita` and
|
Read Audita v4.2 CLI/subprocess/output contracts, then `adapters/audita` and
|
||||||
its current subprocess tests. Replace the single legacy glossary request with
|
its current subprocess tests. Replace the single legacy glossary request with
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ func (f *FakeRunner) Run(ctx context.Context, req PolishRequest) (PolishResult,
|
|||||||
res.ProcessedTranscriptPath = req.OutputProcessedPath
|
res.ProcessedTranscriptPath = req.OutputProcessedPath
|
||||||
}
|
}
|
||||||
if res.Reports == (ReportBundle{}) {
|
if res.Reports == (ReportBundle{}) {
|
||||||
dir := filepath.Dir(req.OutputProcessedPath)
|
dir := reportDirectory(req)
|
||||||
res.Reports = ReportBundle{
|
res.Reports = ReportBundle{
|
||||||
ErrorsPath: filepath.Join(dir, "errors.yml"),
|
ErrorsPath: filepath.Join(dir, "errors.yml"),
|
||||||
RecoveriesPath: filepath.Join(dir, "recoveries.yml"),
|
RecoveriesPath: filepath.Join(dir, "recoveries.yml"),
|
||||||
@@ -78,7 +78,7 @@ func (f *FakeRunner) Run(ctx context.Context, req PolishRequest) (PolishResult,
|
|||||||
func materializePlaceholders(req PolishRequest, reports bool) error {
|
func materializePlaceholders(req PolishRequest, reports bool) error {
|
||||||
if req.GeneratedConfigPath != "" {
|
if req.GeneratedConfigPath != "" {
|
||||||
payload := map[string]any{
|
payload := map[string]any{
|
||||||
"schema": "audita.generated.v2",
|
"schema": "audita.generated.v3",
|
||||||
"placeholder": true,
|
"placeholder": true,
|
||||||
"merged_transcript_path": req.MergedTranscriptPath,
|
"merged_transcript_path": req.MergedTranscriptPath,
|
||||||
"output_path": req.OutputProcessedPath,
|
"output_path": req.OutputProcessedPath,
|
||||||
@@ -111,7 +111,7 @@ func materializePlaceholders(req PolishRequest, reports bool) error {
|
|||||||
{"recoveries.yml", "schema: audita-recoveries\nversion: 1\nstatus: completed\nrecoveries: []\n"},
|
{"recoveries.yml", "schema: audita-recoveries\nversion: 1\nstatus: completed\nrecoveries: []\n"},
|
||||||
{"report.md", "# Audita report\n"},
|
{"report.md", "# Audita report\n"},
|
||||||
} {
|
} {
|
||||||
path := filepath.Join(filepath.Dir(req.OutputProcessedPath), report.name)
|
path := filepath.Join(reportDirectory(req), report.name)
|
||||||
if err := fileops.WriteFileAtomic(path, []byte(report.contents), fileops.WorkspaceFileMode); err != nil {
|
if err := fileops.WriteFileAtomic(path, []byte(report.contents), fileops.WorkspaceFileMode); err != nil {
|
||||||
return fmt.Errorf("write report %q: %w", path, err)
|
return fmt.Errorf("write report %q: %w", path, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,19 +11,19 @@ type Runner interface {
|
|||||||
Run(ctx context.Context, req PolishRequest) (PolishResult, error)
|
Run(ctx context.Context, req PolishRequest) (PolishResult, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PolishRequest describes an Audita invocation. Nil Modules uses the runner's
|
// PolishRequest describes an Audita invocation.
|
||||||
// configured selection; a non-nil empty slice selects no modules.
|
|
||||||
type PolishRequest struct {
|
type PolishRequest struct {
|
||||||
GeneratedConfigPath string
|
GeneratedConfigPath string
|
||||||
MergedTranscriptPath string
|
MergedTranscriptPath string
|
||||||
OutputProcessedPath string
|
OutputProcessedPath string
|
||||||
GlossaryPath string
|
GlossaryFiles []string
|
||||||
Modules []string
|
ReportDir string
|
||||||
|
WorkDir string
|
||||||
StdoutLogPath string
|
StdoutLogPath string
|
||||||
StderrLogPath string
|
StderrLogPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReportBundle contains optional reports adjacent to the requested output.
|
// ReportBundle contains optional reports in the requested report directory.
|
||||||
type ReportBundle struct {
|
type ReportBundle struct {
|
||||||
ErrorsPath string
|
ErrorsPath string
|
||||||
RecoveriesPath string
|
RecoveriesPath string
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ type SubprocessRunnerConfig struct {
|
|||||||
Binary string
|
Binary string
|
||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
Credentials []configkit.Secret
|
Credentials []configkit.Secret
|
||||||
Modules []string
|
Debug bool
|
||||||
Overlay string
|
Overlay string
|
||||||
ProposalProfile string
|
ProposalProfile string
|
||||||
ValidationProfile string
|
ValidationProfile string
|
||||||
@@ -49,11 +49,6 @@ func NewSubprocessRunner(cfg SubprocessRunnerConfig) (*SubprocessRunner, error)
|
|||||||
if cfg.Timeout <= 0 {
|
if cfg.Timeout <= 0 {
|
||||||
return nil, fmt.Errorf("audita timeout must be > 0")
|
return nil, fmt.Errorf("audita timeout must be > 0")
|
||||||
}
|
}
|
||||||
for i, module := range cfg.Modules {
|
|
||||||
if strings.TrimSpace(module) == "" {
|
|
||||||
return nil, fmt.Errorf("audita module at index %d is empty", i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch strings.TrimSpace(cfg.OutputSchema) {
|
switch strings.TrimSpace(cfg.OutputSchema) {
|
||||||
case "", "bare-segments", "audita-v1":
|
case "", "bare-segments", "audita-v1":
|
||||||
default:
|
default:
|
||||||
@@ -61,20 +56,9 @@ func NewSubprocessRunner(cfg SubprocessRunnerConfig) (*SubprocessRunner, error)
|
|||||||
}
|
}
|
||||||
cfg.Binary = strings.TrimSpace(cfg.Binary)
|
cfg.Binary = strings.TrimSpace(cfg.Binary)
|
||||||
cfg.Credentials = append([]configkit.Secret(nil), cfg.Credentials...)
|
cfg.Credentials = append([]configkit.Secret(nil), cfg.Credentials...)
|
||||||
cfg.Modules = cloneModules(cfg.Modules)
|
|
||||||
for i := range cfg.Modules {
|
|
||||||
cfg.Modules[i] = strings.TrimSpace(cfg.Modules[i])
|
|
||||||
}
|
|
||||||
return &SubprocessRunner{cfg: cfg, run: subprocess.Run}, nil
|
return &SubprocessRunner{cfg: cfg, run: subprocess.Run}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func cloneModules(modules []string) []string {
|
|
||||||
if modules == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return append([]string{}, modules...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run executes Audita process and validates its corrected transcript.
|
// Run executes Audita process and validates its corrected transcript.
|
||||||
func (r *SubprocessRunner) Run(ctx context.Context, req PolishRequest) (PolishResult, error) {
|
func (r *SubprocessRunner) Run(ctx context.Context, req PolishRequest) (PolishResult, error) {
|
||||||
if r == nil {
|
if r == nil {
|
||||||
@@ -82,33 +66,24 @@ func (r *SubprocessRunner) Run(ctx context.Context, req PolishRequest) (PolishRe
|
|||||||
}
|
}
|
||||||
for _, field := range []struct{ name, value string }{
|
for _, field := range []struct{ name, value string }{
|
||||||
{"merged transcript path", req.MergedTranscriptPath},
|
{"merged transcript path", req.MergedTranscriptPath},
|
||||||
{"glossary path", req.GlossaryPath},
|
|
||||||
{"output processed path", req.OutputProcessedPath},
|
{"output processed path", req.OutputProcessedPath},
|
||||||
} {
|
} {
|
||||||
if strings.TrimSpace(field.value) == "" {
|
if strings.TrimSpace(field.value) == "" {
|
||||||
return PolishResult{}, fmt.Errorf("audita %s is required", field.name)
|
return PolishResult{}, fmt.Errorf("audita %s is required", field.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
modules := req.Modules
|
for i, path := range req.GlossaryFiles {
|
||||||
if modules == nil {
|
if strings.TrimSpace(path) == "" {
|
||||||
modules = r.cfg.Modules
|
return PolishResult{}, fmt.Errorf("audita glossary file at index %d is empty", i)
|
||||||
}
|
|
||||||
for i, module := range modules {
|
|
||||||
if strings.TrimSpace(module) == "" {
|
|
||||||
return PolishResult{}, fmt.Errorf("audita module at index %d is empty", i)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
modules = cloneModules(modules)
|
args := r.buildArgs("process", req)
|
||||||
for i := range modules {
|
|
||||||
modules[i] = strings.TrimSpace(modules[i])
|
|
||||||
}
|
|
||||||
args := r.buildArgs(req, modules)
|
|
||||||
env, names, err := subprocess.CredentialEnvironment(r.cfg.Credentials)
|
env, names, err := subprocess.CredentialEnvironment(r.cfg.Credentials)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return PolishResult{}, fmt.Errorf("audita credentials: %w", err)
|
return PolishResult{}, fmt.Errorf("audita credentials: %w", err)
|
||||||
}
|
}
|
||||||
if req.GeneratedConfigPath != "" {
|
if req.GeneratedConfigPath != "" {
|
||||||
if err := r.writeInvocationConfig(req, args, modules, names); err != nil {
|
if err := r.writeInvocationConfig(req, args, names); err != nil {
|
||||||
return PolishResult{}, fmt.Errorf("write audita invocation config %q: %w", req.GeneratedConfigPath, err)
|
return PolishResult{}, fmt.Errorf("write audita invocation config %q: %w", req.GeneratedConfigPath, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,17 +96,17 @@ func (r *SubprocessRunner) Run(ctx context.Context, req PolishRequest) (PolishRe
|
|||||||
EnvOverrides: env, SensitiveEnvNames: names, DiagnosticOwner: "audita",
|
EnvOverrides: env, SensitiveEnvNames: names, DiagnosticOwner: "audita",
|
||||||
StdoutLogPath: req.StdoutLogPath, StderrLogPath: req.StderrLogPath,
|
StdoutLogPath: req.StdoutLogPath, StderrLogPath: req.StderrLogPath,
|
||||||
})
|
})
|
||||||
result := r.result(req, modules, names, runRes)
|
result := r.result(req, names, runRes)
|
||||||
if runErr != nil {
|
if runErr != nil {
|
||||||
result.Reports, _ = discoverReports(req.OutputProcessedPath)
|
result.Reports, _ = discoverReports(reportDirectory(req))
|
||||||
return result, fmt.Errorf("run audita process (binary=%q, output_dir=%q, stdout_log=%q, stderr_log=%q): %w",
|
return result, fmt.Errorf("run audita process (binary=%q, output_dir=%q, stdout_log=%q, stderr_log=%q): %w",
|
||||||
r.cfg.Binary, filepath.Dir(req.OutputProcessedPath), req.StdoutLogPath, req.StderrLogPath, runErr)
|
r.cfg.Binary, filepath.Dir(req.OutputProcessedPath), req.StdoutLogPath, req.StderrLogPath, runErr)
|
||||||
}
|
}
|
||||||
if err := validateProcessedOutput(req.OutputProcessedPath); err != nil {
|
if err := validateProcessedOutput(req.OutputProcessedPath); err != nil {
|
||||||
result.Reports, _ = discoverReports(req.OutputProcessedPath)
|
result.Reports, _ = discoverReports(reportDirectory(req))
|
||||||
return result, fmt.Errorf("validate audita processed output %q: %w", req.OutputProcessedPath, err)
|
return result, fmt.Errorf("validate audita processed output %q: %w", req.OutputProcessedPath, err)
|
||||||
}
|
}
|
||||||
reports, err := discoverReports(req.OutputProcessedPath)
|
reports, err := discoverReports(reportDirectory(req))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@@ -139,14 +114,14 @@ func (r *SubprocessRunner) Run(ctx context.Context, req PolishRequest) (PolishRe
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *SubprocessRunner) result(req PolishRequest, modules, names []string, runRes subprocess.RunResult) PolishResult {
|
func (r *SubprocessRunner) result(req PolishRequest, names []string, runRes subprocess.RunResult) PolishResult {
|
||||||
return PolishResult{
|
return PolishResult{
|
||||||
ProcessedTranscriptPath: req.OutputProcessedPath,
|
ProcessedTranscriptPath: req.OutputProcessedPath,
|
||||||
StdoutLogPath: req.StdoutLogPath, StderrLogPath: req.StderrLogPath,
|
StdoutLogPath: req.StdoutLogPath, StderrLogPath: req.StderrLogPath,
|
||||||
GeneratedConfigPath: req.GeneratedConfigPath, ExitCode: runRes.ExitCode,
|
GeneratedConfigPath: req.GeneratedConfigPath, ExitCode: runRes.ExitCode,
|
||||||
Duration: runRes.Duration, InvokedBinary: r.cfg.Binary,
|
Duration: runRes.Duration, InvokedBinary: r.cfg.Binary,
|
||||||
Metadata: map[string]any{
|
Metadata: map[string]any{
|
||||||
"adapter": "audita_subprocess", "modules": modules,
|
"adapter": "audita_subprocess", "glossary_files": req.GlossaryFiles, "report_dir": req.ReportDir, "work_dir": req.WorkDir, "debug": r.cfg.Debug,
|
||||||
"overlay": r.cfg.Overlay, "proposal_profile": r.cfg.ProposalProfile,
|
"overlay": r.cfg.Overlay, "proposal_profile": r.cfg.ProposalProfile,
|
||||||
"validation_profile": r.cfg.ValidationProfile,
|
"validation_profile": r.cfg.ValidationProfile,
|
||||||
"transcript_description": r.cfg.TranscriptDescription,
|
"transcript_description": r.cfg.TranscriptDescription,
|
||||||
@@ -156,37 +131,45 @@ func (r *SubprocessRunner) result(req PolishRequest, modules, names []string, ru
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *SubprocessRunner) buildArgs(req PolishRequest, modules []string) []string {
|
func (r *SubprocessRunner) buildArgs(command string, req PolishRequest) []string {
|
||||||
args := []string{"process", req.MergedTranscriptPath, "--glossary", req.GlossaryPath, "--output", req.OutputProcessedPath}
|
args := []string{command, req.MergedTranscriptPath, "--output", req.OutputProcessedPath}
|
||||||
if modules != nil {
|
for _, path := range req.GlossaryFiles {
|
||||||
args = append(args, "--modules", strings.Join(modules, ","))
|
args = append(args, "--glossary-file", path)
|
||||||
}
|
}
|
||||||
for _, setting := range []struct{ flag, value string }{
|
for _, setting := range []struct{ flag, value string }{
|
||||||
{"--config", r.cfg.ConfigPath}, {"--overlay", r.cfg.Overlay},
|
{"--config", r.cfg.ConfigPath}, {"--overlay", r.cfg.Overlay},
|
||||||
{"--proposal-profile", r.cfg.ProposalProfile}, {"--validation-profile", r.cfg.ValidationProfile},
|
{"--proposal-profile", r.cfg.ProposalProfile}, {"--validation-profile", r.cfg.ValidationProfile},
|
||||||
{"--transcript-description", r.cfg.TranscriptDescription}, {"--output-schema", r.cfg.OutputSchema},
|
{"--transcript-description", r.cfg.TranscriptDescription}, {"--output-schema", r.cfg.OutputSchema},
|
||||||
|
{"--report-dir", req.ReportDir}, {"--work-dir", req.WorkDir},
|
||||||
} {
|
} {
|
||||||
if setting.value != "" {
|
if setting.value != "" {
|
||||||
args = append(args, setting.flag, setting.value)
|
args = append(args, setting.flag, setting.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if r.cfg.Debug {
|
||||||
|
args = append(args, "--debug")
|
||||||
|
}
|
||||||
return args
|
return args
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *SubprocessRunner) writeInvocationConfig(req PolishRequest, args, modules, names []string) error {
|
func (r *SubprocessRunner) writeInvocationConfig(req PolishRequest, args, names []string) error {
|
||||||
return writeGeneratedYAML(req.GeneratedConfigPath, map[string]any{
|
return writeGeneratedYAML(req.GeneratedConfigPath, map[string]any{
|
||||||
"schema": "audita.generated.v2", "binary": r.cfg.Binary, "args": args,
|
"schema": "audita.generated.v3", "binary": r.cfg.Binary, "args": args, "timeout": r.cfg.Timeout.String(),
|
||||||
"timeout": r.cfg.Timeout.String(), "modules": modules,
|
"glossary_files": req.GlossaryFiles, "report_dir": req.ReportDir, "work_dir": req.WorkDir, "debug": r.cfg.Debug,
|
||||||
"overlay": r.cfg.Overlay, "proposal_profile": r.cfg.ProposalProfile,
|
"overlay": r.cfg.Overlay, "proposal_profile": r.cfg.ProposalProfile, "validation_profile": r.cfg.ValidationProfile,
|
||||||
"validation_profile": r.cfg.ValidationProfile,
|
"transcript_description": r.cfg.TranscriptDescription, "config_path": r.cfg.ConfigPath, "output_schema": r.cfg.OutputSchema,
|
||||||
"transcript_description": r.cfg.TranscriptDescription,
|
"merged_transcript_path": req.MergedTranscriptPath, "output_path": req.OutputProcessedPath, "credential_names": names,
|
||||||
"config_path": r.cfg.ConfigPath, "output_schema": r.cfg.OutputSchema,
|
|
||||||
"merged_transcript_path": req.MergedTranscriptPath, "glossary_path": req.GlossaryPath,
|
|
||||||
"output_path": req.OutputProcessedPath, "credential_names": names,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func discoverReports(outputPath string) (ReportBundle, error) {
|
func reportDirectory(req PolishRequest) string {
|
||||||
|
if req.ReportDir != "" {
|
||||||
|
return req.ReportDir
|
||||||
|
}
|
||||||
|
return filepath.Dir(req.OutputProcessedPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
func discoverReports(reportDir string) (ReportBundle, error) {
|
||||||
var reports ReportBundle
|
var reports ReportBundle
|
||||||
for _, report := range []struct {
|
for _, report := range []struct {
|
||||||
name string
|
name string
|
||||||
@@ -196,7 +179,7 @@ func discoverReports(outputPath string) (ReportBundle, error) {
|
|||||||
{"recoveries.yml", &reports.RecoveriesPath},
|
{"recoveries.yml", &reports.RecoveriesPath},
|
||||||
{"report.md", &reports.OverviewPath},
|
{"report.md", &reports.OverviewPath},
|
||||||
} {
|
} {
|
||||||
path := filepath.Join(filepath.Dir(outputPath), report.name)
|
path := filepath.Join(reportDir, report.name)
|
||||||
info, err := os.Lstat(path)
|
info, err := os.Lstat(path)
|
||||||
if errors.Is(err, os.ErrNotExist) {
|
if errors.Is(err, os.ErrNotExist) {
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ func auditaTestRequest(t *testing.T) PolishRequest {
|
|||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
return PolishRequest{
|
return PolishRequest{
|
||||||
MergedTranscriptPath: filepath.Join(dir, "merged.json"),
|
MergedTranscriptPath: filepath.Join(dir, "merged.json"),
|
||||||
GlossaryPath: filepath.Join(dir, "glossary.yml"),
|
GlossaryFiles: []string{filepath.Join(dir, "party.yml"), filepath.Join(dir, "campaign terms.yml")},
|
||||||
OutputProcessedPath: filepath.Join(dir, "polished.json"),
|
OutputProcessedPath: filepath.Join(dir, "polished.json"),
|
||||||
GeneratedConfigPath: filepath.Join(dir, "audita.generated.yml"),
|
GeneratedConfigPath: filepath.Join(dir, "audita.generated.yml"),
|
||||||
StdoutLogPath: filepath.Join(dir, "stdout.log"),
|
StdoutLogPath: filepath.Join(dir, "stdout.log"),
|
||||||
@@ -62,7 +62,7 @@ func writeAuditaTestFile(t *testing.T, path, value string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSubprocessRunnerUsesV2InvocationAndCapturedCredentials(t *testing.T) {
|
func TestSubprocessRunnerUsesNativeInvocationAndCapturedCredentials(t *testing.T) {
|
||||||
const first = "NARRATIO_AUDITA_CUSTOM_ONE"
|
const first = "NARRATIO_AUDITA_CUSTOM_ONE"
|
||||||
const second = "NARRATIO_AUDITA_CUSTOM_TWO"
|
const second = "NARRATIO_AUDITA_CUSTOM_TWO"
|
||||||
firstSecret := auditaTestSecret(t, first, "loaded-one")
|
firstSecret := auditaTestSecret(t, first, "loaded-one")
|
||||||
@@ -72,7 +72,6 @@ func TestSubprocessRunnerUsesV2InvocationAndCapturedCredentials(t *testing.T) {
|
|||||||
t.Setenv("NARRATIO_AUDITA_UNSELECTED", "not-forwarded")
|
t.Setenv("NARRATIO_AUDITA_UNSELECTED", "not-forwarded")
|
||||||
runner := auditaTestRunner(t, SubprocessRunnerConfig{
|
runner := auditaTestRunner(t, SubprocessRunnerConfig{
|
||||||
Credentials: []configkit.Secret{firstSecret, secondSecret},
|
Credentials: []configkit.Secret{firstSecret, secondSecret},
|
||||||
Modules: []string{"grammar", "glossary", "grammar"},
|
|
||||||
Overlay: "testing", ProposalProfile: "proposal", ValidationProfile: "validation",
|
Overlay: "testing", ProposalProfile: "proposal", ValidationProfile: "validation",
|
||||||
TranscriptDescription: "campaign", ConfigPath: "/etc/audita/config.yml", OutputSchema: "audita-v1",
|
TranscriptDescription: "campaign", ConfigPath: "/etc/audita/config.yml", OutputSchema: "audita-v1",
|
||||||
})
|
})
|
||||||
@@ -90,8 +89,8 @@ func TestSubprocessRunnerUsesV2InvocationAndCapturedCredentials(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
want := []string{"process", req.MergedTranscriptPath, "--glossary", req.GlossaryPath, "--output", req.OutputProcessedPath,
|
want := []string{"process", req.MergedTranscriptPath, "--output", req.OutputProcessedPath,
|
||||||
"--modules", "grammar,glossary,grammar", "--config", "/etc/audita/config.yml", "--overlay", "testing",
|
"--glossary-file", req.GlossaryFiles[0], "--glossary-file", req.GlossaryFiles[1], "--config", "/etc/audita/config.yml", "--overlay", "testing",
|
||||||
"--proposal-profile", "proposal", "--validation-profile", "validation", "--transcript-description", "campaign", "--output-schema", "audita-v1"}
|
"--proposal-profile", "proposal", "--validation-profile", "validation", "--transcript-description", "campaign", "--output-schema", "audita-v1"}
|
||||||
if !reflect.DeepEqual(captured.Args, want) {
|
if !reflect.DeepEqual(captured.Args, want) {
|
||||||
t.Fatalf("args = %#v, want %#v", captured.Args, want)
|
t.Fatalf("args = %#v, want %#v", captured.Args, want)
|
||||||
@@ -109,51 +108,11 @@ func TestSubprocessRunnerUsesV2InvocationAndCapturedCredentials(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !strings.Contains(string(generated), "audita.generated.v2") || !strings.Contains(string(generated), first) || strings.Contains(string(generated), "loaded-one") {
|
if !strings.Contains(string(generated), "audita.generated.v3") || !strings.Contains(string(generated), first) || strings.Contains(string(generated), "loaded-one") {
|
||||||
t.Fatalf("unsafe or incomplete generated invocation: %s", generated)
|
t.Fatalf("unsafe or incomplete generated invocation: %s", generated)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSubprocessRunnerModulePresenceAndReportAbsence(t *testing.T) {
|
|
||||||
for _, test := range []struct {
|
|
||||||
name string
|
|
||||||
configured []string
|
|
||||||
requested []string
|
|
||||||
wantFlag bool
|
|
||||||
wantValue string
|
|
||||||
}{
|
|
||||||
{"omitted", nil, nil, false, ""},
|
|
||||||
{"configured", []string{"grammar", "grammar"}, nil, true, "grammar,grammar"},
|
|
||||||
{"empty override", []string{"grammar"}, []string{}, true, ""},
|
|
||||||
} {
|
|
||||||
t.Run(test.name, func(t *testing.T) {
|
|
||||||
runner := auditaTestRunner(t, SubprocessRunnerConfig{Modules: test.configured})
|
|
||||||
req := auditaTestRequest(t)
|
|
||||||
req.Modules = test.requested
|
|
||||||
runner.run = func(_ context.Context, processReq subprocess.RunRequest) (subprocess.RunResult, error) {
|
|
||||||
index := -1
|
|
||||||
for i, arg := range processReq.Args {
|
|
||||||
if arg == "--modules" {
|
|
||||||
index = i
|
|
||||||
}
|
|
||||||
if strings.HasPrefix(arg, "--report") || arg == "--debug" || arg == "--work-dir" {
|
|
||||||
t.Fatalf("retired or unwanted flag %q", arg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (index >= 0) != test.wantFlag || (index >= 0 && processReq.Args[index+1] != test.wantValue) {
|
|
||||||
t.Fatalf("args = %#v", processReq.Args)
|
|
||||||
}
|
|
||||||
writeAuditaTestFile(t, req.OutputProcessedPath, `{"segments":[]}`)
|
|
||||||
return subprocess.RunResult{}, nil
|
|
||||||
}
|
|
||||||
result, err := runner.Run(context.Background(), req)
|
|
||||||
if err != nil || result.Reports != (ReportBundle{}) {
|
|
||||||
t.Fatalf("result = %#v, error = %v", result, err)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSubprocessRunnerRejectsMissingOrMalformedTranscript(t *testing.T) {
|
func TestSubprocessRunnerRejectsMissingOrMalformedTranscript(t *testing.T) {
|
||||||
for _, output := range []string{"", `{"segments":"wrong"}`} {
|
for _, output := range []string{"", `{"segments":"wrong"}`} {
|
||||||
t.Run(output, func(t *testing.T) {
|
t.Run(output, func(t *testing.T) {
|
||||||
@@ -261,3 +220,39 @@ func TestSubprocessRunnerRedactsCustomCredentialStreams(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSubprocessRunnerDestinationsAndDebug(t *testing.T) {
|
||||||
|
for _, debug := range []bool{false, true} {
|
||||||
|
runner := auditaTestRunner(t, SubprocessRunnerConfig{Debug: debug})
|
||||||
|
req := auditaTestRequest(t)
|
||||||
|
req.ReportDir = filepath.Join(t.TempDir(), "reports")
|
||||||
|
req.WorkDir = filepath.Join(t.TempDir(), "work")
|
||||||
|
if err := os.MkdirAll(req.ReportDir, 0755); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
runner.run = func(_ context.Context, processReq subprocess.RunRequest) (subprocess.RunResult, error) {
|
||||||
|
flags := strings.Join(processReq.Args, "|")
|
||||||
|
if !strings.Contains(flags, "--report-dir|"+req.ReportDir) || !strings.Contains(flags, "--work-dir|"+req.WorkDir) || strings.Contains(flags, "--reporting=false") || strings.Contains(flags, "--modules") || strings.Contains(flags, "--debug") != debug {
|
||||||
|
t.Fatalf("args: %v", processReq.Args)
|
||||||
|
}
|
||||||
|
writeAuditaTestFile(t, req.OutputProcessedPath, `{"segments":[]}`)
|
||||||
|
writeAuditaTestFile(t, filepath.Join(req.ReportDir, "errors.yml"), "status: completed\n")
|
||||||
|
return subprocess.RunResult{}, nil
|
||||||
|
}
|
||||||
|
result, err := runner.Run(context.Background(), req)
|
||||||
|
if err != nil || result.Reports.ErrorsPath != filepath.Join(req.ReportDir, "errors.yml") {
|
||||||
|
t.Fatalf("result: %+v %v", result, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWorkDirectoryAloneDoesNotEnableCapture(t *testing.T) {
|
||||||
|
runner := auditaTestRunner(t, SubprocessRunnerConfig{})
|
||||||
|
req := auditaTestRequest(t)
|
||||||
|
req.WorkDir = filepath.Join(t.TempDir(), "work")
|
||||||
|
args := runner.buildArgs("process", req)
|
||||||
|
joined := strings.Join(args, "|")
|
||||||
|
if !strings.Contains(joined, "--work-dir|"+req.WorkDir) || strings.Contains(joined, "--debug") || strings.Contains(joined, "--report-dir") || strings.Contains(joined, "--reporting") {
|
||||||
|
t.Fatalf("args: %v", args)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ func buildDefaultAuditaRunner(cfg *config.Config) (audita.Runner, error) {
|
|||||||
}
|
}
|
||||||
runner, err := audita.NewSubprocessRunner(audita.SubprocessRunnerConfig{
|
runner, err := audita.NewSubprocessRunner(audita.SubprocessRunnerConfig{
|
||||||
Binary: a.Binary, Timeout: timeout, Credentials: a.Credentials,
|
Binary: a.Binary, Timeout: timeout, Credentials: a.Credentials,
|
||||||
Modules: append(a.Modules[:0:0], a.Modules...),
|
Debug: a.Debug,
|
||||||
Overlay: a.Overlay, ProposalProfile: a.ProposalProfile,
|
Overlay: a.Overlay, ProposalProfile: a.ProposalProfile,
|
||||||
ValidationProfile: a.ValidationProfile,
|
ValidationProfile: a.ValidationProfile,
|
||||||
TranscriptDescription: a.TranscriptDescription, ConfigPath: a.ConfigPath,
|
TranscriptDescription: a.TranscriptDescription, ConfigPath: a.ConfigPath,
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ type AuditaConfig struct {
|
|||||||
Binary string `yaml:"binary" json:"binary"`
|
Binary string `yaml:"binary" json:"binary"`
|
||||||
Timeout string `yaml:"timeout" json:"timeout"`
|
Timeout string `yaml:"timeout" json:"timeout"`
|
||||||
Credentials []configkit.Secret `yaml:"credentials,omitempty" json:"credentials,omitempty"`
|
Credentials []configkit.Secret `yaml:"credentials,omitempty" json:"credentials,omitempty"`
|
||||||
Modules []string `yaml:"modules" json:"modules"`
|
Debug bool `yaml:"debug" json:"debug"`
|
||||||
Overlay string `yaml:"overlay" json:"overlay"`
|
Overlay string `yaml:"overlay" json:"overlay"`
|
||||||
ProposalProfile string `yaml:"proposal_profile" json:"proposal_profile"`
|
ProposalProfile string `yaml:"proposal_profile" json:"proposal_profile"`
|
||||||
ValidationProfile string `yaml:"validation_profile" json:"validation_profile"`
|
ValidationProfile string `yaml:"validation_profile" json:"validation_profile"`
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func (cfg AuditaConfig) MarshalYAML() (any, error) {
|
|||||||
Binary string `yaml:"binary"`
|
Binary string `yaml:"binary"`
|
||||||
Timeout string `yaml:"timeout"`
|
Timeout string `yaml:"timeout"`
|
||||||
Credentials []string `yaml:"credentials,omitempty"`
|
Credentials []string `yaml:"credentials,omitempty"`
|
||||||
Modules *[]string `yaml:"modules,omitempty"`
|
Debug bool `yaml:"debug,omitempty"`
|
||||||
Overlay string `yaml:"overlay"`
|
Overlay string `yaml:"overlay"`
|
||||||
ProposalProfile string `yaml:"proposal_profile"`
|
ProposalProfile string `yaml:"proposal_profile"`
|
||||||
ValidationProfile string `yaml:"validation_profile"`
|
ValidationProfile string `yaml:"validation_profile"`
|
||||||
@@ -35,14 +35,9 @@ func (cfg AuditaConfig) MarshalYAML() (any, error) {
|
|||||||
ConfigPath string `yaml:"config_path"`
|
ConfigPath string `yaml:"config_path"`
|
||||||
OutputSchema string `yaml:"output_schema"`
|
OutputSchema string `yaml:"output_schema"`
|
||||||
}
|
}
|
||||||
// A nil pointer omits the override; a pointer to an empty slice disables modules.
|
|
||||||
var modules *[]string
|
|
||||||
if cfg.Modules != nil {
|
|
||||||
modules = &cfg.Modules
|
|
||||||
}
|
|
||||||
return safeAudita{
|
return safeAudita{
|
||||||
Binary: cfg.Binary, Timeout: cfg.Timeout, Credentials: secretReferenceNames(cfg.Credentials),
|
Binary: cfg.Binary, Timeout: cfg.Timeout, Credentials: secretReferenceNames(cfg.Credentials),
|
||||||
Modules: modules, Overlay: cfg.Overlay, ProposalProfile: cfg.ProposalProfile,
|
Debug: cfg.Debug, Overlay: cfg.Overlay, ProposalProfile: cfg.ProposalProfile,
|
||||||
ValidationProfile: cfg.ValidationProfile, TranscriptDescription: cfg.TranscriptDescription,
|
ValidationProfile: cfg.ValidationProfile, TranscriptDescription: cfg.TranscriptDescription,
|
||||||
ConfigPath: cfg.ConfigPath, OutputSchema: cfg.OutputSchema,
|
ConfigPath: cfg.ConfigPath, OutputSchema: cfg.OutputSchema,
|
||||||
}, nil
|
}, nil
|
||||||
|
|||||||
@@ -1,33 +1,17 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAuditaYAMLPreservesModuleSelection(t *testing.T) {
|
func TestAuditaYAMLPreservesDebug(t *testing.T) {
|
||||||
for _, tc := range []struct {
|
data, err := yaml.Marshal(AuditaConfig{Debug: true})
|
||||||
name string
|
|
||||||
modules []string
|
|
||||||
}{
|
|
||||||
{name: "omitted"},
|
|
||||||
{name: "explicit empty", modules: []string{}},
|
|
||||||
{name: "ordered repetitions", modules: []string{"grammar", "names", "grammar"}},
|
|
||||||
} {
|
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
|
||||||
data, err := yaml.Marshal(AuditaConfig{Modules: tc.modules})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
var decoded AuditaConfig
|
var decoded AuditaConfig
|
||||||
if err := yaml.Unmarshal(data, &decoded); err != nil {
|
if err := yaml.Unmarshal(data, &decoded); err != nil || !decoded.Debug {
|
||||||
t.Fatal(err)
|
t.Fatalf("debug round trip: %s %v", data, err)
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(decoded.Modules, tc.modules) {
|
|
||||||
t.Fatalf("modules = %#v, want %#v; YAML:\n%s", decoded.Modules, tc.modules, data)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ type effectiveAuditaConfig struct {
|
|||||||
Binary string `yaml:"binary" json:"binary"`
|
Binary string `yaml:"binary" json:"binary"`
|
||||||
Timeout string `yaml:"timeout" json:"timeout"`
|
Timeout string `yaml:"timeout" json:"timeout"`
|
||||||
Credentials []string `yaml:"credentials" json:"credentials"`
|
Credentials []string `yaml:"credentials" json:"credentials"`
|
||||||
Modules []string `yaml:"modules" json:"modules"`
|
Debug bool `yaml:"debug" json:"debug"`
|
||||||
Overlay string `yaml:"overlay" json:"overlay"`
|
Overlay string `yaml:"overlay" json:"overlay"`
|
||||||
ProposalProfile string `yaml:"proposal_profile" json:"proposal_profile"`
|
ProposalProfile string `yaml:"proposal_profile" json:"proposal_profile"`
|
||||||
ValidationProfile string `yaml:"validation_profile" json:"validation_profile"`
|
ValidationProfile string `yaml:"validation_profile" json:"validation_profile"`
|
||||||
@@ -89,7 +89,7 @@ func projectEffectivePipeline(cfg *PipelineConfig) effectivePipelineProjection {
|
|||||||
projection.Storage.S3 = &effectiveStorageS3Config{Bucket: s3.Bucket, RootPrefix: s3.RootPrefix, Region: s3.Region, Endpoint: s3.Endpoint, ForcePathStyle: s3.ForcePathStyle, AccessKeyID: secretReferenceName(s3.AccessKeyID), SecretAccessKey: secretReferenceName(s3.SecretAccessKey)}
|
projection.Storage.S3 = &effectiveStorageS3Config{Bucket: s3.Bucket, RootPrefix: s3.RootPrefix, Region: s3.Region, Endpoint: s3.Endpoint, ForcePathStyle: s3.ForcePathStyle, AccessKeyID: secretReferenceName(s3.AccessKeyID), SecretAccessKey: secretReferenceName(s3.SecretAccessKey)}
|
||||||
}
|
}
|
||||||
audita := cfg.Audita
|
audita := cfg.Audita
|
||||||
projection.Audita = effectiveAuditaConfig{Binary: audita.Binary, Timeout: audita.Timeout, Credentials: secretReferenceNames(audita.Credentials), Modules: audita.Modules, Overlay: audita.Overlay, ProposalProfile: audita.ProposalProfile, ValidationProfile: audita.ValidationProfile, TranscriptDescription: audita.TranscriptDescription, ConfigPath: audita.ConfigPath, OutputSchema: audita.OutputSchema}
|
projection.Audita = effectiveAuditaConfig{Binary: audita.Binary, Timeout: audita.Timeout, Credentials: secretReferenceNames(audita.Credentials), Debug: audita.Debug, Overlay: audita.Overlay, ProposalProfile: audita.ProposalProfile, ValidationProfile: audita.ValidationProfile, TranscriptDescription: audita.TranscriptDescription, ConfigPath: audita.ConfigPath, OutputSchema: audita.OutputSchema}
|
||||||
if n := cfg.Notarius; n != nil {
|
if n := cfg.Notarius; n != nil {
|
||||||
projection.Notarius = &effectiveNotariusConfig{Enabled: n.Enabled, Binary: n.Binary, Credentials: secretReferenceNames(n.Credentials), ConfigOverlay: n.ConfigOverlay, Resume: n.Resume, ChunkCache: n.ChunkCache, ConfigPath: n.ConfigPath, PipelineID: n.PipelineID, Timeout: n.Timeout, WorkingDirectory: n.WorkingDirectory, References: n.References, Outputs: n.Outputs}
|
projection.Notarius = &effectiveNotariusConfig{Enabled: n.Enabled, Binary: n.Binary, Credentials: secretReferenceNames(n.Credentials), ConfigOverlay: n.ConfigOverlay, Resume: n.Resume, ChunkCache: n.ChunkCache, ConfigPath: n.ConfigPath, PipelineID: n.PipelineID, Timeout: n.Timeout, WorkingDirectory: n.WorkingDirectory, References: n.References, Outputs: n.Outputs}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ notarius:
|
|||||||
|
|
||||||
func TestPipelineMaterializationPreservesNilEmptyAndExactIntegers(t *testing.T) {
|
func TestPipelineMaterializationPreservesNilEmptyAndExactIntegers(t *testing.T) {
|
||||||
base := &PipelineConfig{
|
base := &PipelineConfig{
|
||||||
Audita: AuditaConfig{Modules: nil},
|
Audita: AuditaConfig{},
|
||||||
Scriptorium: &ScriptoriumConfig{Artifacts: nil},
|
Scriptorium: &ScriptoriumConfig{Artifacts: nil},
|
||||||
resolution: &pipelineResolutionMetadata{},
|
resolution: &pipelineResolutionMetadata{},
|
||||||
}
|
}
|
||||||
@@ -197,14 +197,13 @@ func TestPipelineMaterializationPreservesNilEmptyAndExactIntegers(t *testing.T)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !strings.Contains(string(nilYAML), "modules: null\n") || !strings.Contains(string(nilYAML), "artifacts: null\n") {
|
if !strings.Contains(string(nilYAML), "artifacts: null\n") {
|
||||||
t.Fatalf("effective YAML lost null collections: %q", nilYAML)
|
t.Fatalf("effective YAML lost null collections: %q", nilYAML)
|
||||||
}
|
}
|
||||||
if err := recomputePipelineEffectiveDigest(base); err != nil {
|
if err := recomputePipelineEffectiveDigest(base); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
nilDigest := EffectivePipelineDigest(base)
|
nilDigest := EffectivePipelineDigest(base)
|
||||||
base.Audita.Modules = []string{}
|
|
||||||
base.Scriptorium.Artifacts = map[string]ScriptoriumArtifactConfig{}
|
base.Scriptorium.Artifacts = map[string]ScriptoriumArtifactConfig{}
|
||||||
if err := recomputePipelineEffectiveDigest(base); err != nil {
|
if err := recomputePipelineEffectiveDigest(base); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -213,7 +212,7 @@ func TestPipelineMaterializationPreservesNilEmptyAndExactIntegers(t *testing.T)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !strings.Contains(string(emptyYAML), "modules: []\n") || !strings.Contains(string(emptyYAML), "artifacts: {}\n") {
|
if !strings.Contains(string(emptyYAML), "artifacts: {}\n") {
|
||||||
t.Fatalf("effective YAML lost empty collections: %q", emptyYAML)
|
t.Fatalf("effective YAML lost empty collections: %q", emptyYAML)
|
||||||
}
|
}
|
||||||
if err := recomputePipelineEffectiveDigest(base); err != nil {
|
if err := recomputePipelineEffectiveDigest(base); err != nil {
|
||||||
|
|||||||
@@ -453,40 +453,8 @@ func TestPipelineOverlayDoesNotRequireUnusedBaseCredentials(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAuditaModulesPreserveOmittedEmptyAndReplacementSelections(t *testing.T) {
|
|
||||||
for _, test := range []struct {
|
|
||||||
name, base, overlay string
|
|
||||||
wantNil bool
|
|
||||||
want []string
|
|
||||||
}{
|
|
||||||
{name: "omitted", wantNil: true},
|
|
||||||
{name: "null", base: " modules: null\n", wantNil: true},
|
|
||||||
{name: "empty", base: " modules: []\n", want: []string{}},
|
|
||||||
{name: "overlay empty", base: " modules: [glossary]\n", overlay: "audita:\n modules: []\n", want: []string{}},
|
|
||||||
{name: "overlay order", base: " modules: []\n", overlay: "audita:\n modules: [grammar, glossary, grammar]\n", want: []string{"grammar", "glossary", "grammar"}},
|
|
||||||
} {
|
|
||||||
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\naudita:\n binary: audita\n"+test.base)
|
|
||||||
options := PipelineLoadOptions{}
|
|
||||||
if test.overlay != "" {
|
|
||||||
writePipelineFixture(t, dir, "overlays/testing.yml", test.overlay)
|
|
||||||
selection := "testing"
|
|
||||||
options.Overlay = &selection
|
|
||||||
}
|
|
||||||
cfg, err := LoadPipelineWithOptions(root, options)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if (cfg.Audita.Modules == nil) != test.wantNil || !reflect.DeepEqual(cfg.Audita.Modules, test.want) {
|
|
||||||
t.Fatalf("modules = %#v, want %#v (nil=%v)", cfg.Audita.Modules, test.want, test.wantNil)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAuditaRejectsRetiredConfigurationFields(t *testing.T) {
|
func TestAuditaRejectsRetiredConfigurationFields(t *testing.T) {
|
||||||
for _, field := range []string{"llm_api_key", "base_url", "model", "validation_model", "total_llm_concurrency", "proposal_llm_concurrency", "validation_llm_concurrency", "work_dir_retention", "report"} {
|
for _, field := range []string{"llm_api_key", "base_url", "model", "validation_model", "total_llm_concurrency", "proposal_llm_concurrency", "validation_llm_concurrency", "work_dir_retention", "report", "modules"} {
|
||||||
t.Run(field, func(t *testing.T) {
|
t.Run(field, func(t *testing.T) {
|
||||||
root := writePipelineFixture(t, t.TempDir(), "pipeline.yml", "whisperx:\n transcribe_url: https://transcription.example.test/transcribe\naudita:\n "+field+": retired\n")
|
root := writePipelineFixture(t, t.TempDir(), "pipeline.yml", "whisperx:\n transcribe_url: https://transcription.example.test/transcribe\naudita:\n "+field+": retired\n")
|
||||||
if _, err := LoadPipeline(root); err == nil || !strings.Contains(configurationErrorText(err), "decode.unknown_field") {
|
if _, err := LoadPipeline(root); err == nil || !strings.Contains(configurationErrorText(err), "decode.unknown_field") {
|
||||||
|
|||||||
@@ -165,17 +165,6 @@ func validateAudita(cfg AuditaConfig) error {
|
|||||||
if err := validateDuration("pipeline.audita.timeout", cfg.Timeout); err != nil {
|
if err := validateDuration("pipeline.audita.timeout", cfg.Timeout); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for i, m := range cfg.Modules {
|
|
||||||
module := strings.TrimSpace(m)
|
|
||||||
if module == "" {
|
|
||||||
return fmt.Errorf("pipeline.audita.modules[%d] must be non-empty", i)
|
|
||||||
}
|
|
||||||
switch module {
|
|
||||||
case "glossary", "homophones", "spoken_word", "grammar":
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("pipeline.audita.modules[%d] must be one of: glossary, homophones, spoken_word, grammar", i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if strings.TrimSpace(cfg.TranscriptDescription) == "" && cfg.TranscriptDescription != "" {
|
if strings.TrimSpace(cfg.TranscriptDescription) == "" && cfg.TranscriptDescription != "" {
|
||||||
return fmt.Errorf("pipeline.audita.transcript_description must be non-empty when provided")
|
return fmt.Errorf("pipeline.audita.transcript_description must be non-empty when provided")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ func (polishStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*St
|
|||||||
GeneratedConfigPath: generatedConfigPath,
|
GeneratedConfigPath: generatedConfigPath,
|
||||||
MergedTranscriptPath: mergedPath,
|
MergedTranscriptPath: mergedPath,
|
||||||
OutputProcessedPath: processedPath,
|
OutputProcessedPath: processedPath,
|
||||||
GlossaryPath: glossaryPath,
|
GlossaryFiles: []string{glossaryPath},
|
||||||
StdoutLogPath: stdoutPath,
|
StdoutLogPath: stdoutPath,
|
||||||
StderrLogPath: stderrPath,
|
StderrLogPath: stderrPath,
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,6 @@ func (polishStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*St
|
|||||||
"glossary_path": glossaryPath,
|
"glossary_path": glossaryPath,
|
||||||
"run_output_path": finalProcessedPath,
|
"run_output_path": finalProcessedPath,
|
||||||
"output_path": canonicalProcessedPath,
|
"output_path": canonicalProcessedPath,
|
||||||
"modules": append(env.Config.Pipeline.Audita.Modules[:0:0], env.Config.Pipeline.Audita.Modules...),
|
|
||||||
"overlay": env.Config.Pipeline.Audita.Overlay,
|
"overlay": env.Config.Pipeline.Audita.Overlay,
|
||||||
"proposal_profile": env.Config.Pipeline.Audita.ProposalProfile,
|
"proposal_profile": env.Config.Pipeline.Audita.ProposalProfile,
|
||||||
"validation_profile": env.Config.Pipeline.Audita.ValidationProfile,
|
"validation_profile": env.Config.Pipeline.Audita.ValidationProfile,
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ func TestPolishStagePolishesMergedTranscriptAndRecordsMetadata(t *testing.T) {
|
|||||||
if req.MergedTranscriptPath != mergedPath {
|
if req.MergedTranscriptPath != mergedPath {
|
||||||
t.Fatalf("merged path = %q, want %q", req.MergedTranscriptPath, mergedPath)
|
t.Fatalf("merged path = %q, want %q", req.MergedTranscriptPath, mergedPath)
|
||||||
}
|
}
|
||||||
if req.GlossaryPath != filepath.Join(paths.InputsDir, "glossary.yml") {
|
if len(req.GlossaryFiles) != 1 || req.GlossaryFiles[0] != filepath.Join(paths.InputsDir, "glossary.yml") {
|
||||||
t.Fatalf("glossary path = %q", req.GlossaryPath)
|
t.Fatalf("glossary paths = %q", req.GlossaryFiles)
|
||||||
}
|
}
|
||||||
if len(result.Outputs) != 1 {
|
if len(result.Outputs) != 1 {
|
||||||
t.Fatalf("outputs len = %d, want 1", len(result.Outputs))
|
t.Fatalf("outputs len = %d, want 1", len(result.Outputs))
|
||||||
@@ -286,7 +286,6 @@ func setupPolishEnv(t *testing.T) (*Env, *manifest.Manifest) {
|
|||||||
Binary: "audita",
|
Binary: "audita",
|
||||||
Timeout: "3h",
|
Timeout: "3h",
|
||||||
Credentials: []configkit.Secret{*testSecretReference("AUDITA_LLM_API_KEY")},
|
Credentials: []configkit.Secret{*testSecretReference("AUDITA_LLM_API_KEY")},
|
||||||
Modules: []string{"glossary", "homophones", "grammar"},
|
|
||||||
TranscriptDescription: "Campaign Session 42",
|
TranscriptDescription: "Campaign Session 42",
|
||||||
ConfigPath: "/etc/audita/config.yml",
|
ConfigPath: "/etc/audita/config.yml",
|
||||||
OutputSchema: "audita-v1",
|
OutputSchema: "audita-v1",
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type polishSemanticConfig struct {
|
type polishSemanticConfig struct {
|
||||||
Modules []string `json:"modules"`
|
|
||||||
Overlay string `json:"overlay"`
|
Overlay string `json:"overlay"`
|
||||||
ProposalProfile string `json:"proposal_profile"`
|
ProposalProfile string `json:"proposal_profile"`
|
||||||
ValidationProfile string `json:"validation_profile"`
|
ValidationProfile string `json:"validation_profile"`
|
||||||
@@ -67,15 +66,7 @@ func (polishStage) SemanticConfigFingerprint(env *Env) (manifest.SemanticConfigF
|
|||||||
return manifest.SemanticConfigFingerprint{}, fmt.Errorf("polish semantic configuration requires resolved pipeline config")
|
return manifest.SemanticConfigFingerprint{}, fmt.Errorf("polish semantic configuration requires resolved pipeline config")
|
||||||
}
|
}
|
||||||
audita := env.Config.Pipeline.Audita
|
audita := env.Config.Pipeline.Audita
|
||||||
var modules []string
|
|
||||||
if audita.Modules != nil {
|
|
||||||
modules = append([]string{}, audita.Modules...)
|
|
||||||
}
|
|
||||||
for index := range modules {
|
|
||||||
modules[index] = strings.TrimSpace(modules[index])
|
|
||||||
}
|
|
||||||
return FingerprintSemanticConfig(polishSemanticConfigVersion, polishSemanticConfig{
|
return FingerprintSemanticConfig(polishSemanticConfigVersion, polishSemanticConfig{
|
||||||
Modules: modules,
|
|
||||||
Overlay: audita.Overlay,
|
Overlay: audita.Overlay,
|
||||||
ProposalProfile: audita.ProposalProfile,
|
ProposalProfile: audita.ProposalProfile,
|
||||||
ValidationProfile: audita.ValidationProfile,
|
ValidationProfile: audita.ValidationProfile,
|
||||||
|
|||||||
@@ -12,11 +12,6 @@ func TestPolishSemanticConfigSensitivity(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
mutate func(*Env)
|
mutate func(*Env)
|
||||||
}{
|
}{
|
||||||
{name: "modules", mutate: func(env *Env) { env.Config.Pipeline.Audita.Modules = []string{"terms", "speakers", "style"} }},
|
|
||||||
{name: "module order", mutate: func(env *Env) { env.Config.Pipeline.Audita.Modules = []string{"terms", "speakers"} }},
|
|
||||||
{name: "module repetition", mutate: func(env *Env) { env.Config.Pipeline.Audita.Modules = []string{"speakers", "terms", "terms"} }},
|
|
||||||
{name: "modules omitted", mutate: func(env *Env) { env.Config.Pipeline.Audita.Modules = nil }},
|
|
||||||
{name: "modules empty", mutate: func(env *Env) { env.Config.Pipeline.Audita.Modules = []string{} }},
|
|
||||||
{name: "overlay", mutate: func(env *Env) { env.Config.Pipeline.Audita.Overlay = "testing" }},
|
{name: "overlay", mutate: func(env *Env) { env.Config.Pipeline.Audita.Overlay = "testing" }},
|
||||||
{name: "proposal profile", mutate: func(env *Env) { env.Config.Pipeline.Audita.ProposalProfile = "draft" }},
|
{name: "proposal profile", mutate: func(env *Env) { env.Config.Pipeline.Audita.ProposalProfile = "draft" }},
|
||||||
{name: "validation profile", mutate: func(env *Env) { env.Config.Pipeline.Audita.ValidationProfile = "review" }},
|
{name: "validation profile", mutate: func(env *Env) { env.Config.Pipeline.Audita.ValidationProfile = "review" }},
|
||||||
@@ -30,6 +25,7 @@ func TestPolishSemanticConfigSensitivity(t *testing.T) {
|
|||||||
mutate func(*Env)
|
mutate func(*Env)
|
||||||
}{
|
}{
|
||||||
{name: "runner settings", mutate: func(env *Env) {
|
{name: "runner settings", mutate: func(env *Env) {
|
||||||
|
env.Config.Pipeline.Audita.Debug = true
|
||||||
env.Config.Pipeline.Audita.Binary = "/opt/audita"
|
env.Config.Pipeline.Audita.Binary = "/opt/audita"
|
||||||
env.Config.Pipeline.Audita.Timeout = "1h"
|
env.Config.Pipeline.Audita.Timeout = "1h"
|
||||||
env.Config.Pipeline.Audita.Credentials = []configkit.Secret{*testSecretReference("OTHER_KEY")}
|
env.Config.Pipeline.Audita.Credentials = []configkit.Secret{*testSecretReference("OTHER_KEY")}
|
||||||
@@ -37,23 +33,6 @@ func TestPolishSemanticConfigSensitivity(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPolishSemanticConfigDistinguishesOmittedAndExplicitlyEmptyModules(t *testing.T) {
|
|
||||||
env := refinementSemanticEnv()
|
|
||||||
env.Config.Pipeline.Audita.Modules = nil
|
|
||||||
omitted, err := (polishStage{}).SemanticConfigFingerprint(env)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
env.Config.Pipeline.Audita.Modules = []string{}
|
|
||||||
empty, err := (polishStage{}).SemanticConfigFingerprint(env)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if omitted.Equal(empty) {
|
|
||||||
t.Fatal("omitted and explicitly empty module selections have equal semantic evidence")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNormalizeSemanticConfigSensitivity(t *testing.T) {
|
func TestNormalizeSemanticConfigSensitivity(t *testing.T) {
|
||||||
assertRefinementChanges(t, normalizeStage{}, []struct {
|
assertRefinementChanges(t, normalizeStage{}, []struct {
|
||||||
name string
|
name string
|
||||||
@@ -137,7 +116,7 @@ func refinementSemanticEnv() *Env {
|
|||||||
env.Config.Session.Title = "Session title"
|
env.Config.Session.Title = "Session title"
|
||||||
env.Config.Pipeline.Audita = config.AuditaConfig{
|
env.Config.Pipeline.Audita = config.AuditaConfig{
|
||||||
Binary: "audita", Timeout: "10m", Credentials: []configkit.Secret{*testSecretReference("AUDITA_KEY")},
|
Binary: "audita", Timeout: "10m", Credentials: []configkit.Secret{*testSecretReference("AUDITA_KEY")},
|
||||||
Modules: []string{"speakers", "terms"}, TranscriptDescription: "tabletop session",
|
TranscriptDescription: "tabletop session",
|
||||||
ConfigPath: "configs/audita.yml", OutputSchema: "audita.transcript.v1",
|
ConfigPath: "configs/audita.yml", OutputSchema: "audita.transcript.v1",
|
||||||
}
|
}
|
||||||
env.Config.Pipeline.Normalize = &config.NormalizeConfig{
|
env.Config.Pipeline.Normalize = &config.NormalizeConfig{
|
||||||
|
|||||||
Reference in New Issue
Block a user