This document is the design outline for the repo-graph, intent-native memory, resource-ingestion, retention-supervision, and privacy-receipt additions introduced with schema version 3.
flowchart LR
Agent["Agent / host LLM"] --> Intent["remember · link · recall_context (compact) · recall"]
CLI["engraphis-graph CLI"] --> Service["MemoryService"]
MCP["Smart MCP (9 tools) / Classic MCP (34 tools)"] --> Service
HTTP["Dashboard + read-only graph HTTP"] --> Service
Import["Local resources / PostgreSQL catalog"] --> Extractors["Optional local extractors"]
Extractors --> Service
Service --> Engine["MemoryEngine"]
Engine --> Recall["Hybrid recall\nvector + lexical + layered graph"]
Engine --> Resolver["ADD · NOOP · INVALIDATE"]
Engine --> Code["Incremental code index\nAST + regex fallback"]
Engine --> Retention["Optional retention supervisor"]
Recall --> SQLite[("One SQLite file")]
Resolver --> SQLite
Code --> SQLite
Retention --> SQLite
SQLite --> Layers["Temporal · Entity · Causal · Semantic"]
SQLite --> Bridge["Code ↔ Memory links"]
SQLite --> Receipts["Hashed receipt chain"]
SQLite --> History["Bi-temporal history"]
- One service contract. MCP, REST, the dashboard, the CLI, and the read-only server call
MemoryService; none implements independent memory semantics. - One database, logical graph overlays.
edges,mem_links, andcode_edgescarry alayertag (temporal,entity,causal, orsemantic). Filters select overlays without creating separate stores. - Structural and experiential knowledge stay normalized. Code symbols remain in
symbols/code_edges; memories remain inmemories;code_memory_linksconnects them. Re-indexing can replace a changed file without copying memory text or losing history. - Incremental code indexing.
code_filesrecords content hashes. Unchanged files are skipped, changed files are transactionally replaced, deleted files are removed only after a complete scan, and bounded/truncated scans never delete unseen state. - Offline community analysis. Weighted label propagation identifies structural communities without adding an igraph/Leiden dependency to the core. Degree, cross-file degree, god-node flags, and surprising cross-file relationships feed impact analysis.
- Intent-native recall.
intent_recallmaps cognitive intents such asexplain,summarize history, andlocate codeonto layered graph traversal plus normal vector/lexical recall. Existingengraphis_remember,engraphis_link, andengraphis_recallremain the canonical MCP primitives, avoiding duplicate APIs. - Local resource adapters. Text, code, HTML, and DOCX use the standard library. PDF, image OCR, audio/video transcription, and PostgreSQL introspection are optional backends. Missing tools fail actionably; nothing uploads implicitly.
- Advisory retention supervision. A host or configured LLM may classify a write as
ephemeral,normal, orcritical. The engine clamps importance/stability and records the decision; it never silently discards or hard-deletes a memory. - Privacy-safe receipts. Remember/link/recall and indexing operations append content-free, SHA-256-chained receipts with an independently maintained local head/count anchor. Raw memory/query text, workspace names, IDs, and actor identities are excluded from the exported payload. A previously exported head/count can be supplied during verification to anchor the chain outside the database.
- Local-safe exposure. The public dashboard is single-user and supports an optional local
bearer token. The optional
engraphis-graph-serverexposes only read operations and refuses a non-loopback bind without a bearer token. Team identity, roles, and seats are hosted services.
- Layer columns on
edges,mem_links, andcode_edges; durable rationale onmem_links. code_filesfor incremental indexing.code_memory_linksfor code/experience traversal.operation_receiptsplusreceipt_chain_headsfor the privacy-safe hash chain and tail anchor.symbols.docstringfor extracted documentation.
Migration is additive and idempotent. Pre-v3 edge layers are inferred exactly once; explicitly selected layers are never reclassified when a database is reopened.
MemoryEngine.create() and MemoryService.create() default to the exact NumPy index, even when
sqlite-vec is installed, so the default remains portable and deterministic. sqlite-vec and
SQLCipher load incompatible SQLite native libraries in one process: with vector_backend="auto"
Engraphis falls back to NumPy; an explicit vector_backend="sqlite-vec" fails with an actionable
error. Packaged dashboard, REST, and MCP entrypoints use the auto setting, so an installed
vector extra is selected without changing the deterministic constructor contract. Run accelerated
search in a fresh process when using the SQLCipher extra.
The active vector space also needs a durable, secret-free identity. Sentence Transformers use the
resolved Hub commit or a manifest of local artifacts; an unresolved mutable model leaves persistent
vector recall gated rather than mixing embeddings. ApiEmbedder remains valid for ephemeral calls
without identity, but persistent use requires an operator/provider space_version. Its provider
root and /v1 base forms normalize to one /v1/embeddings endpoint.
Recall defaults to the balanced retrieval profile and planning="off". The explicit fast
profile keeps vector + lexical retrieval while skipping graph traversal for small or
latency-sensitive vaults. Opt-in
planning="auto" keeps the original query, admits at most two deterministic or injected query
routes, and fuses them before reranking against the original query. mtype_limits, when provided,
are post-rerank maximum counts rather than relevance boosts. Every packed response has a stable
context_revision derived from the token-counter identity and ordered packed excerpts, so a host
can retain an unchanged prompt prefix. Planner output, per-query rankings, cap drops, and fallback
reasons appear only with diagnostics=True.
The offline planner is the default injected implementation. An application can opt into an LLM
planner without coupling core/ to a provider:
from engraphis.backends.query_planner import LLMQueryPlanner
from engraphis.core.engine import MemoryEngine
engine = MemoryEngine.create(
"engraphis.db",
query_planner=LLMQueryPlanner(my_llm),
)
result = engine.recall(
"why does ReleaseGate depend on AuditLog?",
workspace_id="ws_...",
planning="auto",
mtype_limits={"working": 1, "semantic": 3},
)Planner failures and provider deadlines fail open to the original single-query plan. Planned recall remains opt-in until the checked-in budget, safety, and official LongMemEval-V2 gates justify a default change.
engraphis-graph index -w acme -r api --root .
engraphis-graph search -w acme -r api "UserService"
engraphis-graph query -w acme -r api "where is token rotation implemented?"
engraphis-graph explain -w acme -r api "why does deploy depend on approval?"
engraphis-graph path -w acme -r api UserService DatabasePool
engraphis-graph impact -w acme -r api --root . --git-range origin/main...HEAD
engraphis-graph prs -w acme -r api --base main --head HEAD
engraphis-graph export -w acme -r api -o engraphis-graph-outexport writes graph.json, graph.html, and GRAPH_REPORT.md. A local union merge driver can
be installed with:
engraphis-graph install-merge-driver --root .pip install "engraphis[documents]" # PDF + image OCR bindings
pip install "engraphis[transcription]" # faster-whisper
pip install "engraphis[postgres]" # psycopgFor transcription, set ENGRAPHIS_WHISPER_MODEL to a local model path or an explicitly chosen
model name. For PostgreSQL CLI ingestion, set ENGRAPHIS_POSTGRES_DSN; the value is never stored.