chadtmiller.com/group-host
atmosphere group host
Roles, permissions and memberships are written as the group
MergedThis moves roles, the permissions record and memberships to com.atproto.space.* writes as the group. The host checks each write in member_writes.rs and does what it means: admitting, changing roles, or ejecting. The console, the MCP tools and the command follow.
I read member_writes.rs, the token_writes.rs and scopes.rs changes, and the console's settings/+page.server.ts, actions.ts and asGroup.ts. I did not read the other 48 files, the tests, docs and lexicons among them.
I found no logic hole in what I read:
- The
freshexception only covers roles nobody holds and no grant names. A writer can only add scopes their own roles cover. LastConfigurerandRoleInUseare checked against the end state of the batch.Createrequires a pending join request.
Needs your attention before merge:
- e2e fails on
defining a role(flows.spec.mjs:240). After "Define the role" withinvitechecked, no.roles lifor "Ride leader" appears. The flows after it did not run, so the "signing an app in as her group", assistant and moderation flows are unverified. The cause is probably in the newroleaction in the settings page. Either the write is refused, or the form's response doesn't make the page reload. testwas still running when I looked, so the 100% coverage gate is unverified.- Check this against a refused update: in
members_rules, anUpdateof a membership with no current record falls back to empty current roles (unwrap_or_default). Itsadmitand join-request check is skipped, and onlyrole.assignis asked. I expect the repo layer to refuse an update of a record that isn't there, including throughputRecord's create-or-update resolution. A test with a writer holding onlyrole.assignwould settle it.
crates/group-host/src/member_writes.rsline 382Outdated
These lines can no longer be read.
If rkey has no membership, current is empty and only role.assign is checked, so the admit and JoinRequestNotFound rules are skipped. Please add a test that a writer holding role.assign but not admit cannot make a member this way, with putRecord and applyWrites.
This round adds a merge from main and a test for an assistant's refused method. I looked at what my last round raised.
- e2e: it failed at
f647fcdondefining a role. Atf57a1d8it passed, flows included, so that is fixed. Atb8167bfthe e2e run was still going when I looked. - Coverage:
testatf57a1d8failed the coverage gate. The only uncovered lines wereassistants.rs807-809 and 830-832. The latest commit is aimed at exactly those. Thetestrun atb8167bfwas still going when I looked, so the 100% gate is unconfirmed until it finishes. This is enforced by the check, so I'm not holding the approval for it. - Update with no current record: I couldn't find the test I asked for.
Updateinmembers_rulesstill falls back to empty current roles (member_writes.rs:382), so a writer holding onlyrole.assignwould skip theadmitandJoinRequestNotFoundchecks. This is only a hole if the repo layer lets an update through for a record that isn't there. I couldn't confirm either way. The newJoinRequestNotFoundcases inmembers.rsandjoining.rsall go through create or put with anadmitholder. A test with arole.assign-only writer usingputRecordandapplyWriteson a non-member would settle it. Please add one, or makeUpdateof a missing membership an error in the rule itself.
crates/group-host/src/member_writes.rsline 382Outdated
These lines can no longer be read.
Still falls back to empty current roles when there is no record. Please test that a writer with role.assign but not admit cannot make a member this way, through putRecord and applyWrites. Or refuse an update of a missing membership here.
This round's new commit makes ejection revoke the member's space credentials before the membership delete commits. I read leaving and members_written in member_writes.rs. A revoke failure returns an error before any write, so the member stays and the write can be sent again. The order is right.
Update with no current record: I withdraw this one. Repo::check in repo.rs refuses an Update when no record is at the path ("there is no record at …"), so the unwrap_or_default fallback at member_writes.rs:382 can't be reached with a missing membership. That holds for putRecord too, since it resolves to Create when no record exists, and Create needs a pending join request. A test for a writer holding only role.assign would still be nice, but I'm not asking for one.
Checks at d61104b:
checkfails atrust-lint / fmt, so clippy was skipped. Runcargo fmtand push. The check enforces this, so I'm not holding approval for it.e2e,docsandlexiconspass.testandwebwere still running when I looked. The 100% coverage gate is unconfirmed.
I did not re-read the other files this round.
This round's only new commit is a formatting fix. I did not re-read the code, since my earlier rounds covered member_writes.rs, token_writes.rs, scopes.rs and the console files.
I asked for cargo fmt last round, and it is done. Every check at 53148a1 passes: check (fmt and clippy), test (coverage gate included), e2e (flows included), web, docs and lexicons. That settles the two things I couldn't confirm earlier, the 100% coverage gate and the e2e flows. The "update with no current record" concern I already withdrew, because Repo::check refuses an update when no record is at the path.
I have nothing further to ask for.
What changes
Roles, grants and memberships are records written as the group. An app with a session for the group writes
fyi.opensocial.role, thefyi.opensocial.permissionsrecord andfyi.opensocial.membershipin the members space throughcom.atproto.space.createRecord,putRecord,deleteRecordandapplyWrites.putRole,deleteRole,assignRoles,admitMemberandejectMemberare gone: their routes, handlers, lexicons and MCP tools.requestJoin,cancelJoinRequest,getJoinRequest,leaveGroup,listJoinRequestsanddenyJoinRequeststay.What a write needs. The session's scope must name each write, and the member who signed the app in must hold, at the time of the write,
group.configurefor roles and the permissions record, andadmit,role.assignorejectto create, change or delete a membership. Those three actions are now space scopes on memberships in the members space (space:fyi.opensocial.members?skey=self&collection=fyi.opensocial.membership&action=create|update|delete). A scope over every collection, andinclude:fyi.opensocial.manageMembers, carry all three. The host checks each write inmember_writes.rs, keeping every rule the methods had:RoleInUse). An app deletes the role and writes the permissions record without its grant in oneapplyWrites.selfand is never deleted, with one grant per role. A writer changes only the grants of roles they may assign, or of a new role that nobody holds and no grant names (NotAssignable). A scope they add must be one their own roles hold, as written or within one they hold, with our permission sets read as the scopes they list (ScopeNotHeld). A role they add to anassignablelist must be one they may assign, or a new one. Each named role must be defined.member(MemberRole). It names only defined roles.admitgrants may give. Nobody who has not asked is made a member this way (JoinRequestNotFound).role.assigngrants may give. It also ends any stale request.ejectgrants may give each of their roles. Their space credentials are revoked before the delete commits, so if revoking fails they stay a member and the write can be sent again. Once it commits, their OAuth and assistant grants end, their app passwords go, the index forgets them, and anejectEventnaming who did it goes to the moderation queue.LastConfigurer).The writes of one
applyWritesare each checked against the records as the writes before them left them, under the commit's lock.Shapes. The permissions record's grants are now the proposal's
defs#groupGrant:scopesandassignableare lists of strings.roletakes the proposal's 2,000-grapheme description.getGroup'sroleViewgainsdefault. The foundingadminmay now assignadminandmember, as the proposal's creator role "can assign every role".Tokens for the members space. At approval, the members space counts what the member's grants let them write there, so a narrow scope such as
eject's alone is kept.getGroupAuthfor the members space gives a space scope for each of those collections, and no repo scope.The console writes as the group with a group token for the members space. On a group's page, admitting, giving roles and putting someone out each write the membership. On the settings page, defining a role writes the role and the permissions record at once, with the role added to what the definer's configuring roles may give. Taking a role away deletes the role and its grant.
web/src/lib/actions.tsmaps each action to its scope, andasGroup.tsgainsapplyAsGroupandmembersOf.MCP. The removed tools are replaced by
putRole,deleteRole,putPermissions,putMembershipanddeleteMembership, entries in theRECORDSlist of record tools (Kind::Record), with schemas from the record lexicons. A put takes the record's own fields,createdAtincluded, and anrkey: a role's id, or a membership's member DID. The permissions record is always atself. A delete takes therkey. Each makes the write the member's own group session for the members space would make (record_as, thenwrite_as), with the scopegroup_scopegives the member's roles now, under the same rules.The command.
membership assignandejectwrite the membership as the group, withGroupSession.--reasonis gone.seedmakes its moderator role with oneapplyWrites.Why
The host follows the opensocial proposal, in which apps write the group's records through
com.atproto.space.*and the host enforces each record type's meaning ("Writing a requester's membership approves their request", "deleting one ejects the member"). These are the members space's records. The proposal requires the checks against granting more than one holds. The exception for a new role is what lets anyone set up a role at all: under the proposal's rule alone, a role made after the group exists could never be granted or given by anyone. A role nobody holds and no grant names gives nobody anything, so letting its creator grant it what they hold themselves escalates nothing. The host still refuses a membership for someone who has not asked, so that, as before, nobody becomes a member without asking or an invite.How it was checked
members: a revocation that fails leaves the membership and the queue as they were. Each rule of the oldputRole,deleteRole,assignRolesandejectMembertests, now as record writes: keys, lexicon limits,RoleInUse,LastConfigurer(giving up configure, last admin stripped or put out, a configuring role nobody holds),NotAssignablefor grants, roles given and roles listed,ScopeNotHeld, a new role made and granted in one batch, a writer whose roles shrank (403), and a put-out member's credentials revoked, apps ended, index forgotten and ejection queued.coversis checked over repo, space, manage, rpc and blob scopes.joining: admitting by writing a membership, with refusals, a stale request, and a gatekeeper who may admit but not give roles.group_tokens: a members-space token's scope and collections, and refusal for a member with no grant there.assistants: each record tool, and their refusals.rbac,oauth,oauth_scope,tokensandmoderationfollow the new scopes. The command's tests on the reference PDS: assign, eject,LastConfigurer, and an outsider's 403.cargo test --workspace(with the reference PDS), clippy, fmt,node harness/lexicons.mjs,layers.mjs,docs.mjsandnpm run check, all run here. The e2e flows (admit, give roles, put out) and the coverage gate are left to CI.Shortcomings
deleteRecordhas nowhere to carry one, and the proposal'sejectEventhas none.ejectMembersaidNotAMember.assignablelists. Such a grant can still be changed, but a role of that name made again is not new.listJoinRequestsanddenyJoinRequeststill take the member's service auth, not a group session as the proposal has them.Review
Start at
crates/group-host/src/member_writes.rs(members_rules,Writer::permissions,leaving), thentoken_writes.rs(may_space,write_as) andscopes.rs(covers).🤖 Generated with Claude Code