Skip to content

Memory 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 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.

# Store
await context["engram"].store_working("active_file", "/path/to/file.py")
# Retrieve
path = await context["engram"].get_working("active_file")
# Clear a specific key
await 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 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 record
await context["engram"].store_episodic(
source="atlas",
content="Reviewed cortex.py: added wildcard routing, trust gate unchanged.",
tags=["code", "review", "cortex"],
)
# Query by keyword
results = await context["engram"].query_episodic("cortex routing", limit=5)
# Query by tag
results = 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 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 embedding
embedding = await context["llm"].embed(text)
await context["engram"].store_semantic(
source="dreamweaver",
content=text,
embedding=embedding,
tags=["synthesis"],
)
# Query by similarity
query_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.

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.