> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ngram.space/llms.txt
> Use this file to discover all available pages before exploring further.

# Continuity lives in the runtime

> Follow the boundaries between the Entity, cognition, memory, presence, and inference.

ngram's central object is the Entity. A model request is one operation in its life; it is not the owner of its identity or storage.

```mermaid theme={null}
flowchart TD
  S[Terminal · Telegram · Discord · WebXR] --> P[Presence adapters]
  P --> E[Entity and turn serialization]
  E --> C[Cognition and tool loop]
  C --> I[Controlled inference provider]
  C --> T[Tool registry and execution backends]
  E <--> M[Memory · knowledge · relationships]
  E <--> B[Identity and soma]
  D[Daemon and scheduled routines] --> E
  D --> I
```

## Ownership

| Layer              | Owns                                                                             |
| ------------------ | -------------------------------------------------------------------------------- |
| Entity             | Shared state, turn coordination, provider switching, lifecycle                   |
| Cognition          | Routing, prompt assembly, retrieval context, tool iteration, response completion |
| Memory             | Episodes, beliefs, relational records, knowledge, procedures, consolidation      |
| Identity and soma  | Traits, voice, drive state, simulated body dynamics, generated fragments         |
| Presence           | Platform input/output, background schedules, cross-surface routing               |
| Spatial shell      | Body presentation, animations, browser scene, surface capabilities               |
| Inference provider | Model transport and responses                                                    |

## One turn at a time

Inputs from connected surfaces reach `Entity.perceive`. The Entity serializes complete turns with a shared asynchronous lock, protecting history, body state, relationships, and conversation routing from overlapping changes.

Cancellation and inference-pause controls bypass the normal model turn. That keeps the control path available while the Entity is busy. Pausing also gates the provider shared by background inference consumers.

The lock is scoped to one running Entity process. It is not distributed coordination for independently launched workers sharing arbitrary files.

## Durable state and live context

Live conversation history is assembled for inference and can be compacted. Durable state lives in databases, files, or a portable Entity container. Retrieval chooses which durable material enters a turn; the model does not receive every stored memory each time.

Start with [cognition](/architecture/cognition) to follow a turn, [memory](/architecture/memory) to understand retention, and [presence](/architecture/presence) to understand surfaces and background work.

Source entry point: [`ngram/entity.py`](https://github.com/ngramspatial/ngram/blob/main/ngram/entity.py).
