Reintroduce normalize stage scaffold

This commit is contained in:
2026-05-10 21:26:53 +00:00
parent 7d61901585
commit 86d2dfa6c5
12 changed files with 272 additions and 94 deletions

View File

@@ -23,7 +23,7 @@ func (trimStage) Name() string { return "trim" }
func (trimStage) Declares() IODecl {
return IODecl{
Inputs: []artifacts.Ref{
{Kind: "transcript_processed", Category: "transcripts", RelativePath: "transcripts/processed.json"},
{Kind: "transcript_normalized", Category: "transcripts", RelativePath: "transcripts/normalized.json"},
},
Outputs: []artifacts.Ref{
{Kind: "transcript_trimmed", Category: "transcripts", RelativePath: "transcripts/trimmed.json"},
@@ -55,15 +55,15 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
}
paths := env.ArtifactStore.SessionPaths(sessionID)
processedPath, processedSource, err := discoverProcessedTranscript(m, paths)
normalizedPath, normalizedSource, err := discoverNormalizedTranscript(m, paths)
if err != nil {
return nil, fmt.Errorf("trim: resolve processed transcript: %w", err)
return nil, fmt.Errorf("trim: resolve normalized transcript: %w", err)
}
if processedPath == "" {
return nil, fmt.Errorf("trim: processed transcript input is required")
if normalizedPath == "" {
return nil, fmt.Errorf("trim: normalized transcript input is required")
}
if err := validateProcessedTranscriptOutput(processedPath); err != nil {
return nil, fmt.Errorf("trim: processed transcript %q invalid: %w", processedPath, err)
if err := validateProcessedTranscriptOutput(normalizedPath); err != nil {
return nil, fmt.Errorf("trim: normalized transcript %q invalid: %w", normalizedPath, err)
}
trimCfg := env.Config.Pipeline.Trim
@@ -77,16 +77,16 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
logPaths := []string{}
generatedConfigs := []string{}
metadata := map[string]any{
"stage": "trim",
"trim_enabled": enabled,
"processed_transcript_path": processedPath,
"processed_transcript_source": processedSource,
"trimmed_output_path": trimmedPath,
"stage": "trim",
"trim_enabled": enabled,
"normalized_transcript_path": normalizedPath,
"normalized_transcript_source": normalizedSource,
"trimmed_output_path": trimmedPath,
}
if !enabled {
if err := copyTranscript(env.ArtifactStore, processedPath, trimmedPath); err != nil {
return nil, fmt.Errorf("trim: copy processed transcript to trimmed output: %w", err)
if err := copyTranscript(env.ArtifactStore, normalizedPath, trimmedPath); err != nil {
return nil, fmt.Errorf("trim: copy normalized transcript to trimmed output: %w", err)
}
if err := validateProcessedTranscriptOutput(trimmedPath); err != nil {
return nil, fmt.Errorf("trim: copied trimmed transcript %q invalid: %w", trimmedPath, err)
@@ -127,7 +127,7 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
}
inputPaths := map[string]string{
boundsCfg.TranscriptInputName: processedPath,
boundsCfg.TranscriptInputName: normalizedPath,
}
vars := map[string]string{}
@@ -136,7 +136,7 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
metadata["bounds_output_path"] = boundsOutputPath
metadata["bounds_timeout"] = boundsTimeout.String()
metadata["bounds_input_name"] = boundsCfg.TranscriptInputName
metadata["bounds_input_path"] = processedPath
metadata["bounds_input_path"] = normalizedPath
metadata["bounds_render_debug_enabled"] = boundsCfg.RenderDebug
renderOutputPath := ""
@@ -233,8 +233,8 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
if err != nil {
return nil, fmt.Errorf("trim: parse bounds output %q: %w", finalBoundsOutputPath, err)
}
if err := contracts.ValidateSessionBoundsAgainstTranscript(boundsPayload, processedPath); err != nil {
return nil, fmt.Errorf("trim: validate bounds output %q against transcript %q: %w", finalBoundsOutputPath, processedPath, err)
if err := contracts.ValidateSessionBoundsAgainstTranscript(boundsPayload, normalizedPath); err != nil {
return nil, fmt.Errorf("trim: validate bounds output %q against transcript %q: %w", finalBoundsOutputPath, normalizedPath, err)
}
keepSelector, copyUnchanged, err := contracts.BuildSeriatimKeepSelector(boundsPayload)
@@ -272,8 +272,8 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
}
if copyUnchanged {
if err := copyTranscript(env.ArtifactStore, processedPath, trimmedPath); err != nil {
return nil, fmt.Errorf("trim: copy processed transcript to trimmed output: %w", err)
if err := copyTranscript(env.ArtifactStore, normalizedPath, trimmedPath); err != nil {
return nil, fmt.Errorf("trim: copy normalized transcript to trimmed output: %w", err)
}
} else {
trimStdoutLogPath := filepath.Join(paths.LogsDir, "seriatim.trim.stdout.log")
@@ -285,7 +285,7 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
}
trimReq := seriatim.TrimRequest{
Binary: env.Config.Pipeline.Seriatim.Binary,
InputTranscriptPath: processedPath,
InputTranscriptPath: normalizedPath,
OutputTrimmedPath: trimmedPath,
KeepSelector: keepSelector,
StdoutLogPath: trimStdoutLogPath,