Verify the integrated resilient processing contract

This commit is contained in:
2026-09-24 18:03:25 +00:00
parent a770c77a23
commit 6523d7ac74
5 changed files with 242 additions and 33 deletions

View File

@@ -279,7 +279,10 @@ func TestRunnerKeepsSectionMembershipAfterTextGrowth(t *testing.T) {
cfg.Chunking.MaxSectionTokens = 3
cfg.Chunking.MinSectionTokens = 0
transcript := &schema.Transcript{Segments: []schema.Segment{
{ID: 1, Text: "a"}, {ID: 2, Text: "b"}, {ID: 3, Text: "c"}, {ID: 4, Text: "d"},
{ID: 1, Speaker: "A", Start: 0, End: 1, Text: "a"},
{ID: 2, Speaker: "B", Start: 1, End: 2, Text: "b"},
{ID: 3, Speaker: "A", Start: 2, End: 3, Text: "c"},
{ID: 4, Speaker: "B", Start: 3, End: 4, Text: "d"},
}}
var mu sync.Mutex
seen := make(map[int][]int)
@@ -302,6 +305,9 @@ func TestRunnerKeepsSectionMembershipAfterTextGrowth(t *testing.T) {
if req.Section.Index == 0 && req.WorkingTranscript.Segments[0].Text != updatedText {
return nil, errors.New("later module did not see updated section text")
}
if req.Section.Index == 0 {
return []proposals.CorrectionProposal{{TargetSegmentID: 3, OriginalText: "c", CorrectedText: "C", Confidence: 1}}, nil
}
return nil, nil
}},
}})
@@ -315,9 +321,15 @@ func TestRunnerKeepsSectionMembershipAfterTextGrowth(t *testing.T) {
if len(seen) != 2 || len(seen[0]) != 2 || seen[0][0] != 1 || seen[0][1] != 2 || len(seen[1]) != 2 || seen[1][0] != 3 || seen[1][1] != 4 {
t.Fatalf("later module saw changed section membership: %+v", seen)
}
if len(out.FinalTranscript.Segments) != 4 || out.FinalTranscript.Segments[0].Text != updatedText || out.FinalTranscript.Segments[3].ID != 4 {
if len(out.FinalTranscript.Segments) != 4 || out.FinalTranscript.Segments[0].Text != updatedText || out.FinalTranscript.Segments[2].Text != "c" || out.FinalTranscript.Segments[3].ID != 4 {
t.Fatalf("recombined transcript: %+v", out.FinalTranscript)
}
for i, segment := range out.FinalTranscript.Segments {
original := transcript.Segments[i]
if segment.ID != original.ID || segment.Speaker != original.Speaker || segment.Start != original.Start || segment.End != original.End {
t.Fatalf("segment %d metadata changed: %+v", i, segment)
}
}
if out.WorkUnits[0].CorrectionsApplied != 1 || out.WorkUnits[1].CorrectionsApplied != 0 {
t.Fatalf("section application counts: %+v", out.WorkUnits)
}