Skip to main content

Module compact

Module compact 

Source
Expand description

The compact form of a conversation’s transcript lines (SPEC_HISTORY_COMPACT_FORM_ONLY_2026_11_23.md section 2).

The compact form is the store’s existing line format minus the streaming fragments, and it is lossless: every other line is kept byte for byte. The only lines this module ever drops are stream_event lines of a message whose complete assistant lines hold every block those fragments reassemble to. A reply that was cut off has fragments and no complete line; its fragments are reassembled into one assistant line marked interrupted, with the text and tool input received so far, so nothing a person could see is lost.

  • Keep by default. DROP_RULES names what may be dropped; a line kind it does not name is kept. A new CLI line kind is never lost by an omission. A stream event this module cannot prove (an unknown block or delta kind, a message it never saw start, a fragment that differs from the complete line) is kept as it is and counted, never guessed at.
  • Replay lines stay. A stored isReplay line is either the echo of a turn srv wrote (dropped before it is stored, in stdout_reader, with the ledger only the write path has) or a frame of the CLI’s own, such as a local command’s output, which must stay. Nothing in a stored line tells the two apart, so the compact form keeps every one.
  • Pure. No I/O and no clock: lines in, a Plan out. verify re-checks a result against its input with its own, separate reassembly (checks L1 to L3 of the spec), and no_fragments is check L4. Nothing calls this module yet.

Structs§

Before
What LiveReply::before says of the line it took.
DropRule
A line kind the compact form may drop, and what it needs first.
LiveReply
The write path’s view of one agent’s reply as it streams: fragments are held in output.live, and this tells when they have become redundant (every block is in a complete line and the message has stopped), and what must go to output instead when a turn ends without that.
Plan
The result of planning one window of lines.
Stats
Counts of what a plan did, for the migration’s report. No content.
Synth
A line written in place of fragments: the reassembled interrupted reply.

Enums§

Action
What to do with one input line.
CheckFailure
Which check failed, with counts and positions only (never line content).
Emit
A line the write path appends to output in place of fragments it held back.
Requires
What a drop rule needs before it may drop a line.
WindowEnd
Whether a window of lines ends the zone’s stream, or is only a slice of it.

Constants§

DROP_RULES
The whole list of what may be dropped. Anything not named here is kept.

Functions§

compact_lines
The compact lines of a window, with the plan that made them.
is_turn_boundary
Whether a stored line is a turn boundary (a result, or a session init), as the planner reads it.
last_quiet_line
The last line after which no reply is in flight: every message that has a fragment by then has its complete line and its closing fragments, was taken over by a newer message on its stream, or a turn boundary closed it. A window cut there splits no message between two windows. It is the cut for a stretch so long that no turn boundary comes within the window limit. None when no line qualifies.
no_fragments
Check L4: no stream_event line remains. A file that still has one is not declared compact. Returns how many remain.
plan_window
Plan one window of lines (each one JSON line, without its newline). end says whether more lines follow.
recover_live
What a start finds in output.live, left by a process that was killed mid-reply: tail is the last complete lines of output (their assistant lines say which blocks are already stored), live the held fragments. Returns what must be appended to output before output.live is emptied.
verify
Checks L1 to L3 of the spec: new is a correct compact form of old. Written apart from plan_window: its own reassembly, so a fault in one does not pass the other.