Brain Docs
Learn

Why memory exists

Why agents forgetWhy a bigger window doesn't fix itWhy RAG isn't memory

What a memory is

What a memory isThe statement kindsWhen facts collide

How it answers

How recall decidesDecay and retention

Using it well

What to write, and what not to

Reference

Brain/Docs
✦ ASKBrain on GitHubDashboard
LearnThe statement kinds

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.

PURPOSE

Every statement carries a kind. It isn't decoration and it isn't a label you pick for readability — the kind is a contract about what a later, conflicting claim is allowed to do to this one.

Three kinds, not more

enum StatementKind { Fact, Preference, Event }

That is the whole enum. There is no Attribute, no Directive, and no Custom — a property like Priya's timezone is CET is a Fact with a timezone predicate, and a typed edge between two entities is not a statement kind at all but a Relation, its own record type.

The three are not three storage schemas. Internally every statement is a row in one statements table with one set of columns. What differs is three contracts layered over that one schema: how mutation works, what the validity interval defaults to, and what question the kind answers.

OptionTypeDefault / Env
Factappend-only

A stable claim about the world — Priya is the engineering manager. A contradicting Fact does not delete the old one. Both are stored; the reader returns the higher-confidence one, or the more recent at equal confidence. Validity runs from extraction time with no valid_to until something contradicts it.

Preferencesuperseded

A revisable belief or choice — Priya prefers async meetings. A new Preference on the same (subject, predicate) supersedes the old one: the old row's superseded_by points at the new one and its valid_to is set to the new one's extraction time. "Current preference" returns only the new one; the history query returns the chain.

Eventimmutable

A discrete occurrence at a moment — Priya scheduled a planning session on Tuesday. Events are immutable and never supersede each other. A similar Event is stored as a second, independent Event. event_at is the moment; there is no validity range.

The difference that matters: Fact is not exclusive

This is the one place readers most often carry the wrong model over from relational thinking, so it is worth stating flatly.

A new Fact does not replace the Fact it disagrees with. Writing "Priya manages platform" over an existing "Priya manages billing" leaves you with two Fact rows, both live, both in the audit trail. Nothing was overwritten and nothing was closed off. What changed is which one wins at read time:

Fact (what Brain does)
Exclusive update (what people assume)
On a contradicting write
Both rows stored; the contradiction is recorded between them
The old row is overwritten or its validity is closed
What the reader returns
Higher confidence wins; more recent breaks a confidence tie
Whatever the last write said
If the new claim was wrong
The old one is still there, still has its evidence, still wins once confidence is corrected
Unrecoverable without an audit log you built yourself

Preference is the kind that behaves the way people expect an update to behave — supersession, a closed interval, a link to the replacement. If you want last-write-wins semantics for something, you almost certainly want a Preference predicate, not a Fact one.

Storing events as facts is the destructive error. "Diego was promoted" sounds like a fact about Diego, but it is an Event: it happened once, at a time, and stays true forever. The second promotion does not make the first one false.

The damage is asymmetric. Model an Event as a Preference and each promotion supersedes the last — the career history is closed off one row at a time and the timeline question stops being answerable. Model a Fact as an Event and you merely accumulate rows that never close. One is a tidiness problem; the other loses data you cannot reconstruct.

The contracts, in full

The kind is enforced at the validator, not merely suggested, and each one pins different fields:

FieldFactPreferenceEvent
event_atmust be Nonemust be Nonerequired
valid_fromdefaults to extraction timedefaults to extraction timemust be None
valid_toNone until contradicted or retractedset to the superseder's extraction timemust be None
Supersessionexplicit only, rareautomatic on same (subject, predicate)rejected
Typical objectEntity or ValueValue or EntityEntity or Value
Default queryhighest-confidence non-supersededcurrent onlya time range, sorted by event_at

So "an Event with no event_at" is not a sloppy row — it is a write that fails validation. The kinds earn their existence by making whole classes of malformed claim unrepresentable.

How you delete a Preference: you don't. You record a new Preference that supersedes it, whose object is a sentinel the schema permits — null, "none", whatever you've declared. The chain stays intact, so "what did Priya used to prefer, before she stopped preferring anything" remains answerable.

