Skip to main content

write_compression_event

Function write_compression_event 

Source
pub fn write_compression_event(data_dir: &Path, event: &CompressionEvent)
Expand description

Append event as one JSONL line to <data_dir>/compression.jsonl.

Why: emission must never fail the compaction/cadence operation it instruments — this is observability, not control flow. What: best-effort mkdir -p of data_dir, then opens the file in create + append mode and writes one serde_json::to_string(event) line followed by \n, flushing so the bytes are visible to a concurrent reader. Any I/O or serialization failure logs at debug! and returns — mirrors trusty-agents::usage::append_usage’s failure posture exactly (issue #3867 acceptance criteria: “a broken/unwritable log directory must not fail the compression/summarization operation itself”). Test: tests::write_compression_event_creates_and_appends, tests::write_compression_event_unwritable_dir_does_not_panic.