Prepare normalized processing plans and fixed chunks

This commit is contained in:
2026-11-27 01:15:40 +00:00
parent e761512c1c
commit 2dc057b97e
19 changed files with 315 additions and 260 deletions

View File

@@ -4,35 +4,28 @@ import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
"slices"
"strings"
"testing"
"gitea.maximumdirect.net/eric/audita/v4/internal/core/config"
"gitea.maximumdirect.net/eric/audita/v4/internal/core/diagnostics"
"gitea.maximumdirect.net/eric/audita/v4/internal/core/schema"
)
func TestLaterEmptyGlossaryFailsBeforeOutputPreparation(t *testing.T) {
func TestLaterEmptyGlossaryFailsBeforeProfileInspection(t *testing.T) {
profile, id := "selected", "spells"
cfg := &config.Config{Pipeline: config.Pipeline{Stages: []config.Stage{
{Module: "grammar", LLM: config.LLM{ProposalProfile: &profile, ValidationProfile: &profile}},
{Module: "glossary", ID: &id, Glossaries: []string{"empty"}, LLM: config.LLM{ProposalProfile: &profile, ValidationProfile: &profile}},
}}}
output := filepath.Join(t.TempDir(), "transcript.json")
calls := 0
_, err := Prepare(context.Background(), Input{Config: cfg, Transcript: &schema.SourceTranscript{}, Output: diagnostics.OutputSelection{TranscriptPath: output}, InspectProfile: func(context.Context, string) error { calls++; return nil }})
_, err := BuildPlan(context.Background(), cfg, &schema.SourceTranscript{}, func(context.Context, string) error { calls++; return nil })
if err == nil || !strings.Contains(err.Error(), "stage 2") || !strings.Contains(err.Error(), "spells") || !strings.Contains(err.Error(), "empty") {
t.Fatalf("unexpected error: %v", err)
}
if calls != 0 {
t.Fatal("inspected profiles before checking all glossary selections")
}
if _, err := os.Stat(output); !os.IsNotExist(err) {
t.Fatalf("output exists: %v", err)
}
}
func TestEmptyPipelineNeedsNoProfile(t *testing.T) {
@@ -54,14 +47,10 @@ func TestCorrectionRepairReadinessDependsOnBudget(t *testing.T) {
t.Fatal(err)
}
cfg.Pipeline.Stages[0].LLM.CorrectionRepairAttempts = 1
output := filepath.Join(t.TempDir(), "transcript.json")
_, err := Prepare(context.Background(), Input{Config: cfg, Transcript: &schema.SourceTranscript{}, Output: diagnostics.OutputSelection{TranscriptPath: output}, InspectProfile: inspect})
_, err := BuildPlan(context.Background(), cfg, &schema.SourceTranscript{}, inspect)
if err == nil || !strings.Contains(err.Error(), "correction repair") {
t.Fatalf("readiness error: %v", err)
}
if _, err := os.Stat(output); !os.IsNotExist(err) {
t.Fatalf("output exists: %v", err)
}
}
func TestProcessingPlanReusesOnlyMatchingGlossaryViews(t *testing.T) {