Genuine removal — encoded by accident, or a privacy obligation — is a separate, rare, audited operation with the same grace-period semantics as a hard forget on a memory. The distinction is the same one supersession draws: stopped being true and must not exist are different requests.

Why exactly three

Both edges of that number were argued, and the reasoning is worth knowing because it tells you how to model the thing you can't find a kind for.

Why not one type with a mutable flag? It would be a simpler schema and one fewer concept to teach. It lost on four counts: people genuinely categorise knowledge as fact / preference / event, so the distinction does work at the schema level; extractors producing Events have a different output shape from those producing Preferences, and strong typing prevents misuse; default query behaviour differs per kind and defaults need something to attach to; and validation differs, as the table above shows.

Why not more — Observation, Goal, Rule? Because each new kind costs API surface, validation logic, documentation and tests, and the only justification is that users would otherwise abuse an existing kind. So the test is whether the existing three express it cleanly:

CandidateExpressible?
Observation — "I observed X"Yes — an Event with predicate = observed
Goal — "I want X"Yes — a Preference with predicate = wants
Hypothesis — "X might be true"Yes — a Fact with low confidence
Contradiction marker — "X and Y disagree"Yes — a Fact with predicate = contradicts
Rule — "if X then Y"No — but a rule isn't a claim about an entity, it's a program. It belongs in the extractor or planner layer, not in a statement

Rule is the instructive one. It fails the test not because three kinds are too few but because it isn't the same sort of thing — a claim about an entity is data, a conditional is behaviour, and putting behaviour in the statement table would mean the read path has to decide whether a row is something to return or something to run.

The practical guidance: if you have a sixth-kind use case, express it in the predicate and pick whichever of the three has the mutation contract you want. The predicate carries the meaning; the kind carries the behaviour.

Predicates are namespaced, and may be implicit

A predicate is an interned, namespaced string, and the namespace is what keeps two deployments' prefers from colliding — brain:prefers and crm:prefers are different predicates with different semantics.

Four are seeded for you in the reserved brain: namespace: is_a (entity-type assertion), has_name, mentions and related_to.

Everything else you either declare or write into existence, and which one it was is recorded on the predicate itself:

OptionTypeDefault / Env
Schema-declaredconstraints enforced

Introduced by a schema upload at a known version. Its kind constraint and object-type constraint are enforced on every write, and an undeclared qname in that namespace is rejected rather than accepted.

Implicit from writeopen vocabulary

Interned the first time a statement named it in a namespace with no active schema. It carries no kind or object-type constraint and never enforces supersession, and statements written against it are flagged so tooling can see which rows came from the open-vocabulary path.

An implicit predicate does not supersede. This is the single most surprising consequence of starting schemaless. Write "Priya prefers dark mode" and later "Priya prefers light mode" against an implicit prefers and you get two live Preference rows, not a chain — because supersession is a contract the predicate declaration carries, and an implicit predicate has no declaration.

Declaring the predicate later fixes it going forward: the existing predicate id is preserved, the origin flips to schema-declared, and previously written statements keep their ids while being flagged as outside the new active schema. It does not retroactively build the chains you missed.

Declaring a predicate is three lines, and it buys the object-type constraint too:

define predicate manages {
  kind: Fact
  object: Entity<Person>
}

Now manages can only ever produce Facts, and only ever about a Person — a whole class of extraction error becomes a rejected write rather than a bad row you find in six months.

What a declaration starts rejecting

Declaring types turns three classes of bad write from accepted into refused, each with its own error rather than a generic failure:

ViolationWhat triggered it
PredicateNotInSchemaA statement named a predicate the active schema doesn't declare
RelationTypeNotInSchemaSame, for a relation type
CardinalityViolationA relation would breach its type's declared cardinality

None of these can fire while you are on the open-vocabulary path, because there is no declaration to violate — which is the real trade in starting schemaless. You get frictionless writes and no guardrail, and you convert one into the other when you are ready.

What else the row carries

The three kinds share one row, and a few of its other fields change how you model things:

