chadtmiller.com/monolith
An atproto PDS
Spaces' issuer keys at scale: local keys, a day's window, a bound, kept
MergedThis pull verifies the server's own accounts' spaces tokens against the key the server already holds. It keeps other issuers' keys fresh for PDS_DID_CACHE_SECS and usable up to the new PDS_DID_CACHE_MAX_SECS, with renewal in the background. It bounds the cache at one key per 1 KiB of PDS_CACHE_BYTES, dropping the key used longest ago, and persists the keys to issuer-keys. I read issuers.rs in full, plus the changes in lib.rs, ops.rs, cache.rs, space_credentials.rs, the changeset, and LIMITS.md and STORE.md. I did not read these files: jwt.rs, tests.rs, limits.mjs, compare.mjs, issuers.mjs, SPACES-CREDENTIALS.md. I did not run any checks; the verdict rests on the code and the pull's account of its own checks.
- Logic. The LRU list, the
failed-key handling (a stale key that no longer verifies falls through to a fresh read), the per-issuer turns, and the checksummed temp-file-then-rename write all look correct. - Repository requirements. The spec and
LIMITS.mdare updated,STORE.mdcounts the keys in its bounds, a changeset is present, and no atproto or MCP crates were added. I found no mention ofPDS_DID_CACHE_SECSindocs/guide, so I see no guide to update. - Remaining risk. A key rotated away from is now accepted for up to a day for an idle issuer. The pull's body lists this as a shortcoming, and the spec states it, so I accept it.
4 passed, 1 skipped
On a PDS with hundreds of thousands of users, keeping spaces' issuer keys has three problems: the cache cleared itself at 10,000 keys, renewals every 30 minutes could fill the PLC directory's 8 slots, and every restart read every issuer again. This verifies the server's own accounts with the key it already holds, renews other issuers' keys hourly and keeps them up to a day, drops the key used longest ago past a bound, and keeps the keys across a shutdown.
Claude Opus 5.5 · high
What changes
Spec.
SPACES-CREDENTIALS.md, "Issuers' keys":PDS_DID_CACHE_SECS. From then until the newPDS_DID_CACHE_MAX_SECS(default a day) they are still used, and read again after the answer. Past that, they are read first.PDS_CACHE_BYTES(262,144 by default). Past that, the key used longest ago is forgotten.PDS_DATA_DIR/issuer-keysat shutdown and at most once a minute, never synced, and read back in the background after a start.LIMITS.mdadds the variable.STORE.mdcounts the keys in the Memory and Settled bounds.Harness.
harness/spaces/issuers.mjs, against the server alone, withPDS_CACHE_BYTES=65536so that 64 keys are kept:SIGTERMrestart, a kept key is not read again.PDS_DID_CACHE_SECS=3andPDS_DID_CACHE_MAX_SECS=8: a call at 3.5 s is answered within 1 s and the key is renewed after it; a call at 9 s waits for a read.restartWithin the spaces run can shut the server down gently.plcLocalIssuer. Delegation tokens of accounts here, traded atauthorizeSpaceSync, must read nothing from the directory.pds-server. Built by a fresh agent given AGENTS.md's step 3 rules and the spec alone. Neither it nor its instructions saw the reference's source. The code is in
space_credentials/issuers.rs(moved out ofjwt.rs):Keptholds the keys in a list ordered by last use, the key used last first, each packed into 34 bytes.heldgets the key of an account here.ops::shutdownwrites the keys;run()starts the read-back and the writer each minute once the server serves.Why
At 100k active issuers:
KEYS_KEPT = 10_000cleared every key once full, so the cache emptied over and over.PDS_DID_CACHE_SECSis about 55 reads/s, near the about 69/s that 8 directory slots allow at about 116 ms each. Hourly renewal halves that.Accounts here need no read at all: the server signs their tokens.
How it was checked
main(77b758e): the 64-key bound is never applied, the key is read again after a restart, a key pastPDS_DID_CACHE_SECSwaits 1.5 s, and a local issuer's document is read. Each new check fails.plcLocalIssuerfails. With the shutdown write disabled, the restart check fails.spaces/compare.mjs --seed 1), and so do the limits checksplcLocalIssuer,plcDocuments,plcConnections,spacesPayFirstanddidWebApart.cargo test -p pds-server --lib -- space_credentials(21 tests) andspace_notify(22 tests) pass, as reported by the server agent. Clippy and fmt are clean.Shortcomings
PDS_DID_CACHE_MAX_SECS(a day) for an issuer not in use, where it was an hour before. A rotation to a key is still taken at once.SIGINT;jwt.rswith a script rather than the edit tool. The result is a plain deletion.Review
Start at
verify_issuerandheldincrates/pds-server/src/space_credentials/issuers.rs, thenKept.