chadtmiller.com/group-host
atmosphere group host
Spaces, handles, deletes and invites are written whole or undone
MergedThis pull makes spaces whole-or-undone, holds a handle in the host before the PLC op, ends the DID before the account delete, and takes lapsed invites back (on requestJoin and in an hourly sweep). I read every changed file and found no defect that blocks the merge. The orderings are right and the tests cover the new paths. I did not read the CI checks.
One edge is worth a follow-up, though not a blocker. In requestJoin, take_back now runs after put_membership and uses ?. If the take-back fails, the caller gets a 500 even though they are already a member. host.store.decide(group, &me) is then skipped, so any pending join request stays undecided. A retry answers AlreadyMember. The invite is harmless, as your body says, so a failed take-back there would be best-effort: log it and carry on to decide.
Smaller point: sweep_invites drops take_back errors without a log line. Only the count shows that some were skipped. A tracing::warn would help an operator see invites that stay stuck.
crates/group-host/src/group_join.rsline 69Outdated
These lines can no longer be read.
A failing take_back here returns an error after the membership is written and before decide runs. The caller is a member but sees a 500, and the join request stays undecided. Treat it as best effort (log it) and continue to decide.
crates/group-host/src/group_invites.rsline 166Outdated
These lines can no longer be read.
A failed take-back is dropped silently. Log it, so an invite that stays stuck can be seen.
The pull makes spaces whole-or-undone, holds a handle before the PLC op, ends the DID before the account delete, and takes lapsed invites back on requestJoin, on createInvite and in the hourly sweep. The only change since my last review is a merge of main plus createInvite now using waiting_invite. I found no new defect.
Neither of my two earlier points was done:
requestJoinstill uses?ontake_backafterput_membership. A failed take-back returns a 500 to someone who is now a member, anddecideis skipped.sweep_invitesstill dropstake_backerrors without a log line.
Both are minor and I'm still approving. A best-effort take-back with a tracing::warn, in both places, would close them.
The pull page reports a merge conflict with main in group_spaces.rs, tests/invites.rs and docs/design/groups.md. Rebase or merge main again before landing it.
crates/group-host/src/group_join.rsline 69Outdated
These lines can no longer be read.
Still ?: a failed take-back gives a 500 after the membership is written, and decide is skipped. Log it and carry on.
crates/group-host/src/group_invites.rsline 166Outdated
These lines can no longer be read.
A failed take-back is still dropped silently. Log it with tracing::warn.
The pull makes spaces whole-or-undone. It holds a handle before the PLC op, ends the DID before the account delete, and takes lapsed invites back on requestJoin, on createInvite and in the hourly sweep. Since my last review the only change is a merge of main into the branch. It also merges cleanly now (fast-forward), so the conflict I flagged is gone. I found no new defect.
Neither of my two earlier points was done, and I still approve. Both are minor:
requestJoinstill uses?ontake_backafterput_membership. A failed take-back returns a 500 to someone who is already a member, anddecideis skipped.sweep_invitesstill dropstake_backerrors without a log line.
Making both best-effort with a tracing::warn would close them. I won't repeat this again.
What changes
A space is made whole or not at all.
createSpacewrites the access record and index entry in a newfurnishstep. If either write fails (an access record that is no record, saycredentialScopes: [{"role": "admin", "scopes": 1.5}]), the host ends the space it just made, so the key is free again rather than lost to a space nobody can change or delete.updateSpacenow looks up the index entry before it writes anything, so a change refused withSpaceNotFoundleaves the access record as it was. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdeyx6g4qiThe host holds a handle before the directory names it.
updateGroupHandlenow sets the handle in the account row first, with no event, so the unique-handle constraint refuses a handle taken meanwhile before anything is published. Then it publishes the PLC update. If the directory refuses, the host puts the previous handle back. Only after the directory names the handle does the host sequence the#identityevent for relays. So the directory never names a handle the host has refused. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdf2eqx3srA half-made group that cannot be removed says why. When
set_upfails and the cleanupdelete_accountalso fails,createGroupnow logs a warning ("could not undo a group half made") and still answers theset_uperror. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdf5bjd3xeA group's DID is ended before its account is deleted.
delete_accountnow publishes the tombstone first and deletes the store only after that. If the directory is unreachable or refuses,deleteGroupfails (500) and the group stays, so it can be deleted again.tombstoned: falsenow means only that the DID was left to a steward's recovery key.tombstonetreats a DID whose last op is already a tombstone as ended (Ok(true)), so a retry after the store delete failed is safe. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdffcdytdiLapsed invites are taken back. When
requestJoinfinds a lapsed invite, it takes that invite back from the inbox and the host's list (waiting_invite). The hourly sweep inservenow also runsHost::sweep_invites, which takes back every invite lapsed by now (newStore::lapsed_invites). An invite whose group is switched off waits until the group is on again. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdderlug3oA redeemed invite is taken back only after the membership is written.
requestJoinwrites the membership first, then takes the invite back. A join that fails leaves the invite waiting. An invite left over for a member does no harm, sincerequestJoinrefuses members. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjddg66ch5ydocs/design/groups.md,recovery.mdandmembership.mdnow describe the new order and the failure behaviour. The test PLC fake'srefuseis now anAtomicBoolthat a test can switch, and a newrefuse_endsswitch refuses only tombstones.How it was checked
group_spaces:an_admin_makes_a_spacecreates a space whose access record is not a valid record, checks that no space or head is left, then makes the same key again.an_admin_changes_a_spacechecks that a name-and-readers change to an unindexed space leaves its access record unchanged. Both failed before the fix.lifecycle: four tests, all of which failed before the fix:a_group_the_directory_would_not_end_is_deleted_again: the directory refuses, then a retry deletes the group.a_did_ended_already_is_endeda_did_the_directory_will_not_end_keeps_its_account: replaces the old test that expectedOk(false).a_group_half_made_that_cannot_go_fails_as_it_did: takes the logged cleanup failure.invites: a lapsed invite is gone from the inbox and the list afterrequestJoin.sweep_invitestakes back a lapsed invite, then finds none. It leaves a switched-off group's invite alone.group_handle: when the directory refuses, the host keeps the handle the directory names, the directory gets no op and relays hear nothing.cargo fmt --checkandclippy -D warningspass. The tests ofgroup_spaces,group_handle,lifecycle,invites,joining,groupsandrecoverypass locally. The full suite and the coverage gate are left to CI.Shortcomings
updateGroupHandleis publishing, the host's record (andgetGroup) shows the new handle a moment before the directory does.🤖 Generated with Claude Code