Skip to content
Projects

About

Memory Bridge MemoryBridge — a cross-device, cross-platform shared memory layer for AI | CDSMP implementation

AI & Machine Learning

How these counts are measured

Measured star growth

in 24h
0
in 7 days
+26
in 15 days
+70
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README_EN.md

Original

MemoryBridge (记忆桥)

🌉 Give your AI a memory that follows you — a cross-device × cross-platform shared memory layer.

The official engineering implementation of CDSMP (Cross-Device Semantic Memory Persistence). 中文文档 · Design RFC · Container consistency RFC · Roadmap · Mobile guide · Threat model · Changelog

Version

The problem

You discuss a hard problem with your AI on the phone during the commute; back at your desk you want to continue on the PC — and today that means scrolling history, copy-pasting, and re-explaining everything.

Cloud full-sync is heavy and often unacceptable for privacy; RAG is passive retrieval that only kicks in after you switch; mainstream memory systems (Mem0, MemGPT/Letta, …) are effectively device-locked.

MemoryBridge takes a different position:

  1. Cross-device continuity — memory follows the person, not the app. Devices share one semantic memory graph, synchronized with incremental delta packets, never full dumps.
  2. Edge preloading — before you even open the new device, hot memories are already pushed there. Switching is continuous instead of "switch, then wait for retrieval".
  3. Content freezing — MemoryBridge only extracts associations and tunes structural parameters; it never rewrites your raw memory content. Per the Faulty Memory line of research, letting an LLM auto-abstract/rewrite memory inevitably injects hallucinated distortion.

And it is cross-platform: via MCP, one memory store is shared by Claude Code, Cursor, Cline, and any MCP client. See the coverage matrix in the Chinese README.

Platform coverage

Channel Platforms Status
membridge init auto-config (MCP) ZCode, Claude Code, Claude Desktop, Cursor, Cline, Windsurf, VS Code (Copilot), Gemini CLI, Qwen Code ✅
init skill install (SKILL.md) WorkBuddy (~/.workbuddy/skills), Claude skills dir ✅
Remote MCP (HTTP mode) Coze and other remote-MCP platforms via membridge mcp --http ✅
Manual guides ByteDance TRAE and UI-based MCP clients (init prints steps) ✅
Phones / tablets (gateway, "base-station" mode) membridge gateway: browsers on iOS / Android / tablets (built-in pocket-note page, add-to-home-screen) and any HTTP client such as iOS Shortcuts; Android can also run a full node via Termux (mobile guide) ✅ v0.11
Browser extension Doubao, Kimi, ChatGPT web, … 📋

Status (v0.33)

