Skip to main content

Module memory

Module memory 

Source
Expand description

Global cross-project memory index (Pillar B).

A single SQLite file (data_dir/memory.sqlite) mirrors the high-signal events — decisions, rejections, constraints (and, later, consolidated semantic/procedural/preference facts) — from every project, together with their embeddings. This is what lets the agent recall relevant prior reasoning across its whole history, not just the current repo — the thing single-project memory tools can’t do.

The index is a denormalised cache: the per-project JSONL logs remain the source of truth. It is rebuilt idempotently by sync_from_project and queried by search.

Structs§

GlobalHit
A cross-project recall hit.

Constants§

HIGH_SIGNAL_TYPES
Event types worth surfacing proactively: a committed choice, a ruled-out path, or an external limit. These are the reasoning the agent most wants before repeating itself.

Functions§

count
Count of indexed entries (test/stats helper).
keyword_search
Fast keyword (FTS5) search over the global index — no embedding, so it’s cheap enough to run on every prompt in the proactive hook (loading a model per prompt would be too slow). Builds an OR query from the prompt’s alphanumeric tokens (≥4 chars) and ranks by BM25.
open
Open (creating + migrating) the global memory database at path.
search
Semantic search across the whole global index for the embedder’s model. Returns the top k hits by cosine, with a small penalty applied to superseded/contradicted entries so live reasoning ranks above stale.
sync_from_project
Copy this project’s high-signal embedded events into the global index. Idempotent (INSERT OR REPLACE on event_id); call after embedding a project. Returns how many rows were synced. superseded is flagged from the decisions.superseded_by projection so contradicted decisions can be down-ranked at query time.