BotPassword gives every account, and every organization, its own SQLite database inside a Cloudflare Durable Object, with a small D1 directory for global lookups. This post explains ADR 0002: what was chosen, what it replaced, and the costs the team wrote down.
What does the server store?
Less than people expect. The control plane holds ciphertext revisions and authorization metadata: devices, memberships, grants and leases. It validates outer headers, sizes and authentication, and it never decrypts anything. The key material needed to read a vault lives on trusted devices.
That data partitions naturally. Personal state belongs to one account. Company state belongs to one organization. There is almost no reason for a query to cross from one tenant into another.
What did the team choose?
ADR 0002 sets out four pieces:
- One
AccountDOper account and oneOrgDOper organization hold all authoritative state for that tenant. - A D1
directoryholds global lookups only, such as the mapping from an email hash or a passkey credential ID to an account. - R2 holds blobs and encrypted export staging.
- PostgreSQL, first on Neon and then on RDS, is the documented fallback if a spike fails a stated criterion.
Durable Objects with SQLite give each tenant a single writer, synchronous transactions, WebSockets, alarms and 30-day per-object point-in-time restore, according to the decision record. The earlier plan had recommended PostgreSQL and compared it with D1, but had never considered SQLite-backed Durable Objects at all.
Why does one writer per tenant fit a vault?
A vault is a log of signed revisions with a head. Pushing a change means checking that the writer has the current head, appending, and bumping it. In a typical pooled database that check is a race you defend with transactions and isolation levels. In a Durable Object, there is one writer per tenant, so the check and the write happen in one synchronous step.
The repository rule for these objects is specific: a critical transition is a single transactionSync with no await inside, preconditions are re-checked inside it, and no network calls happen within a transaction. For example, removing a member from an organization verifies the signed roster change, removes the membership, revokes that member’s grants and sessions, bumps the key epoch and arms an alarm, all in one transaction. Output gates make sure the response is sent only after the write is durable.
An alarm then finishes the work that cannot be atomic, such as updating the directory index and notifying the affected account.
What does isolation look like?
Physical rather than logical. There is no row-level security and no pooled tenant context to get wrong, because one tenant’s rows are in a different database from another’s. A query written without a tenant filter cannot accidentally return someone else’s data, since there is no shared table to scan. For a product whose threat model includes a bug in the server, removing a whole class of cross-tenant mistakes is the point.
The jurisdiction option on a Durable Object can also keep a tenant’s storage within a region such as the EU. The design notes add that residency claims must cover logs, R2, backups and push providers as well, not just the database.
What are the costs?
ADR 0002 lists them without softening.
- Cross-tenant changes need explicit two-phase steps. Anything touching two tenants, such as a person leaving a company, cannot be one transaction. It becomes a sequence with idempotent steps and alarms.
- Lock-in deepens. The authoritative store is a Cloudflare product, and the architecture is shaped around it.
- Ad hoc analytics across tenants need an export pipeline. You cannot run one query over all accounts, by design.
- An independent export outside Cloudflare is mandatory.
How is that last cost handled?
By treating it as part of the design rather than an afterthought. A scheduled alarm in each tenant object writes an encrypted snapshot to R2. A separate pull job, run from infrastructure outside Cloudflare using credentials Cloudflare never holds, copies each snapshot to a different provider with object lock. The exports contain only ciphertext and metadata, and they are additionally encrypted to a backup key whose private half is kept offline. Restore drills are planned quarterly.
The Cloudflare audit log is also exported to storage outside the account, with alerts on changes to members, tokens, DNS, SSL, WAF and Worker routes. The aim is that losing the vendor’s account, or someone taking it over, does not lose the vault.
What happens if the approach fails?
The fallback is named in the ADR: PostgreSQL. A spike measures the Durable Object approach against stated criteria before it is relied on, and a failure on any criterion triggers the switch. Because the server stores ciphertext and the protocol is defined independently of the database, the data model can move. That is a deliberate property of keeping the server unable to decrypt: the store holds opaque, signed records, so changing the store does not change what clients trust.
Why does this belong in a post about agents?
Because agents interact with the product through grants, sessions and leases, and those are enforced by the same single-writer objects. Company credentials rely on a short authorization lease from the organization’s object, at most 60 seconds, renewed after re-checking membership and grant state. Revocation is pushed over a WebSocket, so connected brokers stop quickly. A one-writer-per-tenant model makes that check straightforward to reason about.
For how the local side enforces policy, read why a local daemon holds the keys. For the envelopes stored here, see hybrid post-quantum sharing.