aarondb/storage/mnesia

storage/mnesia — recovery-oriented Mnesia StorageAdapter

Thin Gleam wrapper over the aarondb_mnesia_ffi Erlang FFI: creates a disc-copy datoms schema and persists/recovers datoms transactionally. Initialization never rewrites an existing incompatible schema: it reports a descriptive Error and leaves persisted data untouched. Back up and migrate explicitly—or intentionally reset the table—before retrying. STATUS: Supported for one local BEAM node’s recovery path only. init_mnesia and reads/writes return explicit errors, including startup, schema-mismatch, and aborted-transaction failures; they never reset an incompatible table. Test isolation: run the suite with a disposable Mnesia directory, e.g. ERL_FLAGS="-mnesia dir <temporary-directory>" gleam test. The adapter owns no schema migration or cleanup operation: existing data is never reset. Concurrent initialization re-checks the existing table schema. This adapter does not provide multi-node durability, HA, schema migration, concurrent-writer performance guarantee. See ADR 0002.

Values

pub fn adapter() -> storage.StorageAdapter
pub fn init_mnesia() -> Result(Nil, String)
pub fn persist_batch(
  datoms: List(fact.Datom),
) -> Result(Nil, String)
pub fn persist_datom(datom: fact.Datom) -> Result(Nil, String)
pub fn recover_datoms() -> Result(List(fact.Datom), String)
Search Document