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

A group takes a handle on a domain of its own, and its address back

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:host/group-handle

What changes

A group takes a handle on a domain of its own, and its address back.

  • fyi.opensocial.checkGroupHandle (needs group.configure) answers whether a domain is ready and which DID it names now. It changes nothing.
  • fyi.opensocial.updateGroupHandle (needs group.configure) takes the handle, in this order:
    1. Its did:plc gets an update signed with the host's rotation key. This is refused with NotController once the host holds no rotation key for the group, or its DID is ended.
    2. The host records the new handle.
    3. The relays get an #identity event.
  • What a group may take:
    • A handle is read lower case, without @.
    • Under HANDLE_DOMAIN a group may take only its own address, otherwise UnsupportedDomain.
    • A handle another account here holds is refused with HandleNotAvailable.
    • A domain not naming the group is refused with NotPointing.

A group's address is kept apart from its handle, in a new address table written when an account is made. It's where its site is served, and it never changes here. getGroup and listGroups show it as address.

HANDLE_RESOLVERS (new) says how a handle is resolved, each way tried in turn:

  • well-known:<scheme>: the domain's own /.well-known/atproto-did;
  • a service answering com.atproto.identity.resolveHandle, which reads its DNS record.

The default is well-known:https,https://public.api.bsky.app, the same as knotless's KNOTLESS_HANDLE_RESOLVER.

From the lifecycle pull's review: deactivateGroup and activateGroup now let the store's answer decide. A switch that raced another gets AlreadyDeactivated or NotDeactivated, not {}. deleteGroup's comment says syncers are told first. Also a test that putRule refuses a key like a/b, from the config pull's review.

Why

This is the next part of 4d, following the prototype's methods/handle.ts. Handles are resolved as knotless resolves them (identity.rs's resolve_handle), rather than by DNS from the host: a well-known lookup, then a resolver service.

NotPlc is listed in the lexicon but never returned, because every group made here is a did:plc.

How it was checked

tests/group_handle.rs runs a host whose resolvers are well-known:http (which finds nothing under .test, covering its failure) and then a stub resolving service. It covers:

  • Checking: a domain naming the group, another DID, nobody, and its own address, with @ and case normalised.
  • Taking a domain:
    • the PLC update, the stored handle, the #identity event;
    • getGroup keeping the address;
    • a repeat changing nothing, and the address taken back.
  • Every refusal:
    • an invalid handle, another address under the domain, the bare domain, a handle another group took;
    • a domain naming another DID or nobody;
    • a non-configurer, missing fields, an unknown group;
    • a PLC whose rotation keys moved, a tombstoned DID, and a directory that can't answer (500).
  • tests/config.rs covers HANDLE_RESOLVERS.
  • just cov is at 100% of lines and functions. Clippy is clean.

Shortcomings

  • No test can reach a successful /.well-known/atproto-did lookup, because a handle's domain can't be served locally. The lookup is one chain, and its failure is tested.
  • The group's site isn't served at its address yet: that comes with the console.

🤖 Generated with Claude Code

Approved

This adds checkGroupHandle and updateGroupHandle, a separate address table, and HANDLE_RESOLVERS. It also folds in the lifecycle race fix and the putRule test. The order of steps (PLC update, then store, then #identity) is sound. The unique account.handle column does back the "taken meanwhile" comment. Docs and config reference are updated. I found nothing that blocks the merge, but two things are worth fixing.

  1. No backfill for the new table. The migration creates address empty and only insert_account fills it. Any group made before this migration has no row. For such a group, configurable hits expect("a group has an address") and panics. getGroup and listGroups show address: null. If any host already holds groups, add INSERT INTO address SELECT did, handle FROM account to the migration. If none can exist yet, say so in the pull.
  2. Outbound lookups on a caller's input.
    • resolve_handle fetches {scheme}://{handle}/.well-known/atproto-did for a handle chosen by a configurer. The domain may point at an internal address.
    • Reqwest follows redirects by default and .text() reads the whole body. Only the LOOKUP timeout bounds the request, so a hostile host can stream a large body within it.
    • The resolver-service request has no timeout at all.
    • Consider limiting the body size, disabling redirects, and applying LOOKUP to the service call as well. This is not blocking, since group.configure is required.

Minor: the delete_group doc comment now has one very long line.

crates/group-host/src/group_handle.rsline 48Outdated

These lines can no longer be read.

review.knotless.dev

Panics for an account with no address row. The migration doesn't backfill existing accounts.

crates/group-host/src/identity.rsline 122Outdated

These lines can no longer be read.

review.knotless.dev

The service call has no timeout, unlike the well-known one. Also, .text() and .json() read unbounded bodies, and redirects are followed.

Merged as cd3e8d1