2026-05-18 22:03:59 -05:00
|
|
|
# Stage: trim
|
|
|
|
|
|
|
|
|
|
## Purpose
|
2026-08-09 21:50:21 +00:00
|
|
|
|
|
|
|
|
Produce a final-trimmed transcript. By default, the stage generates bounds and
|
|
|
|
|
applies a bounds-driven trim.
|
2026-05-18 22:03:59 -05:00
|
|
|
|
2026-05-23 12:57:59 +00:00
|
|
|
## Inputs
|
2026-08-09 21:50:21 +00:00
|
|
|
|
2026-05-22 19:05:23 -05:00
|
|
|
- `transcripts/final.json`
|
2026-05-18 22:03:59 -05:00
|
|
|
|
2026-05-23 12:57:59 +00:00
|
|
|
## Outputs
|
2026-08-09 21:50:21 +00:00
|
|
|
|
2026-05-22 19:05:23 -05:00
|
|
|
- `transcripts/final.trimmed.json` (or configured trim output path)
|
2026-05-18 22:03:59 -05:00
|
|
|
- when trim enabled: `artifacts/session_bounds.json`
|
|
|
|
|
|
2026-05-23 12:57:59 +00:00
|
|
|
## Key Behavior
|
2026-08-09 21:50:21 +00:00
|
|
|
|
2026-05-23 12:57:59 +00:00
|
|
|
When `trim.enabled=true`:
|
|
|
|
|
- runs Scriptorium bounds artifact generation;
|
|
|
|
|
- optionally runs render-debug output generation;
|
|
|
|
|
- validates bounds payload against transcript;
|
|
|
|
|
- derives keep selector;
|
|
|
|
|
- either copies unchanged transcript or runs Seriatim trim;
|
|
|
|
|
- validates trimmed transcript and materializes bounds output.
|
|
|
|
|
|
2026-05-27 08:35:02 -05:00
|
|
|
When `trim.enabled=false`:
|
|
|
|
|
- copies normalized transcript to trimmed output.
|
|
|
|
|
|
2026-05-23 12:57:59 +00:00
|
|
|
## Invariants
|
2026-08-09 21:50:21 +00:00
|
|
|
|
2026-05-23 12:57:59 +00:00
|
|
|
- normalized transcript is required input.
|
|
|
|
|
- bounds output exists only in enabled trim path.
|
|
|
|
|
- render-debug output is diagnostic and not a declared stage output.
|
2026-08-09 21:50:21 +00:00
|
|
|
|
2026-08-30 13:03:13 +00:00
|
|
|
## Resume Semantics
|
|
|
|
|
|
|
|
|
|
The versioned semantic fingerprint covers enablement, the bounds prompt and
|
|
|
|
|
profile identifiers, the Scriptorium configuration identity, transcript input
|
|
|
|
|
name, sticky session variable, bounds and trimmed output identities, and the
|
|
|
|
|
Seriatim trim operation. Diagnostic bounds rendering, diagnostic output paths,
|
|
|
|
|
timeouts, executable paths, and optional reports are operational and do not
|
|
|
|
|
invalidate the canonical trimmed transcript.
|
|
|
|
|
|
|
|
|
|
Narratio cannot inspect prompt, profile, or configuration content that
|
|
|
|
|
Scriptorium or Seriatim privately resolves behind a stable identifier. Force
|
|
|
|
|
`trim` after changing such private content without changing its identifier.
|
|
|
|
|
|
2026-08-09 21:50:21 +00:00
|
|
|
## Related Contracts And Tests
|
|
|
|
|
|
|
|
|
|
- [Scriptorium](../integrations/scriptorium.md) owns bounds generation and
|
|
|
|
|
debug-render subprocess behavior.
|
|
|
|
|
- [Seriatim](../integrations/seriatim.md) owns transcript trimming behavior.
|
|
|
|
|
- [Configuration](../config.md#pipeline) owns trim fields and defaults.
|
|
|
|
|
- Implementation and tests: `internal/stage/trim.go`,
|
2026-08-30 13:03:13 +00:00
|
|
|
`internal/stage/trim_test.go`,
|
|
|
|
|
`internal/stage/semantic_contracts_refinement.go`
|