| Phase 1's `reconcileAdmins` as the single writer of `adminAt` | `AdminFlags.reconcile`, from [robust-group-admins.md](./robust-group-admins.md), which was built at the same time for the same reason and also runs on the Welcome and once at start. Phase 1's own function was dropped when the two met; its creation-site calls now go through `AdminFlags` |
| Phase 2's lines in the library's order: departures, arrivals, demotions, promotions | after the membership lines, which keep the order they had (arrivals, then departures); then demotions, then promotions |
| Phase 3's statement has a `disband` line | a `component` line per GroupContext component the commit changes, by id and the hash of its new value. Disband, enabling disband and a rename are all that one rule, and a statement cannot sign off one component while the commit changes another |
| Phase 3's kind "in the 303xx range" | 30370, past the last retired wallet kind. 30371 is the own-commit envelope, 30372 the support announcement, 30373 the carrier |
| Phase 4a: the signed statement is published as an application message | inside a **carrier** (30373) sent by a member. The inbound path holds every application message to its sender's own key (MIP-03), and a statement is the room's, so it cannot travel as one -- which is also why `FrostSigningManager.complete` never publishes a group-signed event. The carrier vouches for nothing; the statement inside is checked on its own signature |
| Phase 4a: an own commit (30371) is "signed by the committer's account key" | sent by it: the inner event is an unsigned rumor whose author MLS has already authenticated as its sender, so the check is that the sender is the committer |
| D4: the marker is `giza-governance: threshold/v1` | `Changes need the group's signature; at least N admins.` -- it carries the **floor** too. A floor each device worked out from the ceremony it holds would differ between a founder and a member welcomed later, and the two would disagree about a commit |
| Phase 4a's copy-check reads a commit's proposals off the copy | the proposals off the copy, and who a Remove names off the live group as it stood before the commit: the copy's view can already have the removed leaf blank. Found by the inbound removal test; without it every signed removal was refused at the door |
| Phase 4b: an invite into a governed room is refused for an account that has not announced | not built. A joiner announces as soon as it hears another member say it, which every device does once per room; a joiner on a build that cannot follow is the open problem D4 names |
| Phase 5: any other admin publishes a signed change after a short wait | only the proposer publishes. A proposer who goes quiet after the signature leaves the change waiting until it comes back |
| Phase 5: a stale statement is proposed again automatically | it is marked stale and the room says so; proposing again is the person's |
| Phase 5b: a removal of an admin is two signed commits | one: the proposer builds it on its own copy of the group, which can stage a Remove and the admin-list update together where the library's manager cannot |
| Phase 5b: disband proposes each of its commits | in a room that has not agreed it can be disbanded, the first press proposes that agreement and says to disband again once it is signed |
| D7: founding commits authorised by the key state | dropped: the rule is switched on after founding (Phase 4b), so founding needs nothing |
| Phase 6's removal of an admin is "chained in memory" | through `MarmotEngine.afterConfirmed`, registered *before* the commit it waits on so a relay's OK cannot overtake it, and taken back if publishing throws. Leaving as an admin uses the same hook. In a governed room a removal is one signed commit instead |
| Phase 7's floor is checked on demotion, removal and leaving | on removal and on every governed commit at the door; a keyed room offers no demotion and no leave for an admin until Phases 8 to 10 |
| Phase 10's keyed-room rows: "above the floor" and "at the floor" | one row for now. A keyed room's admin who presses **Leave group** is told, as before, that an admin cannot leave; `AdminLeave.CANNOT` |
| Phase 8: promotion from any keyed room | only from a key past its ceremony's generation. Generation 0 lives in the ceremony's own record, which has no room for an id the ceremony did not make; the first rotation makes the generation rows an enrollment extends. **Make admin** says so when it is refused. *Since then, the offer starts that rotation itself and the promotion waits for it* ([admin-change-rotation.md](./admin-change-rotation.md), Phase 6) |
| Phase 8: offer and acceptance as "a new 303xx kind" | 30374 and 30375, and a third, 30376, for the **handover**: once the change lands, the offering device sends the new admin the table, roster and signed key state. The new member's device holds nothing of the key before that, and checks all of it against the room's own signature -- the state has to be one the room signed, the table has to hash to what it names, and it has to bind the new id to this account under this device's host key |
| Phase 8: `P_n` "interpolated in the exponent from the existing table" | from the table's first `t` entries, with `FrostEnrollment.derivePublicShare`. Every device does it, and adds the id only when the extended table hashes to what the group signed |
| Phase 8: enrollment as `ShareRepairManager` generalised | the repair protocol unchanged but for its `n`: a request names the `n` it runs with (the new id, the table's size before it), helpers check that against their own table, and an enrollment asks no helper for approval -- the signed binding was everyone's chance to say no |
| Phase 8: `n` grows in "the stored key" | a signing session's and a repair's `n` is the generation's table size, which the enrollment grew; the ceremony's `participantCount` is left as the ceremony made it |
| Phase 9: every remaining holder's deal and confirm made automatic | the rotation is started by the proposer's device once the change lands (`GovernanceFollowThrough`), and each holder is asked once to take part, as every rotation now asks (rotate-shares-single-approval). A rotation that cannot start is said in the room and offered from the Shares section. *Since then, nobody is asked: the signed change is every holder's approval, and admin changes and rotations take turns* ([admin-change-rotation.md](./admin-change-rotation.md)) |
| Phase 9: an admin can step down in a keyed room | not offered at first: the rotation that has to follow is the remaining holders', so another admin proposes the demotion. Since offered as a request -- **Step down as admin** sends `PromotionEvents.STEP_DOWN` (30377), and the remaining admin in the lowest leaf (`AdminGovernance.stepDownProposer`) proposes the demotion for them, then rotates their share away as after any demotion it proposed. Leaving as an admin of a keyed room is still not offered |
Read [marmot-v2.md](./marmot-v2.md) Phase 7 first. Removing a member, disbanding and
the derived membership captions all come from there. Read
[frost-share-refresh.md](./frost-share-refresh.md) before Phases 8 and 9: a promotion
is an enrollment and a demotion is a refresh. Read
[frost-batch-signing.md](./frost-batch-signing.md) before Phase 5, because a
governance change is signed as a batch.
---
## The three rules
| | rule | what it means here |
|---|---|---|
| **R1** | **Every admin holds a share of the group's key** | Promotion includes enrolling the new admin into the key. Demotion includes rotating the shares without them. A member row still shows **Admin** and **Holds a share** as two separate labels, because between the commit and the share work they disagree, and that disagreement is how a person sees that an enrollment or a rotation is still owed. |
| **R2** | **Every commit is first a proposal, and becomes a commit only once the group's threshold signature is on it**, except a member's own leave and a member's own key update (D6) | No single admin can change a keyed room. An admin builds the commit and proposes it, `t` share holders sign an event that carries it, and only that signed event is published. Every device refuses a bare commit. |
| **R3** | **A robust group always has at least three admins** | The floor `ChatRoomType.MINIMUM_ROBUST_GROUP_SIZE` (now `Quorum.MINIMUM_GROUP_SIZE`) already sets at creation becomes an invariant. Demotion, removal and leaving are refused when they would break it, and so is anything that would leave fewer admins than the quorum `t`. |
R2 is the hard part: every device has to refuse a commit the group did not sign. The
library cannot be told to -- its commit hook sees neither the commit's
`authenticated_data` nor its epoch, and `MlsGroupManager` hard-codes Marmot's policy --
so the first draft made that upstream work. It does not have to be. **The commit
travels inside the group's signature instead of the signature inside the commit**:
1. The proposer's device stages the commit on a copy and builds the kind:445 event that
carries it, exactly as it would publish it -- and does not publish it.
2. The group signs one event whose content *is* that kind:445 event, with Phase 3's
statement as its tags. Each signer's device runs the commit on a throwaway copy of the
group and checks it does what the tags say before approving.
3. The signed event goes out as an ordinary application message at the commit's epoch.
4. Every device verifies it and hands the inner kind:445 to the engine as if it had
arrived from a relay. In a room where the rule is on, a kind:445 that is a bare
commit is dropped before the engine sees it.
Everything that needs is public and already in the app's hands:
| what the envelope needs | where it is |
|---|---|
| one place every inbound group event passes through, before the engine applies it | `NostrDao.indexCurrentProfileGroupEvent` calls `engine.processGroupEvent` and nothing else does ([NostrDao.kt:1419](../composeApp/src/commonMain/kotlin/mobi/giza/compose/database/dao/NostrDao.kt:1419)) |
| telling a commit from a message without processing it | after the Marmot outer layer, an MLS `PrivateMessage` or `PublicMessage` carries its `contentType` in the clear; `MarmotInboundManager.tryDecryptOuterLayer` already does the outer half |
| running a commit without applying it | `MlsGroup.restore(state, policy)` and `processFramedCommit` are public, and a policy passed to the copy is handed the commit's real proposals |
| applying a commit the app was handed rather than received | the inner kind:445 is a complete signed event; `engine.processGroupEvent` takes it like any other, and convergence sees it as it would any commit |
| the proposer's own commit, which it cannot process | the staged state and the publish gate: `gate.prepare` with the state staged at proposal time, confirmed when a relay accepts the envelope |
| The app has no control for promoting or demoting, but [MarmotOutboundDao.leave](../composeApp/src/commonMain/kotlin/mobi/giza/compose/database/dao/MarmotOutboundDao.kt:950) tells an admin who presses **Leave group** to "hand over admin first" or "make another member an admin, or disband the group" | — | an admin today can disband a group but cannot leave it |
| That message is thrown inside `viewModelScope.launch` in [ChatRoomDetailViewModel.leaveGroup](../composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/view/model/ChatRoomDetailViewModel.kt:197), and nothing catches it | — | the person is never shown it, and on Android an uncaught coroutine exception is a crash. Fixed at the top of Phase 10 |
| `Participant.adminAt` is a cache of the group's admin set, written on each applied commit and, for keyed rooms only, at creation | [MarmotInboundManager.kt:132](../composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/MarmotInboundManager.kt:132), [MarmotGroupCreation.kt:227](../composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/MarmotGroupCreation.kt:227) | it is wrong on the creating device of every convenient room and DM until the first commit. Phase 1 |
| Removing a member stages a bare `Remove`, so a removed admin's key stays in `0x8003` | [MarmotOutboundDao.kt:853](../composeApp/src/commonMain/kotlin/mobi/giza/compose/database/dao/MarmotOutboundDao.kt:853) | **a removed admin who is invited back is an admin again**, with no caption. `AdminPolicyV1` says the key must go in the same commit. Phases 6 and 9 |
| Removal and disband are one admin's commit through the publish gate | `MarmotOutboundDao.removeMember`, `disband` | under R2 that changes in keyed rooms. Phase 5 |
| Repair already runs `FrostReducedEnrollment` for an existing id (`newId < n`) | [ShareRepairManager.kt:268](../composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/ShareRepairManager.kt:268) | promotion is the same primitive at `newId = n`, which nothing builds yet ([frost-share-refresh.md](./frost-share-refresh.md) 10c; [submodule-refresh.md](./submodule-refresh.md) Phase 6). Phase 8 |
| A refresh that withholds a removed member is built | `ChatRepository.rotateSharesWithout`, frost-share-refresh Phase 9 | demotion's share half. Phase 9 |
| The group's key state carries the id-to-member table, `MemberBinding(participantId, memberPublicKey, hostPublicKey)`, signed by the group | [GroupKeyStateEvent.kt:163](../composeApp/src/commonMain/kotlin/mobi/giza/compose/nostr/frost/GroupKeyStateEvent.kt:163) | the authenticated table an enrollment reads its expected public share from |
| Enrollment, refresh and repair sit behind `ExperimentalFeatures.shareRefresh`, off in release, until upstream drops "experimental" | frost-share-refresh D4 | **R1 cannot ship to release users before that.** R2 and R3 can. See *Ship order* |
| `CommitProcessed` names the epoch and not the committer | marmot-kmp `MarmotInboundProcessor.kt:75` | captions are unattributed, as the membership lines are. A keyed room's lines can name the proposer instead, from the signed statement (Phase 2) |
---
## The decisions
### D1. The admin set comes from the group's state, never from `adminAt`
Every check that decides an action reads `currentAdminIdentities()` and the tree off
2. **Commit.** The row reads **Holds a share** only.
3. **Refresh** without them, started automatically by the proposer's device. This is
`rotateSharesWithout`, from frost-share-refresh Phase 9, with each remaining
holder's deal and confirm made automatic when the refresh names a signed demotion
or removal of the member it withholds. The refresh still needs every remaining
holder (frost-share-refresh D8), so a stalled refresh is the case D10's banner is
for.
The demoted member's own device drops nothing by itself: its share becomes worthless
when the refresh completes, which is when frost-share-refresh's Phase 8 deletes the
old generation everywhere.
**Tests:** demote, and the demoted member can no longer help reach `t` after the
refresh, but could before it; remove an admin, and they are off `0x8003` in the same
commit; demote below the floor is refused before anything is proposed.
## Phase 10 — leaving as an admin
**Two days.**
**First, the crash.** `leaveGroup` in the view model wraps the call in `runCatching`
and reports the failure through the notifier, as `disbandGroup` does. Ship this alone
if everything else slips.
Then **Leave group**, pressed by an admin, opens a dialog in place of firing:
| room | dialog | what happens |
|---|---|---|
| convenient, another admin remains | "You'll step down first, then leave" | one-admin step-down commit (Phase 6), then the `SelfRemove` when it is confirmed |
| convenient, the only admin | pick a member to make admin, or **Disband group instead** | promote the pick, then step down and leave, chained |
| keyed, above the floor | "You'll step down, the group signs it, then you leave" | Phase 9's demotion of yourself, then the exempt `SelfRemove` once it lands. The refresh without you runs after you are gone, on the others' devices |
| keyed, at the floor | "A group needs at least {floor} admins. Make someone else an admin before you leave" | nothing until a promotion has landed |
The chain from step-down to `SelfRemove` is held in memory. A restart leaves a
non-admin member who has not left yet, which is safe, and a plain **Leave group** then
works.
**Tests:** each row of the table, and the existing `an admin cannot leave, and is told
why` test changed to check that the message reaches the caller.
## Phase 11 — the member row
**Two days.**
Under each member's name, the labels from D2 (**Admin**, **Holds a share**, joined with
` · `), read from the group and from `SharesSummary.members` with
`ShareStanding.LIVE`, and a third line while a change is pending ("Being made an
admin: 1 of 2 signatures"). **Holds a share** follows the experimental flag, so a
release build shows **Admin** only until R1 ships.
An admin's trailing control becomes an overflow `IconButton` with a `DropdownMenu`.
Its items come from a per-member `memberActions` the view model computes from the
library's permissions, the floor and the room kind. The screen never decides an action
itself.
| row | items |
|---|---|
| a member | **Make admin**, **Remove from group** |
| another admin | **Remove as admin** (above the floor), **Remove from group** |
| an admin with no share | **Retry enrollment** |
| a non-admin with a share | **Rotate shares** |
| yourself, an admin | **Step down as admin** (above the floor) |
The dialogs say what each act gives or takes:
- **Make {name} an admin?** — in a convenient room: "They'll be able to add and remove
members, including you, and disband the group". In a keyed room: "They'll be asked
to accept, then hold a share of the group's key. This needs {t} of you to sign".
- **Remove {name} as admin?** — "They stay in the group as a member". In a keyed room:
"Their share is rotated away once the group signs".
- **Step down as admin?** — "You stay in the group. Only the group can make you an
admin again".
All text comes from the catalogue, in sentence case. Outcomes go through
`rememberNotifier`, read above the handler. The overflow button is a 48dp `IconButton`
with a decided description. `./gradlew :composeApp:m3Audit` stays at its budgets.
**Tests:** `memberActions` for every row above, in both room kinds, at and above the