feat(marmot): leaving, removal, disbanding, and captions derived from the state (v2 Phase 7)

The lifecycle of a current-profile room, through the publish gate. docs/marmot-v2.md,
Phase 7.

Leaving used to be a local flag and a "Left group" chat line: the group never
learned of it, and the leaf stayed in the tree holding the group's keys. A
current-profile room is now left the way v2 leaves: a standalone SelfRemove
proposal on the wire as a kind:445, the LEAVING gate raised first and durably,
the local state dropped, the room closed on this device with its own line. It
is not a commit, so it waits on no relay -- there is no state of ours it would
make canonical. An admin's device that receives the proposal commits it on
receipt, as the library expects, so a leaver is out of the tree without anyone
pressing anything; the commit goes through the gate like every other. The
library refuses a SelfRemove from an admin outright -- an admin self-demotes
first -- so an admin's leave is refused here before anything is raised or
dropped, in words a person can act on: hand over admin, or, for the only
admin, disband. Legacy rooms leave the way they always did.

An admin removes a member with stageRemoveMember through the gate; the library's
admin-depletion guard refuses a commit that would leave no admin. An admin
disbands with stageEnableDisbanding and stageDisband -- two commits when the
group predates the lifecycle component, one otherwise -- under the DISBANDING
gate, which is durable so a crash between raising it and publishing does not
lose the request; the second step is taken by continueDisband when the first
is accepted. Both are on the room detail screen, for a device that administers
a current-profile room: a remove action on every member row but its own, and a
disband button beside leave, with an explainer that says nobody rejoins. A
disbanded room says so and hides every write entrance.

The captions are derived, never received. v2 spells them as kind-1210 system
rows and is explicit that a row arriving over the wire is one member's
assertion, not a fact; here they are written by processGroupMembershipChanges
from the difference between the room's members before a commit and after it --
"X joined the group", "X left the group", "The group was disbanded", "You were
removed from the group" -- on every device that applies the commit, including
the one that made it, which is why an admin's own removal no longer writes a
line of its own: every device says the same thing at the same point. A commit
that removed our own leaf, or disbanded the group, closes the room here as well.
A commit this device made is applied at the relay's OK, where the room now
follows the state it gained. MarmotCommitResult.NO_INVITEE marks a commit that
invites nobody, so the OK sends no Welcome for it.

Tests: GroupLifecycleJvmTest, with quartz's own managers standing in for the
other member, covers an admin committing a member's leave on receipt and the
room saying they left; a removal applied on both sides once the commit lands; a
disband ending the group for everyone, closing the room and refusing what
follows; an admin's leave refused with its reason; and a member's leave sending
the proposal the other side stages, dropping the state and closing the room.
The stand-in is now one fixture, MarmotStandIn, shared with the interop test.
Full JVM suite: 1,182 tests pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Kgothatso NgakoandClaude Opus 5 committed 2026-09-13 23:43:11 +02:00
1 parent f617560cf9
commit c4a46e892f
16 files changed
+966 -164

No files matched your search

@@ -123,6 +123,11 @@
<string name="language">Language</string>
<string name="learn_more">Learn more</string>
<string name="leave_group">Leave group</string>
<string name="remove_from_group">Remove from group</string>
<string name="disband_group">Disband group</string>
<string name="group_disbanded">This group was disbanded. Nothing more can be sent into it, and nobody can rejoin.</string>
<string name="disband_group_explainer">Ends the group for everyone. Nobody can rejoin; a new conversation is a new group.</string>
<string name="member_removal_requested">Removal sent; it takes effect once a relay accepts it</string>
<string name="library">Library</string>
<string name="lightning_invoice">Lightning invoice</string>
<string name="live">LIVE</string>