2.7 KiB
2.7 KiB
Stage: trim
Purpose
Optionally trim the final transcript to session bounds; always produce a durable final-trimmed transcript.
Inputs and Outputs
Inputs:
transcripts/final.json
Outputs:
transcripts/final.trimmed.json(or configured trim output path)- when trim enabled:
artifacts/session_bounds.json
Boundaries
Owns:
- Trim-enabled switch behavior
- Bounds generation via Scriptorium artifact run
- Bounds validation against final transcript
- Keep-selector derivation and Seriatim trim invocation
- Copy-through behavior when disabled or bounds indicate unchanged transcript
Does not own:
- Upstream normalization
- Downstream artifact analysis
Config Fields Used
session.session_idsession.campaignpipeline.workspace.rootpipeline.trim.enabledpipeline.trim.output_pathpipeline.trim.bounds.prompt_idpipeline.trim.bounds.profile_idpipeline.trim.bounds.timeoutpipeline.trim.bounds.output_pathpipeline.trim.bounds.transcript_input_namepipeline.trim.bounds.render_debugpipeline.trim.bounds.render_output_pathpipeline.seriatim.binarypipeline.seriatim.timeoutpipeline.scriptorium.binarypipeline.scriptorium.config_pathpipeline.scriptorium.timeout
External Adapters Used
- Scriptorium adapter:
- optional
RenderArtifactfor bounds debug render RunArtifactfor bounds output
- optional
- Seriatim adapter:
Trimwhen bounds indicate trimming is required
State and Manifest Behavior
- Reads final transcript from normalize manifest outputs when available; falls back to canonical path.
- Uses run-local outputs/logs/reports/config/scratch paths when run layout is enabled.
- Promotes canonical final-trimmed transcript; promotes session bounds when trim enabled.
- Records bounds diagnostics, trim action, keep selector, and adapter metadata.
Skip and Resume Behavior
- Runner-level skip applies when already succeeded and not forced.
- Forced reruns can stale downstream succeeded stages.
- When
trim.enabled=false, stage still succeeds by copying final to final-trimmed output.
Failure Behavior
- Fails on missing/invalid final transcript.
- With trim enabled, fails on missing adapters/config, bounds generation/validation errors, invalid bounds JSON, invalid range/segment ids, trim adapter failures, or invalid final-trimmed output.
Tests to Inspect Before Changing
internal/stage/trim_test.gointernal/adapters/scriptorium/subprocess_test.gointernal/adapters/seriatim/subprocess_test.go
Architectural Invariants
- Trim never falls back to polished transcript; final transcript is required input.
session_boundsoutput exists only for enabled trim path.- Render-debug artifacts are diagnostics and not declared stage outputs.