# Concept clusters (/docs/concept-clusters)



This page is the concept map. Every other doc page is the deep
dive on one of the concepts named here.

The substrate organizes around clusters of three. One triplet
covers the whole runtime — *session, turn, row* — and reduces to
the same primitive used everywhere else: an append-only typed
audit row keyed by `turnId`. Six more cluster triplets sit one
click in. Each one is what the substrate uses to do something
specific: run a turn, route a call, record a call, compose work
across spawns, advance over time, or survive a restart.

If you read the [glossary entry on the name](/docs/glossary#p):
each cluster triplet is a way the lattice carries one weight a
single `streamText` call cannot. Routing, audit, lifecycle,
persistence — different forces, same hedge.

## The substrate-wide triplet [#the-substrate-wide-triplet]

Everything else reduces to these. The homepage opens with this
triplet; the docs index repeats it; every cluster below is built
out of one of them.

* **Session.** Long-lived state for one user × one product
  surface. Channels, storage, family-lock, and the event log all
  hang off it. Mint with `runtime.sessions.create()`; resume by
  id across processes and clients via version-vector sync. See
  [SessionRuntime](/docs/session-runtime).
* **Turn.** One user-message-in / one-answer-out cycle. Walks the
  four-stage lattice — `anchor-plan` → `tool-loop` ⇄ `synthesize`
  → `post-turn` — under singleton-synthesize discipline so
  exactly one final answer fires per turn. See
  [Turn lifecycle](/docs/turn-lifecycle).
* **AuditableCall row.** One append-only typed row per LLM call,
  keyed by `turnId`. Carries `tenantId`, `toolName`,
  `subagentDepth`, `modelId`, and `tokenUsage`. The grain every
  cost rollup, compliance query, and replay reads from. See
  [The AuditableCall row](/docs/auditable-call-row).

## The six cluster triplets [#the-six-cluster-triplets]

Each cluster lives on a host page that walks the three concepts
as parallel bullets. Sibling concept pages open with a one-
paragraph pointer to the cluster framing. The clusters are
ordered roughly by where they fire in a turn — graph schedules
work, the routing cluster picks a model, the audit cluster
records the call, the composing-agents cluster spawns child
work, the runtime-lifecycle cluster advances and persists, and
the state cluster carries everything across restarts.

### Execution-graph cluster [#execution-graph-cluster]

The per-turn execution substrate. Lives *inside* the lattice. Full walk in [Architecture](/docs/architecture#the-execution-graph-cluster).

* **Graph.** Declarative topology — nodes wired to channels,
  edges constrained to the four-stage lattice. See
  [Graph](/docs/graph).
* **Node.** An async function plus typed
  `StateGraphNodeMetadata` declaring `stageId`, `acceptsSeam`,
  `subscribes`, and `writes`. See [Nodes](/docs/nodes).
* **Channel.** Typed reactive state slot. Six kinds with defined
  concurrent-write semantics and a `checkpoint()` / `restore()`
  pair. See [Channels](/docs/channels).
* **Engine.** The `engine/` superstep scheduler (`SuperstepRunner`)
  that *runs* the compiled graph — fires triggered nodes in
  parallel, accumulates their writes, and commits channel updates
  atomically per step. Deterministic and race-free by construction;
  also owns retry, abort composition, and graph↔session state
  sync. See [Architecture → execution-graph cluster](/docs/architecture#the-execution-graph-cluster).

### Routing cluster [#routing-cluster]

Decides which model fires for which kind of call, and pins what
stays locked across the session. Lives between the execution
graph and the LLM transport. Full walk in [Family-locked routing](/docs/family-lock#the-routing-cluster).

* **CallClass.** Four-bucket taxonomy every LLM call declares —
  `utility`, `reasoning`, `converse`, `synthesize`. See
  [Call classes](/docs/call-classes).
* **Seam.** Per-call-class factory that builds a
  `ProviderSeam<C>`. Four factories live in
  `src/graph/seams/`. See [Seams](/docs/seams).
* **Family-lock.** Session-start lock on one `ProviderFamily` and
  one `Transport`. See
  [Family-locked routing](/docs/family-lock).

### Audit-ledger cluster [#audit-ledger-cluster]

The write side. The row is the grain; the ledger is the write
path; the chain is the after-the-fact-tamper detector. Full walk in [Audit ledger](/docs/audit-ledger#the-audit-ledger-cluster).

* **AuditableCall row.** Typed row shape with five typed payload
  slots. See [The AuditableCall row](/docs/auditable-call-row).
* **ProviderDecisionLedger.** Append-only write interface, one
  method, idempotent on
  `(sessionId, turnId, stageId, seqWithinTurn)`. See
  [Audit ledger](/docs/audit-ledger).
* **Tamper-evident hash chain.** `prev_hash` + `row_hash` columns
  detect silent backfill, reorder, and removal. See
  [Hash chain](/docs/hash-chain).

### Composing-agents cluster [#composing-agents-cluster]

How composable work nests inside a session. Names the unit of
work, spawns the child runtime that executes it, records the
rolling signal that decides whether to spawn it again. Full walk in [Agents](/docs/agents#the-composing-agents-cluster).

* **Skill.** Markdown file with YAML frontmatter; `SkillLoader`
  walks three sources. See [Skills](/docs/skills).
* **Subagent.** Child runtime spawned from a tool call against a
  resolved skill spec. `SUBAGENT_LIMITS.maxDepth = 3` caps the
  nesting. See [Subagents](/docs/subagents).
* **Agent profile.** Persistent registry record keyed by
  `specName`. See [Agents](/docs/agents).

### Runtime-lifecycle cluster [#runtime-lifecycle-cluster]

What happens over time and what gets persisted. Sessions outlive
turns; turns outlive their stream frames; the event log outlives
both. Full walk in [Session lifecycle](/docs/session-lifecycle#the-runtime-lifecycle-cluster).

* **Session lifecycle.** `createSession` / `resumeSession` /
  `deleteSession` — the arc above the turn. See
  [Session lifecycle](/docs/session-lifecycle).
* **Turn lifecycle.** The per-message arc between
  `executeMessage` and the final SSE frame. See
  [Turn lifecycle](/docs/turn-lifecycle).
* **Event log.** Append-only typed stream both lifecycles write
  into. See [Event log](/docs/event-log).

### State-and-persistence cluster [#state-and-persistence-cluster]

What makes a session survive a process restart, a fork or
rewind, and a multi-client edit. Lives below the execution
graph and above the schema bundle. Full walk in [Storage](/docs/storage#the-state-and-persistence-cluster).

* **Storage adapter.** Pluggable surface reading and writing
  `SessionState`. Memory / IndexedDB / Supabase adapters all
  implement the same interface. See [Storage](/docs/storage).
* **Checkpoint.** Per-channel snapshot at every stage boundary.
  `runtime.checkpoints.rollback` restores in place;
  `TimeTravelAPI.fork` branches into a new session. See
  [Checkpointing](/docs/checkpointing).
* **Sync (version vector).** `Record<clientId, number>` per
  session. `compareVectors` flags concurrent writes;
  `SyncCoordinator` surfaces conflicts through `sync.conflict`.
  See [Sync](/docs/sync).

## What lives outside the cluster pattern [#what-lives-outside-the-cluster-pattern]

Eight sidebar groups don't carve cleanly into three-concept
triplets. They aren't deficient — they're shapes the pattern
doesn't fit. Three are surfaces (facets, plugins, tools); five
are heterogeneous concept sets or pairs (safety, observability,
frontend, prompts, cross-session state).

* **Facets.** Typed accessors on `runtime.<name>` —
  `runtime.sessions`, `runtime.events`, `runtime.checkpoints`,
  `runtime.tenant`, `runtime.spans`, and the rest. A surface
  pattern that groups related methods by domain so the runtime
  reads as a short list of named accessors instead of a flat
  method dump. Not a three-concept cluster. See
  [Facets](/docs/facets).
* **Plugins.** The `HarnessPlugin` extension contract — \~40
  optional hooks plus four structural invariants the substrate
  enforces against them. A bounded contract, not a triplet. See
  [Plugin contract](/docs/plugin-contract).
* **Tools.** The `defineTool` contract, Zod-validated input /
  output, per-invocation context, and batching. One surface end
  to end — contract, dispatch, result-handling — not a
  three-concept cluster. See [Tools](/docs/tools).
* **Prompts.** Composition of system prompts from typed
  contributions plus the budgeted composer. A pair
  ([prompts](/docs/prompts) + [prompt builder](/docs/prompt-builder)),
  not a triplet.
* **Cross-session state.** [Plans](/docs/plans) span multiple
  turns; [memory](/docs/memory) spans multiple sessions. Two
  variable surfaces that outlive a single session, each with a
  distinct mechanism (revision history vs decay curve). Not a
  three-concept cluster.
* **Safety & determinism.** `safety`, `scrubbers`,
  `fabrication-detection`, `determinism`, `fingerprint`. Five
  concepts, each with a distinct mechanism; no natural triplet.
  `safety.mdx` orients the reader directly.
* **Observability.** `lineage`, `observability`,
  `otel-observability`, `runtime-inspector`. Distinct surfaces a
  reader usually arrives at already knowing which one they need.
* **Frontend integration.** `react`, `server`, `api-routes`,
  `query`, `devtools`. Wiring surfaces, not concepts.

## Where to go next [#where-to-go-next]

<Cards>
  <Card title="Overview" href="/docs/overview" description="The runtime in pictures — session, turn, the four stages, and the ledger row that closes the loop." />

  <Card title="Architecture" href="/docs/architecture" description="Six pieces of the substrate walked in order — SessionRuntime, CompiledGraph, Channels, Seams, the AuditableCall ledger, and the event log." />

  <Card title="Glossary" href="/docs/glossary" description="Canonical terms — anchor-plan, CallClass, family-lock, seam, and the rest of the vocabulary." />
</Cards>
