Remove retired reporting and diagnostic code
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/config"
|
||||
ck "go.maximumdirect.net/configkit"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type selectedConfig struct {
|
||||
Path string
|
||||
Source string
|
||||
Result *ck.Result[config.Config]
|
||||
}
|
||||
|
||||
func selectedReportDir(cfg config.Config, outputPath string, reportDirSet bool) (string, error) {
|
||||
if !cfg.Reporting.Enabled {
|
||||
return "", nil
|
||||
}
|
||||
var reportDir string
|
||||
if outputPath != "" {
|
||||
if reportDirSet {
|
||||
reportDir = cfg.Reporting.StdoutDir
|
||||
} else {
|
||||
reportDir = filepath.Dir(outputPath)
|
||||
}
|
||||
} else {
|
||||
reportDir = cfg.Reporting.StdoutDir
|
||||
}
|
||||
if strings.TrimSpace(reportDir) == "" {
|
||||
return "", fmt.Errorf("report directory is required when reporting is enabled for the selected destination")
|
||||
}
|
||||
return reportDir, nil
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/config"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestReportDirectorySelectionOnlyUsesActiveDestination(t *testing.T) {
|
||||
cfg := config.Config{Reporting: config.Reporting{Enabled: true, StdoutDir: "reports"}}
|
||||
if got, err := selectedReportDir(cfg, "", false); err != nil || got != "reports" {
|
||||
t.Fatalf("stdout destination: %q %v", got, err)
|
||||
}
|
||||
if got, err := selectedReportDir(cfg, filepath.Join("out", "corrected.json"), false); err != nil || got != "out" {
|
||||
t.Fatalf("file destination ignored stdout setting: %q %v", got, err)
|
||||
}
|
||||
if got, err := selectedReportDir(cfg, filepath.Join("out", "corrected.json"), true); err != nil || got != "reports" {
|
||||
t.Fatalf("explicit file report directory: %q %v", got, err)
|
||||
}
|
||||
cfg.Reporting.StdoutDir = ""
|
||||
if got, err := selectedReportDir(cfg, filepath.Join("out", "corrected.json"), false); err != nil || got != "out" {
|
||||
t.Fatalf("inactive blank configured report directory rejected for file output: %q %v", got, err)
|
||||
}
|
||||
if _, err := selectedReportDir(cfg, filepath.Join("out", "corrected.json"), true); err == nil {
|
||||
t.Fatal("active explicit blank report directory accepted for file output")
|
||||
}
|
||||
if _, err := selectedReportDir(cfg, "", false); err == nil {
|
||||
t.Fatal("enabled stdout reporting accepted blank destination")
|
||||
}
|
||||
cfg.Reporting.Enabled = false
|
||||
if got, err := selectedReportDir(cfg, filepath.Join("out", "corrected.json"), true); err != nil || got != "" {
|
||||
t.Fatalf("disabled reporting probed destination: %q %v", got, err)
|
||||
}
|
||||
}
|
||||
@@ -93,6 +93,42 @@ func TestProcessUsesResolvedReportingMode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestProcessChecksOnlyTheActiveReportDirectory(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
flags []string
|
||||
wantReport bool
|
||||
wantError bool
|
||||
}{
|
||||
{"file output ignores blank configured directory", nil, true, false},
|
||||
{"explicit blank directory", []string{"--report-dir="}, false, true},
|
||||
{"disabled reporting ignores explicit blank directory", []string{"--reporting=false", "--report-dir="}, false, false},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
configPath := filepath.Join(dir, "config.yml")
|
||||
if err := os.WriteFile(configPath, []byte("version: 3\npipeline: {stages: []}\nreporting: {stdout_dir: ''}\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
transcript := filepath.Join(dir, "transcript.json")
|
||||
if err := os.WriteFile(transcript, []byte(`[{"speaker":"Alice","start":0,"end":1,"text":"hello"}]`), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
output := filepath.Join(dir, "output.json")
|
||||
args := append([]string{"process", "--config", configPath, "--output", output}, tc.flags...)
|
||||
var stdout, stderr bytes.Buffer
|
||||
status := Run(context.Background(), append(args, transcript), &stdout, &stderr)
|
||||
if (status != 0) != tc.wantError || (tc.wantError && !strings.Contains(stderr.String(), "report directory is required")) {
|
||||
t.Fatalf("status=%d stdout=%q stderr=%q", status, stdout.String(), stderr.String())
|
||||
}
|
||||
_, err := os.Stat(filepath.Join(dir, "errors.yml"))
|
||||
if (tc.wantReport && err != nil) || (!tc.wantReport && !os.IsNotExist(err)) {
|
||||
t.Fatalf("report file: %v, want present=%t", err, tc.wantReport)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestProcessCollectionFlags(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
for name, contents := range map[string]string{
|
||||
|
||||
@@ -39,11 +39,8 @@ func executePipeline(ctx context.Context, loaded *processInputs, prepared *prepa
|
||||
ProposalDiagnosticsDir: debugPath, ValidationDiagnosticsDir: debugPath,
|
||||
CaptureCandidates: debugPath != "", ReportDiagnosticError: warn,
|
||||
})
|
||||
output.Observations = observer.Snapshot()
|
||||
output.ObservationsAvailable = true
|
||||
output.LLMSummary = llm.Summarize(output.Observations)
|
||||
if debug := prepared.Prepared.Debug; debug != nil {
|
||||
warn(debug.WriteJSONArtifact(diagnostics.ArtifactLLMExecution, processreport.BuildLLMExecution(output.Observations)))
|
||||
warn(debug.WriteJSONArtifact(diagnostics.ArtifactLLMExecution, processreport.BuildLLMExecution(observer.Snapshot())))
|
||||
warn(debug.WriteJSONArtifact(diagnostics.ArtifactCorrectionLedger, processreport.BuildCorrectionLedger(processreport.CorrectionLedgerInput{RunDirectoryPath: debug.Path(), RunOutput: &output})))
|
||||
}
|
||||
var failures []processreport.RunFailure
|
||||
|
||||
Reference in New Issue
Block a user