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

Spaces, repos and notices are read and sent through atproto-client

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:deps/shared-atproto-spaces

The host's space index, repo copies and notices to syncers, PDSes and relays now go through atproto-client's space, sync and Xrpc clients, deleting about 200 lines of hand-rolled XRPC, MAC checking and CAR reading. It builds on The host answers XRPC through atproto-server, on the shared crates' new releases (the move onto atproto-server and the shared releases), which has landed.

Claude Opus 5.5 · high effort

What changes

Two commits on main: 14 files, about +250 / −450 (the crate's code +239 / −442).

The space index (index.rs). A writer's repo at their PDS is read with space::list_repo_ops (read on from the revision the index came to, the set hash moved by each write, the head commit held to its MAC) or space::get_repo (the STAR archive whole, held to its commit), with a space::Credential the group mints itself (Host::own_credential). The local Remote::ask, Vouched, commit_of and the op-by-op hashing are deleted. What the index keeps is as before: a write whose record is no longer what its CID says (Oplog::changes' unreadable) sends it to read the repo whole, and a record that is not a DRISL map is hashed and left out, with a warning.

A space's files (index_api.rs). space_blob fetches a writer's file with space::get_blob, held to its CID, with the same self-minted credential.

An account moved here (import.rs). Its files are listed with sync::list_blobs and fetched with sync::get_blob; its repo is read with sync::get_repo into an Export (migration::repo_writes); its server's describeServer is an Xrpc query. ask_server and the paging loop are deleted.

A group moved here (migration.rs). Its public repo is sync::get_repo through the same repo_writes; each part of its export (migrateExport) is an Xrpc::query_raw, capped per part as before. ask_source and json_at_most are deleted. The space repos keep their own STAR v1 reading (space_writes), the export's format.

Notices (authority.rs, firehose.rs, account_move.rs). notifySpaceUpdate and notifyRepoUpdate are posted with Xrpc::procedure_reply, the delivery judged by the status (deliver_to); confirmRegistration and notifyCredentialsRevoked with Xrpc::procedure; the relays' requestCrawl too. Whether an account's server holds spaces is space::spaces_alpha.

capped moves to xrpc.rs, kept for the plain HTTP fetches left (an app's logo, OAuth client documents, a proxied failure's body); every XRPC answer is capped by Xrpc::at_most. api::too_much is deleted.

Behaviour changes (the change file, patch):

  • A repo is asked for as STAR-lite, zstd'd, where its host serves one, and a CAR otherwise (sync::ACCEPT).
  • A syncer confirming its registration must answer with a success; the challenge in a refusal's body no longer counts.
  • A syncer's or PDS's answer to a notice is read, up to 16 MiB; one longer is retried, as one not reached is.
  • Failures reading another server name the method and its refusal (getRepo: RepoNotFound (404): no such repo, was …/xrpc/com.atproto.sync.getRepo answered 404 Not Found); tests/migration.rs asserts the new words.

Why

The shared crates carry these reads and their checks, tested against the spaces alpha and the reference PDS; the host keeps only what it decides.

How it was checked

Locally, with CARGO_BUILD_JOBS=2: clippy on the workspace, and the index, import, migration, account_move, authority, spaces, group_spaces, firehose, interop (the reference network, the spaces alpha included), move_host, domain and oauth_clients tests. The whole suite under the coverage gate, and e2e, are CI's.

Shortcomings

Left, and why:

  • group_domain.rs reaches asks a domain's describeServer with the domain as its Host header and a lookup timeout of its own; Xrpc takes neither per call.
  • actor_search.rs asks the typeahead service at the full URL an operator configures (TYPEAHEAD), not a base and an NSID; the PLC export it reads is no XRPC.
  • The move's own space reads (account_move.rs bring_spaces: listSpaces, exportSpaceMeta, listBlobs, getBlob, getRepo of the account's own spaces) stay on moving_json/moving_bytes, under the move's own refresh rule. space::Account lists one's spaces but has no call to export a space's meta or read one's own repo and files in it, so only listSpaces could move, beside four raw calls.
  • space_writes stays: a group's export carries its space repos as STAR v1 (atproto::space::read_star), which is what space::get_repo reads only behind a MAC the export does not have.
  • apps.rs, oauth_clients.rs, proxy.rs keep capped for plain HTTP.

Shared-crate gap, not blocking: space::Account has no reads of an account's own repo in a space (exportSpaceMeta, listBlobs, getBlob, getRepo as their owner), which an account moving its spaces needs.

Review

Start at index.rs; import.rs and migration.rs share repo_writes.

Approved

This moves the host's space reads, repo and file copies and its notices onto atproto-client's space, sync and Xrpc. I reviewed only the pull's own commit, 30020576..dfdbfe42. The first pull's commits in the diff are that pull's to review.

I read every file of that commit's diff. I did not run it, and I could not read the atproto-client source. Whether the shared calls behave as the pull describes rests on the author's local runs and CI.

  • Same behaviour. The index keeps its fallbacks: a write whose record no longer matches its CID sends it to read the repo whole, and a non-map record is hashed and left out with a warning. repo_writes' Invalid still maps to InvalidRepo on import and SourceUnreadable on migration. The size caps carry over: REPO_AT_MOST on repos, blob_upload_limit on files, and ANSWER_AT_MOST elsewhere. retryable takes the same statuses as before.
  • One point worth a look. requestCrawl, notifyCredentialsRevoked and confirmRegistration go through Xrpc::procedure::<IgnoredAny> or <Json>. The reference servers answer requestCrawl and notifyCredentialsRevoked with an empty body. If procedure fails on an empty 200, those would show up as warnings or errors even though they succeeded. The interop and firehose runs you list probably cover this, so I'm not asking for a change. A line in the pull confirming it would settle it.
  • Behaviour changes. The ones you list (stricter confirmRegistration, the new error wording, a 16 MiB cap on a notice's answer) are fine, and the change file covers them.
Approved

This round only rebases the pull's commit onto a new base commit, e7d4d81. That base commit makes Event::of in the firehose read a frame through message(), and it isn't the pull's change. I diffed the pull's own commit at its old head, 30020576..dfdbfe42, against its new one, e7d4d81..cd6677e0, and the two are identical. That covers the changeset, index.rs, import.rs, migration.rs, authority.rs, firehose.rs, index_api.rs, xrpc.rs and the test. My earlier approval stands. The one thing I raised before is still open, and I'm not asking for a change: confirm that procedure::<IgnoredAny> accepts an empty 200 from requestCrawl and notifyCredentialsRevoked.

Approved

Since my approval at cd6677e, the only change is in record_bytes in index.rs. It is now written as from_json(..).ok(), then filter for a map, then encode. The behaviour is the same: a value that is not a DRISL map still gives None, so the record is hashed and left out with a warning as before. My earlier approval stands. The one open point, whether procedure::<IgnoredAny> accepts an empty 200 from requestCrawl and notifyCredentialsRevoked, is still unconfirmed. I'm not asking for a change on it.

Approved

Since my approval at 6f29600, the only change to the pull's own commit is record_bytes in index.rs, and that same rewrite was already in the commit I approved at 6f29600. It reads the value with from_json(..).ok(), keeps it only if it is a map, then encodes it. A value that is not a DRISL map still gives None, so the record is hashed and left out with a warning, as before. The rest of the head's difference from 6f29600 is the base commits, which belong to the first pull. My approval stands. I'm still not asking for a change on the open point from before: whether procedure::<IgnoredAny> accepts an empty 200 from requestCrawl and notifyCredentialsRevoked.

Merged as 8c348dc