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§
- Global
Hit - 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§
- add_
preference - Record a durable user preference. De-duplicated on text (a repeat is a no-op). Returns whether a new preference was stored.
- 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.
- list_
preferences - All stored preferences, oldest first.
- 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 topkhits 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 REPLACEonevent_id); call after embedding a project. Returns how many rows were synced.supersededis flagged from thedecisions.superseded_byprojection so contradicted decisions can be down-ranked at query time.