The subject may not be resolved yet. A statement's subject is either an EntityId or Pending — a placeholder carrying the audit id of an unfinished resolution. Extraction does not block waiting to be sure which Priya a sentence meant; it writes the claim with a pending subject and lets the resolver settle it as evidence accumulates. A statement you read back with a pending subject is not broken — it is honest about what is still unknown.

The schema version is stamped per statement. Each row records which schema version it was extracted under, so a predicate that later changes meaning doesn't silently reinterpret rows written before the change. After a schema upload, a sweep flags rows whose predicate is no longer in the active schema rather than deleting them.

A tombstone records why. This is the field most people don't expect, and it is the one that makes cleanup auditable:

ReasonWhat happened
SourceMemoryForgottenThe memory this claim cited was forgotten, so the claim lost its evidence
UserRequestSomebody asked for it gone — an erasure obligation
SchemaInvalidationA schema change made the claim unrepresentable
ExtractorRetractionThe extractor that produced it withdrew it

Those are four genuinely different events, and collapsing them into a single deleted flag loses the only information that makes the row's absence explicable six months later. The first one is also the mechanism behind cascading deletes: forget a memory and the claims resting on it tombstone with a reason that points back at the cause.

The whole row averages about 256 bytes — roughly 160 of fixed fields, a 16–64 byte object union, and up to 128 of inline evidence before it spills to overflow.

Statement kind is not memory kind

Two different kind fields live in this system and the API reference uses both words. They are different axes and confusing them produces nonsense.

OptionTypeDefault / Env
MemoryKindEpisodic | Semantic | Consolidated

On the memory — the record holding your text. Episodic (0) is something observed, Semantic (1) a durable generalisation, Consolidated (2) the product of the consolidation worker. It drives salience and decay rates, and it is the kind you see on a recall hit.

StatementKindFact | Preference | Event

On the statement — a typed claim extracted from memories. It drives the mutation contract above.

One sentence you encode produces one memory with a MemoryKind and zero or more statements, each with a StatementKind. A hit's kind: 0 means Episodic. It does not mean Fact.

Schema declares predicates, which carry a kind

You do not declare new kinds — the enum is closed. What a schema declares is a predicate, and each predicate names which of the three kinds its statements will be:

namespace acme

define predicate prefers {
  kind: Preference
  object: Value<text>
}

define relation_type reports_to {
  from: Person
  to: Person
  cardinality: many-to-one
}

So the kind is fixed per predicate at declaration time rather than chosen per write. prefers always produces Preferences; it cannot emit a Fact on Tuesday because the sentence read like one.

Every deployment seeds the reserved brain: system namespace, so extraction runs from the first write with no schema of your own. Declaring types is additive — it widens the vocabulary writes may use. It does not switch retrieval on, change the fan-out, or alter the filter chain; those are wired on every shard from byte zero.

Nothing you fail to declare is lost. A schema controls admission to the typed graph, not whether your text is stored — the raw memory is always kept and always recallable. Declaring a predicate months later kicks off a backfill across memories already stored, so starting unstructured and adding vocabulary once you know what you need is a supported path, not a migration.

Try it

Run Preference and then New hire in the playground and watch the extraction station on each. Then run Promotion twice with different roles and open the Graph tab: you will see two Fact rows with a contradiction recorded between them, not one row that changed.

For the implicit-predicate behaviour, write a preference-shaped sentence twice with different objects and check whether the first row closed. If both are open, you are on the open-vocabulary path — which is the right default for a prototype and the wrong one for production.

See also
When facts collideWhat a memory isSchema and policy

Was this page helpful?

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.

When facts collide

Preferences supersede, facts contradict, events never move, relations obey cardinality and entities merge — five resolutions for five kinds of collision, and none of them overwrite.

On this page

Three kinds, not moreThe difference that matters: Fact is not exclusiveThe contracts, in fullWhy exactly threePredicates are namespaced, and may be implicitWhat a declaration starts rejectingWhat else the row carriesStatement kind is not memory kindSchema declares predicates, which carry a kindTry it
Suggest an editOpen in Playground