clawql-memory (Memory 2.0)
clawql-memory is ClawQL’s durable knowledge layer — the answer to ephemeral agent state. Chat threads, in-process cache keys, and one-shot RAG chunks disappear when a process restarts or a session ends. Memory persists institutional knowledge as Markdown in an Obsidian-style vault, indexes it for hybrid recall, and (optionally) shares it across teammates.
Hands-on MCP walkthrough: Vault memory between chats · Canonical repo docs: memory-obsidian.md · MCP tools § memory · Modularization § Layer 3
Shipped vs vision: This page describes what memory_ingest /
memory_recall do today, then explains how they fit the broader
Memory 2.0 design (typed graph links, ATRClaims on every recall, semantic
pruning, full WORM on memory events). Items marked roadmap are specified
in DAOS v2.7 and Build plan v2.7.1
but not fully implemented in the MCP path yet.
What problem memory solves
Agents lose context when:
- The MCP server restarts or Kubernetes reschedules a pod
- You open a new chat days later on the same project
- Multiple teammates run isolated vault directories
Memory turns distilled outcomes — decisions, debugging notes, API quirks, runbooks — into files you can diff, back up, and recall. The pattern is sometimes called an LLM wiki or incremental wiki: the model is an editor of stable pages, not only a stateless answerer. See memory-obsidian.md for the Karpathy / Obsidian framing.
| Store | Lifetime | Best for |
|---|---|---|
cache (Core) | Single process, LRU | Scratch keys inside one long session |
memory_ingest / memory_recall | Disk vault | Cross-session and cross-restart handoffs |
| Team sync | Shared object bucket | Same Memory/ tree across teammates |
Core design principles
- Markdown as source of truth — Notes live under
Memory/as plain.mdwith YAML frontmatter. Humans can open the vault in Obsidian or any editor. - Hybrid retrieval — Keyword scoring, wikilink graph hops, and optional vector similarity run together in
memory_recall. - Derived index —
memory.db(SQLite via sql.js) mirrors chunks and link edges; it is rebuilt from Markdown and is not the canonical store. - Governance where it matters — Optional Presidio redaction at the gateway, vault path allowlists, and team sync that never uploads API secrets. Full ATRClaims filtering on every recall and WORM on every memory mutation are roadmap (see DAOS Layer 3).
- Fail-closed sync — Team sync failures are logged but do not block ingest/recall locally.
Architecture: vault, graph index, PageIndex, vectors
Today’s shipped stack is a practical subset of the full Memory 2.0 triple-store in the DAOS spec:
| Component | Shipped role | Technology |
|---|---|---|
| Vault | Canonical Markdown notes | CLAWQL_OBSIDIAN_VAULT_PATH → Memory/<slug>.md |
| Graph index | Wikilink edges + chunk rows | memory.db (wikilink_edge, vault_chunk, …) |
| PageIndex | Vectorless hierarchical tree over Markdown | clawql-pageindex + pageindex_* MCP tools |
| Semantic layer | Optional embedding leg in recall | OpenAI-compatible /embeddings + sqlite or postgres vectors |
Roadmap (DAOS): separate encrypted blob vault, typed link ActionTypes, Merkle root on every node at ingest, and recall filtered by signed ATRClaims purpose. Optional Cuckoo / Merkle snapshot env gates exist in memory.db today for chunk membership experiments — see hybrid-memory-backends.md.
MCP tools and enablement
| Tool | Purpose |
|---|---|
memory_ingest | Write or append structured insights, wikilinks, optional tool output |
memory_recall | Hybrid search over the vault (keyword + links + optional vectors) |
memory_sync | Team sync pull/push when object storage is configured |
pageindex_build_tree | Build a hierarchical index from Markdown |
pageindex_traverse | Walk the tree under a token budget |
pageindex_synthesize | Merge selected nodes into agent context |
pageindex_get_content | Read a indexed node’s body |
Default on; hide all memory + PageIndex tools with CLAWQL_ENABLE_MEMORY=0. Hide PageIndex only with CLAWQL_ENABLE_PAGEINDEX=0. Requires a writable CLAWQL_OBSIDIAN_VAULT_PATH for real I/O.
Ingestion: from agent summary to vault page
A typical memory_ingest flow:
- Agent distills — Goal, done, next, constraints, links (not raw megabyte logs unless via
toolOutputsFile). - Write Markdown — File under
Memory/<slug>.mdwith frontmatter;append: true(default) adds a dated section to an existingtitle. - Wikilinks — Optional
wikilinksarray becomes[[Related Page]]lines in the note. - Index rebuild — On success, ClawQL rescans the recall subtree and refreshes
memory.dbrows (chunks +wikilink_edge). - Index page — Optionally maintains
_INDEX_{Provider}.mdwith navigable wikilinks (CLAWQL_MEMORY_INDEX_PAGE,CLAWQL_MEMORY_INDEX_PROVIDER). - Team sync — If
CLAWQL_SYNC_AUTO=1, debounced push after ingest.
Gateway redaction (opt-in): Presidio hooks can run before persistence when enabled on the gateway — see security. Mandatory pre-store redaction on every memory write is the target DAOS pipeline, not yet the default for all deployments.
Wiki-style linking and the knowledge graph
Wikilinks are ClawQL’s lightweight knowledge graph:
- In prose or via
wikilinks:[[Page Name]]or[[Page Name|alias]]. - Semantics today — Links are untyped: they mean “related page,” like Obsidian. They are not yet
contradictsvsdepends_onenums from the DAOS spec (roadmap). - Graph traversal —
memory_recallwalks forward and backward links up tomaxDepth(env defaultCLAWQL_MEMORY_RECALL_MAX_DEPTH). Results can showreason: "link". - Persistence — Edges are parsed from Markdown and stored in
wikilink_edgeso recall can use the graph even when vector search is off.
Why wikilinks matter: Stable title + wikilinks turn isolated session notes into a navigable web agents can traverse without re-embedding entire histories. Operators can inspect backlinks in Obsidian.
Practical pattern:
{
"title": "Acme API — rate limits",
"insights": "## Finding\n429 when burst > 40 rps.\n\n## Mitigation\nExponential backoff on execute.",
"wikilinks": ["Acme API hardening", "Slack MCP"],
"append": true
}
Hybrid recall: keywords, wikilinks, and vectors
memory_recall always runs a lexical leg: keyword scoring over body, headings, and filenames. It merges wikilink neighbors when maxDepth > 0.
Optional vector leg (all must be configured):
CLAWQL_VECTOR_BACKEND=sqliteorpostgresmemory.dbenabled and embedding API key (OPENAI_API_KEYorCLAWQL_EMBEDDING_API_KEY)- Query embedded via OpenAI-compatible
/embeddings; chunks ranked by similarity
Hits include reason: "keyword", "link", or "vector". Tune limit, maxDepth, minScore, and CLAWQL_MEMORY_RECALL_* env vars.
{
"query": "Acme API rate limit backoff",
"limit": 8,
"maxDepth": 2
}
PageIndex complements vectors: hierarchical traverse + synthesize gives deterministic, token-budgeted context without embeddings — useful when you want stable section addresses. See Phase 1 platform guide § PageIndex.
Roadmap: unified hybrid ranking score across exact PageIndex hits, cosine similarity, and graph proximity with ATRClaims classification filters on each node.
Team sync: shared vaults across agents and teammates
Team sync shares Markdown — not secrets — via object storage:
| Path | Synced? |
|---|---|
Memory/ | Yes — team notes for memory_recall |
sources/, pageindex.db.json, Dashboard/chats/ | Yes (optional) |
vault/providers.json, API secrets | Never |
memory.db | No — rebuilt locally after pull |
CLI: clawql sync init, push, pull, status — providers R2 (default), S3, GCS. MCP: memory_sync with direction: auto (pull then push), pull, or push.
Auto sync on MCP runtime:
| Variable | Behavior |
|---|---|
CLAWQL_SYNC_AUTO=1 | Debounced push after successful memory_ingest |
CLAWQL_SYNC_AUTO_PULL=1 | Throttled pull before memory_recall |
CLAWQL_SYNC_AUTO_PULL_ON_START=1 | Pull once at MCP startup |
Full setup: Team vault sync · For teams.
Roadmap (DAOS): governed publish_to_team_memory ActionTypes, role-based visibility on shared nodes, Ouroboros NSV/SGDOP drift signals between agent swarms, and Diversity Dividends for high-value shared knowledge. Today’s sync is file-level consistency with conflict listing — appropriate for engineering teams sharing a vault prefix.
Self-improving loop: memory meets inference
Memory and clawql-inference form a flywheel when both are deployed:
Production inference (OpenAI-compatible gateway)
→ InferenceRecord stored (prompt, response, tier, evaluator verdict, correlation_id)
→ Agent distills outcomes → memory_ingest (wikilinks + stable titles)
→ memory_recall enriches the next session
→ Verdict-filtered export (passed + min score)
→ PII-scrubbed JSONL + WORM dataset manifest
→ Fine-tune → register model on frugal tier
→ Cheaper, better completions → richer ingest material
Shipped inference pieces:
ObservedInferenceGateway— durable call recordsclawql inference export— filter by--verdict passed, tier,--min-score- Presidio scrubbing on export by default
- Semantic cache on the gateway (embedding similarity) — separate from vault vectors but same embedding habit
Memory’s role: Vault notes capture curated lessons (not every raw completion). Wikilinks connect new findings to existing topics. Team sync spreads refined notes across agents.
Roadmap: automatic distillation of long session history into Memory during semantic pruning (below); evaluator-linked correlation_id edges from inference records into graph nodes; Ouroboros feedback when shared knowledge drifts.
Semantic pruning and pre-pruning snapshots (roadmap)
Long sessions can exhaust context windows. The DAOS design adds a pruning engine (not yet the default MCP experience):
- Trigger — Context utilization ≥
pruning_context_threshold(from Manifest policy) - Distillation — Older turns condensed; verbatim tool results and recent
pruning_retain_turnskept - Causal lock — Turns before pending high-impact actions cannot be pruned
- Pre-pruning snapshot — Bit-perfect encrypted snapshot to cold storage before distillation; WORM audit of the event
Practical substitute today: agents memory_ingest checkpoints before context fills up, and use pageindex_traverse / memory_recall instead of carrying full transcripts. See DAOS § Memory pruning and Build plan P2-A.
Governance, security, and observability
| Control | Shipped | Roadmap |
|---|---|---|
| Vault path + file roots allowlist | ✅ CLAWQL_OBSIDIAN_VAULT_PATH, CLAWQL_MEMORY_INGEST_FILE_ROOTS | |
| Opt-in Presidio at gateway | ✅ | Mandatory on all memory writes |
audit ring buffer (Core) | ✅ Ephemeral MCP breadcrumbs | WORM per memory mutation |
| ATRClaims on recall/ingest | Partial via gateway auth | Per-node classification + purpose |
| Merkle on vault nodes | Optional CLAWQL_MERKLE_* artifacts in memory.db | Per-node Merkle at ingest |
| Legal hold / prune gates | Operator CRD + WORM hold bit |
Treat vault Markdown as sensitive if notes contain tokens or PII. Prefer redaction in prose and short-lived credentials. For enterprise Onyx citations in ingest, see enterpriseCitations in mcp-tools.md.
Related guides and references
- Vault memory between chats — MCP examples, PVC/K8s, append threading
- Cache handoff between chats — when
cacheis enough - Team vault sync — R2/S3/GCS, Helm
teamSync,memory_sync - clawql-inference — export, fine-tune, semantic cache, flywheel
- Memory plugin — env table and tool list
- hybrid-memory-backends.md — sqlite vs postgres vectors
- memory-db-schema.md —
wikilink_edgeand chunks - DAOS Unified Architecture § Layer 3 — full Memory 2.0 vision
