Expand description
memnite-core: event-sourced foundation (event log + replay).
Structs§
- Anchor
- Conflict
- A cross-writer lost-field conflict: a value some writer set for
fieldofmemory_iddid not survive into the projected winner (it lost to a different writer). Heuristic — lamport is a total order, not causal — so this can over-report a deliberately-superseded edit. Advisory; never blocks. - Event
- Log
- Append-only NDJSON event log. The single source of truth.
- Memory
- Memory
Data - Memory
Patch - Sparse update: only the fields the writer actually touched are
Some. Presence is the “touched” signal — untouched fields areNoneand skipped on the wire. Enables field-level LWW merge (a whole-snapshot update cannot distinguish “cleared” from “carried a stale copy”).topic_keycannot be cleared via a patch (matchesApp::update);Somesets it, absent leaves it. - Relation
Edge - A projected relation edge (directed, from → to). Reconstructed from the log.
Enums§
Functions§
- apply
- Apply a single event to a state map, in place. This is the per-event fold
step used by
replay; exposed so an incremental projection (e.g. a SQLite store) shares the exact same semantics as a full rebuild. - detect_
conflicts - Detect cross-writer lost-field conflicts across the event log. Pure, total,
deterministic (memory_ids sorted; fields in fixed order). Skips memories with
a terminal
MemoryDeleted. - new_
event_ id - Generate a fresh, monotonic, sortable event id (ULID, 26 chars). This is the only non-deterministic call in the crate; keep it out of fold.
- next_
lamport - Next logical-clock value: one past the highest lamport seen. Empty stream starts at 1.
- replay
- Fold an event stream into current memory state. Deterministic: events are sorted by (lamport, event_id) before applying.
- replay_
relations - Fold
RelationAssertedevents into the current relation graph. Deterministic: last-writer-by-(lamport, event_id)per ordered(from_id, to_id)pair. A winningNotConflictassertion removes the edge (retraction) — it is absent from the map. Non-relation events are ignored.