fix: a rotation reads the admin policy alone, now the founding-admins check is gone

giza deleted FoundingAdmins.check (remove-founding-admins-card): it
cannot tell a founder left out by a buggy creator from one the group
demoted, and every founder is an admin when the room is made. RoomAdmins
drops its missing-founders guard, and A4 says why.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kgothatso NgakoandClaude Opus 5.5 committed 2026-11-20 11:33:06 +02:00
1 parent d072fa7f90
commit d6c34a7762
5 files changed
+14 -21

No files matched your search

@@ -180,8 +180,7 @@ object AdminGovernance {
if (adminChangeHold(database, localChatRoom) != null) return ROTATION_PENDING_REFUSAL
val adminsAfter = (change.admins ?: currentAdmins) - change.removes
val missing = RoomAdmins.of(database, localChatRoom.chatRoom.id)?.missingFounders.orEmpty()
val retire = holders - adminsAfter - missing
val retire = holders - adminsAfter
// Only a change that itself takes a share away owes a rotation.
if (retire.none { it in change.removes || it in currentAdmins }) return null
return ShareRefreshManager.owedRotationRefusal(key, shares, retire)?.let {
@@ -6,22 +6,20 @@ import mobi.giza.compose.database.GizaDatabase
/**
* Who a keyed room's live admin policy names, as far as the share work reads it
* (docs/admin-change-rotation.md): the admins, whether the group's signature
* governs the room -- so that the policy changes only by a signed commit -- and
* any founding member [FoundingAdmins.check] finds the policy missing, whose
* absence the group never signed.
* (docs/admin-change-rotation.md): the admins, and whether the group's signature
* governs the room, so that the policy changes only by a signed commit. Every
* founding member is an admin when the room is made (docs/robust-group-admins.md),
* so a holder a governed room's policy does not name is one the group took out.
*/
data class RoomAdmins(
val admins: Set<HexKey>,
val governed: Boolean,
val missingFounders: Set<HexKey> = emptySet(),
) {
/**
* Whether [member] is someone the group's signature took out of the admins:
* the room is governed, the policy does not name them, and they are not a
* founder it has been missing from the start.
* the room is governed and its policy does not name them.
*/
fun removedBySignature(member: HexKey): Boolean = governed && member !in admins && member !in missingFounders
fun removedBySignature(member: HexKey): Boolean = governed && member !in admins
companion object {
/**
@@ -36,8 +34,7 @@ data class RoomAdmins(
override?.let { return it(chatRoomId) }
val room = database.chatRoomDao().findChatRoomById(chatRoomId) ?: return null
val group = runCatching { database.marmotEngine.groupFor(room.routingId) }.getOrNull() ?: return null
val missing = (FoundingAdmins.check(database, chatRoomId) as? FoundingAdmins.Check.Missing)?.publicKeys.orEmpty()
return RoomAdmins(group.currentAdminIdentities().toSet(), GovernanceGate.isGoverned(group), missing)
return RoomAdmins(group.currentAdminIdentities().toSet(), GovernanceGate.isGoverned(group))
}
}
}
@@ -149,8 +149,7 @@ object ShareRefreshManager {
* A3 and A4): every admin holds a share (R1), so no rotation deals a new one
* to somebody who is no longer an admin -- whichever rotation runs first after
* a demotion takes their share away, the one it owes or anybody's. Only in a
* governed room, whose admins change only by a signed commit, and never for a
* founder the policy has been missing from the start.
* governed room, whose admins change only by a signed commit.
*/
private suspend fun removedBySignature(database: GizaDatabase, localChatRoom: LocalChatRoom, shares: ShareGenerations.Shares): Map<Int, ShareStanding> {
val admins = RoomAdmins.of(database, localChatRoom.chatRoom.id) ?: return emptyMap()
@@ -1496,8 +1496,8 @@ class ShareRefreshRitualJvmTest {
// ---- docs/admin-change-rotation.md: today's behaviour, pinned ---------------------------------------------------
/** The room's live admins, as a governed room's policy would name them after the group signed a change. */
private fun admins(group: Group, vararg removed: HexKey, governed: Boolean = true, missingFounders: Set<HexKey> = emptySet()) {
RoomAdmins.override = { RoomAdmins(group.members.toSet() - removed.toSet(), governed, missingFounders) }
private fun admins(group: Group, vararg removed: HexKey, governed: Boolean = true) {
RoomAdmins.override = { RoomAdmins(group.members.toSet() - removed.toSet(), governed) }
}
private suspend fun approvalLines(device: Device) =
@@ -1567,8 +1567,6 @@ class ShareRefreshRitualJvmTest {
asksBob({ admins(it) }) { all -> propose(all[0], mapOf(all[0].group.idOf[3] to ShareStanding.STALE)) }
// A room whose admins change without the group's signature.
asksBob({ admins(it, it.members[3], governed = false) }, ::without)
// A founder the admin policy has been missing from the start.
asksBob({ admins(it, it.members[3], missingFounders = setOf(it.members[3])) }, ::without)
}
/** A3: every rotation retires the holders the group took out of the admins, not only the one a removal owes. */
@@ -1582,8 +1580,6 @@ class ShareRefreshRitualJvmTest {
admins(group, dave, governed = false)
assertEquals(emptyMap(), ShareRefreshManager.preview(alice.db, alice.room, alice.publicKey)!!.withheld, "an ungoverned room's admins are not the group's word")
admins(group, dave, missingFounders = setOf(dave))
assertEquals(emptyMap(), ShareRefreshManager.preview(alice.db, alice.room, alice.publicKey)!!.withheld, "a missing founder lost their share")
admins(group, dave)
assertEquals(mapOf(dave to ShareStanding.RETIRED), ShareRefreshManager.preview(alice.db, alice.room, alice.publicKey)!!.withheld)
+3 -1
View File
@@ -19,7 +19,8 @@ make on its own**, to the one ask they left in the admin-change flow.
(`4550201d` to the commit that adds this header; Phases 3 and 4 are one commit, since
they ship together), against `b7de119e`, on 2026-11-20. A removal's rotation now asks
nobody: the only taps in a removal are the `t` signatures on the change. jvmTest
1411, `m3Audit` at its budgets. The phases are kept as written because they are the
1411, and 1404 once merged with `giza`, whose founding-admins removal took that check's
tests; `m3Audit` at its budgets. The phases are kept as written because they are the
reasoning. Where the build chose differently:
| what the plan said | what it turned out to be |
@@ -42,6 +43,7 @@ reasoning. Where the build chose differently:
| Phase 6: the whole first promotion in one test | in parts: the offer starting its rotation, the wait, and the abandon in the governance harness, and the rotation running unasked in the ritual harness (A2). The same harness gap as above |
| Phase 7: the member row's line comes from member-row-actions Phase 5's pending lines | that phase did not leave a line on the row to extend. **Holds a share** reads **Share being rotated away** instead while a running rotation takes it, from `SharesSummary.Running.takingAway` |
| (not in the plan) | two full `jvmTest` runs each had one identity test time out at 5 seconds (`MultipleProfilesRoundTripJvmTest`, then `IdentitySwitchJvmTest`). Both pass alone, repeatedly, neither starts the governance follow-through, and a third full run passed whole. Load, not this work; not investigated |
| A4: never retire a founding member `FoundingAdmins.check` reports `Missing` | built, then taken out when this branch met [remove-founding-admins-card.md](./remove-founding-admins-card.md) on `giza`, which deleted the check: it cannot tell a founder a buggy creator left out from one the group demoted, and every founder is an admin when the room is made (robust-group-admins). A governed room's live policy is the whole answer. The two tests of the guard went with it |
| (not in the plan) | this worktree's build needed its submodules initialised, from the main checkout's copies, and their `local.properties` copied in |
**Not done:** the emulator session in Phase 8. Nothing here has run on a device: not the