What a memory is
Four record types — memory, entity, statement, relation — the fields each carries, the eight edges that join memories to each other, and the one modelling decision users get wrong most often.
One sentence in, four kinds of record out
You hand Brain plain text. It keeps the text, and it derives structure from it.
Memory
The raw experience, kept verbatim, with an embedding, a salience, edges to related memories, and provenance. Nothing is thrown away.
Entity
A canonical noun — a person, a team, a product — with a stable identity and an alias list, so "Priya", "Priya S." and "she" resolve to one thing.
Statement
A typed claim about entities: subject, predicate, object. This is the record that can be true, false, current or replaced.
Relation
A typed edge between two entities — reports_to, works_on — with
cardinality and its own evidence.
The memory is what you said. The other three are what it means, and they are derived by an extraction pipeline rather than asked of you.
They are also cleanly separable: memories mention entities, statements are about entities, relations are between entities. Nothing in the typed graph replaces the text, and the text never has to be re-parsed to answer a question the graph already holds.
Anatomy of a memory
The memory record is the one you create directly, so it's worth knowing what Brain attaches to your text:
struct Memory {
id: MemoryId, // 16 bytes, opaque — encodes shard + slot + version
namespace_id: NamespaceId, // the outer tenant wall
space_id: SpaceId, // the inner wall; decides which shard holds it
text: String, // your text, verbatim, never parsed or rewritten
vector: [f32; 384], // L2-normalized embedding; internal
kind: MemoryKind, // Episodic | Semantic | Consolidated
session_id: SessionId,
state: LifecycleState, // Active | Tombstoned | Reclaimed
created_at: u64, // server write time — always stamped
occurred_at: Option<u64>, // client event time — when it actually happened
salience: f32, // [0, 1]
last_accessed_at: u64,
access_count: u32,
embedding_model_fp: [u8; 16], // which model produced the vector
source_request_id: RequestId,
edges: Vec<EdgeId>,
}Four things in there are worth dwelling on.
The owner scope is stamped, not supplied. namespace_id is the outer wall
(the company-level tenant); space_id is the inner one (the app). Both are
written by the server from the authenticated connection — a row can never be
built without naming its owner, which is what makes cross-tenant leakage a
structural impossibility rather than a filter you remembered to apply. A
memory's space_id is immutable for its lifetime; "moving" one means encoding
it under the destination and forgetting the original.
There are two clocks, and this is the one people skip. created_at is when
the server durably committed the row. occurred_at is when the content
actually happened, and you supply it. A memory written today about an event
in 2020 has created_at ≈ now and occurred_at ≈ 2020. If you don't pass it,
it is None — and then the only timeline Brain has is write order.
Use occurred_at rather than writing the date into the sentence. It is
stored verbatim, survives crash recovery through the WAL, is echoed back on
every recall, and is the field the recency
boost
reads. A date buried in the text is a string the embedder blurs; a date in
occurred_at is a number the pipeline can sort on.
The vector is an implementation detail with an invariant. Every memory's
vector is the embedding of its text under the model named by
embedding_model_fp. Change the model and the vector is stale until
re-embedded — which is why the fingerprint is stored on the row rather than
assumed globally, and why a memory stamped with a different model isn't
filtered out of results so much as not comparable to the query at all.
Your text is never touched. UTF-8, stored verbatim, opaque to Brain — not parsed, not validated, not rewritten. Everything structured is derived alongside it, never instead of it.
What a memory costs. The arena slot is a fixed 1600 bytes — 1536 for
the 384-dim f32 vector plus 64 of slot metadata. Add text, metadata, edges
and the index entries and a typical memory is about 2.2 KB all in. A
million memories is roughly 2.2 GiB on disk. That is the number to plan
capacity against, not the length of your sentences.
Memories are also a graph
Before the typed graph, there is a simpler one: memories link directly to other
memories by typed, directed, weighted edges. This layer is easy to miss because
extraction gets the attention, but it is what reason and plan actually walk.
There are eight edge kinds, fixed in v1:
| Kind | Meaning | Auto-derived? |
|---|---|---|
CAUSED | Source caused target | No — only your explicit assertion counts |
FOLLOWED_BY | Source precedes target in time, no causal claim | Yes, within a session |
DERIVED_FROM | Source was derived from target | Yes, required on every consolidated memory |
SIMILAR_TO | Semantically similar, weight = cosine at creation | Yes, above 0.85 |
CONTRADICTS | Source contradicts target's claim | No |
SUPPORTS | Source evidences target's claim | No |
REFERENCES | Source mentions target | No |
PART_OF | Source is a component of target | Yes, during episode identification |
Each edge carries a weight in [0, 1] whose meaning is kind-specific —
cosine similarity for SIMILAR_TO, your confidence for CAUSED — and an
origin marking it Explicit or AutoDerived.
Brain will not invent a causal claim. CAUSED, CONTRADICTS and
SUPPORTS are never auto-derived, because deciding that one memory caused or
refutes another needs understanding Brain does not claim to have. The
auto-derived four are all structural or geometric: temporal adjacency,
derivation, cosine proximity, episode membership. If a causal edge exists in
your graph, someone asserted it — which is exactly the property you want when
reason later walks that edge to explain an answer.
A memory owns its outgoing edges (capped at 1000, configurable); incoming
edges are discoverable through a secondary index but not stored on the target.
That asymmetry shows up on forget: outgoing edges are removed immediately
because they are colocated, while incoming ones are merely filtered during
traversal until the slot is reclaimed, at which point a sweep rewrites the
index. Rewriting every by-target entry eagerly would turn one small delete into
an unbounded one.
Anatomy of a statement
The statement is where the interesting behaviour lives:
{
"statement_id": "…",
"kind": "Preference",
"subject": "…", // an entity id
"predicate": "prefers",
"object": { "kind": "value", "value": { "type": "text", "value": "async meetings" } },
"confidence": 0.92,
"event_at_unix_nanos": 1750000000000000000,
"valid_from_unix_nanos": 1750000000000000000,
"valid_to_unix_nanos": 9223372036854775807,
"version": 1,
"supersedes": null,
"superseded_by": null,
"chain_root": "…",
"tombstoned": false
}Four groups of fields, four jobs:
Identity — subject / predicate / object. The claim decomposed. This is
the structure a text chunk doesn't have, and it's what makes two claims
comparable: same subject, same predicate, different object means they are
competing to describe the same thing. Every resolution in
when facts collide is a comparison over these three
fields plus the interval.
Time — event_at / valid_from / valid_to. Two different clocks again.
event_at is when the thing happened; valid_from/valid_to are when the
claim holds. A promotion that happened in June and still holds has an
event_at in June and a valid_to at the maximum. That distinction is what
lets you ask "what did we believe in August?" rather than only "what do we
believe now?"
Confidence and evidence. Confidence is not asserted — it is
aggregated from the evidence
by noisy-OR, and it decays with the evidence's age at a rate set by the kind. A
statement with no evidence has confidence 0.0 by construction. Nothing enters
the graph unattributed, so if a model hallucinated something in turn four, you
can find out that is where it came from.
Lineage — version / supersedes / superseded_by / chain_root. A
statement is never edited in place. A newer claim links to the one it replaced,
and chain_root lets you walk the whole history of how a belief changed.
Alongside those, the row records the extractor_id that produced it and the
schema_version it was extracted under — so a predicate whose meaning changes
later doesn't silently reinterpret rows written before the change. A whole
statement averages about 256 bytes.
One field is worth knowing before you read any back: a statement's subject is
either an entity id or Pending, carrying the audit id of a resolution
that hasn't settled. Extraction does not block to be certain which Priya a
sentence meant — it writes the claim and lets the resolver converge. A pending
subject is the system being honest about what it doesn't know yet, not a
half-written row.
Objects can point at other records
object isn't only a literal. It's one of four shapes:
| Object kind | Meaning |
|---|---|
value | A literal — text, integer, float, bool, timestamp or blob |
entity | Points at another entity, making the statement a graph edge |
memory | Points at a source memory |
statement | Points at another statement — claims about claims |
So the same mechanism carries "Priya's timezone is CET" and "Priya reports to Dev" without needing two systems.
Anatomy of an entity
An entity is the identity of a referent — the thing a memory mentions, a statement is about, or a relation connects:
struct Entity {
id: EntityId, // UUIDv7
namespace_id, space_id, // owner scope, stamped like everything else
entity_type_id: EntityTypeId, // interned — "Person", "Organization", …
canonical_name: String,
aliases: Vec<String>,
attributes: EntityAttributes,
created_at_unix_nanos, last_seen_at_unix_nanos,
tombstoned: bool,
merged_into: Option<EntityId>, // None while live; Some(id) after a merge
}Six entity types are seeded for you — Person, Organization, Project,
Place, Concept, Event — and a schema adds deployment-specific ones.
The id is stable in exactly the ways that matter. Renaming the entity
changes canonical_name; adding "Priya S." changes aliases; updating
attributes changes attributes. The EntityId survives all three. It changes
only through a merge, and even then the merged-away id becomes a redirect
(merged_into) rather than a dangling reference — so an id you stored last
month still resolves.
Resolution is scoped per tenant, and this surprises people building
multi-tenant systems. The resolver's exact-name, alias and trigram indexes
are all keyed under a leading (namespace, space) prefix. "Priya Patel" in
tenant acme and "Priya Patel" in tenant globex are two separate
entities with two separate ids — not one entity seen by two tenants.
That is the correct default, and it is the thing that makes one tenant's resolution structurally incapable of reaching another's rows. But it does mean a shared reference entity (a product catalogue, a public org chart) is not something you get for free by writing the same name twice.
Relations, and the cardinality that governs them
A relation is a typed edge between two entities, and unlike a memory edge it carries a cardinality declared on the relation type:
| Cardinality | Constraint | Example |
|---|---|---|
OneToOne | At most one current relation touching either side | married_to |
OneToMany | At most one touching the to side | employed_by |
ManyToOne | At most one touching the from side | reports_to |
ManyToMany | No constraint | discussed_with, attended |
Cardinality is not documentation. It drives auto-supersession: asserting a
new reports_to for Priya when she already has one supersedes the old one
inside the same transaction, closing its validity and linking the chain — the
same mechanism Preferences use, generalised over four variants.
Without a schema, relation types are interned on first use and default to
ManyToMany with no from/to constraints — so they never auto-supersede
and never raise a cardinality violation. Declaring the type later keeps the
existing id and flips its origin to schema-declared, at which point the
constraints start being enforced on new writes.
This is why "it worked in the prototype and started rejecting writes after we added a schema" is expected rather than a regression: you asked for the constraint.
Relation or statement? The decision users get wrong
This is the most common modelling question, and both answers are queryable — a wrong call costs ergonomics, not correctness.
Worked through:
- "Priya manages Bob" → Relation. Two entities, bidirectional, cardinality meaningful.
- "Priya's email is priya@example.com" → Statement (Fact). An email is not an entity you track.
- "Priya prefers async meetings" → Statement (Preference). The object is a concept, not a tracked thing.
- "Priya is a member of the engineering team" → Relation if the team is a tracked entity, otherwise a Fact.
The test that resolves most cases: would I ever want to start from the other end? If you'll ask "who reports to Priya" as well as "who does Bob report to", that is a relation. If you'll only ever ask about the subject, it's a statement.
The lifecycle, and why ids don't alias
A memory moves through exactly three states:
Active → Tombstoned → ReclaimedActive is the normal case. Tombstoned means forgotten but still occupying
its slot — hidden from queries, recoverable until the grace period elapses.
Reclaimed means the slot has been returned to the free list and reused.
The MemoryId encodes shard, slot and version. When a slot is reclaimed its
version increments, so an id you held from before reclamation no longer matches
the slot's current occupant: it reads as absent rather than resolving to
somebody else's memory. That is why ids are safe to persist on your side — a
stale one fails closed.
Try it
Run the Team + role fixture in the playground, then open the Memories tab and the Graph tab side by side.
One sentence produced: a memory (your text), two entities (the person, the team), and a statement joining them. You wrote none of that structure — and every piece of it links back to the sentence you did write.
Then run Cross-team link and look at the graph again. The second sentence mentions a person the first one already introduced, and it resolves to the same entity id rather than creating a second Priya. That resolution — not the embedding — is what makes the two sentences answerable as one fact.
Was this page helpful?
Why RAG isn't memory
A text chunk has no subject and no validity interval, so two chunks can never disagree — and the four places a vector database's model is the wrong shape for an agent's memory.
The statement kinds
Fact, preference and event — three kinds over one storage schema, three mutation contracts, why there are exactly three, and the modelling error that silently erases history.