Skip to main content

Crate memnite_core

Crate memnite_core 

Source
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 field of memory_id did 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
MemoryData
MemoryPatch
Sparse update: only the fields the writer actually touched are Some. Presence is the “touched” signal — untouched fields are None and skipped on the wire. Enables field-level LWW merge (a whole-snapshot update cannot distinguish “cleared” from “carried a stale copy”). topic_key cannot be cleared via a patch (matches App::update); Some sets it, absent leaves it.
RelationEdge
A projected relation edge (directed, from → to). Reconstructed from the log.

Enums§

CoreError
EventKind
Relation
Scope
StaleReason
Status

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 RelationAsserted events into the current relation graph. Deterministic: last-writer-by-(lamport, event_id) per ordered (from_id, to_id) pair. A winning NotConflict assertion removes the edge (retraction) — it is absent from the map. Non-relation events are ignored.