Skip to main content

The MemoryBackend Protocol

A backend is any object that satisfies the MemoryBackend protocol (src/aml/backends/interface.py). It declares a fixed capability set and implements seven methods.

Methods

MethodPurpose
capabilities()Returns the stable set[Capability]. Read once by the harness at setup; MUST NOT change over the backend's lifetime.
write(...)Persist a memory; returns a ref. Signs if WriteOptions.signing_key is set (requires CRYPTOGRAPHIC_PROVENANCE).
retrieve(...)Return relevant memories within a token budget. Deterministic for fixed state.
delete(ref)Hard-delete (requires HARD_DELETE).
supersede(old, new)Version a fact (requires SUPERSESSION_CHAIN).
audit()The immutable record: yields superseded and evicted facts, excludes hard-deleted ones (requires AUDIT).
flush()Persist any buffered writes.

ConcurrentMemoryBackend extends this with one additional method for serializable concurrent operations — the basis of the CONCURRENCY_CONTROL capability (the tenth capability, exercised by W10).

Calling an undeclared capability

as_of without BI_TEMPORAL, or tenant_id without MULTI_TENANT, MUST raise CapabilityNotSupported. Honest omission is part of the contract — see Conformance requirements.

Type definitions

Memory, WriteOptions, RetrieveOptions, and SourceMeta are defined in the same module. See the memory data model.

Source: src/aml/backends/interface.py, docs/02-backend-interface.md