Skip to main content

Module lossless_collapse

Module lossless_collapse 

Source
Expand description

Strictly lossless repeat collapse for the governor’s R2 rule (governor design v1 §2 R2).

A run of at least MIN_RUN byte-identical consecutive lines becomes the line once plus a marker line [×N identical lines], where N counts the whole run. Nothing else changes: no timestamp stripping, no blank-line removal, no truncation, no reordering, no \r progress folding (folding progress rewrites drops bytes, so it is not lossless and is left out).

expand inverts collapse exactly. To keep the marker unambiguous, collapse refuses input that already contains a marker-shaped line or the header line; the caller then keeps the original. This is deliberately not log_dedup::compress, which is lossy and stays as it is for ctx_shell.

Structs§

Collapsed
The collapse result: the rendered text and how many lines it removed.

Constants§

HEADER_PREFIX
First line of a collapsed text, so the model knows the marker semantics.
MIN_RUN
Shortest run of identical lines that is collapsed.

Functions§

collapse
Collapse runs of identical lines. None when nothing collapses or the input carries a reserved line (the result would not invert exactly).
expand
Exact inverse of collapse. Text without the header is returned as is.