Keep transcript decoding and encoding on typed data

This commit is contained in:
2026-11-16 03:56:54 +00:00
parent b63c8af467
commit f465496dd8
19 changed files with 286 additions and 386 deletions

View File

@@ -80,7 +80,7 @@ func TestMaintainedProjectsWithControlledProvider(t *testing.T) {
t.Fatal(err)
}
defer prepared.Prepared.Output.Close()
if _, err := executePipeline(context.Background(), inputs, prepared, sourceToCanonicalTranscript(source), func(error) {}); err != nil {
if _, err := executePipeline(context.Background(), inputs, prepared, source.Canonical(), func(error) {}); err != nil {
t.Fatal(err)
}
if int(calls.Load()) != len(loaded.Config.Pipeline.Stages) {

View File

@@ -52,12 +52,15 @@ func runProcess(inv commandkit.Invocation, input processInput) commandkit.Outcom
if debug != nil {
warn(debug.WriteSourceTranscript(loaded.Source, loaded.RawTranscript))
}
loaded.RawTranscript = nil
cfg := &loaded.Configuration.Config
normalizer := normalization.NewNormalizer(normalization.NormalizationConfig{
MaxSegmentGap: cfg.Normalization.MaxSegmentGap, EllipsisGap: cfg.Normalization.EllipsisGap,
MaxSegmentDuration: cfg.Normalization.MaxSegmentDuration, MaxSegmentTokens: cfg.Normalization.MaxSegmentTokens,
})
normalized, summary := normalizer.Normalize(sourceToCanonicalTranscript(loaded.Source))
transcript := loaded.Source.Canonical()
loaded.Source = nil
normalized, summary := normalizer.Normalize(transcript)
if debug != nil {
warn(debug.WriteNormalizedTranscript(normalized))
warn(debug.WriteNormalizationSummary(summary))

View File

@@ -58,6 +58,9 @@ func loadProcessInputs(ctx context.Context, input processInput, mode commandkit.
if err != nil {
return nil, err
}
if !input.Debug.Value {
raw = nil
}
protected := append([]string(nil), runtime.SourcePaths...)
for _, entry := range loaded.Sources() {
if entry.Kind == ck.SourceKindFile && entry.Path != "" {

View File

@@ -122,7 +122,7 @@ pipeline:
t.Fatal(err)
}
defer prepared.Prepared.Output.Close()
result, err := executePipeline(context.Background(), inputs, prepared, sourceToCanonicalTranscript(source), func(error) {})
result, err := executePipeline(context.Background(), inputs, prepared, source.Canonical(), func(error) {})
if err != nil {
t.Fatal(err)
}
@@ -194,7 +194,7 @@ func TestRecoverableModelFailureKeepsNormalizedTranscript(t *testing.T) {
t.Fatal(err)
}
defer prepared.Prepared.Output.Close()
result, err := executePipeline(context.Background(), inputs, prepared, sourceToCanonicalTranscript(source), func(error) {})
result, err := executePipeline(context.Background(), inputs, prepared, source.Canonical(), func(error) {})
if err != nil {
t.Fatal(err)
}

View File

@@ -156,7 +156,7 @@ func TestCanceledEmptyPipelineLeavesTranscriptAndFinalizesReports(t *testing.T)
t.Fatal(err)
}
defer prepared.Prepared.Output.Close()
result, err := executePipeline(inv.Context, loaded, prepared, sourceToCanonicalTranscript(loaded.Source), func(error) {})
result, err := executePipeline(inv.Context, loaded, prepared, loaded.Source.Canonical(), func(error) {})
if err != nil {
t.Fatal(err)
}

View File

@@ -5,29 +5,9 @@ import (
"fmt"
"io"
"gitea.maximumdirect.net/eric/audita/v3/internal/core/schema"
commandkit "go.maximumdirect.net/commandkit"
)
func sourceToCanonicalTranscript(source *schema.SourceTranscript) *schema.Transcript {
segments := make([]schema.Segment, len(source.Segments))
for i, s := range source.Segments {
id := i + 1
if s.ID != nil {
id = *s.ID
}
segments[i] = schema.Segment{
ID: id,
Speaker: s.Speaker,
Start: s.Start,
End: s.End,
Text: s.Text,
Categories: s.Categories,
}
}
return &schema.Transcript{Segments: segments}
}
// Run executes the application with the provided arguments and streams.
func Run(ctx context.Context, args []string, stdout, stderr io.Writer) int {
app, err := buildApplication()