~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

Sessions, blobs, identity and what a relay reads, built in parallel

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/monolith:wave2

Four slices, built in parallel: sessions, blobs, identity, and what a relay reads. For each, one agent probed the reference and wrote the spec page and harness checks; a second built the server from the committed spec without reading reference source. The four were then merged here.

Sessions (spec/SESSIONS.md)

  • Tokens are JWTs. The Bluesky app decodes exp and scope. Access tokens are at+jwt, last 2h and hold no state. Refresh tokens are refresh+jwt with a jti, last 90 days, and are tracked: a successor, a 2h grace window, reuse answering the same successor, and concurrent refreshes all succeeding.
  • New methods: refreshSession, deleteSession, and app passwords (createAppPassword, listAppPasswords, revokeAppPassword). It specs what an app-password session may do, and that revoking a password ends its sessions.
  • Tools and commands for methods with no output: a tool answers {}, and a command prints {}.
  • A reference fault we don't copy: refreshing a session made with an app password named "" turns it into a full session, which survives revoking the password. That is privilege escalation. The server keeps such sessions app-password sessions, and the harness doesn't log in with an empty-named app password.

Blobs (spec/BLOBS.md)

  • uploadBlob: checks the token, then Content-Type, then the 5 MB limit (413, draining the body so the client reads the answer). The MIME type is sniffed for six formats.
  • Blob refs in records: checked last: BlobNotFound, InvalidMimeType, InvalidSize. Malformed blob-shaped maps are stored as they are, as the reference does. References are counted from the records as the commit leaves them, and a blob goes with its last reference.
  • Serving: getBlob serves referenced blobs only, with the reference's security headers. listBlobs pages by CID, with since.
  • Storage: content-addressed files per account, written and deleted crash-safely.
  • Not compared, both reference races: a batch writing one key twice, and the reference sometimes serving a blob that a refused write named.

Identity (spec/IDENTITY.md)

  • resolveHandle.
  • updateHandle: createAccount's handle checks; a PLC update operation built on the directory's last one and signed with the rotation key; #identity; and the old handle freed at once. Of two accounts racing for one handle, one wins. The reference's loser sometimes gets 500 after its operation was already posted; ours gets HandleNotAvailable and posts nothing.
  • Crashes: a change is recorded before it is posted. After a restart it is settled in the background, so a PLC outage never stops the server from starting.
  • Also: /.well-known/atproto-did by Host, getRecommendedDidCredentials, and describeRepo's didDoc and handleIsCorrect, now compared.

What a relay reads (spec/FEDERATION.md)

  • listRepos, with cursors that survive account creation and restarts;
  • getRepoStatus;
  • getBlocks: a CID the repository doesn't hold refuses the call;
  • sync getRecord, proving presence and absence;
  • requestCrawl sent to PDS_CRAWLERS at the first event, then at most every 20 minutes.

A reference fault not copied: killed between a commit and its account-table update, the reference's listRepos lags.

Integration

  • Shared plumbing: one Resp::Nothing; sessions' Bearer and Auth::Expired used by every token check; one handler kind for token-before-input; one tool rule (JSON or no output, and JSON or no input).
  • Harness: the status table for the new error names.
  • Counts: 23 MCP tools; 64 server tests.

The checks bite. One bug planted per slice, each caught on every seed tried:

SlicePlantCaught
Sessionsaccess tokens live 1hseed 1 step 12, seed 2 step 14
SynclistRepos reversedseed 1 step 8, seed 2 step 71
Identityold handle not freedseed 1 step 26, seed 2 step 21
BlobsgetBlob with the wrong Content-Typeseeds 1–3, steps 203, 137, 289

Found along the way and fixed:

  • Server:
    • PNG sniffing was stricter than the reference;
    • a 413 reset the connection instead of reaching the client;
    • a keep-alive race in the PLC client (accounts, earlier).
  • Harness:
    • a malformed test PNG;
    • a login with another account's app password recorded as the wrong session.

Checked: just gates: all 15 harness runs, conformance, and every crate's tests pass. Before that, each slice passed its own harness: plain seeds 1–3, --commands 31–32, and crash seeds 21, 22 and 41.

🤖 Generated with Claude Code

Approved

This pull adds four slices to the PDS: sessions, blobs, identity and what a relay reads. It is about 9,700 lines across 59 files, and I did not read all of them.

Read in full:

  • Cargo.toml, Cargo.lock and crates/pds-server/Cargo.toml
  • README.md
  • harness/compare.mjs, harness/lib/xrpc.mjs, and the changes to harness/checks/{accounts,commands,crashes,firehose}.mjs
  • harness/conformance.yaml
  • crates/pds-server/src/sessions.rs, lines 300–560 (token checks, session start, refreshSession, deleteSession, app-password methods)

Not read:

  • The rest of sessions.rs (its tests).
  • blobs.rs, federation.rs, identity.rs, plc.rs and log.rs.
  • The other changes under crates/ (pds-cli, pds-lexicon, pds-repo, and the lib.rs, mcp.rs, repo.rs, server.rs, events.rs, sync.rs changes in pds-server).
  • The new harness checks blobs.mjs, federation.mjs, identity.mjs and sessions.mjs, and the remaining harness/lib/ changes.
  • Everything under spec/, including the new pages and lexicons.

I make no claims about those. No runs were listed for this pull, so I relied on the author's report that just gates passes.

What I checked against .knotless/review.md:

  • Crates: the only new dependencies are hmac and http-body, plus tokio's time feature. None is an atproto or MCP crate.
  • README: it now says what is built and which gaps remain, not how it was built.
  • conformance.yaml: unchanged, so there are no new excuses to justify.
  • Harness: the firehose check is stricter, since it now compares each #identity handle in order. normalize now treats a missing body as {}. This matches the new rule that tools and commands for methods with no output answer {}, and I don't see it loosening a check.
  • Session code: it matches the claims in the body. A refresh keeps the session's scope, so an app-password session stays one. createAppPassword needs a full-access token. The refresh grace window and reuse of the successor are implemented as described.

Nothing I read needs changing. Whoever merges should know the large unread portion above.

Merged as 6aa625c