Skip to main content

Module summarize

Module summarize 

Source
Expand description

TR-7 (T20): the injectable side-call that turns an A10 TurnsCleared span into a short LLM-written summary paragraph, instead of leaving it as the deterministic [turns cleared] stub — “what incumbents’ compaction writes, but with the original retained in the sidecar” (TR-7.md).

Purity boundary. super::project_messages must stay pure and I/O-free (its own doc comment: “nothing here touches the filesystem”). Exactly like A8’s disk probe (super::probe_read_freshness), the one side-call this feature ever makes lives OUTSIDE projection, in super::prepare_cleared_turns_summary — called by the driving caller (Agent::build_request_messages, or a test) BEFORE project/project_messages ever runs, with the result threaded through super::ReductionPolicy::cleared_turns_summary (data, not a config knob — mirrors super::ReductionPolicy::read_freshness).

Never blocks, never fails the pass. SpanSummarizer::summarize returning Err (a real implementation’s way of modeling a timeout, a provider error, a budget exhaustion — whatever the caller wants) simply means super::prepare_cleared_turns_summary returns None, and project_messages falls back to the byte-identical deterministic stub — SPEC.md TR-7 dev/03.

Off by default. super::ReductionPolicy::summarize_cleared_turns defaults to false; with it off, project_messages never even looks at super::ReductionPolicy::cleared_turns_summary, so the A10 stub stays byte-identical to pre-TR-7 behavior (dev/01) regardless of what a caller did or didn’t precompute.

Constants§

PROMPT_VERSION
The fixed, in-repo, VERSIONED summarization prompt template (SPEC.md TR-7: “summarization prompt is fixed and versioned in-repo”). Bump this any time render_prompt’s wording changes — the version rides the audit trail (super::SpanSummary::prompt_version) precisely so a later reader can tell which wording produced a given summary.

Traits§

SpanSummarizer
Injectable summarization side-call (SPEC.md TR-7’s “explicit, budgeted, injectable side-call”). A real implementation calls out to a cheap model; tests inject a deterministic fake (and, for the dev/03 fault-injection AC, one that always errors) — nothing in this crate’s own test suite ever performs a real network/model call.

Functions§

render_prompt
Render the fixed prompt for summarizing one cleared span’s rendered text (see render_span_text). Exposed so a real SpanSummarizer implementation (elsewhere — never in this crate’s test-only code) sends exactly the wording PROMPT_VERSION names.