Expand description
Lattice-based log compaction for the bones event log.
Over time the event log grows. Compaction replaces event sequences for
completed items with a single item.snapshot event — the semilattice join
of all events for that item. Compaction is coordination-free: each replica
compacts independently and converges to identical state.
§Snapshot Semantics
Snapshots are lattice elements, not regular updates.
- For every LWW field the snapshot carries the winning
(stamp, wall_ts, agent_id, event_hash, value)tuple — not just the value. - For OR-Sets and G-Sets the snapshot carries the full set state.
- Applying a snapshot uses
merge(state, snapshot_state)— a field-wise lattice join, not “overwrite with snapshot clock”.
This is critical: if a snapshot used a single event clock for all fields, it would incorrectly dominate concurrent events that were not observed at compaction time, violating semantic preservation.
§Redaction Interaction
Snapshots check the redaction set before including field values. Compaction must never reintroduce redacted content.
§Audit Metadata
Each snapshot carries _compacted_from (count of original events),
_earliest_ts, and _latest_ts timestamps for audit trail.
Structs§
- Compaction
Policy - Configuration for the compaction policy.
- Compaction
Report - Report from compacting eligible items.
- LwwSnapshot
- Serializable representation of a single LWW register with its clock.
- Snapshot
Payload - Full snapshot payload encoding every CRDT field with its clock metadata.
Functions§
- compact_
item - Compact all events for a single item into one
item.snapshotevent. - compact_
items - Compact eligible items from a collection of events grouped by item ID.
- extract_
snapshot_ payload - Extract and deserialize the
SnapshotPayloadfrom anitem.snapshotevent. - is_
eligible - Check if a work item is eligible for compaction.
- verify_
compaction - Verify that compacted state matches uncompacted state.
- verify_
lattice_ join - Verify lattice join property: merge(original, snapshot) == original.