Skip to main content
CyberOS BRAIN is the platform’s remembering faculty — BRAIN is the name you speak, memory is the name you write in code. Under the hood it is two cooperating layers sharing one source of truth: a tamper-evident Layer 1 store on local disk, and a Layer 2 service that derives searchable, tiered structure from it. Everything any agent or human records — decisions, facts, people, projects — flows through this store and is chained together so that no byte can change without breaking the chain.

Layer 1 — the protocol store

The protocol store is the authoritative record. It lives on disk at .cyberos/memory/store/ relative to your project root, inside the gitignored .cyberos/ tree alongside the CUO workflow engine.
The store is tenant data. It is always gitignored and must never be committed to version control. Keep it local; use cyberos export when you need a portable snapshot.

Store layout

Every store is a self-contained, zippable artefact with a predictable structure:

The four canonical operations

Every mutation to the store is expressed as exactly one of four canonical operations. There is no fifth.

Merkle audit chain

Each audit record carries two chain fields: prev_chain (the chain hash of the preceding record) and chain, computed as:
Monthly binlog segments are binary-framed ([u32 length][u32 crc32c][u64 seq][u64 ts_ns][payload]). At consolidation, sealed segments are compressed with deterministic zstd and a signed tree-head anchor is written to audit/checkpoints/. This means you can replay any record, prove any write happened, or detect any byte-level tampering — even across machines and over time.

Layer 2 — the brain service

Layer 2 reads the Layer 1 store and builds derived structure on top of it:

Embeddings

Per-event embeddings enabling semantic recall over every memory the store has ever recorded.

Summaries

Rolling summaries computed over recent audit rows so agents can load context-efficient snapshots rather than raw ledger data.

Hot / Warm / Cold Tiers

Memories tiered by occurred_at time. Recall answers queries over the hot index with full provenance back to the exact Layer 1 rows.
Access to the Layer 2 service is consent-gated and tenant-scoped with fail-closed row-level security.

Day-to-day usage

Installation and setup

A fresh store is scaffolded automatically when you run npx cyberos install in any project. The installer creates .cyberos/memory/store/ and wires it to the workflow engine. To skip store creation (e.g. in a CI-only environment), set CYBEROS_NO_MEMORY=1. If you need to point agents at a different store location, pass --store <path> or set the CYBEROS_STORE environment variable. Resolution order is: explicit override → nearest .cyberos/memory/store/ walking up from the working directory.
Sandbox and ephemeral paths (e.g. /tmp/, runner scratch directories) are explicitly rejected by the store invariants. If you are running inside a CI runner, set CYBEROS_HOST_MOUNT_PREFIX to exempt a stable mount point, or disable memory with CYBEROS_NO_MEMORY=1.

CLI commands

cyberos doctor derives the store’s current state:

Python API

The public surface is intentionally small:
Everything heavier (SQLite, mmap, msgspec, hashlib) is loaded lazily from subcommand handlers, so a cold python -m cyberos --help starts in under 30 ms.

BRAIN in practice

Add .cyberos/memory/store/ to your .gitignore before your first commit. The installer does this for you, but double-check any repo that was initialised manually. Committing the store exposes tenant data and breaks the single-writer guarantee.
The store enforces a single-writer guarantee: only one process may hold LOCK_EX on .lock at a time. The lock record carries a JSON lease (pid, host, monotonic_ns, expiry_ns) with a 10-second TTL and a 3-second renew interval. Stale leases left by a killed writer are reaped in microseconds. If two agents need to share memories, use cyberos import to merge one store into another — never share a store directory between concurrent writers.
Sandbox and ephemeral paths are rejected at the protocol level (invariant layout-no-sandbox-path in memory.invariants.yaml). A store created at /tmp/ or inside a container scratch layer will be refused on the next doctor run. Use a stable, host-mounted path and set CYBEROS_HOST_MOUNT_PREFIX if needed.

Install CyberOS

Run npx cyberos install in your repo to scaffold the store, the workflow engine, and the agent entry point in one step.