Capability Status
Session index + rule pinning + skip classification (v0.33) — session-ingest scans session archives read-only and writes one syncable index line per task (date + title + artifact filenames + session id): zero LLM, no conversation body, content-deduplicated, PAMS still applies. It closes the last gap where a task was finished but never written to the store. Memories tagged rule / lesson / 勿再 are kept in the hook's candidate pool regardless of heat ranking and get priority when task keywords match. sync / fetch now split skips into normal (archived / self-published / duplicate) and ⚠️ abnormal (passphrase or corrupt packet), so "fetched 0" is no longer misread as a broken sync ✅ v0.33
Automatic injection (v0.32) After membridge hook --install, a hook feeds the matching memories into the context at session start and/or on each message. --warm precomputes a heat-ranked candidate pool plus the handoff workbench into ~/.membridge/inject-cache.json while the machine is idle, so conversation time only reads that cache — milliseconds, no DB open, no embedding pass. No match means not a single byte is emitted (silence contract), so irrelevant memories never burn tokens. It appends only its own hook entry (the command carries the -m membridge hook marker), leaves every other hook untouched, and backs up the host config before writing; --uninstall removes just its own. --events session pays the cost once per session, --events prompt once per message
Zero-config cross-device sync (the password is written into the project docs, in encrypted form) — the channel key is deterministically derived from a source-code seed (PBKDF2-HMAC-SHA256, 200,000 rounds, stdlib only), so every end computes it locally and gets byte-identical results; the channel folder no longer holds a plaintext key file. The README publishes the algorithm / salt / round count / self-check ciphertext verbatim, so any AI or language can derive the key and open packets without installing this project. Local historical passphrases (env var / vault) no longer shadow it, and as of v0.31.1 a leftover channel.key in the channel folder no longer shadows it either — the derived value is the single source of truth, and an old key is only a fallback for opening packets sealed by not-yet-upgraded devices ✅ v0.31 / v0.31.1
Time-window retrieval (Hindsight borrowing — structure layer only) — scope gains at:: relative at:7d / at:12h / at:30m / at:2w, month at:2026-09, day at:2026-09-20, range at:2026-09-01..2026-09-20 (either side omittable, right end includes that whole day). Mirrors Hindsight's 4th recall route (temporal), filtering before fusion; pure stdlib, invalid syntax = no filter, tag: / scene: / kind: behaviour byte-identical ✅ v0.30
Evidence count (proof count, Hindsight borrowing) — counts how many distinct memories reference a node (in+out edges deduped): search appends a read-only · referenced by N memories suffix and the count acts as the RRF tie-breaker. Deliberately absent from the injected context block (every character there is a recurring token cost). Edge relations stored since v0.14 become visible outside the store for the first time ✅ v0.30
Container consistency (declarable, reconcilable schema across ends) — a container manifest (schema.py) reads the local store and emits a device identity card (schema version / node+edge fields / kind enum / storage planes / migration registry); membridge schema shows the local card, --peer reconciles against any remote card in both directions, auto-ALTERs missing columns via the migration registry; deltas now carry an edges_v2 5-tuple (src, dst, weight, kind, evidence) reconciled before apply — v0.14's typed edges no longer degrade across devices ✅ v0.16
Storage-plane declaration (inspired by mem0) — manifest declares graph (edges) / vector (nodes.embedding) / kv (meta) planes, read from the actual table structure; a missing plane changes the fingerprint and shows up in doctor ✅ v0.16
Seq version negotiation (inspired by rig) — outbound deltas get a monotonically increasing seq; receivers track a per-device sync_watermark (monotonic), duplicate/out-of-order packets converge idempotently via content-fingerprint dedup ✅ v0.16
Channel key travels with the channel — (superseded by v0.31: the key is no longer a file in the channel folder; it is derived from the source seed, so there is nothing to sync and nothing to hand over. Kept here as history.) The original v0.17 design put a channel.key in the channel folder so it reached every end through the cloud drive: no passphrase to remember, transfer, or read aloud across devices ✅ v0.17 → v0.31
Device heartbeat (see who is on the channel at a glance) — each end writes only its own devices/<device>.json (name / platform / last seen / node count / container fingerprint). Write-only-your-own means no shared mutable state, so zero conflicts; init registers too, so a device that never published is no longer invisible ✅ v0.17
membridge sync one-command bidirectional — fetch other devices' memories, then publish your own, in one line of output. Web / phone / tablet align without a scheduler; every end shares the same rhythm ✅ v0.17
Channel wiring descriptor — configure once, every end follows The device you configure encrypts "which drive / remote sub-path / role / credential" into wiring.json inside the channel folder — written exactly once: the writer is unique (written_by; every other device is read-only), so there is no shared mutable state and no wiring (1).json conflict copy ever appears (same rule as the devices/ heartbeat). Every other end's init reads it and wires itself up automatically, with no second entry of account or app password. Credentials use the same encryption chain as delta packages (Fernet + PBKDF2, random salt carried in the file); the plaintext part holds only writer/time/version/channel id, while account and password are encrypted as one block; without the key it writes nothing (nocrypto) instead of plaintext. Wiring state also moved back to a local file <store dir>/netdisk.json (it used to live inside the shared drive, where cross-end read-modify-write loses updates; the old location is auto-migrated and the old file is never deleted)
Cloud-drive reach for headless ends — dual drives, primary/backup split (Jianguoyun primary + OneDrive backup) — three-step wiring for headless Linux: rclone readiness (auto-installed in containers) → authorization (credentials written to rclone config only, mode 600, never printed) → initial pull of the channel folder. Jianguoyun/Nutstore uses WebDAV + an app password (reachable from every end, no browser round-trip; the password is rclone obscured before it touches disk) and is the primary channel; OneDrive is the backup that takes over if Jianguoyun has problems — not deprecated; there is always exactly one primary. One channel folder can carry both drives at once (primary runs first in every sync round; --role overrides the default). On PC / Mac with an existing drive client it takes a shortcut: detect the local drive folder and point at it, zero configuration. netdisk-sync runs one full round per wired drive of folder-level bidirectional + package-level sync; channel --move relocates the channel host in one command (v0.20); old rclone without bisync auto-degrades to fetch-then-push double copy (v0.21); the health check recognises desktop-client direct sync and --dir falls back to the configured channel (v0.22) ✅ v0.22
Shift handover (handover cards + workbench) — a third memory kind kind=handover: when a task phase ends, the context runs low, or you're about to switch devices, write a handover card (line-prefix convention goal:/done:/failed:/next:/refs:; the failed line keeps the hard format "tried X; failed because Y; don't retry unless Z"). The newest non-stale card becomes the workbench, injected constantly — a state declaration, not a retrieval hit, so it skips relevance ranking and the silence contract; a new card automatically supersedes the old one (supersession is derived, zero new state — every device converges on the same card after sync); cards stale >7 days silently demote to ordinary memory (an outdated workbench is worse than none); handover-touched edges get a structural weight decay so a card can't become a super-hub; membridge handoff shows the workbench, membridge handoff-hint prints a resident reminder, and the pocket-note page ships a five-line card form ✅ v0.15
Typed edges + evidence — every edge carries a kind (semantic / cooccur / entity) plus a tiny evidence note, so every link answers "why are these two related?"; existing stores migrate on open (old edges labeled semantic) — structure only, content untouched ✅ v0.14
Entity-anchor edges — zero-dependency regex extraction of code symbols / file paths / repos / tags as deterministic anchors; memories sharing an anchor get linked — no reliance on literal coincidence, works across mixed Chinese-English phrasing ✅ v0.14
Cluster preload — preload --cluster: union-find splits memory into clusters and preloads the whole cluster around the hottest node — on a new device, the entire task-line context is already in place ✅ v0.14
Recall-reason annotation — context marks each line with a tiny hit path (vector / keyword / graph) so users can judge at a glance whether to trust a memory; hybrid_search stays a compatible thin wrapper ✅ v0.14
Channel convergence (all devices point at the same cloud channel) — a channel ID card channel.json: the first device creates it, every later device auto-adopts it at init / sync time; a split (local ID ≠ the ID card in the channel) warns loudly — first come, first served, the card is never rewritten; membridge channel shows the whole picture in one screen (local channel / ID card / devices seen in the channel); OneDrive multi-root detection (OneDrive - Personal-style variants); doctor channel-health warnings. Pure metadata: no passphrase, never touches memory content ✅ v0.13
Gateway observability + IP allowlist — what a resident base-station service needs to debug: uptime / request count / adds / searches / hits reported live by /health and shown in the pocket-note page; --allow admits clients by IP/prefix — token first, allowlist second ✅ v0.12
Phone / tablet access — membridge gateway (base-station mode): one always-on home device runs a token-protected HTTP gateway; phones read/write that device's store without holding a full copy (they only ever need Add / Search / Preload). Built-in pocket-note web page; iOS Shortcuts and any HTTP client work out of the box; pure stdlib, zero new dependencies. A retired phone makes a fine 24/7 low-power base station (5–10 W) and can pair with OlliteRT local models into a zero-cloud personal AI stack — see the mobile guide ✅ v0.11
Markdown export view — membridge export renders the whole store as human-readable Markdown (grouped by scene, sectioned by fact/procedure, with device/time provenance): a read-only view that never writes back — memories become auditable, git-friendly, portable ✅ v0.10
Resident recall hint — membridge recall-hint prints a one-liner you may paste into CLAUDE.md / AGENTS.md: "recall before you answer" instead of "hope the agent remembers to search"; prints only, never edits host files ✅ v0.10
Hybrid retrieval + RRF — three recall routes (vector + keyword for exact-literal matches + one-hop SAN graph) fused by Reciprocal Rank Fusion (k=60): multi-route consensus wins, nothing to tune ✅ v0.9
Budgeted injection + silence contract — Path A blocks obey a token budget; the first over-budget entry is injected as a prefix of the original text (truncation ≠ rewriting — content freezing intact); when nothing passes the quality bar the tool says so ("no intervention this turn") instead of padding weak hits; since v0.26 overflow recalls degrade to one-line pointers (mb:#id snippet, fetch full text via search "snippet" when needed, inspired by Headroom CCR — the source stays frozen in the store, only the injected view shrinks), with stable-prefix section ordering and byte-identical output for identical input to hit host KV-cache ✅ v0.9 / v0.26
Slim MCP tool descriptions — each of the 3 tool descriptions compressed to one line: descriptions live in every client session, so this is where token savings start ✅ v0.9
Gap discovery — zero-hit queries are logged locally (pure metadata) and surfaced by doctor: the system only reminds; what gets written is always the user's call ✅ v0.9
Optional kind tagging — fact (stable facts) / procedure (what was tried, what happened); strictly optional ✅ v0.9
Incremental edge building — on write, only the new node is paired against existing nodes (O(n), no more full O(n²) recompute per add); membridge rebuild-edges is the explicit full-rebuild exit ✅ v0.8
Engineering robustness — SQLite WAL concurrency + single atomic transaction (add + edge building, delta apply); delta packets split into "data error → skip" vs "environment error → kept for retry" ✅ v0.8
Token economy — MCP tools consolidated to 3 (memory_context merged into memory_search), retrieval relative-threshold filters weak hits, oversized memories get a soft "one sentence per memory" hint on write ✅ v0.8
doctor location health — warns when the DB sits in a temp/generated directory, when the default DB and the env-var DB coexist (likely a split store), or when the device name is unset ✅ v0.8
Storage & retrieval — embeddings stored as float32 BLOBs (⅓–⅕ of the JSON size, legacy DBs auto-migrate on open); two-phase search with an in-process vector cache ✅ v0.8
One-command setup — membridge init: mandatory cloud channel (auto-picked by priority rule; when no drive client is detected, an interactive guided wiring takes over — reassurance copy, step-by-step Jianguoyun primary wiring, connection gate with an explicit "later" exit, optional OneDrive backup question, v0.25), channel key derived from the source seed — nothing to remember or hand over (before v0.31 a sync passphrase was auto-generated & vaulted: DPAPI on Windows, a permission-600 file vault bound to the local user on Linux/macOS since v0.23; that vault is now ignored and only produces a notice), scheduled auto-sync every 15 min, platform auto-config + WorkBuddy skill install ✅ implemented
Auto-sync engine — important memories upload immediately, routine ones batched (≥5 or ≥24h), local-tagged never leave the device ✅ implemented
SAN (semantic association network, w_ij = λ·co-occurrence + (1−λ)·cosine) ✅ implemented
Path A injection (auditable context block) ✅ implemented
MCP server (Add / Search / Preload only) + remote HTTP mode for Coze-class platforms ✅ implemented
DSS delta sync (semantic fingerprints, ε quantization, embedder-consistency handshake) ✅ implemented
Netdisk-folder transport (--force rebuilds a wiped channel) + end-to-end encryption ✅ implemented
PAMS privacy gates (L1 migration tags + L2 scene domains) ✅ implemented; L3 DP deferred
TMT heat & preloading (recency × frequency heuristic) ✅ heuristic done; edge tiers in Phase 3
Encryption key (automatic by default, manual for special cases) Default and mainstream: automatic derivation — the channel key is computed deterministically from the source seed, so day to day you pass nothing at all, and every end on the same channel lands on the same key by itself (an AI can take over just by reading the docs). Manual only for specific cases: --passphrase your-passphrase, used to carry memories by hand to a portable drive / USB stick / offline archive, to decrypt on a machine that doesn't have MemoryBridge installed, or to give different channels different keys. Precedence: --passphrase > source-seed derivation > environment variable > vault. ⚠️ Do not set a MEMBRIDGE_PASSPHRASE environment variable: it is per-machine history, invisible across machines, and will be ignored with a warning
Portable membridge.exe (ncnn-style per-platform binaries) ✅ v0.4
AEE adaptive evolution (α / π_nav / θ_window) 📋 Phase 4 (interfaces reserved)
Path B hidden-state fusion 🧪 Phase 4 experimental branch

How it differs from alternatives

MemoryBridge OpenMemory (mem0) MemGPT/Letta memU
Cross-app sharing (MCP) ✅ ✅ — ✅ (host adapters)
Cross-device sync (phone↔PC↔edge) ✅ core capability (E2E encrypted; the netdisk only ever sees ciphertext) ❌ device-locked ❌ via its hosted cloud
Preloading before you switch (zero wait) ✅ ❌ passive retrieval ❌ ❌
Content freezing (never rewrites memory) ✅ architectural constraint ❌ LLM summarization partial ❌ (LLM auto-distillation into the store)
Human-auditable memory ✅ v0.10 Markdown export view ❌ ❌ ✅ (Markdown as memory)
Privacy tiers (migration tags + scene domains) ✅ partial ❌ ❌

memU deserves credit: its automatic skill distillation and zero-LLM backend are genuinely good. The fork is where memory content comes from — memU lets the LLM distill and generate it; MemoryBridge insists on explicit writes (memory_add), with experience captured via the kind=procedure convention below, so hallucinations never get a path into the store.

Field convergence: external memory is getting backed by frontier research

MemoryBridge's three differentiators are not isolated design choices. In 2026, frontier work converged on the same route from three independent directions:

  • Metis (Memory Foundation Model, arXiv 2607.26760) compresses history into in-model parameters, but the paper itself concedes: fixed capacity must forget, and parametric state is hard to audit, hard to delete precisely, and hard to bound for privacy — and proposes a hybrid blueprint where low-frequency, auditable, long-horizon history stays in external storage, which provides capacity, explainable retrieval, and error correction. That is exactly MemoryBridge's niche: native memory is a complement, not a replacement.
  • Proactive Memory Agent (Meta, arXiv 2607.08716) shows that long-horizon tasks fail not from missing information but from losing its grip on behavior; the fix is a keeper policy over an external structured memory store, and ablations show "silence as an action" beats always-exposing the store. MemoryBridge v0.9's silence contract and relative-threshold filtering are isomorphic to this.
  • Perplexity Portable Computer (local agent, zero token cost) validates the "extreme token economy" principle — tiny system prompts, few core tools, on-demand loading — and its "sensitive content never leaves the device + explicit exit gating" matches the PAMS philosophy.

v0.9 is a borrowing release aligned with these three works (retrieval quality / token economy / gap discovery), touching only the retrieval, injection, and scheduling layers — never rewriting memory content. Item-by-item mapping and the explicit not-borrowed list: Roadmap, "Borrowing release".

A fourth data point comes from the open-source project memU (NevaMind-AI): it likewise insists on a zero-LLM memory backend — the "what is worth remembering" judgment stays with the host agent while the memory service only stores, embeds, and retrieves. That division of labor is isomorphic to MemoryBridge's core. The fork is twofold: memU lets the LLM distill and generate memory content (MemoryBridge refuses: content freezing), and its cross-device story runs through its hosted cloud (MemoryBridge insists on self-held E2E-encrypted channels). v0.10 borrows its "memory as files" auditability (membridge export, a read-only view that never writes back) — see Roadmap, "memU borrowing release".

GitNexus (abhigyanpatwari/GitNexus), a zero-server code knowledge-graph engine, is the reference for v0.14. The useful insight is not "use a graph" — MemoryBridge has had graph retrieval since v0.9 (vector + keyword + one-hop SAN expansion, RRF-fused) — but that a graph is only as good as the certainty of its edges: GitNexus derives edges from an AST, while MemoryBridge's came from a statistical proxy (character n-gram co-occurrence). v0.14 therefore adds a deterministic anchor layer: zero-dependency regex extraction of code symbols / file paths / repos / tags (no AST, no parser, no new dependency), with memories sharing an anchor linked by an entity edge — plus typed edges (kind + evidence) so every link can answer "why are these related?". Its [[file:line]] provenance becomes recall-reason annotations, and its community detection becomes cluster preload (preload --cluster, union-find). Explicitly not borrowed: graph databases (they would break the single-file promise), full Tree-sitter AST parsing (memories are natural language, and it would break zero dependencies), PDG / taint analysis, and post-commit auto-reindexing (content freezing means there is no stale index to rebuild) — see Roadmap, "GitNexus borrowing release".

Hindsight (vectorize-io/hindsight, 42k★, which claims to let an agent learn rather than merely remember) is borrowed from at the structure layer only: v0.30 takes its 4th recall route (temporal → scope's at: time window) and its proof count (→ a read-only "evidence count" plus the RRF tie-breaker). Everything that makes Hindsight valuable lives in its LLM pipeline — retain extracting facts/entities, consolidation generating observations, reflect reasoning, mental models rewriting in the background — and every one of those collides with content freezing and "zero LLM on the server", so none of it is borrowed. The Faulty Memory paper (ACL 2026) cited by our own paper is precisely the evidence that such abstraction is unreliable. Item-by-item comparison in the design note and Roadmap, "Hindsight benchmark".

A fifth data point comes from the edge: devices are becoming first-class AI infrastructure. Ornith-1.5's 9B quantized build (~1.5 GB) runs directly on phones; OlliteRT turns a retired Android phone into a 24/7 LAN model server. Once a phone can host both the model and the service, MemoryBridge's base-station mode supplies the missing piece — memory. One old phone running OlliteRT (local inference) plus membridge gateway (the memory substrate) is a fully self-held, zero-cloud personal AI stack (recipes in the mobile guide). The boundary stays sharp: the local model lives on the host side; the memory core remains LLM-free.

A sixth data point comes from inside the parametric camp: Qualcomm AI Research's MoNe (ICML 2026) bolts an online-writable neural memory onto a frozen Transformer backbone — the context is written once, queries never re-read it. Its architectural discipline is isomorphic to MemoryBridge's: freeze the body, only the bolt-on is writable. The fork is where memory lives: MoNe writes history into weights (parametric state), the very route Metis concedes is hard to audit, hard to delete precisely, and hard to bound for privacy; MemoryBridge keeps memory in human-auditable external storage. Freezing is the shared discipline of both camps — the only difference is what gets frozen: they freeze the model, we freeze the content.

Quick start

git clone https://github.com/jiabaobei/memory-bridge.git
cd memory-bridge
pip install -e .           # editable local install. ⚠️ Never run `pip install membridge` (see the warning below)
membridge init             # mandatory cloud-drive channel setup first (auto-detects installed
                           # sync clients, guides you to a free one otherwise; explicit confirm
                           # required to skip), then wires up every AI platform detected here
python examples/demo.py    # phone memories → delta packet → PC, in 90 seconds

⚠️ pip install membridge does not install this project. The membridge name on PyPI belongs to a different project and has nothing to do with this repository. memory-bridge has never been published to PyPI; always install from the Git source (the three lines above: clone → cd → pip install -e .).

This has nothing to do with renaming the project — the repository name, module name and CLI name do not need to change.

Why is cloud-drive setup the first thing? Without the cloud, cross-device sync does not exist. A discussion on your phone in the morning can only be picked up by the office PC once it is in a cloud channel. By the paper's estimate your memory runs to about 1 GB a year, so any free cloud drive is plenty; and what syncs is end-to-end encrypted delta packets — the cloud provider cannot see the content either.

CLI:

membridge init                                      # cloud channel (auto-picked) + platform wiring;
                                                    # the channel key is derived from the source seed,
                                                    # so there is nothing to remember or hand over
membridge add "Working on the MemoryBridge project" --tags dev
                                                    # optional: --kind fact / procedure / handover
membridge search "MemoryBridge" -k 3              # hybrid: vector + keyword + graph, RRF-fused
                                                    # (--scope tag:dev to go straight to a known range, at:7d for a time window)
membridge context "continue this morning's discussion"
                                                    # newest handover card injected constantly in a
                                                    # 【workbench】 section; explicit "no injection this
                                                    # turn" only when there is no card and no hit
membridge handoff                                 # show the current workbench (latest handover card)
membridge handoff-hint                            # print the resident handover reminder
membridge hook --warm                                    # pre-warm the injection cache (idle/boot: one DB pass)
membridge hook --install                                 # wire auto-injection into detected AI hosts (adds only its own entry)
membridge hook --status                                  # show which hosts are wired and how fresh the cache is
membridge preload my-phone
membridge autosync                                  # runs automatically every 15 min (scheduled task)
membridge show-passphrase                           # inspect this machine's passphrase (rarely needed after v0.31: derivation is the default)
membridge delta phone.db --out delta.json           # or: --passphrase "..." to encrypt, --plaintext to opt out
membridge apply delta.json                          # or: --passphrase "..." for an encrypted packet
membridge publish --dir "D:/netdisk-sync/membridge"           # no passphrase needed: derived key
membridge publish --dir "D:/netdisk-sync/membridge" --force   # rebuild a wiped channel
membridge fetch   --dir "D:/netdisk-sync/membridge"           # no passphrase needed: derived key
membridge stats
membridge channel                               # channel-convergence check: same cloud channel on all devices?
membridge gateway                               # phone/tablet gateway (base-station mode, token-protected)
membridge gateway-token                         # show the gateway access token (when configuring a phone)
membridge export                                # human-readable Markdown view (--out writes to disk)
membridge recall-hint                           # print the resident recall one-liner (paste it yourself)
membridge rebuild-edges                             # full rebuild of association edges (regular adds build incrementally)
membridge doctor                                    # env self-check (DB location + channel health + memory gaps)

⚠️ Do not set a MEMBRIDGE_PASSPHRASE environment variable. It is per-machine history that is invisible across machines, so it silently splits one channel into two incompatible keys — the packets one device publishes cannot be opened by another. Since v0.31 the derived key takes precedence and the variable is ignored with a warning. Two real incidents have already happened this way (2026-09-28, vault passphrase; 2026-10-03, environment variable).

If you do need a separate key (a different channel, or a manual carry to physical media), pass --passphrase on the command — it takes priority and is scoped to that run.

Experience-distillation convention (with kind tags). When you solve a hard problem, store the experience so future similar tasks hit it directly:

membridge add "arm64 deploys segfault; switching to the x86 image fixed it" --kind procedure --tags dev

--kind procedure = "what was tried, what happened"; --kind fact = stable facts. Strictly optional — defaults are unchanged.

Shift-handover convention (kind=handover, v0.15). An agent's context is finite, and long tasks survive by repeated compaction — which is lossy: "option B was rejected" may survive the summary, but "why it was rejected" is usually the first thing lost. MemoryBridge's answer: the outgoing side writes one handover card explicitly; the full history stays in the store, queryable at any time.

membridge add "goal: fix the sync module
done: delta computation landed
failed: full AST parsing; deps too heavy; don't retry unless we drop zero-deps
next: converge the line-prefix parser
refs: membridge/store.py" --kind handover
  • Five-line convention goal / done / failed / next / refs; the card body is content-frozen; the failed line keeps the hard format: tried X; failed because Y; don't retry unless Z changes;
  • A new card automatically supersedes the old one — the newest card is the workbench, older ones demote to history, still searchable and auditable, never deleted;
  • At injection time the workbench is constantly present (it is a state declaration, not a retrieval hit, so the silence contract does not apply); all other retrieved memories keep their original contract;
  • Cards stale >7 days stop being injected constantly (an outdated workbench is worse than none) and demote to ordinary memory; membridge doctor reminds you;
  • membridge handoff-hint prints a resident reminder to paste into CLAUDE.md / AGENTS.md, so the host agent builds the habit of "hand over before you leave, read the workbench first when you arrive" (a soft contract, same philosophy as recall-hint).

Phones don't need the command: the gateway pocket-note page ships a five-line handover form — fill it in, tap "交接班", done.

Recovering a lost channel. publish only sends memories that are not yet marked as published locally. If the delta packets are deleted on the cloud side (or a sync failure empties the channel), the local record still says "published", so a plain publish reports nothing to do. Use --force to rebuild the channel from scratch:

membridge publish --dir "..." --force

How multiple devices converge on the same channel (v0.13). The channel's identity lives in the channel itself, not on each device — adoption replaces path-bookkeeping. All you do is point every device's channel folder at the same cloud-synced location (e.g. OneDrive/membridge on all of them). Then:

  • The first device writes a channel ID card channel.json into the channel directory on its first publish (channel ID / creator / creation time / embedder fingerprint) — pure metadata: no passphrase, never any memory content;
  • Every later device detects the card at membridge init (or its first publish/fetch/autosync) and auto-adopts the same channel, printing "joined an existing channel (created by …)" — no path to remember, no config to copy;
  • If a device is misconfigured to a different channel (its recorded channel ID disagrees with the card), membridge channel / doctor / publish / fetch / auto-sync all warn loudly (first come, first served — the card is never rewritten, so two devices can't clobber each other);
  • membridge channel is the one-screen health check: local channel, the ID card, and every device seen in the channel.

Phones / tablets don't need a channel at all — they join through the membridge gateway base-station mode (mobile guide) and inherently point at that one store.

MCP clients (Cursor mcp.json):

{
  "mcpServers": {
    "memory-bridge": {
      "command": "membridge",
      "args": ["mcp"],
      "env": { "MEMBRIDGE_DB": "D:/mem/my.db", "MEMBRIDGE_DEVICE": "my-pc" }
    }
  }
}

Tools exposed: memory_add (optional kind tag: fact / procedure / handover), memory_search (hybrid three-route retrieval; optional scope (e.g. tag:dev, at:7d, at:2026-09-01..2026-09-20) for direct access to a known range, e.g. tag:dev; as_context=true returns a budgeted Path A injection block — the newest handover card is injected constantly in a workbench section — and explicitly reports "no intervention" when there is no card and nothing passes the quality bar), memory_preload — strictly limited to the UEP permission boundary; there is no "rewrite memory" tool.

Cross-device sync: what the channel is, what the password is, how to push and pull

This section is written for humans and AIs alike: read it and you can carry memories to another device, or pull them back, without asking anyone for a password. Every algorithm and parameter is spelled out here verbatim, so an implementer in any language can reproduce it independently — no dependency on this project's code.

1. A channel is just a cloud-drive folder

membridge init creates a membridge/ directory in the cloud drive you pick. That directory is the channel:

<your-cloud-drive>/membridge/
├── channel.json       ← channel ID card (channel id / creator / time)
├── devices/           ← per-device heartbeat (online state, node count, container fingerprint)
├── outbox/            ← encrypted delta packets waiting to be pulled
└── archive/           ← packets already pulled

No server, no account, no API key. The cloud drive is only where the devices meet.

As of v0.31 the channel folder no longer stores a channel.key. The key is derived deterministically from the seed below; every end computes it locally and gets byte-identical results. See the next section.

As of v0.31.1, even if a stray channel.key is still present in the channel folder (written back by a not-yet-upgraded device, for instance), it no longer takes effect — the derived value is always the single source of truth. An old key is only tried as a fallback when fetching, to open packets sealed by old devices; it is never used to publish. (Why this matters: an earlier release let the file win, to avoid breaking historical packets. One stale client then wrote a fresh random key back, hijacked the whole channel, and 33 packets became unreadable — sync was down for 6 days.)

2. The password (channel key): a seed plus a standard KDF, computed locally

The channel key is not generated at random and passed around as a file. It is deterministically derived from a seed in the source code. Any device, any time, any language produces exactly the same result — that is why devices share a key by construction, and why "install the project and it just works, no asking anyone" holds.

Seed (in src/membridge/channel.py, constant CHANNEL_SEED):

membridge/mb-639d44f1/jiabaobei

Fixed salt (same file, constant SEED_SALT):

membridge.channel.v1

Iteration count (same file, constant KDF_ITERATIONS):

200000

Derivation (implementable in any language, standard primitives only):

dk  = PBKDF2-HMAC-SHA256(
          password = utf8(seed),
          salt     = utf8(fixed salt),
          iterations = 200000,
          dkLen    = 32 )
key = base64.urlsafe_b64encode(dk)     # standard base64, alphabet A–Z a–z 0–9 - _
key = key.rstrip("=")                  # drop trailing = padding

The resulting key is 43 characters — that is the channel key, used directly as a Fernet passphrase.

Do not take a shortcut like hashlib.sha256(seed) — it must go through PBKDF2 with the parameters above, or your key will differ from everyone else's, which shows up as "sender and receiver must use the same passphrase".

Self-check ciphertext (verify your derivation before silently publishing):

gAAAAABqwKqSJr8bLK6huRI9Dg5pLs-O8uMg5UYxU66NlZ1elIKgQ7qFCGF9WuZgUpheTigx4ekl-QABZT4qAr3UVtb_MBXZrbH90TheJo5JGyUg8M_0qco=

It is the result of encrypting the plaintext membridge-channel-ok with the derived key, a fixed salt of 00×16, and Fernet. Decrypt it and get that plaintext back → your derivation is correct. (The salt is fixed at 16 zero bytes, so this ciphertext is identical every time it is generated and can be compared directly.)

Full reproduction in Python:

import base64, hashlib
from cryptography.fernet import Fernet

SEED = "membridge/mb-639d44f1/jiabaobei"
SALT = "membridge.channel.v1"
dk = hashlib.pbkdf2_hmac("sha256", SEED.encode(), SALT.encode(), 200000, 32)
key = base64.urlsafe_b64encode(dk).decode().rstrip("=")
print(key)   # this is the channel key

On security, stated plainly: the seed ships with the source, so anyone who has this source can compute the channel key. That is a logical trade-off between "anyone who reads the docs can do it themselves" and "the key stays secret" — not an implementation defect. For an AI to complete the task independently, the derivation input cannot be a secret. Zero configuration wins here, because the key's job is "all devices use one key, and the cloud provider only ever sees ciphertext" — not "keep out people who can read the source". What actually keeps unauthorised visitors out is the access permission of the cloud-drive folder itself, which is exactly what that folder is for. (This project is open source under MIT, and says so without hedging.)

3. Encryption rules (delta packets)

What encrypts the channel key derived above (43 characters)
Algorithm Fernet (AES-128-CBC + HMAC-SHA256); the passphrase itself goes through PBKDF2-HMAC-SHA256 for 200,000 rounds
Per-packet salt 16 random bytes, carried with the packet (the envelope's salt field)
Envelope format {"fmt":"membridge-delta-enc-v1","salt":"<hex>","token":"<fernet>"}
What the cloud provider sees only the ciphertext inside token — never your content

4. Push (publish)

membridge sync      # pull other ends' memories + publish this machine's new ones (manual, run anytime)
membridge publish   # publish only

Scheduled jobs (registered by init, no configuration needed):

Platform Mechanism Frequency
Windows scheduled task MemoryBridge AutoSync every 15 minutes
macOS / Linux cron membridge-autosync every 15 minutes

Encryption is always on by default — pass nothing at all and the derived key is used internally. For strict end-to-end or cross-channel work, pass --passphrase your-passphrase explicitly (it then takes priority, for that run only).

Important memories go up immediately, routine ones in batches; memories tagged migration=local never leave the device on any code path (see Privacy).

4b. Specific case: carrying memories to other hardware with a manual passphrase

Beyond cloud-drive sync there is another scenario: moving a whole store by hand to a portable drive, USB stick or offline archive, or handing it to a machine that has no MemoryBridge installed. You do not need this day to day — devices on the same channel use the automatic derivation above; a manual passphrase is only for leaving the channel and moving to physical media. The commands are:

# On the source machine: produce an encrypted delta packet (--out may be a USB / portable-drive path)
membridge delta D:/store.db --out E:/memory-backup.mbd --passphrase "my-passphrase"

# On the target machine: unseal with the same passphrase and merge
membridge apply E:/memory-backup.mbd --passphrase "my-passphrase"

# To inspect the contents first (optional; produces a plaintext file, use with care)
membridge delta D:/store.db --out plain.json --plaintext
  • Omitting --passphrase still encrypts — with the source-derived value, which suits carrying memories between devices on the same channel.
  • Passing --passphrase uses the one you give; the other machine must be given the same one to decrypt.
  • The resulting .mbd is ordinary JSON text; copy it to any medium you like.
  • Plaintext mode (--plaintext) must be explicit and is labelled (plaintext) in the output to remind you.

5. Pull (fetch)

membridge fetch     # pull delta packets published by other ends
membridge sync      # equivalent: fetch then publish — this is the daily driver

With no --dir, the channel directory configured by init is used. No passphrase needed here either — derivation handles it.

6. Joining from a new device: three steps, zero configuration

git clone https://github.com/jiabaobei/memory-bridge.git
cd memory-bridge && pip install -e .
membridge init          # point at the same cloud-drive folder; wire up local AI platforms
membridge sync          # immediately pull everything this device had before

Not one step asks for a password, and not one step transfers a key file. Point the new device at the same cloud-drive folder and the key is computed from the source, byte-identical to every other device.

7. When something goes wrong, run these first

membridge doctor         # one-screen health check: store, channel, platform wiring
membridge netdisk-status # is the cloud drive inside the client's sync scope?
membridge channel        # channel identity + key fingerprint + device roster

What the common messages mean:

Message Meaning and what to do
local vault / env var disagrees with the channel key That machine still holds a historical passphrase. The derived key has already taken over; nothing is broken. Clear that historical entry to silence the notice.
the channel folder holds an old key … which disagrees with the derived value An old key from before the upgrade is lying around (or was written back by a not-yet-upgraded device). As of v0.31.1 the derived value has taken over and the file no longer takes effect, so sync is unaffected; it is only tried as a fallback when fetching. Once no legacy client remains on the channel, move channel.key out of the channel folder.
sender and receiver must use the same passphrase The sending end is still on a pre-v0.30.3 passphrase. Upgrade that device and resend.
passphrase mismatch, cannot decrypt Same issue, seen from the receiving side. The program already tries the derived value and any leftover old keys in turn; this error only appears when all of them fail, which usually means the sender used a passphrase of their own.

8. One-page cheat sheet for an AI

If you are operating this project on a user's behalf, follow these four steps and do not ask for a password:

  1. Confirm the channel directory: the first line of membridge channel. All devices must point at the same directory.
  2. Pull other ends' memories: membridge fetch (equivalently membridge sync). Do not pass --passphrase.
  3. Publish this machine's memories: membridge publish. Do not pass --passphrase.
  4. Check it is the same key: the channel key: fingerprint xxxx line in membridge channel should match on every end.

To encrypt or decrypt yourself: derive the 43-character key as in section 2 and use it as the Fernet passphrase; use a per-packet random 16-byte salt written into the envelope's salt field as hex; confirm the derivation against the self-check ciphertext before decrypting.

Never print the channel key or any passphrase into a chat, commit it to a repository, or paste it into an issue — it is not a secret from anyone who can read the source, but leaking it still lets an unauthorised party read your memory content.

9. New in v0.33: find what was done on another machine

membridge session-ingest --dry-run --verbose   # scan session archives, no writes
membridge session-ingest                       # write one index line per session
membridge search "<artifact or task name>" --scope tag:session

When a user says "I did this on another computer", check in this order: ① local session archives (session-ingest --dry-run or the task list), ② search --scope tag:session / tag:rule, ③ cloud-drive connectors. Zero hits in the memory store only proves nothing was written there — never that the work was never done (real incident, 2026-11-08). Likewise, sync reporting fetched 0, normal skips N means there is nothing new to receive, not a broken channel.

Relationship to the paper

MemoryBridge implements the CDSMP architecture (v7 preprint, in Chinese). Components deliberately deferred in the paper (Path B, AEE, L3 differential privacy, full UEP benchmarking) are deferred in the same order here. The preprint is published on Zenodo (full LaTeX source included): DOI 10.5281/zenodo.22064641. Experimental figures cited from the paper (e.g., TCR 94.7%, bandwidth −89%, token overhead −87.1%) are paper-reported values; reproduction scripts ship in Phase 4.

@techreport{cdsmp2026,
  title  = {Cross-Device Semantic Memory Persistence: Zero-Cognitive-Overhead Inference via Edge Preloading and Multi-Level Hot Caching (CDSMP)},
  author = {Xian, Yujia},
  year   = {2026},
  doi    = {10.5281/zenodo.22064641},
  note   = {Preprint v7}
}

Privacy

Three standing commitments (see the threat model):

  1. Memories tagged local cannot leave the device — enforced in code paths, not by policy.
  2. Every sync/payload exits through PAMS L1/L2 gates; sensitive content is auto-downgraded to local.
  3. The store is a single SQLite file per device: encrypt it, delete it, or take it with you.

Contributing

pip install -e ".[dev]"   # or zero-install: python tests/run_tests.py
pytest -q

Good first areas: real embedding backends, mobile connectors, the sync relay, benchmark reproduction.

License

MIT

Explore related projects

Loading…