Expand description
Time-sharded event file management.
Events are stored in monthly shard files under .bones/events/YYYY-MM.events.
This module manages the directory layout, shard rotation, atomic append
operations, and replay (reading all shards in chronological order).
§Directory Layout
.bones/
events/
2026-01.events # sealed shard
2026-01.manifest # manifest for sealed shard
2026-02.events # active shard
cache/
clock # monotonic wall-clock file (microseconds)
lock # repo-wide advisory lock§Invariants
- Sealed (frozen) shards are never modified after rotation.
- The active shard is the only one that receives appends.
- The active shard is derived from
list_shards().last()(sorted filenames). - Each append uses
O_APPEND+write_all+flushfor crash consistency. - Torn-write recovery truncates incomplete trailing lines on startup.
- Monotonic timestamps:
wall_ts_us = max(system_time_us, last + 1).
Structs§
- Shard
Integrity Issue - A shard integrity problem found during validation.
- Shard
Manager - Manages time-sharded event files in a
.bonesrepository. - Shard
Manifest - Manifest for a sealed shard file, recording integrity metadata.
Enums§
- Shard
Error - Errors that can occur during shard operations.
Functions§
- validate_
shard_ header - Validate that a shard file starts with the expected header line.