Skip to main content
Glama
README.md
# SynapseVault

**English** | [简体中文](README.zh-CN.md) | [Changelog (v2.0.0)](CHANGELOG.md) | [Beginner Quick-Start Guide](docs/BEGINNER_GUIDE.md) | [Full User Manual](docs/USER_MANUAL.md) | [完整操作手册 (中文)](docs/USER_MANUAL.zh-CN.md)

[![Release: v2.0.0](https://img.shields.io/badge/release-v2.0.0-0ea5e9)](https://github.com/Krittof/SynapseVault/releases/tag/v2.0.0)
[![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-3776AB?logo=python&logoColor=white)](https://www.python.org/)
[![Dependencies: Zero](https://img.shields.io/badge/core%20deps-0%20(stdlib%20only)-10b981)](#design-philosophy--architecture)
[![OS: Windows | Linux | macOS](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-38bdf8)](#cross-platform-compatibility)
[![License: MIT](https://img.shields.io/badge/license-MIT-818cf8)](LICENSE)
[![SynapseVault MCP server – quality and maintenance score on Glama](https://glama.ai/mcp/servers/Krittof/SynapseVault/badges/score.svg)](https://glama.ai/mcp/servers/Krittof/SynapseVault)

**SynapseVault** (`llm-memory-local`) is a **beyond-naive-vector-DB**, local-first, **zero-dependency Python 3.11+ standard-library** structured long-term memory hub for multi-Agent AI workflows.

Stop repeating your preferences, architecture decisions, and debugging lessons every time you switch between **Cursor**, **Claude Code**, **OpenAI Codex**, **Antigravity**, **DeepSeek Harness (`dsh`)**, or any MCP-compatible AI assistant.

> **Working across multiple machines or a team?** `SynapseVault` is 100% free & MIT for single-machine local use. Need `< 15 ms` offline cross-device sync (Work Laptop ↔ Home Desktop ↔ VPS) over Tailscale/HTTPS + Team RBAC? See **[SynapseVault Pro (Self-Hosted Hub)](#free-local-track-1-vs-self-hosted-hub-pro-track-2)**.

---

## Design Philosophy & Architecture

### 1. Why Not a Naive Vector DB?

Dumping raw chat chunks into a vector database and fetching Top-K by cosine similarity breaks down quickly for long-term coding-agent memory. Modern coding agents (such as Claude Code's `CLAUDE.md` + `MEMORY.md` index and Codex's layered `AGENTS.md` + `MEMORY.md`) have shifted away from naive vector RAG toward **structured, layered, index-first memory**.

SynapseVault follows that same structured paradigm — and extends it **across tools** (bridging Cursor, Claude Code, Codex, Antigravity, `dsh`, and MCP clients through one local SQLite vault) by directly addressing the 4 failure modes of pure vector memory:

| Failure Mode of Pure Vector Memory | SynapseVault's Structured Solution |
| --- | --- |
| **No Time, Version, or Forgetting Semantics** *(old & new decisions collide)* | **Bi-temporal `as_of` validity** + **CAS version chains** (`memory_revisions`) + **`supersedes` / `contradicts` relations** + **Decay / Suppress / Anti-resurrection Tombstones** |
| **Semantic Similarity ≠ Rule Criticality** *(zero-overlap project guardrails get missed)* | Explicit **`pinned` Guaranteed Guardrail Slots** (`[PINNED #id vN ...]`) that are never crowded out under tight Top-3/4 budgets |
| **Near-Duplicate Crowding in Top-K** *(3 paraphrases of one topic drop parallel facts)* | Pure-stdlib **MMR Diversity Reranking** (`ratio-to-max` scale-invariant normalization), lifting compound multi-fact coverage from `50.0%` → **`100.0%`** |
| **Black-Box Un-Auditable Chunks** *(cannot trace which memory caused a bad answer)* | Persisted **`recall_traces`** audit table (`trace_id` + `[#id vN @machine/client]`), **3-Layer Progressive Disclosure MCP** (`memory_index` → `memory_timeline` → `memory_get`), and read-only Git-diffable **Markdown Mirror** (`export-md`) |

### 2. Two Orthogonal Layers: Lifecycle Forgetting vs. Optional Vector Fallback

SynapseVault intentionally separates **memory lifecycle governance** from **optional vector retrieval**:

- **Forgetting & Lifecycle Governance (`Decay` / `Suppress` / `Tombstone` / `Revisions`)** governs *what stays true over time*: stale `transient` notes gently decay while frequently verified memories get bounded access reinforcement (`pinned`, `persona`, and `user_profile` are immune to decay); wrong entries can be version-corrected, soft-suppressed, or permanently tombstoned so re-scans never resurrect them.
- **Optional Vector Retrieval (`Tier 1A` / `Tier 1B`)** is strictly a **semantic blind-spot fallback**, *not* the primary engine. Its sole job is rescuing **zero-lexical-overlap** paraphrases or cross-lingual queries — for example, when a memory is stored only in Chinese (`每天上午习惯喝冰美式咖啡`) without English `search_terms` and later queried in English (`"What caffeinated beverage do I prefer in the morning?"`). Every vector call races against a **620–750 ms deadline** with Query Vector LRU caching and falls back seamlessly to Tier 0 on timeout or offline mode.

### 3. 3-Tier Adaptive Retrieval Engine

Start with zero hardware or API requirements in **Tier 0** (`97.73%` Recall@1 / `100.0%` Recall@5 on curated bilingual memories), and opt into Tier 1 semantic fallback only when needed:

| Tier | Role | Runtime Requirements | Memory / VRAM | Retrieval Strategy | Best For |
| --- | --- | --- | --- | --- | --- |
| **Tier 0** *(Default Primary)* | Zero-Model Structured Lexical + Relational | Pure Python 3.11+ stdlib (SQLite WAL + FTS5) | `~17–25 MB` RAM · **`0 MB` VRAM** | NFKC + CJK 2-gram + BM25 + 3× bilingual `search_terms` + clause MaxSim + dual-scope + 1-hop relations + MMR | Everyday local use, no-GPU laptops, 100% offline privacy |
| **Tier 1A** *(Optional Fallback)* | Cloud / Remote Semantic Blind-Spot Plug-in | Any OpenAI-compatible `/v1/embeddings` API | `~20–28 MB` RAM · **`0 MB` VRAM** | Tier 0 + Cosine Vector Search fused via **RRF** + Query Vector LRU + **620–750 ms** fail-closed fallback to Tier 0 | Zero-overlap cross-lingual / fuzzy phrasing without local GPU |
| **Tier 1B** *(Optional Fallback)* | Local On-Demand GGUF Semantic Plug-in | Local `llama-server` + `.gguf` embedding model | **`0 MB` idle VRAM** (spawns on backfill, exits immediately) | Batch-syncs local vectors on demand, then serves Tier 1 Hybrid RRF offline | 100% offline semantic fallback on machines with local GPU/CPU |

### 4. End-to-End Capture, Governance & Retrieval Flow

1. **Read-Only Capture & Safety Screening**: Turns enter via MCP `memory_capture`, native `dsh` bridge, manual import, or the opt-in read-only incremental watcher (never mutates source logs), pass secret/`blocked_terms` checks and 5-tuple idempotency into the **Staging Inbox**.
2. **Distillation & Lifecycle Persistence**: WebUI curation, a `curator` Agent, or the opt-in LLM Auto-Curator distills atomic memories (`user_profile`, `episode`, `transient`) with bilingual `search_terms` and 1-hop typed relations into SQLite WAL with CAS version chains and anti-resurrection tombstones.
3. **Adaptive Recall, MMR, Guardrails & Audit**: Substantive queries skip small talk, apply bi-temporal `as_of` + gentle decay/reinforcement, score via Tier 0 (plus optional Tier 1 RRF race), rerank with **MMR**, reserve **Pinned Guardrail Slots**, exclude suppressed/forgotten records (`0%` leaks), persist a **`recall_traces`** audit record, and wrap output in `<long_term_memory_context trace_id="...">` with `[#id vN @machine/client]` provenance.

```mermaid
flowchart TD
  subgraph Ingest["1. Capture, Curation & Lifecycle Governance"]
    SRC["Multi-Agent Logs & Clients\n(Cursor / Claude / Codex / dsh / Antigravity)"] -->|"MCP / Hook / Strictly Read-Only Scan"| POL["Secret & Blocked-Term Policy\n+ 5-Tuple Idempotency"]
    POL --> INBOX["Staging Inbox (SQLite)"]
    INBOX -->|"WebUI / Curator Agent / Opt-In LLM Auto-Curator"| DISTILL["Atomic Memories + Bilingual search_terms\n+ 1-Hop Relations + CAS Version Chain"]
    DISTILL --> LIFE["Lifecycle Governance\nBi-Temporal as_of · Decay · Suppress · Tombstone"]
    LIFE --> DB[("Single-File SQLite WAL + FTS5\n+ Recall Traces + Optional Vector Cache")]
  end

  subgraph Recall["2. Structured Recall, Optional Semantic Fallback & Audit"]
    Q["Incoming Query\n(Hook / 16-Tool Progressive MCP / Host Recall)"] --> ABST{"Small-Talk\nAbstention?"}
    ABST -->|"Yes"| EMPTY["Return Empty (0 Noise)"]
    ABST -->|"No"| NORM["NFKC + CJK 2-gram + Identifier Split\n+ Bi-Temporal as_of Validity Filter"]
    NORM --> T0["Tier 0 Primary Engine (0 MB VRAM)\nBM25 + 3x search_terms + Clause MaxSim\n+ Dual-Scope + Gentle Decay/Reinforcement"]
    NORM --> T1{"Optional Tier 1A/1B\nSemantic Fallback?"}
    T1 -->|"Enabled (<= 750ms Race + LRU)"| VEC["Cosine Semantic Rescue\n(Zero-Overlap Paraphrases)"]
    T1 -->|"Off / Timeout Fallback"| RRF["RRF Fusion -> MMR Diversity Rerank\n+ 1-Hop Relation Expansion"]
    T0 --> RRF
    VEC --> RRF
    RRF --> GUARD["Merge Guaranteed Pinned Guardrails\nBlock Suppressed/Tombstoned + Persist recall_traces"]
    GUARD --> OUT["Inject Auditable Budgeted Context\n(trace_id + #id vN @machine/client)"]
  end

  DB -.-> T0
  DB -.-> VEC
  GUARD -.-> DB
```

---

## Advantage Zone & Honest Positioning

No single memory architecture wins every workload. SynapseVault is intentionally engineered for a specific **advantage zone** — and is equally explicit about where heavier graph/cloud systems or pure-Markdown tools fit better:

### Where SynapseVault Wins (Core Advantage Zone)

| Dimension | SynapseVault v1.1 Sweet Spot | Why It Matters in Daily Work |
| --- | --- | --- |
| **Cross-Tool Local Hub** | Unified memory across **Cursor, Claude Code, Codex, Antigravity, DeepSeek Harness (`dsh`), and any MCP client** | One local SQLite vault instead of fragmented per-IDE rules; strictly **read-only** session scanning never mutates original tool logs. |
| **Zero-Infra Footprint** | Pure Python 3.11+ stdlib (`~17–25 MB` RAM, **`0 MB` VRAM**, zero Docker / Postgres / Neo4j) | Runs effortlessly on laptops without GPUs or containers, with instant Tier 0 fallback even offline. |
| **Governance & Auditability** | Version chains (`memory_revisions`), CAS optimistic locks, anti-resurrection tombstones, 4-tier RBAC `scoped_tokens`, persisted **`recall_traces`**, and `[#id vN]` provenance | When an Agent acts on a wrong memory, you can trace the exact `trace_id`, memory ID, version, client, and score — then correct, suppress, or tombstone it. |
| **Tight-Budget Recall Quality** | **MMR diversity reranking** + **guaranteed `pinned` guardrail slots** + **3-layer Progressive Disclosure MCP** (`memory_index` → `memory_timeline` → `memory_get`) | Preserves parallel facts and critical project rules under tight Top-3/4 per-turn budgets, while keeping active MCP exploration ultra-lean. |
| **Modular Upgrade Potential** | Strict 4-layer DAG + **8 swappable Layer 0 `Protocol` contracts** + AST-enforced `<= 550`-line module ceiling | Swap in custom rerankers (`DiversityReranker`), external trace sinks (`RecallTraceStore`), embeddings (`EmbeddingProvider`), or exporters (`MemoryExporter`) without touching core domain logic. |
| **Scale Sweet Spot** | Dozens to **~10,000 distilled atomic facts, rules, preferences, and debugging decisions** per local vault | Sub-10 ms Tier 0 lexical + MaxSim + MMR latency without index bloat. |

### Honest Boundaries (When Another Architecture Fits Better)

| Workload / Requirement | Better-Suited Category & Examples | SynapseVault Position |
| --- | --- | --- |
| **Full-Codebase or 500-Page Raw PDF RAG** | Dedicated code/document RAG indexers | SynapseVault stores distilled atomic facts & decisions, not raw 100k-line source trees or raw book PDFs. |
| **Million-Entity Enterprise Temporal Knowledge Graph** | Server-backed graph/DB systems (**Zep / Graphiti**, **Hindsight**, **Mem0** cloud/Postgres/Neo4j) | SynapseVault deliberately avoids Neo4j/Postgres/Docker to stay single-file local and zero-ops. |
| **Autonomous Stateful Agent OS Runtime** | Self-editing runtime frameworks (**Letta / MemGPT**) | SynapseVault is a tool-agnostic external vault (MCP + Hook), not a replacement Agent runtime. |
| **Single-Tool Built-In Markdown Memory** | Native per-tool files (**Claude Code `MEMORY.md`**, **Codex `AGENTS.md`**) | Complementary, not mutually exclusive: keep static repo instructions in `CLAUDE.md`/`AGENTS.md`, and use SynapseVault to bridge dynamic memory across all your tools and scale past 200-line file limits. |
| **Obsidian-First Manual Note Editing** | File-first Markdown vaults (**Basic Memory**, **ByteRover**) | SQLite is SynapseVault's transactional source of truth; use `synapsevault export-md` whenever you want a clean, read-only, Git-diffable Markdown mirror. |
| **Multi-Device Public Cloud Sync** | Hosted memory APIs (**Supermemory**, **Mem0 Cloud**) | Track 1 binds strictly to `127.0.0.1` loopback for privacy; cross-device self-hosted sync is available in [Track 2 (`llm-memory-hub Pro`)](#free-local-track-1-vs-self-hosted-hub-pro-track-2) via the `SyncTransport` contract. |

---

## Measured Benchmarks (Honest Dual-Baseline)

We separate **structured retrieval ablations** (comparing against strong structured baselines on the same vault) from **raw-history compression** (comparing against re-reading raw chat logs) so every number has a clear, reproducible baseline.

### 1. Structured Retrieval Ablation (`python -m eval.benchmark_ablation` · v1.1)

Tested on compound queries containing 3× near-duplicate paraphrases + distinct parallel facts, pinned project guardrails, and bi-temporal supersession:

| Retrieval Strategy | Multi-Fact Coverage | Pinned Guardrail Adherence | Bi-Temporal `as_of` | Avg Injected Tokens | Trace Audit | P95 Latency |
| --- | --- | --- | --- | --- | --- | --- |
| `Top-10` Unfiltered Lexical | `100.0%` | `16.7%` | — | `184.0` | `0.0%` | `5.52 ms` |
| `Top-3` Nearest-Neighbor (No MMR, No Guardrail) | `50.0%` *(near-dupes crowd out parallel facts)* | `0.0%` | — | `72.8` | `0.0%` | `4.32 ms` |
| `Top-3` Pure MMR (`λ=0.65`) | **`100.0%`** (**+50.0 pp**) | — | — | `~73` | — | `< 6 ms` |
| **SynapseVault v1.1** *(1 Guardrail + 3 MMR + `recall_traces`)* | **`100.0%`** (**+50.0 pp** vs Top-3) | **`100.0%`** | **`100.0%`** | **`100.5`** (**45.4% saved** vs Top-10) | **`100.0%`** | **`15.02 ms`** *(incl. SQLite trace write)* |

### 2. Core Bilingual Stress & Raw-History Comparison (`python -m eval.benchmark_v2` · Tier 0 · 0 MB VRAM)

| Metric | Baseline | SynapseVault (Tier 0) | Improvement |
| --- | --- | --- | --- |
| **Context Tokens vs Raw History** *(4 real multi-Agent sessions)* | `27,502` user-only tokens (`1.75M` full raw JSONL) | **`59.6` avg tokens** per top-3 injection (max `97`) | **99.78% saved vs raw full history** (`461×` smaller) |
| **Retrieval Latency** | `233.2 ms` brute-force scan across 40 local logs | **`4.93 ms`** P95 in-process (`6.34 ms` P50 @ 1,000 memories) | **`47×` faster** (`37×` @ 1k scale) |
| **Real-World Recall** *(12 cross-Agent queries)* | `0%` cold start · `58.3%` naive keyword search | **`100.0%` Recall@1** (`12/12`, MRR `1.000`) | **+41.7 pp** over naive search |
| **Bilingual Stress Recall** *(44 queries + 1,000 memories)* | `63.6%` R@1 / `68.2%` R@5 naive search | **`97.73%` R@1 / `100.0%` R@5** (`0` leaks) | **+34.1 pp R@1 / +31.8 pp R@5** |
| **Idle Footprint** | Heavy resident embedding / vector DB containers | **`~17–25 MB` RAM · `0 MB` VRAM** | Pure stdlib SQLite WAL + FTS5 |

---

## What's New in `v2.0.0` (Major Milestone · 100% Backward-Compatible with v1.x)

> Upgrading from `v1.x` is completely automatic and lossless (`SQLite schema v2 -> v5`, zero breaking API/MCP changes). Full notes in [CHANGELOG.md](CHANGELOG.md).

- **Unified Conflict & Machine-Env Review Modal (with Smart Defaults)**: Unresolved `contradicts` pairs and machine-bound configs (`env:<machine>`) surface together in a 1-by-1 decision popup with deterministic **`★ Default Pick`** recommendations (`human_verified > code_observed > doc_extracted > agent_inferred` > `pinned` > newer), **`Prev` / `Next`** navigation with draft preservation, **`Keep Both`**, and **1-click Resolve All Defaults** / **Rollbackable Approve All**.
- **Safe Backup-First 1-Click Agent Auto-Write & Honest Connection Status**: Auto-detects config files for **Antigravity**, **Cursor**, **Claude**, **Codex**, and **DeepSeek Harness (`dsh`)**; previews exact merged changes (`dry_run`), creates unique `.bak-synapsevault-*` backups before atomic writes, enforces strict directory/filename/symlink guardrails, distinguishes **`● Live`** vs **`✓ Written · Restart App`** vs **`⏳ Awaiting Config`**, and offers **1-click Cancel / Disconnect & Revoke** (never deletes imported memories).
- **Per-Session Import Badges & Anti-Echo Filtering**: Displays **`✓ Imported X/N`** and per-session **`✓ Imported`** / **`🔄 +K new`** badges with 3-layer idempotent deduplication across reconnects, and automatically strips injected `<long_term_memory_context>` / `[记忆 #N | Top-K]` blocks so recalled memory never echoes back into chat imports. *(Note: Staging Inbox intentionally buffers raw chats for noise-free distillation by the opt-in LLM Auto-Curator / Curator Agent and holds machine-local configs for human review.)*
- **Next-Gen Web Console (Light & Dark Themes · Smooth Accordions · Spotlight Tour)**: One-click **Light / Dark theme** toggle (including Light-adapted 2D/3D Canvas Graph), zero-flash CSS Grid accordions across all collapsible panels, **Memories Module Filter dropdown**, streamlined **`⋯`** row menus with 1-click **`🔒 Make Decay-Immune` (`user_profile`)**, clickable **`Active` / `Inbox`** shortcut pills, and a **9-step Interactive Spotlight Walkthrough Tour**.
- **Hardened & ARM64-Verified**: Passed **2 rounds of independent adversarial security & UX audits** (`0` P0 remaining), **63/63** unit & architecture-guard tests (`<= 550` lines/module, `0` third-party Python deps, `0` CDN), and native **ARM64 Linux CI** (`ubuntu-24.04-arm`).

---

## Key Features

- **3 Connection Modes for Every Agent (User-Selectable)**:
  - **Mode A (Automatic Per-Turn Injection)**: Native host bridge for `dsh`; fail-closed `hook-inject` CLI for Claude Code (`UserPromptSubmit`), Cursor (`beforeSubmitPrompt`), and generic hooks — emitting `trace_id`, guaranteed `[PINNED #id vN ...]` guardrails, `auth=<source_authority>` provenance, and `[CONFLICT with=...]` cues.
  - **Mode B (Standard MCP Tools — 21 Tools)**: Zero-dependency MCP stdio server covering standard CRUD/search/curation/relations/vectors plus **3-Layer Progressive Disclosure** (`memory_index`, `memory_timeline`, `memory_get`), **`memory_traces`**, **`memory_pin`**, **`memory_module`**, **`memory_reclassify`**, **`memory_batch`**, and **`memory_reviews`**.
  - **Mode A + B Together**: Automatic per-turn recall + full MCP read/write/progressive-disclosure/audit tools.
- **Machine-Environment Scope (`env:<machine>`), One-by-One Review Modal & 2D/3D Module-Aware Graph (`v1.4.0`)**:
  - **3-Layer Scope Isolation (`personal` / `env:<machine>` / `project:<slug>`)**: Keeps machine-local proxies, toolchains, and LAN hosts in `env:<machine>` (auto-joined for local recall, strictly isolated across machines via `bound_machine` RBAC, and unmount-capable in Modular Packs).
  - **One-by-One Human Review Modal + Rollbackable Approve All**: Machine-bound configs detected during curation are staged for explicit per-item decisions (`Allow -> env:<machine>` / `Keep in project` / `Promote -> personal` / `Discard`) with inline editing, plus a **One-Click Approve All** logged to `batch_audit_log` for 1-click atomic rollback (restoring both memories and pending reviews).
  - **Pure-Canvas 2D / 3D Dual-Mode Relation Graph (Zero CDN, Zero WebGL)**: Hover any node to highlight all memories in the same module (`Scope` / `Topic` / `Kind`), render 2D Convex Hull outlines & viewport-clamped tooltips, lock focus via Module Capsules, inspect clickable neighbors, or orbit the 3D Star Map across 4 projection presets.
- **Full-Auto Global Promotion, Bulk Remediation & Adaptive Injection (`v1.3.0`)**:
  - **Auto-Curator Scope Routing + Leak Guardrail**: Automatically promotes generic cross-project lessons & daily-chat habits into `personal` (`pinned=False`) while deterministically demoting any leaked project slugs, local absolute paths, or private IPs/internal hosts back to `project:<slug>` (supports `auto` and `confirm` modes, with `batch_id` rollback).
  - **Single-Item Reclassify/Promote & Two-Phase Bulk Remediation**: In-place `scope`/`kind` reclassification, one-click scrubbed promotion to global `personal`, plus filtered bulk `move_scope`/`reclassify`/`replace`/`supersede`/`suppress`/`restore`/`forget` protected by mandatory `dry_run` → `confirm_token` preview and atomic 1-click `rollback_batch`.
  - **Adaptive Dynamic Injection Cutoff**: Dual-gate relevance cutoff (`min_score` + `min_ratio_to_top`) dynamically injects `0` items on irrelevant queries, `1` item on simple queries, or expands up to `limit` on rich multi-fact queries (exempting `pinned` guardrails and `contradicts` conflict pairs).
- **4-Tier Truth Authority & Conflict-Safe Recall (`v1.2.0`)**: Ranks conflicting multi-source facts by `human_verified > code_observed > doc_extracted > agent_inferred`, automatically folds active bi-temporal `supersedes` chains out of default recall (recoverable via `as_of` or `include_superseded`), and **protects confirmed `contradicts` pairs from MMR duplicate suppression** with explicit `[CONFLICT]` cues so the LLM surfaces disagreements and asks the user rather than guessing.
- **Modular Memory Packs — Core vs Project/Client Isolation (`v1.2.0`)**: Cleanly separates evergreen **Core Memory (`personal`)** from project/client modules (`project:<slug>` scopes & `#topic` packs). When a client task finishes, **Unmount** it in 1 click (WebUI / `synapsevault module unmount` / MCP `memory_module`) to stop all future recall injections with zero data loss, or batch **Archive** / **Forget** (with a hard guardrail protecting whole-`personal` core).
- **Customizable Recall Injection Budget (`lean` / `balanced` / `deep` / `custom`)**: Tune injection depth vs token spend (`1–15` items, `0–5` pinned guardrail slots, `240–8000` chars, MMR `λ`) globally or per Agent client right from the WebUI Settings panel, HTTP `/v1/config/recall-budget`, or CLI (`synapsevault budget set --preset deep --client claude-code`) — takes effect immediately across hooks with zero client restarts.
- **Strictly Read-Only Multi-Agent Session Scanner**: Auto-discovers local logs from Antigravity, Codex, DeepSeek Harness (`.jsonl.zstd` & `projcache`), Cursor (`agent-transcripts/*.jsonl` & read-only `state.vscdb`), Claude Code, plus persistent custom scan folders (`.jsonl`, `.json`, `.md`, `.txt`).
- **Auditable Governance & Markdown Mirror**: Full `memory_revisions` version history, anti-resurrection tombstones, 4-tier RBAC `scoped_tokens`, persisted `recall_traces` (`synapsevault traces`), `pin` guardrails (`synapsevault pin <id>`), and deterministic read-only Markdown export (`synapsevault export-md --out ./mirror`).
- **Opt-In Full-Auto Loop**: Background incremental read-only watcher + OpenAI-compatible Cloud/Local LLM Auto-Curator (disabled by default for zero idle overhead).
- **Zero-CDN Bilingual Web Console (`ZH` / `EN`)**: Agent Mount Manager, Memory Search/Edit/History, Dynamic Topics, Inbox Curation, 2D Knowledge Graph, and an interactive 4-step Quick-Start Guide.

---

## Quick Start (3 Steps)

> First time setting up MCP or local AI memory? Follow the step-by-step **[Beginner Quick-Start Guide](docs/BEGINNER_GUIDE.md)** ([中文版](docs/BEGINNER_GUIDE.zh-CN.md)). For daily operations, all 7 WebUI tabs, CLI flags, and 16 MCP tools, see the **[Full User Manual](docs/USER_MANUAL.md)** ([完整操作手册](docs/USER_MANUAL.zh-CN.md)).

```bash
# 1. Clone and start loopback daemon (Python 3.11+, zero pip install required)
git clone https://github.com/Krittof/SynapseVault.git
cd SynapseVault
python -m llm_memory.clients.cli daemon --port 8775

# 2. In a second terminal, fetch your local admin token
python -m llm_memory.clients.cli token bootstrap
```

3. Open **`http://127.0.0.1:8775/`**, paste the `lm2_...` token, open **Agent Mounts**, choose **Mode A / Mode B / Mode A+B**, click **Connect**, and paste the auto-filled snippet into your Agent.

> **Where is the Management UI?** The built-in Web Console lives in [`ui/web-console/`](ui/web-console/) and is served automatically at **`http://127.0.0.1:8775/`** whenever the daemon runs (zero build, no Node.js required; do not double-click `index.html` directly). An optional standalone 3D Star Map viewer lives in [`ui/desktop-3d/`](ui/desktop-3d/) (`cd ui/desktop-3d && npm install && npm start`). See [USER_MANUAL.md](docs/USER_MANUAL.md#1-management-ui-locations--how-to-open-them).

---

## Customizing Recall Injection Budget (Token Spend vs Recall Depth)

SynapseVault does **not** hardcode a fixed 3-item injection. You can tune injection volume globally or per Agent client at any time (takes effect immediately across hooks without restarting clients):

| Preset | Items (`limit`) | Pinned Guardrails | Max Chars | MMR `λ` | Typical Use |
| --- | :---: | :---: | :---: | :---: | --- |
| **`lean`** | `3` | `1` | `900` | `0.65` | Ultra-low token spend (~60–80 tokens/turn) |
| **`balanced`** *(default)* | `4` | `1` | `1400` | `0.72` | Everyday multi-Agent coding (~100–130 tokens/turn) |
| **`deep`** | `8` | `2` | `3200` | `0.78` | Complex multi-module refactors & deep context |
| **`custom`** | `1–15` | `0–5` | `240–8000` | `0.05–1.0` | Fine-grained per-turn or per-client tuning |

```bash
# 1. Switch global preset (lean = 3 items / 900 chars, deep = 8 items / 3200 chars)
python -m llm_memory.clients.cli budget set --preset lean
python -m llm_memory.clients.cli budget set --preset deep

# 2. Set different budgets per Agent client (e.g. lean for Cursor, 10-item deep for Claude Code)
python -m llm_memory.clients.cli budget set --client cursor --preset lean
python -m llm_memory.clients.cli budget set --client claude-code --limit 10 --guaranteed 2 --max-chars 4000

# 3. Inspect current global & per-client budgets
python -m llm_memory.clients.cli budget show
```

- **WebUI Live Switch**: Open **`http://127.0.0.1:8775/` → Settings → Custom Recall Injection Budget** to switch presets, adjust sliders with real-time token estimates, or add/remove per-client overrides.
- **Precedence**: `Per-request explicit flags` > `Per-client override` > `Global policy` (for the frozen `dsh` Node adapter, item count scales cleanly within `1–5` to preserve adapter compatibility).

---

## One-Click Agent Deploy & Mount Prompt

Copy and paste the prompt below directly into **Cursor**, **Claude Code**, **Codex**, **Antigravity**, or **DeepSeek Harness (`dsh`)** to let your AI assistant deploy, verify, and mount SynapseVault automatically:

````markdown
Help me deploy and mount SynapseVault (https://github.com/Krittof/SynapseVault) locally on my machine. Follow these steps strictly:

1. **Environment check**: Verify Python >= 3.11 (`python --version` or `python3 --version`) and capture the absolute path of the Python executable.
2. **Clone & verify**: Clone `https://github.com/Krittof/SynapseVault.git` into a dedicated folder (do not scatter files into system directories), then run `python -m unittest discover -s tests/v2 -v` to confirm all tests pass.
3. **Start loopback daemon**: Check if `http://127.0.0.1:8775/v1/health` is already live. If not, start the loopback daemon (`python -m llm_memory.clients.cli daemon --port 8775`, or register auto-start via `deploy/install.ps1` on Windows / `deploy/install.sh` on Linux/macOS after asking me).
4. **Issue least-privilege token**: Issue a scoped token for THIS client (`python -m llm_memory.clients.cli token issue --role contributor --client <client-name> --machine local --scopes "*"`; add `--allow-dsh-host` if mounting `dsh`). Never echo raw tokens back in chat logs unnecessarily.
5. **Non-destructive mount**: Back up my existing client config before editing, then **merge** (never overwrite other MCP servers or settings!) the SynapseVault config using absolute paths for both `python` and `PYTHONPATH`:
   - Choose my preferred mode (ask me first if unclear): **Mode A** (Auto-Inject hook via `hook-inject` / `dsh` host bridge), **Mode B** (Standard MCP `llm_memory.clients.mcp_stdio`), or **Mode A + B** (recommended).
   - Also append the short Auto-Recall / Auto-Capture rule snippet to my client's rules file (`AGENTS.md` / `CLAUDE.md` / `.cursor/rules/llm-memory.mdc` / Global Rules) if I approve.
6. **Verify & report**: Verify `/v1/health`, run a quick smoke check via `hook-inject` or `memory_status`, and tell me the WebUI URL (`http://127.0.0.1:8775/`) plus how to retrieve the admin token (`python -m llm_memory.clients.cli token bootstrap`). Do NOT modify or delete any of my historical chat logs.
````

### Common Deployment Pitfalls & Fixes

| Pitfall / Symptom | Root Cause | Solution |
| --- | --- | --- |
| `No module named llm_memory` when MCP / Hook launches | IDE spawns `python` outside the repo directory without `PYTHONPATH`. | Set `PYTHONPATH` to the **absolute repo path** in `env`, or run `pip install --no-deps -e .` once inside the repo. |
| `python` not found or wrong Python (< 3.11) in MCP subprocess | GUI IDEs often do not inherit your shell `PATH` / conda / pyenv. | Always use the **absolute path** to your Python 3.11+ executable (auto-filled in WebUI templates). |
| Daemon fails to start (`Another llm-memory daemon instance is already running` or port in use) | An instance already owns `daemon.lock`, or another service uses `8775`. | Check `http://127.0.0.1:8775/v1/health` first; if another app uses `8775`, switch to `--port 8776` and update `--origin` in client configs. |
| `HTTP 401 Unauthorized` or `HTTP 403 client_unmounted` | Wrong/revoked token, or the Agent toggle was paused in WebUI. | Re-issue a scoped token for `401`; for `403 client_unmounted`, simply flip the Agent's switch back **ON** in **Agent Mounts** (no re-paste needed). |
| PowerShell blocks `deploy\install.ps1` (`ExecutionPolicy`) | Windows default script execution restriction. | Run `powershell -ExecutionPolicy Bypass -File .\deploy\install.ps1 -Port 8775 -RegisterTask`. |
| Linux / macOS `Permission denied` on `deploy/install.sh` | Executable bit not set after checkout/download. | Run `chmod +x ./deploy/install.sh && ./deploy/install.sh --port 8775 --register-service`. |
| Existing MCP servers disappeared after agent edit | Agent overwrote `mcp.json` / `settings.json` / `config.toml` instead of merging. | Restore the `.bak` backup and merge only the `llm-memory-local` block into `mcpServers` / `hooks`. |
| `dsh` `.jsonl.zstd` logs show fewer turns on a clean Python 3.11–3.13 machine | Pure stdlib falls back to `session_projcache/*.json` when `zstandard` is absent. | Optional: install `pip install zstandard` (or use Python 3.14+ stdlib `compression.zstd`) to stream-decompress full multi-frame `.zstd` logs. |

---

## Cross-Platform Compatibility

| OS | Daemon & Core | Credential Protection | Auto-Start Script | Verified |
| --- | --- | --- | --- | --- |
| **Windows 10 / 11** | Python 3.11+ stdlib, `msvcrt` lock | Windows DPAPI (`.dpapi`) | `.\deploy\install.ps1 -Port 8775 -RegisterTask` (`conhost --headless`) | Full 44-test suite PASS |
| **Linux (Ubuntu / Debian / Arch)** | Python 3.11+ stdlib, `fcntl` lock | `0600` atomic file permissions | `./deploy/install.sh --port 8775 --register-service` (`systemd --user`) | Full 44-test suite PASS (GitHub CI & WSL2) |
| **macOS (Apple Silicon / Intel)** | Python 3.11+ stdlib, `fcntl` lock, `resource` RSS | `0600` atomic file permissions | `./deploy/install.sh --port 8775 --register-service` (`launchd`) | Full 44-test suite PASS (GitHub CI) |

---

## Verification & Benchmarks

```bash
# Full 44-test suite (architecture guards, RBAC, MCP 16 tools, hooks, MMR, recall_budget, traces, export)
python -m unittest discover -s tests/v2 -v

# Bilingual Tier 0 Recall@5 benchmark
python -m eval.benchmark_v2

# Structured ablation benchmark (Top-10 vs Top-3 No-MMR vs SynapseVault v1.1 MMR + Guardrail + Trace)
python -m eval.benchmark_ablation
```

---

## Free Local (Track 1) vs. Self-Hosted Hub Pro (Track 2)

`SynapseVault` (this repository, `v2.0.0`) is **100% free, MIT-licensed, and fully functional** for single-machine multi-agent memory on `127.0.0.1` (`~17–25 MB` RAM, zero third-party dependencies, Schema v5, 21-tool progressive MCP, `env:<machine>` scope isolation, Pure-Canvas 2D/3D graph, customizable recall budgets, MMR diversity, and recall traces).

If you work across **multiple machines** (e.g., Work Laptop ↔ Home Desktop ↔ Linux VPS) or want a **private team memory hub** without running Postgres/Qdrant/Docker bloat — or risking SQLite corruption on Google Drive/Dropbox — there is an optional commercial self-hosted Pro Kit (**SynapseVault Pro**, one-time license, no recurring subscription, includes 12 months of all updates):

| Capability | SynapseVault Local (Free · MIT · v2.0) | SynapseVault Pro ($49 one-time · Self-Hosted Hub) |
| :--- | :---: | :---: |
| Single-machine loopback daemon (`127.0.0.1`, ~21–32 MB RAM, Pure-Canvas 2D/3D Graph) | **Schema v5** (Included) | **Schema v5 + SQLite FTS5 + Perf Profiles** |
| 21-tool Progressive MCP stdio + `env:<machine>` + 4-tier Truth Authority + Recall Traces | Included | Included |
| Authoritative Hub sync (`/v1/sync/delta`, batch capture, hot encrypted backup export) | — | **Included** |
| Streamable HTTP `/mcp` (21 tools) + per-token rate limiting + server `machine` stamping | — | **Included** |
| PC `edge-sync` mirror (`< 15 ms` offline reads + `SIGKILL`-safe Outbox + tombstone purge + synced budgets) | — | **Included** |
| Built-in standalone Mode B scheduled LLM curator (`curator-run`) + Mode A draft fallback | — | **Included** |
| Tailscale zero-domain HTTPS, 2-minute Docker + Caddy stack, `init` / `setup --apply` / `doctor` / `archive` CLI | — | **Included** |

- **SynapseVault Pro ($49 Solo / $149 Team · 14-day refund)**: https://krittof.gumroad.com/l/llm-memory-hub-pro
- **Custom team deployment**: Details and inquiry options are listed on the Pro Kit page.

---

## Future Roadmap

- **Self-Created Detached Multi-Vaults with Per-Agent ACL**: Create physically separate SQLite memory libraries at custom paths/drives, bind each library to specific allowed Agents, and enforce per-library offline locks. See **[docs/ROADMAP_MULTI_VAULT.md](docs/ROADMAP_MULTI_VAULT.md)**.

## Security & Contributing

- Security model & reporting: **[SECURITY.md](SECURITY.md)**
- Architecture guardrails & contribution guide: **[CONTRIBUTING.md](CONTRIBUTING.md)**
- License: **[MIT](LICENSE)**

TDQS

B3.2/5.0

Scored across 21 tools

Disambiguation3/5

Several read paths are cleanly separated by the progressive-disclosure tiers (memory_index / memory_search / memory_get / memory_timeline), but the write and mutation surface overlaps: memory_add, memory_capture, and memory_consolidate_commit all create memory content, while memory_pin and memory_reclassify both mutate importance/source_authority, and memory_suppress vs memory_forget vs memory_module suppress/forget differ mainly by blast radius. The descriptions do clarify admin-vs-agent roles and staging-vs-official semantics, which keeps an agent from catastrophic misselection, but boundaries are not crisp.

Naming Consistency4/5

All 21 tools share a uniform `memory_` prefix in snake_case, which is highly predictable. The only deviation is that some suffixes are verbs (add, correct, search, get, relate, suppress, forget, capture) while others are nouns or noun_verb compounds (index, module, batch, reviews, timeline, traces, status, vectors_upsert, consolidate_pull), so the pattern is consistent in style but not uniformly verb-first.

Tool Count3/5

21 tools sits in the heavy band for what is fundamentally a memory store. The tiered read path and vector maintenance justify some of the count, but the admin/curation surface (batch, reviews, two consolidate steps, vectors_missing/upsert, status, traces) pushes toward a size where an agent must reason carefully about which entrypoint applies.

Completeness4/5

The lifecycle is largely covered: capture -> consolidate commit -> search/get/index/timeline -> correct -> suppress/restore -> forget with tombstones, plus relations, vectors, audit traces, and batch rollback. The notable gap is relation maintenance: memory_relate only creates directed edges, with no tool to delete, retype, or list-and-prune a relation, leaving a dead end for correcting bad edges.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues