One Canonical Brain, Many Clients: SAKO Brain's Multi-User Turn
How a personal Markdown vault became a self-hosted, multi-client, multi-user knowledge substrate — and the four production incidents that shaped it along the way.
What SAKO Brain was, briefly
SAKO Brain started as a folder of Markdown files on one laptop: project records, decisions, a timeline, session handoffs, all plain text, all read and written by a small CLI. The idea was unglamorous on purpose — the files are the system, the index is a disposable cache, and an AI assistant is a client of that state, never the place the state lives. The first open-source release, v0.1.0, shipped in September. This is what happened after.
From one laptop to one server
The first real architectural move was getting the canonical vault off my laptop entirely. It now lives on a self-hosted TrueNAS server, reached the same way regardless of which machine is asking: an SSH forced-command dispatcher for local CLI clients, now joined by a self-hosted OAuth 2.1 + Streamable HTTP MCP gateway for web and remote clients. Claude Code and Codex connect through the first. ChatGPT web, Claude.ai web, and — most recently — Hermes Agent, a local agent runtime, connect through the second.
The design constraint that made this tolerable: the gateway is a capability adapter, never a second Brain. Every tool call it handles is forwarded, unmodified, to the exact same dispatch Claude Code and Codex already use. No client gets special-cased code. I proved that directly rather than assumed it: I connected Hermes to the live gateway and watched it search, read and write through the real production system — including correctly refusing a secret-shaped write and a restricted-sensitivity write without explicit confirmation, exactly like every other client does, because it’s the same shared policy underneath, not a reimplementation.
From one user to several, without becoming several Brains
The second move was multi-user support, built in two deliberate stages. Stage one established identity: principals, groups, a way to say who is acting. Stage two added the actual visibility model — owner_principal and audience on every record’s own frontmatter, read live off the file every time, never trusted from the index. A record’s owner may modify it; being in the audience grants reading it, never editing it. There is no editors/grants subsystem layered on top — ownership is the only thing that can change a record, full stop, and that holds for an administrator too. I proved that one directly as well: an admin principal asking for a record it doesn’t own gets told the record doesn’t exist — the identical response a genuinely missing id would produce, not a permission-denied message that would at least confirm the record is there.
The part I’m most satisfied with is the role-policy layer, because of how it fails. A role (an ordinary string, not a hardcoded engine concept — the actual role names are deployment configuration, not something the software ships opinions about) can be granted two things: whether it may write restricted-sensitivity content, and which audiences it may share its own records with. The question that mattered was: what happens when a role’s policy can’t be resolved — a typo, a deleted configuration record, something lost in a deployment? The honest answer, for a while, was: it quietly became fully permissive. That is exactly backwards for an access-control system, and once it was named plainly it got fixed structurally — an unresolved role now resolves to the least permissive point in the whole capability space, never the most. A broken configuration can no longer accidentally become a privilege escalation.
Four incidents, and what each one actually taught
None of these were catastrophic. All four were caught before they mattered, and all four were caught by the same discipline: a live acceptance test against the real deployed system, not just a green unit-test suite.
MCP tool-list drift. Early on, the HTTP bridge advertised tools it couldn’t actually execute — twenty tools known to the server, nine with a real translator. A client could see and attempt to call eleven tools that would always fail. Fixed by making the advertised list derive mechanically from what’s actually callable, with a permanent test comparing the two directly rather than trusting a synthetic fixture to catch future drift.
Write/index consistency. A write and the search index that’s supposed to reflect it could briefly disagree — a note existed on disk but a query run immediately afterwards wouldn’t find it. Every write path now reindexes the one file it touched, synchronously, so there’s no window where “I just saved this” and “I can find this” give different answers.
Deployment drift, twice. The SSH dispatcher script lives outside the installable package, deployed as a separate step — and that step was once simply forgotten, leaving the server running tested, correct code that nobody had actually shipped. The specific fix was a deployed-version marker the health check can report, so this is visible on inspection instead of only discoverable by a live test behaving wrong. The general lesson recurred independently, during this same multi-user work, as a container occasionally executing a stale cached copy of its own init script despite the host-side source being verified correct — same shape, different mechanism, same cure: a live check against the actual running system, not just the artifact meant to be deployed.
A forgotten delegation flag, found by trying it for real. The remote gateway asserts which principal it’s acting on behalf of; the dispatcher independently re-validates that assertion before honouring it. The two SSH identities the gateway uses to do this were missing the one flag that told the dispatcher to trust them as delegation-capable at all — invisible for months, because the only real traffic so far had only ever needed the single default identity, which never engages delegation in the first place. A live, disposable-principal OAuth test against the production gateway found it immediately: every single request refused, for a reason that had nothing to do with who was logging in. Fixed directly on the server, verified by the same test passing afterwards, then formalised into the test suite so it can’t silently regress.
An even quieter version of the same bug. Closely related, found while actually onboarding real accounts: some already-issued connector tokens — mine, predating the multi-user work entirely — carried no bound identity at all, a gap opened by a schema migration that correctly handled new logins but never touched tokens issued before the column it depended on existed. The fix is now two-layered on principle, not just for this one case: a one-time migration repairs what already exists, and a permanent guard refuses to ever issue — or honour — a token with nothing bound to it again, by any path, including ones that don’t exist yet.
What ties all four together isn’t bad luck; it’s that automated test coverage proves code is correct, never that the code in front of you is the thing actually running, with the actual configuration actually deployed. A live acceptance test against the real system is the only thing that closes that specific gap, and I now treat it as non-negotiable before calling any security-relevant stage done.
Where it stands
Four real principals now exist against this multi-user model, each proven individually against their own actual role, not a simulation: private records stay private, sharing works exactly as each role’s policy allows — including a role that’s explicitly forbidden from sharing to a particular audience, confirmed refused — and nothing, administrator included, bypasses another principal’s ownership. One AI agent runtime (Hermes) now reaches the same canonical state over the exact same gateway ChatGPT and Claude.ai use, with its own distinct identity, and — this mattered to me specifically — its own local memory holding only lightweight operational context, never a second copy of anything Brain already owns. If the gateway is unreachable, the correct behaviour is to say so, not to quietly answer from something stale.
None of this needed a second Brain, a new router, or a new general-purpose service. It needed the existing authorization chokepoint applied consistently, and a habit of proving things against the real system before calling them done.
A brief word on the wider picture
SAKO Brain is one piece of a small personal ecosystem, and it’s worth being precise about which piece. Brain holds state — the knowledge, decisions and current status of my work. It is not an automation engine and I’m not going to describe it as one. Agent reasoning and tool use live elsewhere (Hermes); policy, execution and audit for anything that acts in the world live elsewhere again (TRON); workflow integrations are their own layer (n8n); messaging and presentation are their own layer too (Matrix). What changed this round is that Brain now has a real, tested, live-proven way for tools in those other layers to read and write canonical state as clients — governed by exactly the same rules a human typing a command is subject to, nothing bypassed, nothing special-cased.