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

Groups are switched off, back on, and deleted

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

What changes

A group can be switched off, back on, and deleted. These are new methods in group_lifecycle.rs, over lifecycle.rs, which does the same to any account.

  • fyi.opensocial.deactivateGroup (needs group.configure) switches the group off:
    • The relays get #account {active: false, status: "deactivated"}.
    • Its repo reads as RepoDeactivated in sync.getRepo, getLatestCommit, repo.* and getBlob, and in listRepos it shows active: false, status: "deactivated". Its repos in spaces read as RepoDeactivated too.
    • Nothing writes as it, and its spaces issue no credentials and admit no writes, so nobody reads them, its admins included.
    • getGroup and listGroups show it as deactivated and nothing more.
    • Who held group.configure at that moment is kept in a new deactivation table, since its memberships can't be read while it's off.
  • fyi.opensocial.activateGroup switches it back on, for one of those stewards.
  • fyi.opensocial.deleteGroup deletes it. While it's on, that takes group.configure; while it's off, one of the stewards kept when it went off.
    1. The services syncing its spaces get notifySpaceDeleted, best effort, signed by the group while it still has a key.
    2. Its account, repos, spaces, grants, writer sets, outbox and blobs go.
    3. The relays get #account {status: "deleted"}.
    4. Its DID is ended in the directory with a tombstone, since only this host holds a key to it. The method answers {tombstoned}.

A group whose setup fails partway is deleted, so its handle is free again. This answers the groups pull's review.

Why

This is the next part of 4d, following the prototype's methods/lifecycle.ts. It differs in two ways:

  • The switched-off state, and who may undo it, live in their own table rather than on a groups row; this host has no groups table.
  • It always tombstones, because recovery keys, which would keep a DID a steward's, haven't arrived yet (step 8).

How it was checked

tests/lifecycle.rs covers:

  • Switching off:
    • every read refused; listRepos's status; no writes as it; may false; its space repo refused;
    • shown as switched off to its admin and in the list;
    • the stewards kept, and off twice changing nothing.
  • Switching back on: a stranger refused, and a steward from then accepted. Reads work again, on twice changes nothing, and the relays heard both events.
  • Deleting:
    • a plain member refused;
    • account, spaces and blobs gone, the DID tombstoned, getGroup not found;
    • a syncer told, and a refusing syncer holding nothing up.
  • Deleting while off, by a steward from then.
  • A DID the directory has no operations for is left as it is.
  • A group half made frees its handle, with a steward whose did:web can't be a record key.

The fake PLC now serves /log/last. just cov is at 100% of lines and functions, and clippy is clean.

Shortcomings

  • A deleted group's events stay in the firehose's history, as a PDS's do.
  • A tombstone the directory refuses leaves the DID pointing at nothing. It's logged, and tombstoned says so.

🤖 Generated with Claude Code

Approved

This adds deactivateGroup, activateGroup and deleteGroup over the existing account lifecycle. It adds a deactivation table that keeps the stewards, and it deletes a group whose setup failed partway. The latest head (08b4c685) passes check, test (with the 100% gate), web and lexicons. The earlier run on e8e995cc failed only because it conflicted with main, and the new head no longer conflicts.

I read group_lifecycle.rs, lifecycle.rs and the store's deactivate, activate and delete_account. I did not read the whole 59k-character diff, so the tests and docs are not reviewed line by line. The authorization logic looks right:

  • The stewards are read before the group goes dark.
  • The deactivate and delete steps each run in one transaction that also writes the #account event.
  • A tombstone that fails is logged and reported as tombstoned: false, not turned into a failed delete.

Two small notes, neither blocking:

  • deactivate_group checks deactivation().is_some(), then steward, then configurers, then deactivate_account. Store::deactivate returns false when the group is already off, but the handler ignores that result. If two requests race, the second returns {} without an error. The same applies to activate_group. You could map false to the AlreadyDeactivated / NotDeactivated errors.
  • deleteGroup tells the syncing services before it deletes anything. If the delete then fails, those services have been told of a deletion that didn't happen. That seems acceptable for best-effort notices, but the doc comment could say so.
Merged as c39222e