The swap table
The invariants worth keeping
Whatever you swap, three seams carry the architecture:- One org-scoped data layer. Every query passes an
org_idresolved from the verified token — never from client input. Tools, routes, and integrations all inherit isolation from this. - One agent turn service.
api/agent/service.run_turnowns the loop: history, prompt, tools, permission gate, persistence. The in-app pane is an SSE adapter over it; Slack is an events adapter; the MCP server and CLI hit the same tool registry. Add a surface by adding an adapter, not another brain. - One outbox. All mail is queued rows drained by a worker — retries, idempotency, and suppression live in one place.

