chadtmiller.com/group-host
atmosphere group host
host: the firehose, with each commit's proof, and relays told of news
MergedThis adds subscribeRepos over WebSocket and an event table written in the same transaction as each change. Commit events follow sync 1.1: ops with prev, since, prevData, and a CAR slice. It also adds throttled requestCrawl to the PDS_CRAWLERS relays, plus decode_first, into_map and time::iso.
I read the firehose, store, repo, config, time and drisl changes. I did not read the rest of the 212-file diff, which is mostly the stacked repos pull (lexicons, web, vendored interop data). I did not run anything or read the checks. The code I read is sound:
- The stream subscribes to wake-ups before reading
last_seq, so no event is missed between reading and waiting. - A lagged receiver only loses wake-ups, and the database fills the gap.
announceruns after the commit, so a stream never wakes for an event that isn't stored.- Event rows are inserted in the same transaction as the repo update.
Two small things, neither blocking:
- A negative
cursor(e.g.-5) passes thec > lastcheck and replays everything. Treating it as a 400, like a non-number, would be more consistent. last_seq()andevents_after()errors are swallowed withunwrap_or_default(). A DB error at connect time shows up to the client asFutureCursor, and a later one makes the stream wait silently. Logging or closing the socket would make this visible.
crates/group-host/src/firehose.rsline 83Outdated
These lines can no longer be read.
If last_seq() fails, last becomes 0 and any positive cursor is refused as FutureCursor. Also, a negative cursor is accepted here and replays from the start. Consider rejecting c < 0 with the 400, and not hiding the DB error.
crates/group-host/src/firehose.rsline 90Outdated
These lines can no longer be read.
A DB error here gives an empty page, so the loop waits as if there were no news. The client sees nothing wrong. A log line, or closing the socket, would help.
This is the same pull as before: subscribeRepos over WebSocket, an event table written in the change's transaction, sync 1.1 commit events with proof CARs, and throttled requestCrawl to the PDS_CRAWLERS relays. I looked only at the head's follow loop and the cursor test in crates/group-host/src/firehose.rs and tests/firehose.rs. I did not re-read the rest of the diff or the checks.
My two earlier nits are not addressed, and neither blocks the merge:
- A negative
cursorstill passes thec > lastcheck and replays everything. A 400, like the non-numeric case, would be more consistent. last_seq()andevents_after()still useunwrap_or_default()infollow. A database error at connect time reaches the client asFutureCursor, and a later one stalls the stream silently. Log it or close the socket.
What changes
The firehose.
com.atproto.sync.subscribeReposover WebSocket: every event aftercursor, then each as it is made; without a cursor, from now. A frame is a DRISL header (op1,t) and body with itsseq; a cursor past the last event is refused with anop-1 frame,FutureCursor, and one that is not a number with 400.Events, kept with what they report. A new table,
event, holds each in the same transaction as the change: a new account's#identity,#accountand first#commit, and each write's#commit. A commit event is sync 1.1's: its ops, each with itsprevCID for an update or delete;sinceandprevDatafrom the commit before; and a CAR slice of the commit, the nodes the new tree has that the old lacked, each changed path's covering proof (as the interop commit-proof vectors check them inatproto), and the records written.Relays told of news.
PDS_CRAWLERSnames relays sentrequestCrawlwith the host's hostname after a change: at most every 20 minutes, and the first time after a start, as the prototype and the reference PDS do.Beside them:
atproto::drisl::decode_firstreads a value and says how many bytes it took, for a frame's two;Value::into_map; andgroup_host::time::isowrites times as atproto does, with no date crate.docs/reference/config.mdgainsPLC_URL, which the repos pull left out, andPDS_CRAWLERS.Why
A relay, an appview and a member's app follow a group's repo through its host's firehose; without it nothing a group writes is seen.
How it was checked
tests/firehose.rs, over a real WebSocket: the four events of an account and a write in order, their kinds andseqs; the write's op, itssince, itsprevData, and its CAR, whose commit verifies with the account's key and holds the new root and the record; an update's and a delete's ops followed live; following from now without a cursor; 513 events read through pages of 500;FutureCursor; a bad cursor's 400; a client's message and close; and the relays told once of two changes, one relay answering and one not there.cargo llvm-covat 100% of lines and functions, clippy clean.Shortcomings
Stacked on the repos pull. Events are kept forever: no window, so no
OutdatedCursoryet.#syncand#infoframes are not sent. The firehose has no backpressure past the WebSocket's own.