Files
narratio/docs/internal/stage-trim.md

2.4 KiB

Stage: trim

Purpose

Produce a final-trimmed transcript. By default, the stage generates bounds and applies a bounds-driven trim.

Inputs

  • transcripts/final.json

Outputs

  • transcripts/final.trimmed.json (or configured trim output path)
  • when trim enabled: artifacts/session_bounds.json

Key Behavior

When trim.enabled=true:

  • shares the effective prompt context with early requirements inspection;
  • 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.

When trim.enabled=false:

  • copies normalized transcript to trimmed output.

Invariants

  • normalized transcript is required input.
  • bounds output exists only in enabled trim path.
  • render-debug output is diagnostic and not a declared stage output.
  • prepared preview and generated bounds use separate result destinations; Scriptorium stderr and invocation records are the diagnostic references.

The application checks projected bounds requirements before attempting any stage. See preflight internals; actual transcript resolution and bounds validation remain responsibilities of this stage.

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.

  • Scriptorium owns bounds generation and debug-render subprocess behavior.
  • Seriatim owns transcript trimming behavior.
  • Configuration owns trim fields and defaults.
  • Implementation and tests: internal/stage/trim.go, internal/stage/trim_test.go, internal/stage/semantic_contracts_refinement.go