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

Invites are records the group writes in the invitee's inbox

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:proposal/writes-invites

What changes

Invites are written as the group. An app invites someone by writing an fyi.opensocial.invite record in the group's repo in their inbox (at://<invitee>/space/fyi.opensocial.invites/self) through com.atproto.space.createRecord, putRecord or applyWrites (one write), with a session for the group, and takes it back with deleteRecord. The host makes each such write as createInvite and revokeInvite did: the member who signed the app in must hold invite at the time of the write; the invitee may not be a member (AlreadyMember); expiresAt must be a datetime still to come; one invite per group and invitee, so writing again answers the one waiting unchanged, unless it is written at that one's key, which replaces it; deleting one not waiting is InviteNotFound. The host's list of invites keeps in step, the write is told to the invitee's PDS with the retry outbox, and a delete takes it out of the inbox and the list. An inbox holds invites alone, at self.

Sessions for inboxes. The invite action is now granted by space:fyi.opensocial.invites?authority=*&collection=fyi.opensocial.invite (it was rpc:…createInvite). At approval, a raw space:fyi.opensocial.invites?… scope is kept for roles holding invite when it asks for invites alone, in anyone's inbox or one person's; include:fyi.opensocial.manageMembers already carried the inbox permission. getGroupAuth also takes someone's inbox as its space: for a member who may invite, a token scoped to writing invites there and nothing in the group's repo.

Lexicons. fyi.opensocial.createInvite and fyi.opensocial.revokeInvite are removed, and with them their methods in manageMembers. fyi.opensocial.invite and getGroupAuth say how they are written and used now. listInvites, getActorInvites and declineInvite stay.

Console, command, assistants. The console's "Invite someone" and "Take back" take a group token for the inbox and write as the group (web/src/lib/asGroup.ts, a DPoP key made per action, the proof naming the host as its protected-resource metadata names it). opensocial membership invite and seed do the same in Rust. The MCP tools createInvite and revokeInvite become sendInvite and takeBackInvite, which make the write the member's own session for the inbox would, in process, logged under the assistant.

Smaller. now_millis and iso moved from the host into atproto::time, for the command to write a createdAt.

Why

The opensocial proposal has the group author invites in its own repo through the standard CRUD methods with a group-DID session, deleting one to revoke it, so apps written to the proposal invite without methods of this host's. Nobody uses the host yet, so the methods go rather than staying beside the writes. Routing the inbox write to its own function, rather than the access-record path the group's own spaces take, keeps the invite rules (one per invitee, members refused, the host's list) where they were, and leaves the other record writes in token_writes.rs untouched.

How it was checked

  • tests/invites.rs: each case the methods' tests held, now as record writes with a group token: written and told to the PDS, answered again, listed and paged, redeemed, refused (member, bad DID, bad or past expiresAt, long message, no invite), taken back and not found, declined, lapsed and swept. New: the token's scope, ScopeMissing in another inbox, a non-invite record, an inbox not at self, two writes at once, applyWrites of one, a put that replaces, and a member who lost invite since the token.
  • tests/oauth_scope.rs: the raw inbox scope kept and withheld; tests/rbac.rs: an inbox scope for other records grants nothing.
  • tests/assistants.rs and the MCP crate's tests: sendInvite, takeBackInvite, their refusals and schemas.
  • tests/interop.rs (an invite into an inbox on the reference PDS) and the command's tests, run here over the reference PDS.
  • just e2e here: inviting, now also taking back and inviting again; the app-password flow no longer expects no grants at all, since the console's own group token from inviting is listed.
  • clippy, node harness/lexicons.mjs, node harness/docs.mjs, npm run check. The coverage gate is left to CI.

Shortcomings

  • An invite's role check is made just before its write, not under the write lock as other token writes' are.
  • The console makes a DPoP key and a group token for each invite it sends or takes back.
  • takeBackInvite names the invitee, not the invite's URI.

🤖 Generated with Claude Code

Approved

This pull moves invites onto the standard record writes. A group token for the invitee's inbox writes or deletes an fyi.opensocial.invite through write_invite, which keeps the old rules: invite held, no members, a future expiresAt, one invite per invitee, InviteNotFound on delete. The createInvite/revokeInvite methods are gone. The scope mapping, getGroupAuth for inboxes, the console helper and the assistant tools all line up with that. I read group_invites.rs, token_writes.rs, group_tokens.rs, oauth_scope.rs, rbac.rs, asGroup.ts and the console action. I did not read the tests, docs, lexicon JSON, CLI or MCP diffs.

One thing to keep in mind, which the body already flags. In write_invite the waiting_invite lookup and the member check happen before space_write takes its lock. Two concurrent writes with different keys could both see no waiting invite and both write. You say tests/invites.rs covers two writes at once, but I did not confirm that it exercises this interleaving or that the store's INVITE insert rejects the second one. If it doesn't, a follow-up to move the check under the lock would be worth it.

A small point: in inbox_scope, a raw space:fyi.opensocial.invites?… scope with no collection passes the all(...) check vacuously. This is harmless because write_invite only accepts the invite collection, but you may want to require the collection explicitly.

Merged as b4f5b68