model
model
¶
Pure value types for memory-backend/1.1.
Scope keys, permissions, fact identity, evidence-bearing fact records,
tombstones, the recall-cursor/1 and memory-health/1 shapes, and the
migration-facts/1 batch. Wire payloads are TypedDicts: at runtime
they are the plain dicts the gateway serialises, statically they are checked.
Nothing here touches the filesystem, a socket or the daemon.
Classes¶
Permission
¶
Bases: str, Enum
The seven memory permissions. They live in conductor access records, never in score YAML.
ScopeKey
dataclass
¶
A canonical scope: one family and one identifier.
The canonical spelling is local:<id> for the local family and
<family>/<id> for every other, so one (family, id) pair has exactly
one string everywhere it is joined on.
Provenance
¶
Bases: TypedDict
Evidence a musician supplies with a declaration.
evidence_locator names where the claim can be re-checked (a path, a
URL, snapshot:<sha256>); observed_at is the source observation
clock, distinct from the backend's asserted_at write clock.
RecallResult
¶
Bases: TypedDict
One recall page.
cursor is a page cut (resume with its token) or None when nothing
is left. Units too large for the page cap are never truncated: each is
listed in oversized with remedy: fetch, so a page cut and several
oversized markers can travel in one response.
FactRecord
¶
Bases: TypedDict
One fact with its evidence and its clocks, as it migrates.
Tombstone
¶
Bases: TypedDict
A generational erasure: revokes the claim at or before cutoff.
MigrationBatch
¶
Bases: TypedDict
One migration-facts/1 record yielded by stream_facts.
Functions:¶
parse_scope
¶
Parse and canonicalise a scope expression, or raise E3 scope_refused.
Grammar: <family>(:|/)<id> with <id> in [a-z0-9_.-]+; input is
stripped and lowercased. An id made only of dots is refused because the
files backend maps a scope onto a directory and .. would escape it.
Source code in src/marianne/memory/model.py
validate_principal
¶
Return principal if it is person:|agent:|team:|org:<id>, else E7.
Source code in src/marianne/memory/model.py
content_hash
¶
derive_fact_id
¶
Deterministic 16-hex fact id over (scope, locator, content hash, claim digest).
Fields are NUL-separated so ("a", "bc") and ("ab", "c") differ.
Re-declaring the same claim with the same evidence yields the same id.
Source code in src/marianne/memory/model.py
page_cursor
¶
A page cut: resume with cursor to receive the omitted sections.
oversized_unit_cursor
¶
A single unit larger than the page cap: page it with fetch.
Source code in src/marianne/memory/model.py
memory_health
¶
Build a memory-health/1 record; failure_class follows status.