backend_protocol
backend_protocol
¶
The memory-backend/1.1 protocol and its per-call RequestContext.
A backend is anything that implements these nine operations. The gateway
(conductor side) builds a :class:RequestContext for every call from the
session it admitted, never from data the musician sent, and a backend trusts
the context: principal, canonical scope, permission ceiling and deadline.
Mapping from GH #496's first sketch: remember is declare, export
is stream_facts. consolidate is not part of the frozen protocol; a
backend that cannot consolidate says so through its capability table.
Classes¶
RequestContext
dataclass
¶
RequestContext(principal, scope, permissions, deadline_at, dispatch_id=None, job_id=None, session_id=None)
The immutable per-call envelope (memory-backend/1.1).
deadline_at is a POSIX timestamp. A conforming backend clamps every
lock wait to remaining_seconds and aborts with E10 before it mutates
anything once the deadline has passed. scope is canonicalised on
construction; permissions is the session's ceiling.
Attributes¶
Methods:¶
require
¶
Raise E2 naming permission when the ceiling lacks it.
Source code in src/marianne/memory/backend_protocol.py
require_any
¶
Raise E2 unless the ceiling holds at least one of permissions.
Source code in src/marianne/memory/backend_protocol.py
MemoryBackend
¶
Bases: Protocol
memory-backend/1.1: what every memory backend implements.
Every operation takes the gateway-built :class:RequestContext first.
Failures raise a typed :class:~marianne.memory.errors.MemoryBackendError
subclass; a backend never returns an error as a success-shaped dict.
Methods:¶
declare
¶
Remember fact with its evidence; idempotent per (claim, evidence).
Source code in src/marianne/memory/backend_protocol.py
recall
¶
Facts relevant to query, within the per-response byte cap.
cap_bytes is an optional per-call ceiling the gateway sets to
min(recall_cap_bytes, quota_remaining); the backend applies the
smaller of it and its own cap, stops reading at it and returns its
cursor. None keeps the backend's own cap (the 1.1 behaviour).
Source code in src/marianne/memory/backend_protocol.py
verify
¶
bind
¶
Bind a freshly verified fact to an action; re-checks disk first.
forget
¶
fetch
¶
stream_facts
¶
Export every live fact and tombstone as migration-facts/1 batches.
migration_ingest
¶
Staged import: begin -> batch... -> finalize | abort.