backend
backend
¶
The files backend: journaled, custody-checked, capped scope-tree memory on disk.
On-disk layout (all under the files root, ~/.marianne/memory/files by default)::
<root>/<family>/<id>/*.md tier files (recent.md, growth.md, ...)
<root>/<family>/<id>/{displaced,archive,actions}/ prior tier versions, forgotten
facts, bind receipts
<root>/trees/<tree-key>/state.json the ledger (facts, tombstones, revision)
<root>/trees/<tree-key>/journal/NNNNNNNN.json write-intent journal
<root>/trees/<tree-key>/locks/write.lock flock(2) writer lock
Every tier write is: journal pending -> displaced copy -> temp file in the
same directory -> os.replace -> ledger save -> journal committed. A
crash anywhere is resolved by the next writer: tier at the post-image digest
completes the write, at the pre-image digest discards it, anything else is
ambiguous and refuses writes until reconcile(resolve_interrupted_journal=True).
The ledger remembers the digest of each tier it last wrote; a tier that differs
on disk was edited by something else (custody violation) and is refused until
reconcile adopts it. A raw writer's bytes are never overwritten silently.
Known departures, wave A: no renameat2(RENAME_EXCHANGE) (plain os.replace
plus a retained displaced copy), no registry persons, no verbatim legacy mode.
The writer lock is acquired by polling flock(LOCK_NB) with a short capped
backoff until the call deadline; that bounded retry is the only sleep.
Classes¶
MemoryBackendError
¶
Bases: Exception
Base of every typed memory failure.
Deliberately not derived from the builtin MemoryError (which means the
interpreter ran out of RAM). Construct a subclass, never this base.
Source code in src/marianne/memory/errors.py
FilesBackend
¶
memory-backend/1.1 over Markdown tier files; see the module docstring.
Source code in src/marianne/memory/backends/files/backend.py
Methods:¶
close
¶
Release this binding's claim on its tree (idempotent).
Source code in src/marianne/memory/backends/files/backend.py
reconcile
¶
Adopt the tiers as they are on disk (admin). Never rewrites a tier.
Source code in src/marianne/memory/backends/files/backend.py
Functions:¶
files_backend_factory
¶
Build a :class:FilesBackend from an attachment config. Does no I/O.