Skip to content

SanctumBridge

A small Mac app bundle at a stone gate, four SQLite scrolls flowing through a thin pipe into it

There’s a class of macOS databases that nothing should ever need to touch directly — chat.db, Calendar.sqlitedb, ChatStorage.sqlite, AddressBook-v22.abcddb. Apple’s TCC framework guards them behind Full Disk Access, the most powerful single grant on the system. Granting FDA to your terminal is a rite of passage and, like every rite of passage, the kind of thing you eventually stop questioning. SanctumBridge is the answer to “why are we granting FDA to terminal at all?”

It’s a single notarized .app bundle running on 127.0.0.1:4444 (Sanctum 1.0 “One Door”) whose entire job is to answer authenticated, read-only queries against Apple’s protected local stores over loopback HTTP. Every other process — Jocasta, the council agents, Yoda’s tool calls — gets to be FDA-clean. They just speak Bearer-authenticated HTTP to the bridge.

TCC attaches Full Disk Access and Calendar access to a signed code identity. Granting FDA to Terminal.app extends to every shell child it spawns. But that scope is wider than it looks, and easily lost when the shell host changes — iTerm vs Terminal vs a tmux reattach. An app bundle with its own CFBundleIdentifier carries its own TCC entry, so the grant survives reboots, shell reorganizations, and Homebrew updates that swap node versions.

The bundle is a signed, notarized C launcher (launcher/main.c) that posix_spawns /usr/local/bin/node --disable-sigusr1 (closing Node’s SIGUSR1 inspector attach vector) against Resources/bridge/server.js. /usr/local/bin/node is the Node.js Foundation .pkg install: signed, notarized, and pinned to a path that never moves. Homebrew node was retired from the bridge on 2026-05-21 precisely because TCC keys grants to a binary identity, and brew’s versioned Cellar path churns on every upgrade. The .pkg path stays put forever, so the grant does too.

POST /bridge/query
Authorization: Bearer <bridge-token>
Content-Type: application/json
{"db": "imessage|whatsapp|contacts|notes|photos|mail|calendar_live", "sql": "...", "params": []}

Returns {"rows": [...], "count": N, "elapsed_ms": M} or {"error": "..."}. SELECT and PRAGMA only — anything that mutates data is rejected at the server, not at the database, and every call is logged with consumer and store. The bridge is read-only and Bearer-authenticated by construction.

GET /health

Returns {"status": "ok"} on loopback (127.0.0.1:4444).

db Path
imessage ~/Library/Messages/chat.db
whatsapp ~/Library/Group Containers/group.net.whatsapp.WhatsApp.shared/ChatStorage.sqlite
calendar ~/Library/Group Containers/group.com.apple.calendar/Calendar.sqlitedb
contacts the largest ~/Library/Application Support/AddressBook/Sources/<uuid>/AddressBook-v22.abcddb

The contacts resolver picks by file size on purpose. macOS keeps one folder per address book account (iCloud, On My Mac, etc); most are 2-record stubs and the iCloud one is the 7,500-record real source. Picking the first folder lexically, which is what the original implementation did, silently returned the stub on every machine where iCloud Contacts was enabled. That bug was fixed 2026-04-28 and the contacts resolver is now load-bearing in the Yoda truth-telling chain — a 2-record contacts table looks like an empty result, which the model would then need to not fabricate around.

The on-disk Calendar.sqlitedb on macOS Sequoia (15) and Tahoe (26) is a stale snapshot, not an empty one — which is the more dangerous of the two. It holds thousands of rows of subscribed holidays and old events, while live calendar events route through Apple’s EventKit XPC service. In Sanctum 1.0 One Door (2026-11-21), SanctumBridge holds the Calendars TCC grant (responsible = haus.sanctum.bridge) and exposes a calendar_live store directly, so jocasta_read_calendar routes through the bridge instead of keeping a separate Calendar-privileged helper on disk.

Ogilthorp3/sanctum-bridge — make build produces the notarized .app bundle from launcher/main.c and bridge/server.js. make install drops it into ~/Applications/.

The repo was reconstructed 2026-04-28 from the live deployed bundle. The original source had been inline-edited into the .app and never committed — the running binary on the Mac Mini was the only artifact, not on either Mac’s filesystem, in any restic snapshot, on any external drive, or in any Trash. The launcher was reverse-engineered from its strings(1) output — a binary that strips down to a single-digit handful of strings doesn’t hide much — and the legacy bash launcher (preserved as launcher/SanctumBridge.bash.legacy); the bridge/server.js is the live production code with the contacts-resolver fix and One Door store isolation folded in.

The bundle is also now in the restic backup paths (~/.sanctum/scripts/sanctum-backup.sh) so a future inline-edit incident has somewhere to recover from.

The bridge reads SANCTUM_BRIDGE_PORT from the environment (default 4444 in Sanctum 1.0; :4078 now hosts the PQ TLS terminator). The LaunchAgent at ~/Library/LaunchAgents/haus.sanctum.bridge.plist doesn’t hardcode the port — it resolves services.sanctum_bridge.port from ~/.sanctum/instance.yaml. Single source of truth, doctrine-clean.

The jocasta-mcp client side mirrors this: SANCTUM_BRIDGE_URL is set by ~/.sanctum/bin/jocasta-mcp-stdio.sh from the same YAML key. Changing the port is one edit to instance.yaml, then launchctl kickstart -k and the openclaw-gateway restart — no plist edits, no source code changes.

The bundle ID ai.openclaw.denchclaw is a fossil. The Mac-side stack was called DenchClaw for a few months in early 2026 before the Sanctum rename — Judi Dench as M, running operations from headquarters while Bond is in the field, while the agents are deployed across the infrastructure. The bundle ID was kept stable across the rename because changing it invalidates the TCC grant, and re-prompting for FDA on every reboot is the kind of thing Bert refuses to live with.