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

@@ -9,7 +9,6 @@ import (
"sync"
"gitea.maximumdirect.net/eric/audita/v4/internal/core/chunking"
"gitea.maximumdirect.net/eric/audita/v4/internal/core/config"
"gitea.maximumdirect.net/eric/audita/v4/internal/core/glossary"
"gitea.maximumdirect.net/eric/audita/v4/internal/core/modulecatalog"
"gitea.maximumdirect.net/eric/audita/v4/internal/core/schema"
@@ -114,7 +113,7 @@ func selectEvidence(selection *EvidenceSelection) evidenceNeeds {
// RunInput is the deterministic runner input.
type RunInput struct {
Config *config.Config
Sections []chunking.Section
Transcript *schema.Transcript
ModuleSpecs []contracts.ModuleRunSpec
Interactions structuredoutput.InteractionSink
@@ -145,12 +144,8 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (RunOutput, error) {
return RunOutput{}, &ExecutionFailure{Phase: "setup", Cause: errors.New("runner module factory is required")}
}
working := input.Transcript.Clone()
results := make([]ModuleResult, 0, len(input.ModuleSpecs))
sections, err := chunkWorkingTranscript(input.Config, working)
if err != nil {
return RunOutput{FinalTranscript: working}, &ExecutionFailure{Phase: "chunking", Cause: fmt.Errorf("chunk normalized transcript: %w", err)}
}
sections := input.Sections
evidence := selectEvidence(input.Evidence)
totals := outcomes.WorkTotals{Total: len(input.ModuleSpecs) * len(sections)}
var inventory []contracts.SectionMetadata
@@ -1031,41 +1026,6 @@ func reorderValidatorsForPipeline(in []validators.Validator) ([]validators.Valid
return ordered, order
}
func chunkWorkingTranscript(cfg *config.Config, transcript *schema.Transcript) ([]chunking.Section, error) {
if cfg == nil {
if transcript == nil || len(transcript.Segments) == 0 {
return []chunking.Section{}, nil
}
return []chunking.Section{
{
Index: 0,
EstimatedTokens: estimateTranscriptTokens(transcript),
Segments: append([]schema.Segment(nil), transcript.Segments...),
StartSegmentID: transcript.Segments[0].ID,
EndSegmentID: transcript.Segments[len(transcript.Segments)-1].ID,
},
}, nil
}
chunker := chunking.NewChunker(chunking.ChunkingConfig{
MaxSectionTokens: cfg.Chunking.MaxSectionTokens,
MinSectionTokens: cfg.Chunking.MinSectionTokens,
TargetSections: cfg.Chunking.TargetSections,
})
return chunker.ChunkTranscript(transcript)
}
func estimateTranscriptTokens(transcript *schema.Transcript) int {
if transcript == nil || len(transcript.Segments) == 0 {
return 0
}
estimator := chunking.NewSimpleTokenEstimator()
total := 0
for _, segment := range transcript.Segments {
total += estimator.EstimateTokens(segment.Text)
}
return total
}
func transcriptFromSection(section chunking.Section) *schema.Transcript {
segments := make([]schema.Segment, len(section.Segments))
copy(segments, section.Segments)