chadtmiller.com/group-host
atmosphere group host
0
0
The relays are asked to read the host as it starts and every 20 minutes
Merged Approved
This moves the requestCrawl asks out of Host::announce and into a firehose::crawling loop that serve spawns. The loop asks each relay as the host starts and again every 20 minutes. announce now only wakes the firehose streams.
I read the whole diff and found nothing that must change.
- The loop does what the body says. A failing relay is logged and does not stop the loop. Asks go out one relay at a time, so a slow relay delays the ones after it. That is fine at a 20-minute interval.
- Removing the
crawledfield andCRAWL_EVERYfromrepo.rsleaves no stray references in the diff. GROUP_HOST_CRAWLERSindeploying.mdis the compose-side name forPDS_CRAWLERS, so that line is correct.- Tests cover the start-up ask through the real binary, stopped with SIGTERM as AGENTS.md asks. They also cover the repeated ask and the failing-relay path.
- The change file and the doc updates are present.
The rest is covered by CI's coverage gate.
Approved
The only change since my approval is in the serve.rs test. After the relay is asked, it now waits for /xrpc/_health to answer 200 before sending SIGTERM. That closes a race where the ask can arrive before the host listens for SIGTERM. It doesn't affect the earlier approval.
All checks have passed
8 passed, 1 skipped
Merged as 23c8f43
What changes
Asked as it starts. The host asks each relay in
PDS_CRAWLERSto read its firehose (com.atproto.sync.requestCrawl) as it starts, before it writes anything, fromfirehose::crawling, whichservespawns. It logsasked the relay to crawlorrequestCrawl failedfor each relay each time.Asked again every 20 minutes. The same loop asks again every
CRAWL_EVERY(20 minutes), whether or not anything was written. Writing an event no longer asks:Host::announceonly wakes the firehose's streams, and thecrawledtimestamp onHostis gone.No re-announcement. A relay that connects with no cursor still gets only the events after it connects. The host sends no
#sync, replays nothing and makes no fresh commits on its behalf (Why says why).Docs.
docs/reference/config.md(PDS_CRAWLERS), a new "How relays hear of a group" section indocs/design/groups.md, its line indocs/design/README.md, and the log lines indocs/deploying.md.Why
groups.grain.social started with
PDS_CRAWLERS=https://bsky.networkand wrote nothing for hours, so it asked no relay. The first group's#identity,#accountand#commitwent out at 00:50:13, and that first write is what made the host ask. The relays connected at 00:50:15. A relay that has never taken an event from a host connects with no cursor (indigo'ssubscribeWithRedialeradds?cursor=only whencursor > 0; its HACKING.md: "for a new host … the relay will connect at 'current' firehose offset"). So they missed all three, and still report the host withaccountCount 0, seq -1. Grain learns groups from the relays, through Jetstream, so it never saw the group'sorg.atgrp.declaration.Asking at the start means a relay is reading before the first group exists. Asking every 20 minutes keeps it reading. Per indigo's relay:
requestCrawlfor a host it is already subscribed to returns at once (SubscribeToHostchecksCheckIfSubscribed), so asking again costs onedescribeServercheck.offline. Its HACKING.md also plans to drop quiet hosts asidle. A host in either state is subscribed again only byrequestCrawl. On restart, the relay resubscribes onlyactivehosts.Asking only on news fixes neither case. The event that prompts the ask is written before the relay connects, and while the relay's cursor for the host is still -1 it reconnects with no cursor. Once a relay holds a cursor, it reconnects with it, and the host replays from its event log, which it never prunes. 20 minutes is the interval
CRAWL_EVERYalready set.Re-announcement was considered and left out:
#sync, or a fresh commit of the declaration, on each cursorless connect. The firehose is one sequenced log that every subscriber reads, so an event can't go to one consumer alone. Anyone may opensubscribeRepos(it spends no limits), so anyone could make the host write. A relay reconnects with no cursor on every redial until it takes its first event, so each redial would write again. A commit made only to be seen would also change a group's rev without anyone writing.#syncalone. It wouldn't reach Grain. The sync spec defines it as the repo's current commit with no records, and Jetstream turns it into no record ops. Grain only updates accounts it already tracks on#identityand#account.The relay-side cause (no relay reading when the first group starts) is fixed here. The one group already missed won't appear on the relay until its next event. Grain should read such a group's repo itself (
com.atproto.sync.getRepo), which belongs in Grain's own fix.How it was checked
serve.rsasks_the_relays_to_crawl_as_it_starts: the built binary, withPDS_CRAWLERSnaming a fake relay and nothing written, asks it with{"hostname": "groups.example.com"}as it starts. It is stopped with SIGTERM, so it writes coverage.firehose.rsasks_the_relays_to_crawl_every_so_often:crawlingevery 50 ms asks the answering relay three times or more, the event log still empty. A second relay that isn't there covers the failure path.cargo fmt --check, clippy with-D warningsongroup-host(all targets),cargo test --test serve(all pass) and--test firehose. The firehose run failed onlyreads_as_atprotos_own_consumer_reads_itanda_groups_events_read_as_a_jetstream_reads_them, which needharness/firehose.mjs's packages, not installed in this worktree, and don't touch crawling. The coverage gate and the rest are left to CI.Shortcomings