Memory Tiers
Why Three Tiers
Section titled “Why Three Tiers”A single key-value store would be simpler. But a single store forces a tradeoff: either everything is queryable (expensive) or nothing is (useless for synthesis). NEXUS separates memory into three tiers that serve different access patterns.
All three tiers live in engram.db, a single SQLite file, and are accessible through the same context["engram"] interface. The separation is logical, not operational.
Working Memory
Section titled “Working Memory”Working memory is an ephemeral key-value store. It lives only for the current session.
Use it for transient state that is relevant right now but should not persist: the file currently being analyzed, the search query in progress, a partial result being assembled.
# Storeawait context["engram"].store_working("active_file", "/path/to/file.py")
# Retrievepath = await context["engram"].get_working("active_file")
# Clear a specific keyawait context["engram"].clear_working("active_file")Working memory is cleared on nexus forget --yes and at the start of each new session. It is never written to episodic or semantic tiers automatically.
Episodic Memory
Section titled “Episodic Memory”Episodic memory stores timestamped records. Every message, response, and notable event is stored here by the kernel automatically. Modules can also write directly.
The backing index is SQLite FTS5 (full-text search). This means episodic queries are fast keyword searches against natural language content, no LLM, no embeddings, no network call.
# Store an episodic recordawait context["engram"].store_episodic( source="atlas", content="Reviewed cortex.py: added wildcard routing, trust gate unchanged.", tags=["code", "review", "cortex"],)
# Query by keywordresults = await context["engram"].query_episodic("cortex routing", limit=5)
# Query by tagresults = await context["engram"].query_episodic(tags=["code", "review"])Episodic memory accumulates over time. After months of use, it becomes a searchable log of everything NEXUS has done on your behalf.
Semantic Memory
Section titled “Semantic Memory”Semantic memory stores vector embeddings alongside text. Queries return records by embedding similarity rather than keyword match, enabling retrieval of conceptually related content that shares no keywords with the query.
The backing index is sqlite-vec, a SQLite extension for approximate nearest-neighbor search. Embeddings are generated by the configured LLM.
# Store with embeddingembedding = await context["llm"].embed(text)await context["engram"].store_semantic( source="dreamweaver", content=text, embedding=embedding, tags=["synthesis"],)
# Query by similarityquery_vec = await context["llm"].embed("security vulnerability patterns")results = await context["engram"].query_semantic(query_vec, limit=10)Semantic memory is most useful for cross-domain retrieval: finding a security note from Sentry that is conceptually related to a code change analyzed by Atlas, even though the two records share no keywords.
Cross-Domain Synthesis
Section titled “Cross-Domain Synthesis”The reason all three tiers are shared across all modules is synthesis.
When Dreamweaver runs its overnight synthesis pass, it queries all three tiers, searching episodic memory for patterns, pulling semantically similar records across domains, and comparing against working context. A security concern noted by Sentry, a related code smell found by Atlas, and a configuration anomaly logged by Oracle can be connected into a single insight that none of the three modules could have generated alone.
Shared memory is what makes NEXUS more than a collection of independent agents.