Expand description
SqlitePersistenceStore — impl of PersistencePort for mempill-sqlite.
§Append-only
Every write method is an INSERT. No UPDATE or DELETE paths exist in this file. Attempts to update or delete data must be rejected at the application layer.
§Atomic commit unit
The store does NOT manage transaction lifecycle — the application use-case does.
begin_atomic moves the connection into a SqliteTxn; commit and rollback return
it. This guarantees that {claim + validity assertion + ledger entry + edge} land in one
SQLite transaction or not at all.
§Single-writer per agent_id
v0.1 is single-process embedded. The AgentWriteLockMap in mempill-core coordinates
per-agent_id writes at the async boundary. The store is structurally read-safe because
reads do not acquire any lock, and writes are serialised by the application layer.
§Connection ownership model
The store owns Box<Connection> inside a std::cell::Cell-like hand-off: begin_atomic
takes it out; commit/rollback put it back. We use Arc<Mutex<Option<Box<Connection>>>>
so the store is Send + Sync and can be shared across spawn_blocking calls.
The Option is always Some except during the window between begin_atomic and
commit/rollback. Calling begin_atomic while a txn is already open returns an error.
Structs§
- Sqlite
Pending Store - SQLite-backed
PendingAdjudicationPortimplementation. - Sqlite
Persistence Store - The SQLite-backed implementation of
PersistencePort.