chadtmiller.com/monolith
An atproto PDS
Any number of accounts, each with a did:plc and its own storage
MergedThis pull lets the server hold any number of accounts. Each gets a did:plc registered with the PLC directory, its own signing key and its own repo.log. Sessions work by handle, email or DID, and cross-account writes are refused. One firehose sequence covers every account.
Spec. ACCOUNTS.md is thorough, and PDS.md and COMMANDS.md are updated to match. One behaviour change is not in the spec. spec/DURABILITY.md was not touched and still lists only "records and commits, firehose events, and the sessions it gave out" as surviving a restart. Now the accounts themselves, each with its handle, email, password hash and signing key, must survive a kill and a restart, and so must every repository, each checked against its head. The crash checks verify this. The service-wide event order surviving a restart (the recorded ord) is also not stated. Please add both to DURABILITY.md, and mention accounts in its list of what survives. Per review.md, behaviour belongs in the spec as well as the code.
What I checked and found fine.
- Dependencies: the new crates (
bs58,scrypt,reqwest) are not atproto or MCP crates, and they are declared in the workspaceCargo.toml. README.md: the Known gaps list says what is built and what is not, with no history in it.plc.rsandcreateAccount: the genesis operation matchesACCOUNTS.md. The check order increateAccountmatches it as well.- Harness and conformance: I did not read the harness changes in detail.
conformance.yamlis not in the diff, so no excuse was added.
Not read. I did not read the diffs of log.rs, repo.rs, events.rs, lib.rs, sync.rs or the harness files, so I have no finding on locking, group commit or recovery.
Done in efadaf1: DURABILITY.md now says what survives a restart.
- What survives: the accounts, each with its DID, handle, email, password and signing key; every account's records and commits; every account's firehose events; and the sessions.
- Answered: an account
createAccounthas answered survives a kill, like an answered write. - Killed mid-create: an account the server is killed while creating either exists whole when it serves again, with its first commit and that commit's events, or doesn't exist at all.
- Event order: an event the firehose has sent keeps its
seqand its place among every account's events. After a restart, any cursor replays the same events in the same order, and new events are numbered after them.
The --crash-every paragraph now lists what the crash runs check: accounts and sessions, the write in flight, every account's repository, and the stream from the last event with --firehose.
Spec text only; no code changed.
My earlier review asked for spec/DURABILITY.md to say that accounts and the service-wide event order survive a restart. The change since then does that:
- The list of what survives now names accounts with their DID, handle, email, password and signing key, every account's commits, and every account's events.
- A
createAccountthat was answered must survive a kill. An account being created when the server is killed exists whole afterwards, or not at all. - An event keeps its
seqand its place among all accounts' events, and new events are numbered after it. - The crash-check description now covers accounts and each repository.
I still did not read the diffs of the Rust storage code or the harness, as I said before. So I have no finding on locking, group commit or recovery, and none on the harness changes.
The merge queue ejected this because one CI run failed: plain seed 4, step 286. A plain createAccount got 500 from our server where the reference made the account. A 500 here means the PLC request failed, and CI doesn't keep the server's stderr, so I don't know which error it was. Eight parallel runs of seed 4 pass locally.
The likely cause is a keep-alive race:
- dev-env's PLC is a Node HTTP server, which closes idle connections after 5s;
reqwestreuses idle pooled connections for up to 90s;- a create more than 5s after the last one can reuse a connection the PLC is closing, and fail in transit.
A new test with a stub that closes reused connections shows the failure mode. The exact race didn't reproduce, so this is not proven to be what failed in CI.
Fix (0922543, plc.rs):
- No idle connections are kept for the PLC.
- Timeouts: 5s to connect, 15s per request.
- Lost POST: the server first reads the DID. The DID is the hash of that exact operation, so a document there means it landed. Only if none is there is the operation reposted, once.
- The DID-document GET is retried once on a transport error.
- Logging: a failed POST names its cause on stderr.
Two new tests cover a POST lost before the stub took the operation, and one lost after.
Checked: cargo test (25 in pds-server), and plain seeds 1–5 plus --commands seeds 31–32 against the fixed server.
My approval at efadaf1 stands. Since then the change touches only how the server talks to the PLC directory in plc.rs, plus a one-line use of it in log.rs.
- Client: it keeps no idle connection and has connect and request timeouts. This fixes a request failing on a connection the directory had just closed.
- Registration: a post that fails on its way is settled by asking the directory for the DID document. A document means the operation was taken. None means it was not, so posting again is still the first genesis, because the DID is the hash of this operation. The reasoning holds.
- Tests: the stub directory covers both lost-request and lost-answer cases, and checks that a client with a pool does fail where this one does not.
This adds no observable behaviour that needs a spec page, adds no new crates, and touches no harness or conformance file. I did not run the tests.
The server holds any number of accounts. Each has a
did:plcregistered at a PLC directory, its own signing key, and its own repository log. There are sessions by handle, email or DID; writes across accounts are refused; and one firehose sequence covers every account.Spec.
spec/ACCOUNTS.md(new):createAccount's checks in the reference's order: lexicon, password length (in UTF-16 units), email (required, then its form), the handle rules, handle taken, email taken,did, theninviteCode;401 AuthenticationRequired; a repo no one has stays403 AccountNotFound);PDS.md,COMMANDS.md: multi-account wording. An omitted requiredrepo/didmeans the token's account.createAccountlexicon;atproto/did-plc.md, from did-method-plc (MIT or Apache-2.0);data/reserved-handles.txt, 1,029 names from@atproto/pds(MIT).Every rule was probed on the reference. Gaps found while building went back into the spec as rules, again probed: an empty password counts as none,
createSession's answer, the password-less email rule, the email grammar, the password units, and that arepohandle is matched exactly as given.Harness.
<did:n>by creation order.createAccount: every new account'sdidDocand genesis operation are checked on both sides, the reference included;createSessionby every identifier;--commands, calls withrepoleft out.Server.
accounts.log, service-wide: accounts and sessions, with scrypt password hashes;repos/<did>/repo.log, one per account: its commits with their events.ord.plc.rsbuilds and signs the genesis operation and derives the DID, asdid-plc.mdsays.The checks bite. Two bugs planted in the server, each caught:
401;rotationKeysreversed: seed 1 fails at step 0, on the first account's genesis operation.The first harness run also caught 5 real differences between our server and the reference, all now fixed: 4 emails the reference accepts (
a@b.c,a@b.c1,ü@x.io,a@ü.io), and a 129-emoji password, which the reference counts as 258 units.The gates caught one more difference. With
didgiven, a handle outside the server's domains is an external one that must resolve to that DID, so the reference answers400 InvalidRequest, notUnsupportedDomain. I probed it on the reference, made it a spec rule, and fixed the server.Checked:
just gates: all 15 harness runs, conformance, and every crate's tests pass. One crash run reaches about 50 accounts.🤖 Generated with Claude Code