Skip to main content

Module compact

Module compact 

Source
Expand description

The stepped compaction engine: what the view says about the aged prefix, and who writes it.

Compaction is stepped, not rolling. The log’s aged prefix is covered by sections — ranges tiling [0, cut) without gaps, each carrying one dense text. Between flushes nothing left of the cut changes: the block is append-only, so the request prefix (system prompt, then block, then whole band) is stable for long stretches and a prompt cache holds it. A flush moves the cut only when the budget is actually breached, and overshoots to half the allowance, so the next break is a whole hysteresis of growth away — never the next step.

Two writers fill a section’s text. The extractive fill is the mechanical digest — a few hundred bytes, cannot be wrong about what happened, only short; it is the fallback and the default. The model fill is a Summarizer: a cheap worker call that rewrites the same range densely. A worker failure never blocks the request — the extractive digest stands in and the section keeps the address it already committed.

Sections are ranges of the log, so crate::zoom reaches every original through them; compaction deletes nothing and the durable session is untouched.

Structs§

ModelSummarizer
The model fill over any ModelProvider: the range goes to the worker as one rendered transcript, the answer comes back capped at SUMMARY_MAX_BYTES. Retryable provider errors are retried ModelSummarizer::attempts times; anything else fails straight to the extractive stand-in.
PendingSummary
A section the plan committed with its extractive stand-in, waiting for a Summarizer to upgrade. The handoff carries the range’s messages by value: history is immutable, so the worker reads a snapshot and the mirror lock is never held across the call.
Section
One committed piece of the block: the log range it covers and the text standing in for it. Sections tile their span of the log without gaps or overlap, and once committed a section never moves or changes range — the block only grows by appending.

Enums§

SectionOrigin
How the text of a section came to be.

Constants§

SUMMARY_MAX_BYTES
Bytes a model-written section text is kept at: a longer worker answer is cut on a char boundary with an ellipsis. A summary that cannot say it in 8 KiB is not a summary.

Traits§

Summarizer
The model fill: writes one section’s dense text from its messages. Implementations must be callable from any task and must not retain the messages beyond the call.