chadtmiller.com/group-host
atmosphere group host
Groups keep repos in spaces, read with an authority's credential
MergedI read only crates/group-host/src/space_api.rs. I did not read the other files in the diff, so the rest of the pull is unreviewed: the store migrations and tables, space_write, the notifyWrite call, the atproto additions, the docs and the tests.
credential holds up. It checks these in order:
issmust equal the authority named in the credential'ssub.- The signature is checked against the PLC directory's key for that issuer.
submust match the requested space.- The
atproto-space-audienceheader must equal therepoparameter. - The request must be signed with the key the credential is bound to (
cnf). - The credential's
jtimust not be revoked.
asked then confirms the repo is hosted here. notify_credential_revoked requires service auth from the space's authority and a hosted audience, and it caps a batch at 100 credentials.
I found nothing that needs changing. I did not run the tests or look at CI results.
This is round 2. The only change since my last review is the final commit, which edits the plan. Nothing I raised earlier is outstanding. The test and check workflows were still queued when I looked, so I haven't seen their results. I did not run anything.
Last round I read only space_api.rs. This round I also read space.rs, store.rs, repo.rs, lib.rs and api.rs, and found nothing that must change:
checkwas pulled out ofrepo.rswithout changing the public repo's behaviour.space_commitserialises writes with thewritinglock and moves the head with a compare-and-set onrev. A raced write fails and changes nothing.- The set hash is updated element by element, removing the old CID on an update or delete.
FORGET_ORPHANnow also checksspace_record_blob, so a blob that a space still references survives a public-repo delete.
I did not read the other files in the diff: the atproto crate additions, tests/spaces.rs, tests/interop.rs, the test helpers and the docs. They are unreviewed.
One thing to fix, though I'm not blocking on it. Host.http is a bare reqwest::Client::new() with no timeout. space_write awaits notify_write before it returns. An authority PDS that accepts the connection and never answers will hang the caller indefinitely, even though the write is already committed. Give that request a timeout, for example .timeout(Duration::from_secs(10)) on the notifyWrite call. The new Host.http use and the directory lookups on every read have the same exposure.
crates/group-host/src/space.rslines 140 to 146Outdated
These lines can no longer be read.
No timeout here. A hung authority PDS blocks space_write after the commit is already stored. Add a per-request timeout; the failure is already logged and ignored.
Round 3. The only change since my last review is the last commit. It answers my timeout comment: Host.http and the PLC Directory now use a shared client() with a 10-second OUTGOING_TIMEOUT. A test with a PDS that accepts the connection and never answers checks that space_write returns after about the timeout. The design doc now says the same.
I found nothing that must change. I did not run the tests or look at CI results. One small note: that test sleeps about 10 seconds in real time, which makes the suite slower. That is acceptable.
I have not read the atproto crate additions, the rest of tests/spaces.rs, tests/interop.rs or the other test helpers. They remain unreviewed.
What changes
Each group has a KEM key. A group's
did:plcdocument now names a P-256#atproto_kemkey beside its signing key. A space's syncer agrees a secret with that key, and the host vouches for what it serves under that secret. The key is kept with the account. The first migration gains the column instead of adding a new migration, because no host has run yet.Groups keep repos in spaces.
Host::space_writewrites a group's records into a space as one revision. It runs the same checks as the public repo: the data model,$type, blobs uploaded to the group. Records go in the store's newspace_repo,space_record,space_opandspace_record_blobtables. The commit is the digest of the records' LtHash, updated element by element. A blob is forgotten once no record references it, in the public repo or any space.Each write is told to the space's authority. After a write, the host sends
com.atproto.space.notifyWriteto the authority's PDS, with service auth signed by the group for<authority>#atproto_pds. If the authority doesn't hear of it, the write still stands.The space read methods, for a credential's holder.
com.atproto.space.{getRecord, listRecords, getRepo, getLatestCommit, listRepoOps, getBlob, listBlobs}answer only a request that brings a space credential. The credential must be issued by the space's authority, for that space, unexpired and unrevoked. The request must name the repo as its audience and be HTTP-signed with the credential's key.Atproto-Space-Want-Mackey share agrees a secret against the group's KEM key. The answer carries the commit's MAC, or the record's.com.atproto.space.notifyCredentialRevoked, with service auth from the authority, revokes credentials until they would have lapsed.atprotogainsspace::SpaceRef, the space alpha'sat://<did>/space/<type>/<skey>.docs/design/spaces.mdexplains the repo host's side. The plan marks this step done.Why
This is the next part of step 4: being the repo host for a group's repos in spaces. A group writes into its own spaces and others', so this side comes before the authority side. The authority side (4c) and the groups (4d) build on it.
Compared with the prototype's
pds/api/space.ts:listSpacesandclearRecords; they come with step 6.notifySpaceDeletedis left out: this host syncs no other authority's spaces, so it has nothing to do with it.How it was checked
crates/group-host/tests/spaces.rsports the cases the prototype's and the reference's space tests hold. It uses a fake authority: a DID on the fake PLC whose PDS records eachnotifyWrite.#atproto_pds;getRepois the STAR archive the vectors check, with its commit MAC;getLatestCommitandgetRecordcarry their MACs;listRecordspages in path order, withcollection,reverseandexcludeValues;listRepoOpspages with a cursor andsince, leaves the value off a superseded op, and puts the commit only on its last page;notifyCredentialRevoked.just cov: 100% of lines and functions. Clippy is clean.tests/interop.rsaddsa_groups_repo_in_a_space_of_the_reference_pds, against the alpha at11c5d98in CI:listReposshows the group's revision and digest as the host computed them.This test runs only in CI. The local alpha checkout is older than
11c5d98and has nocreateSpace.Shortcomings
notifyWritethe authority doesn't get is not retried. The reference PDS retries for a day.did:plc: the host resolves DIDs only through the PLC directory.Review
Start with
crates/group-host/src/space_api.rs'scredential: that check decides who reads a group's records.🤖 Generated with Claude Code