Compress sealed ledger segments during manual compaction
Follow-on to #217 (ledger search CLI): sealed history can remain searchable
while using less disk. At 66e26c85, manual compaction rotates the active
ledger into a plain sealed segment; readers already accept legacy gzip
segments.
This request is limited to gzip output for sealed segments created by a manual
cccc ledger compact / ledger_compact call. Gzip becomes the default for
future manual compactions. A group setting, ledger_segment_codec, accepts
exactly gzip or none; none preserves plain output. A null patch removes
the setting and restores the gzip default. Any other present value or type is
rejected at settings update and at compaction rather than silently defaulting.
The writer seals the plain file first, writes and fsyncs a gzip candidate, decodes it, and compares the decoded SHA-256 and line count with the plain segment before publishing it. It fsyncs the segment directory before removing the plain representation. If compression or verification fails, the plain segment remains authoritative. The manifest records the codec and keeps the existing compressed flag for older readers; readers still select one logical source when both plain and gzip exist.
Search behavior is unchanged. The test suite covers public ledger_search
filters and before/after cursors over history that exists only in a gzip
segment, using the retained real redacted fixture. It also covers default-gzip
follower rotation and the existing group-copy decoded-size and trailing-member
limits. No crash-step test is added; the existing corrupt-candidate hook is
retained only for gzip verification fallback.
This does not request automatic compaction, a byte-threshold trigger, event
trimming, retention or expiration policy, zstd support, or decoder plugins.
Those are separate designs. Selecting none affects future manual compaction
output only and does not rewrite existing gzip archives.
External tools that read sealed segment bytes directly must follow the
manifest codec or the .gz suffix; they cannot assume sealed bytes are plain
JSONL. The publication checks are not claimed as a complete crash or
power-loss proof.
Closing this alongside #223, following the reply there. Thank you for considering it.