Use normalized transcript for trimming
This commit is contained in:
@@ -105,7 +105,7 @@ Trim behavior summary:
|
||||
- trim uses Scriptorium bounds (`dnd_session.bounds` by example config) to produce `artifacts/session_bounds.json`
|
||||
- bounds IDs are validated against the same normalized transcript ID space that Seriatim trim will consume
|
||||
- trim converts bounds to Seriatim keep selector (for example `10-868`) and runs Seriatim trim
|
||||
- if trim is disabled, Narratio copies processed transcript to trimmed transcript and records `trim_action=copy_disabled`
|
||||
- if trim is disabled, Narratio copies normalized transcript to trimmed transcript and records `trim_action=copy_disabled`
|
||||
|
||||
Trim outputs and diagnostics:
|
||||
|
||||
|
||||
@@ -204,8 +204,5 @@ func discoverNormalizedTranscript(m *manifest.Manifest, paths artifacts.SessionP
|
||||
if info, err := os.Stat(fallback); err == nil && !info.IsDir() {
|
||||
return filepath.Clean(fallback), "fallback.transcripts_dir", nil
|
||||
}
|
||||
if len(deduped) > 0 {
|
||||
return deduped[0], "manifest.normalize.outputs", nil
|
||||
}
|
||||
return "", "", nil
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
|
||||
return nil, fmt.Errorf("trim: resolve normalized transcript: %w", err)
|
||||
}
|
||||
if normalizedPath == "" {
|
||||
return nil, fmt.Errorf("trim: normalized transcript input is required")
|
||||
return nil, fmt.Errorf("trim: normalized transcript input is required; run normalize stage first")
|
||||
}
|
||||
if err := validateProcessedTranscriptOutput(normalizedPath); err != nil {
|
||||
return nil, fmt.Errorf("trim: normalized transcript %q invalid: %w", normalizedPath, err)
|
||||
|
||||
@@ -145,11 +145,31 @@ func TestTrimStageFailsWhenNormalizedTranscriptMissing(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Fatal("expected error, got nil")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "normalized transcript input is required") {
|
||||
if !strings.Contains(err.Error(), "normalized transcript input is required; run normalize stage first") {
|
||||
t.Fatalf("error = %q", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestTrimStageDoesNotFallBackToProcessedTranscript(t *testing.T) {
|
||||
env, m, scr, ser := setupTrimEnv(t)
|
||||
paths := env.ArtifactStore.SessionPaths(m.SessionID)
|
||||
writeFile(t, filepath.Join(paths.TranscriptsDir, "processed.json"), `{"segments":[{"id":1},{"id":2}]}`)
|
||||
|
||||
_, err := (trimStage{}).Run(context.Background(), env, m)
|
||||
if err == nil {
|
||||
t.Fatal("expected error, got nil")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "run normalize stage first") {
|
||||
t.Fatalf("error = %q", err.Error())
|
||||
}
|
||||
if len(scr.RunRequests) != 0 {
|
||||
t.Fatalf("scriptorium should not run without normalized transcript, got %d calls", len(scr.RunRequests))
|
||||
}
|
||||
if len(ser.TrimRequests) != 0 {
|
||||
t.Fatalf("seriatim trim should not run without normalized transcript, got %d calls", len(ser.TrimRequests))
|
||||
}
|
||||
}
|
||||
|
||||
func TestTrimStageFailsWhenNormalizedTranscriptInvalidJSON(t *testing.T) {
|
||||
env, m, _, _ := setupTrimEnv(t)
|
||||
paths := env.ArtifactStore.SessionPaths(m.SessionID)
|
||||
|
||||
Reference in New Issue
Block a user