Inspiration

Most "AI memory" systems bolt a vector store onto an LLM and call it memory. We wanted to test a stricter claim: that a distributed database's own primitives — TTL, MVCC, transactions — are sufficient to implement the actual mechanics of biological memory: decay, consolidation, and introspection. Not as a metaphor, as a literal mapping.

What it does

SOMNUS is an agent whose memory dynamics are implemented as CockroachDB operations. Episodes decay via row-level TTL. Consolidation (moving episodic memories into stable schemas) is an atomic transaction, so a trace can't be lost mid-transfer. Belief introspection — "what did you believe an hour ago" — is AS OF SYSTEM TIME, not a log replay. A neuromodulatory system (ACh/NA/DA analogues) governs when to encode, when to recall, and when to harden a memory into a permanent schema.

On the benchmark (Task A → drift → Task B → return to Task A unannounced), SOMNUS shows a 66.8% reduction in catastrophic forgetting versus a no-memory control, reproducible in 30 seconds with make bench-full, no credentials required.

How we built it

Python core with an ObservationEncoder → ContextualPredictor loop generating prediction errors, gated by a NeuromodulatorySystem (expected/unexpected uncertainty via CUSUM changepoint detection, dopamine-style novelty/value scoring). Hippocampal writes (episodes with TTL) and neocortical schemas live in CockroachDB, using native VECTOR columns for pattern-completion recall. AWS Bedrock provides Titan embeddings and Claude-based rule generation; S3 archives expired episodes; an MCP server exposes recall/introspection tools directly to Claude Desktop.

Challenges we ran into

CockroachDB is not Postgres with a vector extension bolted on — it rejects pgvector/HNSW syntax outright and expects its native VECTOR type with C-SPANN indexing, which broke our first migration completely. Titan embeddings v2 only accepts 1024/512/256 dimensions (not v1's 1536), silently failing every embed call until we caught it. CockroachDB's serializable isolation meant we had to add explicit 40001 retry handling that a Postgres-first codebase wouldn't need. We also hit a live cluster connection issue late in the timeline that we weren't able to resolve before submission — the system currently runs and is fully tested against an in-memory backend (make run without COCKROACH_DB_URL set), but end-to-end verification against a live CockroachDB Cloud cluster is incomplete.

Accomplishments that we're proud of

The benchmark result is real and independently reproducible — no cherry-picked run, 12 seeds, mean and stdev reported. We also chose to publish the ablation results honestly even though they complicate our own story: the difference between ablation arms (schema recall, metaplastic hardening, interleaved replay) falls within run-to-run variance, and we say so directly rather than hiding it. We'd rather show an accurate picture of what's proven and what isn't.

What we learned

That most of the measured benefit currently comes from one mechanism — noradrenergic changepoint detection triggering a context reset — rather than the full system working in concert. That finding came from actually running the ablations instead of assuming the architecture diagram implies the results. It also told us exactly what the next experiment needs: a task where a single observation isn't enough to identify the regime, so recall has something to actually contribute.

What's next for SOMNUS

Finish and verify the live CockroachDB Cloud + Bedrock integration end-to-end. Package the Lambda sleep-cycle handler (written and tested, not yet deployed — no SAM/CDK, IAM role, or EventBridge schedule exists yet). Implement REM-style generative recombination, which is designed but not built. And redesign the benchmark task so recall and consolidation are forced to earn their keep, rather than mostly measuring the changepoint detector alone.

Built With

Share this project:

Updates

Submission history