No description
  • Python 86.9%
  • Swift 10.7%
  • Shell 2.2%
  • Makefile 0.1%
  • Dockerfile 0.1%
Find a file
svc-svd-writer acc6c052b6
All checks were successful
ci/woodpecker/push/validation Pipeline was successful
Harden single-host checks and removal guidance (#102)
2026-11-16 13:35:16 +00:00
.woodpecker Harden deployment manifests and render them in CI (#63) 2026-11-15 03:38:29 +00:00
contracts/feeder-v1 Bound Feeder pages and strengthen hardening coverage (#61) 2026-11-15 02:23:09 +00:00
deploy Harden deployment manifests and render them in CI (#63) 2026-11-15 03:38:29 +00:00
docs Harden single-host checks and removal guidance (#102) 2026-11-16 13:35:16 +00:00
feeder Bound Feeder pages and strengthen hardening coverage (#61) 2026-11-15 02:23:09 +00:00
scripts Probe v5: transport by text shape, orphan rows, edit kinds, deletion-table history 2026-11-13 06:06:06 +11:00
src/messages_mind_mcp Harden single-host checks and removal guidance (#102) 2026-11-16 13:35:16 +00:00
tests Harden single-host checks and removal guidance (#102) 2026-11-16 13:35:16 +00:00
.dockerignore Harden deployment manifests and render them in CI (#63) 2026-11-15 03:38:29 +00:00
.gitignore Add the Feeder read service on MessagesCore (#57) 2026-11-14 20:46:54 +00:00
.python-version Scaffold the package, the Kit and the encrypted store (#7) 2026-11-13 07:37:52 +11:00
compose.yaml Add hardened container, Compose and Kubernetes deployment packaging (#51) 2026-11-13 22:39:58 +00:00
config.example.toml Implement deletion, Reconcile, Forget and Rebuild (#59) 2026-11-15 00:09:43 +00:00
Containerfile Add hardened container, Compose and Kubernetes deployment packaging (#51) 2026-11-13 22:39:58 +00:00
GLOSSARY.md Bound Feeder pages and strengthen hardening coverage (#61) 2026-11-15 02:23:09 +00:00
LICENSE Scaffold the package, the Kit and the encrypted store (#7) 2026-11-13 07:37:52 +11:00
Makefile Add the Feeder read service on MessagesCore (#57) 2026-11-14 20:46:54 +00:00
pyproject.toml Add hardened container, Compose and Kubernetes deployment packaging (#51) 2026-11-13 22:39:58 +00:00
README.md Harden single-host checks and removal guidance (#102) 2026-11-16 13:35:16 +00:00
SECURITY.md Harden single-host checks and removal guidance (#102) 2026-11-16 13:35:16 +00:00
uv.lock The feeder-v1 contract, its fixtures and a fake Feeder (#8) 2026-11-13 13:45:49 +11:00

Messages Mind MCP

A self-hosted, read-only mirror of your iMessage history for agents. Messages Mind copies your messages into a local store, indexes them, and serves them to an MCP client over Streamable HTTP with a bearer token. It runs as one instance per person, beside Mail Mind and People Mind or alone.

Blades expose a system's capabilities; minds maintain durable domain knowledge over time. Messages Mind owns the message mirror. It never sends a message.

Status: building. The foundation exists: the package, the Kit, the encrypted store, an offline check command and the api with its five read tools and two feed tools. The sync worker mirrors a Feeder through the closed feeder-v1 contract. A Containerfile, a compose stack with a fake Feeder and Kubernetes manifests exist. The real feeder is not built yet. This README records the design and the one decision that shapes it: we read iMessage with our own small feeder, not with BlueBubbles.

Current capabilities

  • Config. One TOML file (config.example.toml). Every secret is a path to an owner-only file. A config that names a write token is refused. A file named as a write token beside a secret file is refused too, and so is a secrets directory that the service cannot list. The [server] table is required: every deployment states its bind address, as text, and the list of Host names that the api accepts.
  • The store. One SQLCipher file in WAL mode with full-text search, and a separate small Tombstone store. The sync worker opens the writer. The api opens a reader that writes nothing and a positions connection that writes Consumer positions and nothing else.
  • The Kit. Token scopes, the row format, the page footer, cursors and Consumer positions, in src/messages_mind_mcp/kit/.
  • messagesmind check --config FILE. Validates the config, the secret files, the store and the single-host controls. It makes no network request and prints the bind address, a host= line, counts and codes only. On a Mac, the host line reports the store’s Time Machine and Spotlight exclusions and whether another user can write to the environment or code, plus, in the final snapshots= field, whether tmutil listlocalsnapshots lists a snapshot name that starts with com.apple.TimeMachine. on the volume of the store directory. The field does not see other local snapshots, for example for a macOS update or from another tool. The key, the salt and the Tombstone store may sit on another volume, which it does not probe; elsewhere these checks are n/a. Exit status: 0 valid, 1 store error or failed host check, 2 config or secret error.
  • messagesmind sync --config FILE [--once]. Pulls from the configured Feeder, once or in a loop. The token comes from an owner-only file. It never opens an auth token file or a Consumer token file. Saved positions cover new rows, Backfill, Edits and Unsends, Recently Deleted and hard deletions. Reconcile runs daily or with --reconcile, which refuses with sync-running while the sync agent runs; --rebuild EXPORT restores Tombstones and builds a new Mirror. Replies and attachment type and size are kept; an Edit replaces the text and an Unsend removes it from the store and index. Output holds counts and codes only. Its config, limits, output and codes are in The sync worker. The sync worker connects only to the addresses of the one configured Feeder host. A DNS name such as localhost can resolve to more than one address. It follows no redirect.
  • messagesmind api --config FILE. Serves the five read tools and two feed tools over stateless Streamable HTTP. It opens each configured Consumer token file. It never opens the Feeder token file or the tombstone salt file. It binds the one address that [server] states, on port 8420 unless the config sets another, and it serves the tool path /mcp and two health paths. It does not start without a read token, and it does not start without a Host allow-list. It does not start when a FASTMCP_ environment variable, or a .env file in the working directory, changes a setting of the MCP framework: such a setting can turn the Host and Origin checks off. It then prints server=error code=framework-settings.
  • The read tools. messages_status, messages_chats, messages_recent, messages_search and messages_context. Each opens the store in reader mode for one read transaction. The read token reaches them. The evidence and Consumer tokens do not.
  • What the api refuses. Each control answers with a status and one fixed word. The controls run in this order:
    1. Host. A request whose Host is not an entry of server.allowed_hosts gets 421. The match is exact, without the port. There is no wildcard, and a loopback name that the list does not hold is refused. A request with no Host header, or with two, is refused too.
    2. Origin. A request that carries an Origin header gets 403. A web browser sends that header and an MCP client does not, so no web page can call the api.
    3. Rate. Each remote address gets server.rate_burst requests at once (default 20) and server.rate_per_second after that (default 5). An address over its rate gets 429 with Retry-After in whole seconds. The remote address is the address of the socket: the caller, or the proxy in front of the api. The api tracks at most 1,024 remote addresses, and refuses a new address while every tracked address is in use.
    4. Body. A request body over 65,536 bytes gets 413. A body that does not arrive within 5 seconds gets 408.
    5. Token. A request with no held token gets 401.
    6. Deadline. A tool call that reads the store for more than 10 seconds stops and answers Error: code=deadline-exceeded. The deadline stops a query. It does not cover a wait for a lock on the store, which ends after 5 seconds, or a block in the operating system.
  • What the HTTP server limits. It serves at most 128 connections at once and answers 503 over that. It refuses a request header over 16,384 bytes with 400, and closes an idle connection after 5 seconds. It has no time limit for a header that arrives slowly: a caller that can reach the port can hold a connection open, up to the 128. In a published deployment the proxy sets that limit.
  • What the api does not read. It ignores X-Forwarded-For and every other forwarding header. Behind a proxy, every caller therefore shares one rate bucket: the proxy's address. The HTTP server holds no WebSocket code, so a WebSocket handshake is an HTTP request like any other. The api holds no client code, so no tool argument can reach an outbound request.
  • Health. GET /healthz answers ok while the process serves requests. GET /healthz/sync answers ok when a successful sync ended in the last 15 minutes and no later pass failed, and 503 with the word unavailable when none did or the store cannot be read. Neither path needs a token, and neither returns a count, a time or a name. Both pass the Host and Origin controls, so a probe must send an allowed Host. A GET /healthz with no body is outside the rate limit. /healthz/sync is inside it, so it answers 429 to an address over its rate. /healthz/sync answers 503 at once after a failed pass, and again ok after the next pass that succeeds. /healthz stays ok. A deployment must not use /healthz/sync as a readiness probe: a Feeder that is down would then take the api out of service.
  • Errors. A refused call answers Error: code=<code>, for example unknown-chat, invalid-argument, invalid-cursor or unknown-tool. A tool outside the scope of the token is unknown-tool to that token. No error repeats an argument, a tool name that the caller sent, a file path or the message of a fault. A reply with a status outside 2xx holds one fixed word for that status, for example unauthorized or bad request, and no text or header from the MCP library: the library's own error text repeats values of the request. The api has no redirect: the redirect that the router gives for a trailing slash repeats the query, so it becomes 404. A fault that no layer caught is 500 with the word error. The HTTP server answers two cases itself, each with a fixed text of its own: 400 with Invalid HTTP request received. for bytes that it cannot parse, and 503 with Service Unavailable over its connection limit.
  • The log. One line for each call: the tool, the role of the token, the number of lines in its page and the code, for example tool=messages_recent role=read lines=52 code=ok. The roles are read, evidence and feed:<name>, where <name> is the configured Consumer name. One line for each kind of refusal, at most once in 10 seconds, with a count and no address: refused=host count=3. The kinds are host, origin, rate, body, body-time, token and protocol. A fault prints its class and where it happened, and never its message or its traceback: fault=RuntimeError where=request. That holds for a fault in a thread and for a fault that nothing caught.
  • What the log drops. The HTTP server can log an address, a path and a query. So the process prints a line of the HTTP server only when the line is in a closed list of start and stop lines. Any other record of the server becomes a count with the same 10-second rule, for example server=http count=2, or the class of its fault. The process drops every record of a library and every Python warning, because a library can log what a request holds. Every line passes a scrub that replaces a held token, and the word after Bearer, with [token]. The HTTP server's access log is off.

Recently Deleted and hard deletions remove mirrored messages. Reconcile applies deny-list changes, restores rows and replaces changed bodies, daily or with messagesmind sync --config FILE --reconcile, which refuses with sync-running while the sync agent runs. messagesmind forget --config FILE m123 removes a message and keeps a salted Tombstone so it stays forgotten through Backfill, Reconcile and Rebuild. See Forget and recovery. The event log holds message events only. A Tapback writes no event in 0.1.0.

The sync worker keeps an event at least 30 days after sync recorded it and prunes only a prefix of the log at the end of each successful pass. Pruning stops before the first event still inside the window, even if later events have older times. Known limit: if the clock of the sync host steps forward and then back, an event stamped in the future stops every later prune until it is 30 days old by its own stamp. It clears without help. Until then the log holds more events than the window.

Not built yet: the feeder, the peer producer, the release lane that builds, scans and signs a published image (ADR 0009).

The sync worker

Config

Key Bound
url, socket Exactly one of the two; otherwise config is refused at feeder. The url has scheme http, an IP address or lower-case DNS host name, an optional port, and no path but /. A bracketed host must be an IPv6 address; unspecified addresses are refused. It starts with lower-case http://, contains only printable ASCII characters without spaces, no ?, # or % anywhere, and no user name or password. A port, if its colon is present, must not be empty. A host that is not an IP address must not end in an all-digit label or a label starting with 0x. Example: http://127.0.0.1:8421.
token_file An owner-only file with at least 32 characters.
poll_seconds 5 to 300 seconds, default 60.

Limits of the Feeder client

  • The timeout of 30 seconds applies to each read and each write of the connection. No limit applies to the full time of one response.
  • A response over 16 MiB is refused. For an oversized page, sync then asks again with half the limit, down to 1.
  • One page holds at most 500 rows or 500 Chats, or 5000 deletion records or Reconcile entries.
  • Reconcile runs every 86400 seconds, when hard-deletion records do not explain a count change, or when forced. The first pass after an upgrade from a Mirror without deletion positions also reconciles.
  • One pass reads at most 20 Backfill pages.
  • sync checks the socket path's mode bits at stat time and refuses any group or other permission bit with feeder-socket-mode. It checks neither the socket's owner nor the peer. The socket's parent directory must be writable by its owner only; this is a deployment duty that no code checks.

Output

sync=ok new=N backfill=N changed=N removed=N reconciled=0|1 backfill_left=N
sync=error code=<code>

A successful pass or a stopped loop exits 0. Config and secret refusals print config=error code=<code> at=<location> or secret=error code=<code> at=<location> and exit 2, as for check. These are not sync= lines.

Codes

Code Cause Exit with --once The loop
feeder-missing No [feeder] table, or no Feeder token. 2 Does not start.
feeder-address Both or neither address supplied; config refuses this first with config=error and exit 2. 1 Exits at start.
feeder-socket-mode Socket has a group or other permission bit. 1 Tries again.
feeder-unreachable Connect, read or write failed or timed out, or reply is not HTTP. 1 Tries again.
response-too-large Response over 16 MiB at a limit of 1. check asks with no limit, so an oversized check reply gets this code at once. 1 Tries again.
feeder-unauthorized Feeder answered 401; a reply over the size cap reports response-too-large first. 1 Tries again.
schema-pin Feeder answered 503 with schema-pin, or check reports a missing pinned column. 1 Tries again.
feeder-status Any other status but 200. 1 Tries again.
feeder-contract Media type is not JSON, body is outside the closed contract, or check has no newest row. 1 Tries again.
unknown-chat A row names a Chat absent from the Chat list. 1 Tries again.
source-replaced Saved row position or hard-deletion count is past the Feeder's; stop the sync agent first (Stop the sync agent), then replace the Mirror (Replace the Mirror); the Tombstone store stays in place. 3 Stops. The shipped launchd agent starts it again about every 60 s.
row-id-reused A held row id now has a different guid; stop the sync agent first (Stop the sync agent), then replace the Mirror (Replace the Mirror); the Tombstone store stays in place. 3 Stops. The shipped launchd agent starts it again about every 60 s.
tombstones-not-restored Mirror and Tombstone store are absent but the configured export exists; stop the sync agent first (Stop the sync agent), then use sync --rebuild EXPORT. 2 Does not start.
tombstones-missing Mirror exists but its Tombstone store is missing; stop the sync agent first, move the Mirror aside and run sync --rebuild EXPORT. 2 Does not start.
tombstones-salt-mismatch The current salt does not match the Tombstone store or export; restore the original salt. 2 Does not start.
tombstones-export-invalid Restore or configured export failed validation; no unverified rows are copied. 2 Does not start.
tombstones-export Pending export could not be written; Forget remains applied. 1 Tries again next pass.
sync-running Another sync or Rebuild holds the lock file beside the Mirror; stop the agent first. 2 Does not start.
rebuild-store-present Rebuild requires an absent Mirror. 2 Does not start.
tombstones-present Rebuild refuses to overwrite the Tombstone store. 2 Does not start.
store-key Key is not 64 hex characters. 3 Stops. The shipped launchd agent starts it again about every 60 s.
store-schema-ahead Store is from a newer release. 3 Stops. The shipped launchd agent starts it again about every 60 s.
store-unreadable Wrong key, or file is not a store. 3 Stops. The shipped launchd agent starts it again about every 60 s.
store-unavailable Store cannot be opened or written. The Tombstone may already be written; run Forget again, or the next Reconcile removes the message. 1 Tries again.
tombstones-schema-ahead Tombstone store is from a newer release. 3 Stops. The shipped launchd agent starts it again about every 60 s.
tombstones-unreadable Tombstone store cannot be opened or read. A 0-byte file is refused except a 0.1.0 file beside a Mirror without the deletion_slice marker; that file is initialized in place. 1 Tries again.
interrupted Ctrl-C interrupted sync or Rebuild; no traceback is printed. 130 Exits.
internal An unrecognized error code was suppressed. 1 Tries again after a pass failure; exits at start.

Exit 3 stops the process. The shipped launchd agent (KeepAlive, ThrottleInterval 60) starts it again about every 60 s. Compose (restart: unless-stopped) also restarts it, at the interval of the engine. Kubernetes restarts it too. The code shows in the log each time. /healthz/sync answers 503: at once when the stop recorded its time, otherwise once the last successful sync is 15 minutes old.

Before each start retry, the loop reads the config and the secret files again, as a restart does. A refusal then prints the config=error or secret=error line and exits 2. A reload with no [feeder] table prints sync=error code=feeder-missing and exits 2. A refusal at start that records its time writes no deletion_slice marker. With a damaged Tombstone store, a Mirror stop code (for example store-unreadable for a wrong key) shows only after the Tombstone store is repaired, because the Tombstone store opens first.

Sync and Rebuild hold <mirror>.lock; a second instance refuses with sync-running (exit 2) while a process holds the lock. The lock uses flock and holds between processes on one host with a local filesystem. On some NFS or SMB mounts, the lock does not reach another host, so run one sync for each store. On some NFS or SMB mounts, where flock fails, sync never starts and logs store-unavailable. The lock is keyed on the Mirror path as the config writes it. A second config with another Mirror path and the same Tombstone store, or a Mirror reached through a symlink by another spelling, does not meet the lock. Run one config for each store. Stop the sync agent before you move the Mirror or run a Rebuild. The lock does not cover the gap between launchd restarts. If the agent is not stopped and no export file is at the configured path, with both stores moved aside, a restarted agent makes a new empty Mirror and Tombstone store and can sync Forgotten messages back; a Rebuild then refuses with rebuild-store-present. A restarted agent makes a new empty Mirror and Tombstone store only when the Mirror and the Tombstone store are both absent and no export file is at the configured path. If only the Mirror is moved, the agent makes a new Mirror and keeps the Tombstone store, so Forgotten messages stay forgotten. Moving the whole store directory moves <mirror>.lock with it, and the old agent keeps holding the moved file. Deleting the lock file has the same effect. Either way, a sync or Rebuild at the original path then meets no lock while the old agent runs. In the shipped configurations, the Mirror and Tombstone store share one directory. Moving the whole store directory moves both stores, so the fresh-store condition applies. With store.tombstone_export_path set, every verb, the Rebuild included, then refuses with config-validation at=store.tombstone_export_path until the directory exists again. Move the store files and keep the directory. The Mirror moves with its -wal and -shm files. The Tombstone store moves with its -journal file, if one is present. A new Mirror keeps Forgotten messages forgotten only while the Tombstone store stays in place.

An unreadable Mirror directory gives store-unavailable (exit 1, retried), because sync opens the lock file beside the Mirror first. An unreadable Tombstone or export directory gives store-unreadable (exit 3).

A failed pass attempts to record its time; see Current capabilities for its effect on /healthz/sync.

Stop the sync agent

A plain launchctl bootout lasts only until the next login: launchd loads every plist in ~/Library/LaunchAgents at each login, and RunAtLoad and KeepAlive then start the job. KeepAlive and ThrottleInterval restart it after an exit. Disable the agent so it stays stopped. A restarted agent makes a new empty Mirror and Tombstone store only when the Mirror and the Tombstone store are both absent and no export file is at the configured path. If only the Mirror is moved, the agent makes a new Mirror and keeps the Tombstone store, so Forgotten messages stay forgotten. In the shipped configurations, the Mirror and Tombstone store share one directory. Moving the whole store directory moves both stores, so the fresh-store condition applies. With store.tombstone_export_path set, every verb, the Rebuild included, then refuses with config-validation at=store.tombstone_export_path until the directory exists again. Move the store files and keep the directory. The Mirror moves with its -wal and -shm files. The Tombstone store moves with its -journal file, if one is present.

FILE is the config file, EXPORT is the store.tombstone_export_path value, MIRROR is the store.path value, TOMBSTONES is the store.tombstone_path value, and ASIDE is a new directory beside the Mirror. Replace each placeholder everywhere it appears, including in MIRROR-wal and TOMBSTONES-journal, and keep the quotes around it, because a store path can hold a space. Use $HOME, not ~, in a path. The messagesmind command is in the virtual environment’s bin directory; put it on PATH before running these commands.

Run the stop block to stop and check both agents.

launchctl disable gui/$(id -u)/asia.groupthink.messagesmind.sync && launchctl bootout gui/$(id -u)/asia.groupthink.messagesmind.sync
launchctl disable gui/$(id -u)/asia.groupthink.messagesmind.api && launchctl bootout gui/$(id -u)/asia.groupthink.messagesmind.api
launchctl print-disabled gui/$(id -u) | grep -E '"asia\.groupthink\.messagesmind\.sync" => (disabled|true)' && launchctl print-disabled gui/$(id -u) | grep -E '"asia\.groupthink\.messagesmind\.api" => (disabled|true)' && ! launchctl print gui/$(id -u)/asia.groupthink.messagesmind.sync >/dev/null 2>&1 && ! launchctl print gui/$(id -u)/asia.groupthink.messagesmind.api >/dev/null 2>&1 && echo stopped

Continue only when the last line prints stopped. launchctl bootout fails with No such process when an agent is not loaded; the check line decides. If disable fails, bootout does not run, and the check does not print stopped. The stop block stops the api too, because each api call opens the Mirror by its path and writes Consumer positions. A sync that you started by hand does not stop: stop it first.

Then follow one path. Use Replace the Mirror whenever the Tombstone store still opens: after source-replaced, after row-id-reused, or for a damaged Mirror. Use Restore a lost Tombstone store only when no Tombstone store that opens is left: after tombstones-missing, after tombstones-not-restored, or when the sync log still repeats tombstones-unreadable after you free disk space and check the store files' owner and mode.

Replace the Mirror

This path keeps the Tombstone store in place, so every Forget stays. A plain start of sync opens that store, rolls back a crash journal and upgrades a version-1 store. Sync then makes a new Mirror, and Backfill copies the history again without each Forgotten message.

Run block A1 to move the Mirror files aside.

mkdir -m 700 "ASIDE" && for f in "MIRROR" "MIRROR-wal" "MIRROR-shm"; do if [ -e "$f" ]; then mv "$f" "ASIDE/"; fi; done

Run block A2 to start sync on a new Mirror.

if test -f "TOMBSTONES" && test ! -e "MIRROR" && test ! -e "MIRROR-wal" && test ! -e "MIRROR-shm"; then launchctl enable gui/$(id -u)/asia.groupthink.messagesmind.sync && launchctl bootstrap gui/$(id -u) "$HOME/Library/LaunchAgents/asia.groupthink.messagesmind.sync.plist"; else echo "not run: a check failed"; fi

If block A2 printed not run: a check failed, sync did not start: the Tombstone store file is missing, or a Mirror file is still in place. Keep sync stopped, check block A1 and the paths, and run block A2 again. Then go to Start the api again.

Restore a lost Tombstone store

A Rebuild restores only the Forgets that the export holds. A Forget that is newer than the export is lost, and Backfill copies that message again. Use this path only when no Tombstone store that opens is left. If a Tombstone store that you moved aside earlier still opens, move it back to store.tombstone_path together with its -journal file, if one is present, and use Replace the Mirror instead. A store moved back without its -journal file can open with Forgets missing and no error.

Before you move the stores, make sure store.tombstone_export_path is set and the export file you restore from is at that path. If the path is not set, set it and copy the export there. Use that path as EXPORT. While both stores are absent and that file exists, every sync start refuses with tombstones-not-restored and creates no store; it creates only <mirror>.lock. So a failed Rebuild or an early restart cannot make fresh stores. The path rules of store.tombstone_export_path in Forget and recovery apply; Forget then writes its exports to that path.

Run block B1 to move the store files aside.

mkdir -m 700 "ASIDE" && for f in "MIRROR" "MIRROR-wal" "MIRROR-shm" "TOMBSTONES" "TOMBSTONES-journal"; do if [ -e "$f" ]; then mv "$f" "ASIDE/"; fi; done

Run block B2 to restore the Tombstone store from the export.

if test -f "EXPORT" && test ! -e "MIRROR" && test ! -e "MIRROR-wal" && test ! -e "MIRROR-shm" && test ! -e "TOMBSTONES" && test ! -e "TOMBSTONES-journal"; then messagesmind sync --config "FILE" --rebuild "EXPORT"; else echo "not run: a check failed"; fi

Start sync again only when the Rebuild restored the Tombstone store. If block B2 printed not run: a check failed, no Rebuild ran: keep sync stopped, check block B1 and the paths in block B2, and run block B2 again. Otherwise, check the Tombstone store file at store.tombstone_path. Block B2 runs the Rebuild only when no store file and no sidecar is there, and the Rebuild installs that file only after the restore copied and checked every row. If the file exists, the restore succeeded: run block B3, even if the sync pass after the restore printed an error code. One exception: tombstones-present means that another process made the file during the Rebuild, so keep sync stopped and find that process. If the file does not exist, the restore failed or was refused: keep sync stopped and disabled, look up the printed code in Codes, fix the cause and run block B2 again.

Run block B3 to start sync after checking the Tombstone store file.

test -f "TOMBSTONES" && launchctl enable gui/$(id -u)/asia.groupthink.messagesmind.sync && launchctl bootstrap gui/$(id -u) "$HOME/Library/LaunchAgents/asia.groupthink.messagesmind.sync.plist"

Then go to Start the api again.

Start the api again

Run the api block only when the sync log shows a sync=ok line after the restart. If the log repeats an error code instead, look it up in Codes first; while sync fails at the Tombstone store or the export, it makes no Feeder read.

launchctl enable gui/$(id -u)/asia.groupthink.messagesmind.api && launchctl bootstrap gui/$(id -u) "$HOME/Library/LaunchAgents/asia.groupthink.messagesmind.api.plist"

The ASIDE directory holds the old Mirror, which holds message text. Delete the old Mirror files once the sync log shows sync=ok. After a Rebuild, ASIDE also holds the old Tombstone store files; they hold digests, not text. A local APFS snapshot taken before the delete can still hold the old Mirror. A launchd install deletes them with the delete block in section 6 of the install guide.

Compose uses restart: unless-stopped. Run docker compose stop sync; a stopped container stays stopped across an engine restart. docker compose up, docker compose start, docker compose restart, and any command that starts api or smoke (for example docker compose up api or docker compose run api) can start sync again, because api depends on sync and smoke depends on api. After the Rebuild, check the Tombstone store file before docker compose start sync.

For Kubernetes, pause reconciliation first: kubectl apply -k or a GitOps reconcile sets replicas back to 1 and starts sync. NAMESPACE is the namespace of the Deployment. Scale down with kubectl -n NAMESPACE scale deploy/messagesmind --replicas=0; this stops the api too, because sync and api share one pod. After the Rebuild, check the Tombstone store file before kubectl -n NAMESPACE scale deploy/messagesmind --replicas=1.

The Compose and Kubernetes Rebuild steps are not documented yet: where the export lives, how to run the Rebuild in a container or a Job, and how to pause a GitOps reconcile (#88).

Order after an upgrade

An older example had [feed] consumers = []. It is now refused with config=error code=config-validation at=feed. Delete the line, or use a [feed.consumers] table.

  1. sync migrates the store when it opens it.
  2. The api refuses an older store schema: each tool answers Error: code=store-schema-behind, /healthz/sync answers 503, and check prints store=error code=store-schema-behind.
  3. After an upgrade, start sync before the api, with the sync agent stopped. Once is enough: messagesmind sync --config FILE --once.

Forget and recovery

messagesmind forget --config FILE m123 is a CLI command, with no MCP tool. It reads only the store key and Tombstone salt and makes no Feeder request. It writes the Tombstone before removing the message, its attachments and target Tapbacks, and clears replies to it. Each message removal writes one del event; removing a Tapback writes none.

Success prints forget=ok wal=ok or forget=ok wal=busy. A busy checkpoint means a reader held a snapshot; sync retries it at the end of the next pass, including a failed pass. With store.tombstone_export_path configured, Forget atomically exports the Tombstone store there and adds export=ok. The deployment ships that private file to its object bucket. It contains salted hashes, Forget times and recovery metadata; retain the same salt separately for recovery. An export failure returns an error after the Forget has already been applied. The Tombstone keeps export_pending set until a successful export; sync writes the export again on the next pass, before any Feeder read, and retries a failed export on later passes. The export must use a separate directory from both live stores; place it on another volume. Its parent directory must already exist. The rule compares the device and inode of the directories and files: a second spelling, a case difference or a second mount of the same directory is refused. The export file must not share the identity of the config, any secret or either live database. Export checks the directories again before replacing the file; database sidecars share those directories. An interrupted export can leave a temp sibling named .<export>.<random>.tmp beside the export file, where <export> is the export file name. It holds digests only; the operator may delete it.

Both live-store parent directories must also exist for the identity checks; a directory-stat error is config-validation at store.tombstone_export_path.

At the start of each pass and before each Forget, sync merges validated digests from the configured export into the Tombstone store. An invalid file fails with tombstones-export-invalid. Each export preserves the union of the live store and the file it replaces. If the existing file fails validation, export fails with tombstones-export and leaves it unchanged; the operator must move that file aside. An export that fails on every pass stops every pass, so deletions are not applied until the export path works.

Code Cause Exit
invalid-message Argument is not m followed by ASCII digits. 1
unknown-message Message is absent. 1
tombstones-missing Tombstone store is missing; stop the sync agent first, move the Mirror aside and run sync --rebuild EXPORT. 1
tombstones-salt-mismatch Restore the original salt; it must match the Tombstone store. 1
store-absent Mirror is absent; Forget creates no Mirror. 1
store-key Key is not 64 hex characters. 1
store-schema-ahead Store is from a newer release. 1
store-unreadable Wrong key, or file is not a store. 1
store-unavailable Store cannot be opened or written. The Tombstone may already be written; run Forget again, or the next Reconcile removes the message. 1
tombstones-schema-ahead Tombstone store is from a newer release. 1
tombstones-unreadable Tombstone store cannot be opened or read. A 0-byte file is refused except a 0.1.0 file beside a Mirror without the deletion_slice marker; that file is initialized in place. 1
tombstones-export-invalid Configured export failed validation; Forget did not run. 1
interrupted Ctrl-C interrupted Forget; no traceback is printed. 130
tombstones-export Forget is applied; export could not be written. Sync writes the export again on the next pass. 1
internal An unrecognized error code was suppressed. 1

Errors print only forget=error code=<code>. Ctrl-C during sync, Forget or Rebuild prints sync=error code=interrupted or forget=error code=interrupted and exits 130 without a traceback. Config and secret refusals use the same output and exit 2 as other verbs.

Stop the sync agent first (Stop the sync agent). Use a Rebuild only when no Tombstone store that opens is left; otherwise replace the Mirror (Replace the Mirror). Start sync again after a Rebuild only as the rule in Restore a lost Tombstone store says. messagesmind sync --config FILE --rebuild EXPORT requires an absent Mirror and Tombstone store. A Rebuild opens only the Tombstone store it restored, so it does not meet tombstones-schema-ahead. It opens the export read-only. The restore checks the structure (quick_check), the schema, the salt and each row; it cannot detect a row that someone removed from the export, or an older export put in place of a newer one. Each at must have the form that store.now() writes: YYYY-MM-DDTHH:MM:SS.sssZ, with a valid UTC date and time. Another value is tombstones-export-invalid. It copies only validated Tombstone rows into a fresh private store before installing it and opening a new Mirror. A failed restore leaves no Tombstone file and removes its temporary sibling. A process killed during restore can leave a temp sibling named .tombstones.db.<random>.tmp beside the Tombstone store. It holds digests only; the guard still works, and the operator may delete it. After a restore, a configured export is marked export_pending so the next pass writes it at the configured path. It then syncs until Backfill is complete. After a Rebuild whose pass fails, a plain sync finishes the work; --rebuild again answers rebuild-store-present. The Mirror has no backup; recover it from the Feeder. Never put back an older copy of the Mirror; use a Rebuild from an export. Preserve the export and its salt before replacing a volume. A new Mirror starts with a new epoch, an empty event log and no Consumer positions; Backfill then writes new add events.

Every open checks a stored HMAC salt check against the current salt before any Mirror write or Feeder request; a mismatch returns tombstones-salt-mismatch. A version-1 Tombstone store is upgraded with the current salt and any held Tombstones are queued for export. Keep that original salt for recovery.

A plain sync, including --once and --reconcile, refuses with tombstones-not-restored when both stores are absent and the configured export exists. Stop the sync agent first (Stop the sync agent), then restore with sync --rebuild EXPORT. If you moved aside a Tombstone store that still opens, move it back instead, together with its -journal file if one is present; a plain sync then keeps every Forget. If a Mirror with the deletion_slice marker exists but the Tombstone store is missing, sync refuses with tombstones-missing, and Forget refuses too. A Mirror from 0.1.0 with no marker and a missing or 0-byte Tombstone file held no Tombstones in that crash window; sync initializes its Tombstone store. After the Tombstone store opens, the first writer open by sync, Forget or Rebuild writes the marker, even if the Feeder read then fails. A marked Mirror with a 0-byte file is refused with tombstones-unreadable. Stop the sync agent first. Move the Mirror aside and run sync --rebuild EXPORT. With no export, a Forgotten message cannot be found again: rebuild the Mirror and forget it again. A lost Mirror with its Tombstone store still present can safely re-mirror. A first run creates the Tombstone store before the Mirror. The guard works only while the export file is at the configured path. After a lost volume, copy the export back to that path before the first sync. A Forget whose export has not yet been written is lost with the volume. With no export file at the configured path and no Mirror, sync starts a new Mirror and cannot know of earlier Forgets. The source-replaced and row-id-reused stops need a new Mirror: stop the sync agent and replace the Mirror (Replace the Mirror). Reconcile does not repair row-id reuse.

How it fits together

flowchart LR
  subgraph Mac["Your Mac — one macOS user per person"]
    M[Messages] --> DB[(chat.db)]
    DB -- read-only --> F["Messages Feeder<br/>signed, notarised<br/>no send code"]
  end
  subgraph Server["Your server — one container group per person"]
    S[sync] --> ST[("SQLite mirror<br/>FTS5")]
    ST --> A[api]
  end
  S -- "polls over a private network<br/>feeder token" --> F
  AG[Hosted agent] -- "HTTPS, read token" --> A
  C[Consumer] -- "HTTPS, Consumer token" --> A
  PM[People Mind] -- "evidence token<br/>no message text" --> A
  • Messages Feeder runs on the Mac. It is the only program that reads chat.db, and it can only read.
  • sync is the only client of the Feeder and the only writer of messages and events.
  • api opens a reader that writes nothing for every tool. messages_changes_ack alone opens a positions connection that writes the consumers table and nothing else: this is the api's only write. It keeps serving the last synced state when the Mac is off.

The diagram shows the split shape, where the Mac is a Source and not the host. A Mac sleeps, restarts and travels; an agent should still get an answer. A person with one always-on Mac can run everything on it: that is the single-host shape.

Deployment shapes

There are two, and the code is the same in both (ADR 0011).

  • Split. The feeder runs on the Mac. sync, the mirror and the api run on a host that is always on. The mirror answers when the Mac is off. Message text sits on that host, encrypted at rest.
  • Single-host. The feeder, sync, the mirror and the api run on one Mac, in one macOS user. No message text leaves the Mac. The service answers only while that user is logged in and the Mac is awake.

In both shapes the feeder is the only program that reads chat.db. It is our own signed program. apple-messages-blade-mcp gives the feeder a library, and the blade has no network face of its own.

What listens, and who can reach it

Split Single-host
Feeder listens on One port on the Mac's private-network address One Unix socket with mode 0600, in a 0700 directory the Owner owns. No network address.
Feeder can be reached by The service, by one access rule on the private network. Another macOS user on the Mac. A process of your macOS user. An administrator of the Mac.
api listens on The address you state in server.host, behind the host's network controls The loopback address you state in server.host
api can be reached by What the host's network controls allow Every process on the Mac, including a web browser. A proxy that you set up to publish it.
Installed from The signed image The lock file, with a hash for every runtime dependency (not the build backend)

Controls in both shapes

  • Every request carries a bearer token, on the feeder and on the api.
  • server.host has no default. You state the bind address, and check prints it. The port defaults to 8420 and the path is /mcp.
  • The api checks the Host of every request against server.allowed_hosts and refuses every request that carries an Origin. The list is required and has no default: the api refuses to start without one (ADR 0011). List the names and addresses that a client puts in its URL. To publish the api through a proxy, list the public name; the bind address stays a loopback or private address.
  • The api limits the rate of each remote address, the size and the arrival time of a request body, the number of open connections, and the time of a store read. "Current capabilities" gives each number.
  • The feeder refuses to listen on every interface.
  • The store is encrypted with SQLCipher.

Controls in the single-host shape

  • sync and the api run from the locked environment under the templates in deploy/launchagents/. Start-up fetches no code. Follow the single-host install guide.
  • The store directory or an ancestor ends in .noindex to exclude Spotlight, and tmutil addexclusion excludes the store and secrets from Time Machine. check reports the store exclusions and whether another user can write to the environment or code. Time Machine local snapshots can still hold the store, with no guaranteed expiry.
  • The outbound check tests that sync connects only to the Feeder and that the api opens no outbound connection. Its Python audit hook does not see DNS lookups or sockets opened in C code. A Mac has no network policy, so these tests are the control within those limits.
  • Each feeder release states its hash and the Team ID of its signature. The install document gives the commands that check both, and you run them before you grant Full Disk Access.

What each shape does not protect against

  • Both. An administrator of the Mac can read everything on it. A program that runs as your macOS user can read the files in your home, and those include the feeder's copy of its token. Such a program can ask the feeder for messages without a Full Disk Access grant of its own. A proxy that terminates TLS in front of the api can read every response.
  • Split. Whoever operates the always-on host and can read the key file can read the mirror. Another macOS user on the Mac can reach the feeder's port, and still needs the token.
  • Single-host. The service does not answer while you are logged out or the Mac sleeps. Every local process can reach the api's port; the token, the Host allow-list and the Origin check are the controls. Time Machine local snapshots can hold the store and key, Forgotten messages included, with no guaranteed expiry (ADR 0007 Amendment 1).

The decision: our own feeder, not BlueBubbles

Decided 2026-11-12 by the project owner. ADR 0002 records the decision. This section holds the findings behind it.

The constraint

Apple offers no API for Messages history. The only source is ~/Library/Messages/chat.db, a SQLite file inside each macOS user's home. macOS guards it with Full Disk Access, and the grant is tied to the code signature of the program that asks. Two consequences follow:

  • A container cannot read it, and the Mac cannot be the host.
  • A reader that is rebuilt by Nix or uv gets a new signature on each build and loses the grant each time.

So some signed program on the Mac must hold Full Disk Access and hand the messages on. The question is which program.

The options

Option What holds Full Disk Access Verdict
The mind reads chat.db itself An unsigned or rebuilt binary Rejected. The grant does not survive a rebuild, and the Mac would become the host.
BlueBubbles Server, as shipped A vendor-signed Electron app Rejected. See the findings below.
BlueBubbles, built from an audited commit and signed by us The same code under our signature Rejected. We would know where the code came from. Its size and its abilities would not change.
Another community reader Someone else's code, smaller Not chosen. The grant still goes to code we do not own, and several of these can send.
Our own feeder A small Swift agent that we write and sign Chosen.

What we found in BlueBubbles

BlueBubbles is a full iMessage client bridge. Sending, tunnels, push notification and its Private API are its purpose, and none of them is a defect. Each one is extra surface beside a Full Disk Access grant that this project does not need.

We read bluebubbles-server at commit 76d2b2e (v1.9.12, 2026-10-27) on 2026-11-12. We did not install or run it.

  • Size. It is an Electron 25.9.8 app. The lock file resolves 2,245 npm packages.
  • Abilities it carries. Its dependencies include firebase-admin, googleapis, ngrok and electron-updater. Its resources include Cloudflare, ngrok and zrok tunnel clients and the Private API helper libraries.
  • Entitlements. They include disable-library-validation, allow-unsigned-executable-memory, allow-jit and Apple Events automation.
  • It can send. The send route defaults to an AppleScript method that needs no Private API. Once the Mac grants Automation access, the API password is a send credential. Our server would hold that password.
  • Authentication. The password travels in the query string (guid, password or token). There is no header form.
  • Network. The HTTP server listens with no host argument, so it accepts connections on every interface.
  • The API does not fit a mirror. No route returns changed messages; one route returns their count. The after and before filters test the message date. A poll therefore cannot see an edit or an unsend of an older message, and it misses history that iCloud delivers late.
  • Release rhythm. The releases page shows v1.9.9 on 2025-05-16 and then v1.9.10 to v1.9.12 on 2026-10-27.
  • Gatekeeper. Homebrew disabled its bluebubbles cask on 2026-09-01 with the note "does not pass the macOS Gatekeeper check". The v1.9.12 notes say notarisation is restored; we did not verify that.

With BlueBubbles, "read-only" would be a habit of our client. It would not be a property of the system.

Why our own feeder

The rule we applied: the program that holds Full Disk Access is the smallest program we can write, and we sign it.

  1. Read-only by construction. The feeder contains no send code. A test fails the build if a write path appears. No credential in the system can send a message.
  2. Small enough to audit. It builds on apple-messages-blade-mcp, a Swift package of about 2,400 lines that already reads chat.db read-only and decodes message text. About 1,300 of those lines are the reader; the feeder links only them. It has no Electron, no npm tree, no tunnel client and no updater that fetches code.
  3. The grant survives updates. A Developer ID signature and notarisation give each release the same identity, so macOS keeps the Full Disk Access grant.
  4. The API fits the mirror. The feeder pages by row id in both directions. It reports an edit or an unsend as a change to that row, from the edit time that chat.db records, and it reports a deletion from the deletion records and the deletion count that chat.db keeps. sync needs no re-read window to find them.
  5. A closed network face. The feeder binds to one private-network address, never to every interface. It takes a bearer token in a header.
  6. One decoder to maintain. The same library serves the Stallari desktop app, so a fix for a new macOS release lands once.

What it costs

  • A second deliverable. The feeder is Swift, with its own signing and notarisation step. The mind is Python in a container.
  • macOS changes are ours to absorb. Apple changes chat.db without notice. The feeder pins the schema it knows, warns on a column it does not, and ships a probe that checks a new macOS release.
  • No community finds our bugs first.
  • Fewer features, on purpose. No send of a message or of a Tapback, no typing state, no attachments in the first release.

What would change this decision

  • Apple ships a supported way to read Messages history. We move to it.
  • The feeder proves costly to keep working across macOS releases. The Source interface in sync is a seam: a second Source kind can be added without a change to the store or the tools.

Design commitments

  • Read-only, permanently. No token writes Mirror data and there is no outbox. A Consumer token writes only its own position. A write token file is refused at startup.
  • One-time codes never leave the feeder. Deterministic rules in the feeder replace a one-time code with the marker [code]. The row keeps its sender, time and direction. No switch turns this off.
  • An unsend is honoured. When a sender unsends a message, the mirror deletes the text and its index entry. A deletion on your devices also reaches the mirror. Only the latest edit is kept.
  • Only what Messages shows. The feeder serves a message only if it belongs to a chat. A message in Recently Deleted is never served.
  • A deny list of chats and people is a file on the Mac. The feeder applies it, so a denied chat never leaves the feeder.
  • No copy of message text leaves the volume that holds the mirror. There is no backup of the mirror. A lost volume is rebuilt from the feeder.
  • Evidence without text. People Mind with only an evidence token receives who, when, which direction and which transport, and never what was said. Never give People Mind a Consumer token: a Consumer token reads message text through the feed.
  • One instance per person. A token sees one person's messages. A second person is a second instance with its own store and its own macOS user.
  • Logs carry counts, roles and error codes. The role feed:<name> holds the configured Consumer name. A line never holds a Handle, a contact name or a word of a message. Choose a Consumer name that does not identify a person.
  • Message text is untrusted data. Anyone with your number can put text in the mirror. Every tool says so, and no tool argument ever reaches an outbound request.

The feeder contract

contracts/feeder-v1/ fixes every field that can leave the Mac. The feeder serves those fields and no other. sync refuses a response that holds any other field, so such a field never reaches the mirror.

  • Eight operations, all GET. Each has a fixed list of parameters, and each parameter is a decimal number. The feeder refuses a request with any other parameter. No operation changes the Messages history.
  • The token is in the Authorization header and nowhere else. A request with a token in its query string is refused.
  • Every object is closed. A message row has twelve fields, and a tapback row has ten. An attachment is a type and a size. A tapback has a kind, a sender and a target, and no text.
  • The contract lists what the feeder never serves. The contract tests search every response of a feeder, body and headers, for the synthetic texts that stand for these:
    • a row in no chat;
    • a denied chat or handle;
    • the text before an edit;
    • the text of a tapback;
    • a body before redaction;
    • the name of an attachment.
  • One set of tests for every feeder. conformance.py runs against a feeder on a port or on a Unix socket. It reads a synthetic history in eight steps, with recorded responses for each step.

The contract, its fixtures and a fake feeder exist. The fake feeder is a test program in tests/ and is not in the package. The real feeder is not built yet, and it must pass the same tests.

Tools (first release)

Tool Scope State Purpose
messages_status read built Counts, last sync, newest message time, backfill state
messages_chats read built Chats with members, message count, first and last day
messages_recent read built One chat as a transcript page
messages_search read built Full-text search; returns pointers, not bodies
messages_context read built The messages around one message
messages_changes, messages_changes_ack feed built A pulled change feed with named Consumers
messages_peer_info, messages_peer_changes_v1, messages_peer_snapshot_v1, messages_peer_evidence_v1 evidence planned The shared mind contract, for People Mind

Wakes and semantic search come later. A send tool does not.

The change feed

A Consumer's position stays in the store after its entry leaves the config. A new Consumer that reuses the name starts at the old position. Give a new Consumer a name that no earlier Consumer used.

Each Consumer has its own token file under [feed.consumers], for example grok = "/run/secrets/messagesmind/feed-grok-token". The table requires [auth]. Consumer names are lower-case local names; two Consumers cannot share a token file or token value, and no Consumer token may equal a read or evidence token. Neither feed tool takes a Consumer argument: the token selects the Consumer. The read and evidence tokens reach no feed tool, and a Consumer token reaches no read or evidence tool.

A Consumer token reads the current text of each message whose event is still in the log, in every Chat, with the same Handle values as the read token. No Consumer is limited to some Chats. Sync writes an add event for each mirrored Backfill row. After a Backfill or a Rebuild this is the whole history until retention removes the Backfill add events; as an upper bound on what a Consumer token reads, it holds. The event window limits the order of changes, not the age of the messages those changes name.

Pass the last next_cursor you received on every read; with no saved cursor, call with none. With no cursor, messages_changes reads from the Consumer's saved position. Each row starts with add, edit, unsend or del, followed by message and chat ids. A row with a live message also holds the message's UTC time, sender, text and flags; a del row always holds ids only. The feed reads the current Mirror, so an old event does not expose old message text. The footer always holds next_cursor=<cursor> more=0|1, even on an empty page.

After processing a page, call messages_changes_ack(cursor=<next_cursor>). It replies acked=N and advances only that Consumer's saved position. A repeat ack is safe and never moves backwards. A read does not advance the position; passing next_cursor to the next read can page ahead before acking. Reads start at the greater of the saved position and the supplied cursor.

Cursors carry the Mirror epoch. After a Rebuild, a cursor from the old Mirror answers cursor-expired: start again without a cursor. A new Mirror has a new epoch, an empty event log and no Consumer positions before Backfill. Its m<id> and c<id> values can name different messages and Chats. A Consumer that sees cursor-expired or a new epoch drops its copy and reads the feed again from the start. An ack beyond the last event answers cursor-ahead. A Consumer behind the retention floor gets no event rows and this line:

behind-retention: events up to this cursor are gone. Read the Mirror again, remove what it no longer holds, then ack next_cursor

Reconcile the Consumer's copy with the current Mirror using the read tools and a separate read token, including removals. Then ack the supplied floor cursor and resume the feed. more=1 means events remain after that floor; it does not fill the missing history.

Token efficiency

A transcript is many short rows, so the cost of each row decides the cost of the page. A page names up to twelve handles in a legend, prints the date once per day, uses short local ids, and folds a Tapback into the row it belongs to.

c2 | Weekend plans | p1=+61491570156 | p2=alex@example.test
2026-11-11
p1 09:14 Running late, start without me
me 09:15 ok | love:p1
p2 09:40 Your parcel is at the depot | sms edited
next_cursor=recent,dd38b265,2,2026-11-11T09:14:00.000Z,58 more=1 total=1482
  • Ids. c2 is a chat, m340 is a message and p1 is a handle. me is you.
  • The legend names the senders on the page first, then the other members of the chat, twelve handles at most. +N counts the senders and members that it does not name. The change-feed legend also names at most twelve senders, with +N for the rest.
  • Flags. What follows | on a row is a list of flags: sms, rcs, edited, unsent, and kind:sender for a Tapback.
  • Times are UTC.
  • Message text cannot forge a row. Message text is one line, and the service removes every | from it. So a line start and a | are always the service's own.
  • Search returns pointers. A pointer is m340 c2 09:14 p1 under a date line. messages_context reads the rows around it.
  • The cursor is plain text. An encoded cursor costs about 20 tokens more on every page.

A tokenizer in the test suite holds the budgets. It runs offline: the vocabulary is a file in this repository, checked against its published hash.

What Budget in tokens
The whole tool list, eleven tools 2,500
The five read tools in that list 660
The two feed tools in that list 260
A default messages_changes page of 50 events 1,500
One transcript row, mean 18
A default messages_recent page of 50 rows 960
A default messages_search page of 20 pointers 300
A default messages_chats page of 20 chats 780
A default messages_context page of 11 rows 270
messages_status 32

A chat row costs about 37 tokens, twice a transcript row, because it holds handles and two dates.

Who holds which credential

Credential Held by What it allows
Feeder token sync Read from the feeder
Read token Your agent The read tools
Evidence token People Mind Closed envelopes with no text
Consumer token Each Consumer The two feed tools for that Consumer only
Anything that can send Nobody No such code exists

Which verb opens which secret file:

Secret file check api sync forget
store.key_file yes yes yes yes
store.tombstone_salt_file yes never yes yes
auth.read_token_file yes yes never never
auth.evidence_token_file yes yes never never
feeder.token_file yes never yes never
feed.consumers yes yes never never

The table is built from SECRET_FILE_VERBS in src/messages_mind_mcp/startup.py, and a test compares the two.

One secret file serves one role. Two Consumers that name the same path are refused first at feed with config-validation. Any other two entries that resolve to the same path answer secret-file-shared. Config validation compares paths after Path.resolve() and also refuses a secret path that resolves to the config file itself, with secret-file-shared at the secret location and config. Startup also refuses existing files with the same device and inode, including hard links, with secret-file-shared. A secret that is a hard link of the config file answers secret-file-shared at the secret location and config. These errors name only the config locations, never a path or a Consumer name. A secret path that cannot be resolved answers secret-path-invalid at its config location. A symlink loop is refused that way on every supported Python. The startup check uses os.stat and opens no secret file.

The rule compares paths and files named in one config. tokens-equal compares every pair of secrets that the verb reads: the read, evidence, Consumer and Feeder tokens, the store key and the tombstone salt. check reads every secret. The api never reads the Feeder token or the salt, so it compares its tokens with each other and with the store key. It compares each pair in normalised form: the bytes of the value with ASCII whitespace (space, tab, newline, carriage return, vertical tab and form feed) removed at both ends and ASCII letters folded to lower case. Two values that differ only in ASCII case or in that outer whitespace are refused, and so are two values that are equal byte for byte. Non-ASCII letters are not folded, and other outer bytes, such as a no-break space or \x1c, are not removed. Each token is also compared with the store key as text, through Python str.strip() and str.lower(), because the key reader reads the key that way. str.strip() removes Unicode whitespace and also \x1c to \x1f. The salt gets the same text comparison when its file is ASCII, so a salt that is the key with \x1c around it, or a copy of the key file, is refused. A salt that is not ASCII is skipped in that comparison only: a salt that is the key with a no-break space around it is not refused. Such a salt cannot come from a copy of the key file, because a non-ASCII key file is refused with key-format. The comparison changes no secret: the tombstone salt reaches HMAC as the bytes of its file, less one final newline. The device and inode check skips a file that the process cannot stat, except for a symlink loop.

A file is opened only when the config names it. The api never opens the Feeder token file. The api never opens the tombstone salt file. sync never opens an auth token file or a Consumer token file, even when the config holds [auth] and [feed.consumers]. The api also starts when the Feeder token file is absent, too short or open to another user, because it does not read that file. Every verb lists the directory of each secret file the config names, including the Feeder token's directory, to refuse a write token; listing a directory opens no file.

On an api-only host, check opens the Feeder token file whenever the config holds [feeder], so it refuses with secret-missing at=feeder.token_file if the file is absent, although api starts. Leave [feeder] out of the config of a host that never runs sync. On a sync-only host, check opens the auth token files whenever the config holds [auth], so it refuses with secret-missing at=auth.read_token_file if that file is absent, although sync starts. Leave [auth] and [feed.consumers] out of the config of a host that never runs the api. On an api-only host, check still opens the required tombstone salt file; the host needs a valid salt file for check to pass, although api starts without it.

Tokens and keys are files owned by the service user. They are never environment variables and never tool arguments.

Who it is for

Grok Bot custom connectors first, and any MCP client that speaks Streamable HTTP. The floor is one HTTPS URL that your agent can reach and one Authorization: Bearer header, with no interactive login and no webhook. Messages Mind ships no MCP Apps views. You need a Mac that stays signed in to Messages.

Roadmap

Phase Scope
0 A read-only probe of chat.db to confirm the facts the sync design depends on. Glossary and ADRs.
A The feeder. The mirror, sync and redaction. The read tools and the change feed. The peer producer. A signed container image for the split shape, and a native install for the single-host shape.
B People Mind reads the evidence feed. Shared code moves to a common package. Semantic search. Wakes.
C Attachment text.

Messages Mind implements the approved shared mind contract and recovery model. It remains useful alone, with optional peers and direct integration that requires neither Kubernetes nor a message broker.

Decisions

The words this project uses are in GLOSSARY.md. The security position is in SECURITY.md. The decisions are in docs/adr/:

ADR Decision
0001 Service and read-only scope
0002 Our own feeder, not BlueBubbles
0003 Kit boundary and shared-code timing
0004 Source Mac and the feeder's network face
0005 Chat selection and one-time-code redaction
0006 Retention, deletion and Forget
0007 Store encryption and backup
0008 Feeder package, signing and update
0009 Image release and supply chain
0010 The messages-people/1.0 peer profile
0011 Two deployment shapes: split and single-host

CI

make check is the local validation command. It needs uv and runs four checks:

  1. ruff check: the linter, with the S security rules.
  2. ruff format --check: the formatter.
  3. mypy: the type check, in strict mode, over src, tests and contracts.
  4. pytest: the tests, with a base temp directory outside the worktree.

The pipeline in .woodpecker/validation.yaml runs make check on Linux for every pull request and every push to main. It holds no secret. Its images are pinned by digest, and uv installs from uv.lock, which holds a hash for every runtime dependency, and enforces the downloaded dependency hashes. uv builds this project editably with its build backend hatchling, which uv resolves at install time; uv.lock does not pin or hash that backend. The container image avoids that install-time resolution by installing the project without a build: it installs the locked dependencies and copies the package source into site-packages. The pipeline is also the gate in ADR 0007: the SQLCipher wheel and full-text search must pass there on Linux.

The darwin-only host-check tests run only on a Mac. No macOS CI lane exists yet; adding one under .woodpecker/ is architect work.

No branch-protection rule or required status check is configured yet. Until one is, a green pipeline is evidence and not merge protection.

The architect rider adds the pipeline's manifests step. It renders the base and each overlay with a pinned kustomize, validates each result with a pinned kubeconform in strict mode, and checks the rendered NetworkPolicy, pod and images. The pipeline does not build the image. The offline structural test stays in make check.

The tests hold these rules, among others:

  • A LaunchAgent template runs only the environment's interpreter and names no package manager or download command.
  • The tests check that sync connects to the Feeder and nothing else and that the api opens no outbound connection; a self-test checks that the outbound check catches a second address. Its Python audit hook does not see DNS lookups or sockets opened in C code.
  • On a Mac, check fails when a store exclusion is missing or another user can write to the environment or code directory.
  • No Kit module imports from the rest of the service.
  • A write token stops the service at startup.
  • The store file opened without the key yields no row, and holds no readable text.
  • Neither api connection can write a message row, or any table but Consumer positions.
  • No code reads a secret from the environment.
  • No manifest puts a secret in the environment.
  • Sync and api receive only their own subsets of owner-only secret files.
  • Every base and tool image is pinned by digest, and the image runs as uid 10001.
  • The NetworkPolicy allows the api port from labelled clients and egress to the Feeder only.
  • Each process has its own memory-backed /tmp and mounts only its own secret volume.
  • The base names a fully qualified, digest-pinned placeholder image, so the base alone does not start.
  • Only sync and the api mount the data volume; no container copies the Mirror.
  • The evidence token reaches no read tool.
  • messages_search returns no message text.
  • Paging a chat shows every row once, when rows share one timestamp.
  • No module that the api loads imports client code.
  • No argument, no tool name from a caller and no fault message reaches a reply or the log.
  • One test for each control of the api: a Host outside the allow-list, an Origin, a burst over the rate, a body over the cap, a body that arrives too slowly, and a store read past its deadline.
  • A run of every tool over every fixture row, with requests that carry fixture text in each field a caller controls, logs no Handle, no contact name, no word of a message and no token; the role feed:<name> holds the configured Consumer name. The run includes a WebSocket handshake, bytes that are no request, and each refusal. Every line of that log has one of a closed list of forms.
  • A reply with a status outside 2xx names no file path and no secret, and repeats no value of the request. A redirect is one of them.
  • A forwarding header does not change the remote address that the rate limit uses.
  • A record of the HTTP server that is not in the closed list never reaches the log as text.
  • Only a GET of /healthz with no body is outside the rate limit.
  • The documents state the limits that the code holds: a test compares each number.
  • A FASTMCP_ variable or a .env file stops the api at startup.
  • A token budget holds for the tool list, for a transcript row and for a default page of each read tool.

Test fixtures are synthetic. No real message enters this repository.

Releases and deploy

The Containerfile builds a non-root image with digest-pinned base and tool images and hash-enforced dependencies from uv.lock. It installs no project build backend. The api and sync run as uid 10001, with separate config and secret files.

From a clean checkout with Docker Compose v2, run:

docker compose up -d --build
docker compose --profile smoke run --rm smoke

The stack syncs synthetic fixtures from the fake Feeder and exposes the api on 127.0.0.1:8420. The smoke calls messages_status and prints smoke=ok messages=N when N is positive; it prints no message text. Synthetic secrets live in separate named volumes and survive restarts with the data volume. Every service has a read-only root filesystem. On SELinux hosts, the fixture and config bind mounts may need :z labelling.

The namespace-agnostic Kustomize base is in deploy/k8s/base. The example overlay and its deploy and NetworkPolicy verification instructions show one pod group per instance with owner-only mounted secret files. There are still no releases and no published images. The overlay's image digest is a placeholder; replace it and the documentation-only Feeder address before deploying.

The family convention applies: an annotated vX.Y.Z or vX.Y.Z-rc.N git tag, and an immutable image version without the v, pinned by digest for deployment. Kubernetes stays optional.

Licence

MIT, as the sibling minds. See LICENSE.