Brain Docs

Reference

ConceptsArchitectureWrite pipelineEntitiesIdentity by keyNamespaces, spaces and sessionsPolicies
Brain/Docs
✦ ASKBrain on GitHubDashboard
ConceptsConcepts

Concepts

Mental models for Brain — typed memory, the write/read pipelines, identity-by-key, the entity graph, and the single-binary architecture.

PURPOSE

These pages are the load-bearing mental models for Brain. Read them in order if you're new — every page here is referenced from the SDK and API references when behaviour bottoms out at a design decision. Each page is one model; if you find yourself splitting attention across two ideas, that's two pages.

The four pillars

01

Typed memory + entity graph

You write plain text. Brain embeds it, stores it as a memory, and asynchronously extracts a typed graph — entities, and Fact / Preference / Event statements and relations between them. Retrieval can walk that graph instead of reducing everything to cosine distance.

02

Identity by key

An API key is bound to a (namespace, space, permissions) scope when it's minted. Clients never send a scope — the server derives it from the key, and every memory, entity, and index is isolated per (namespace, space).

03

One write path, one read verb

Every write is an encode; every read is a recall. encode acks the moment the WAL is fsynced, then derives edges and the typed graph in the background. recall fuses three retrievers into a membership answer — Single, Many, or None.

04

Single binary, no external database

One process embeds everything: an mmap arena for vectors, a WAL, a redb metadata store, in-RAM HNSW, tantivy, and the bundled BGE-small embedder and GLiNER classifier. (The cross-encoder reranker is not bundled — it ships disabled.) Parallelism is sharding. The only outbound dependency is an LLM provider.

Reading order

01
How memory works

Three-minute orientation: the round trip from a chat turn to a recall answer.

02
Memory types

Fact / Preference / Event — the three kinds, and how the mutation contract differs for each.

03
Identity by key

The design wedge: keys carry scope, clients never do.

04
Write pipeline

A synchronous fast path (validate → embed → reserve → persist), then async derivation.

05
Read pipeline

Three retrievers, RRF fusion, the filter chain, and the membership band.

06
Architecture

The crate graph and the single-binary, shard-per-core design.

07
Namespaces and spaces

Two isolation axes and one grouping — and why per-user isolation is a prefix, not a key.

08
Entities

Resolution, merging, relations and cardinality — the typed graph's identity layer.

09
Policies

The four enable/disable categories, the read-time filters that exist, and the ones that don't.

If you read one thing on each page

Architecture — parallelism is sharding, and the trade is tail-latency predictability bought with throughput. Write pipeline — the ack barrier splits durability from derivation, but a fresh memory is semantically searchable immediately. Entities — an ambiguous resolution writes no link at all, silently. Identity by key — the namespace comes from the credential; the space is per-request at scale. Namespaces — never mint a key per end user. Policies — a disabled thing is always observable as disabled.

Was this page helpful?

Scaling and limits

Shards are chosen once, tenants are capped at single-shard throughput, and the engine is single-node — the boundaries to know before you build on it.

Architecture

Brain is one Rust binary with a strict one-way crate graph — an mmap arena, a WAL, redb, HNSW, tantivy, and bundled models, sharded thread-per-core. No external database.

On this page

The four pillarsReading order
Suggest an editOpen in Playground