Skip to main content

Module writer

Module writer 

Source
Expand description

TSJSON event writer/serializer.

Serializes Event structs to TSJSON (tab-separated) lines. Guarantees:

  • Canonical JSON payload (keys sorted, compact, no whitespace).
  • One-line invariant: no literal \n in the serialized JSON.
  • Deterministic: same event always produces the same output bytes.
  • Event hash is BLAKE3 of fields 1–7 joined by tabs, newline-terminated.

§TSJSON Format

{wall_ts_us}\t{agent}\t{itc}\t{parents}\t{type}\t{item_id}\t{data_json}\t{event_hash}\n

Enums§

WriteError
Errors that can occur during event writing.

Constants§

FIELD_COMMENT
The field-description comment line written after the shard header.
SHARD_HEADER
The shard header line written at the start of new event log files.

Functions§

compute_event_hash
Compute the BLAKE3 event hash from fields 1–7 of an Event.
shard_header
Return the shard header block (header + field comment) for a new event file.
to_tsjson_line
Serialize an Event to a single TSJSON line (without trailing newline).
write_event
Compute the event hash and set it on a mutable Event, then serialize.
write_line
Serialize an Event to a TSJSON line with trailing newline.