fix: a member invited into a keyed room says it follows signed commits on joining

An invited member of a robust group could never be made an admin. Making
one needs the room to require the group's signature, which waits until
every member's device has said it follows signed commits. A device said
so when the room's screen was opened, or back when it heard another say
it -- but the founders said it before the invite, at an epoch the new
member cannot read, so it heard nothing, nobody said it again, and the
room waited on a screen the member had no reason to open.

A device now says it on joining (the Welcome path) and once each start
(GovernanceSupport.announceAll), for members who joined before this.
The waiting notice names who the room waits on and what for, instead of
"X need to update Giza".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kgothatso NgakoandClaude Opus 5.5 committed 2026-11-20 09:01:14 +02:00
1 parent aa4c8eba05
commit 6aae56520b
8 files changed
+125 -5

No files matched your search

@@ -127,7 +127,7 @@
<string name="governance_on">Changes to who is in this group need the group's signature. It always keeps at least %1$d admins.</string>
<string name="require_signatures">Require the group's signature for changes</string>
<string name="require_signatures_explainer">From then on, adding or removing a member, or changing who the admins are, is proposed and has to be signed by the group before it happens.</string>
<string name="governance_waiting">Before changes can need the group's signature, %1$s need to update Giza.</string>
<string name="governance_waiting">Waiting for %1$s to open an up-to-date Giza. Until then, this group can't require its signature on changes, and nobody else can be made an admin.</string>
<string name="make_admin_body_keyed">They'll be asked to accept, then the group signs it, and they'll hold a share of the group's key and be asked to approve its changes.</string>
<string name="remove_as_admin_body_keyed">Once the group signs it, they stay in the group as a member and their share of the group's key is rotated away.</string>
<string name="admin_offer_sent">Asked; they become an admin once they accept and the group signs it</string>
@@ -921,6 +921,15 @@ abstract class NostrDao(
mlsGroup = group,
)
// That this device follows signed commits, said on
// joining. It cannot read the others saying it -- that
// was before its epoch -- so it would never answer, and
// the room would wait on it until its screen was opened.
// docs/remove-convenient-groups.md, "After the build".
if (group.currentGroupState().isCurrentProfile) {
GovernanceSupport.announce(database, nostrGroupId, group, userPublicKey)
}
// Save ChatRoom Relays...
participants.filter { it.participantPublicKey != userPublicKey }.forEach { participant ->
val publicKey = participant.participantPublicKey
@@ -145,6 +145,8 @@ class DatabaseChatRepository(
override suspend fun reconcileAdminFlags(): Int = AdminFlags.reconcileAll(database)
override suspend fun announceGovernanceSupport(): Int = GovernanceSupport.announceAll(database)
override suspend fun followThroughCeremonies(keyPair: KeyPair) = kotlinx.coroutines.coroutineScope {
launch { CeremonyFollowThrough.observe(database = database, chatRepository = this@DatabaseChatRepository, keyPair = keyPair) }
// What a governed room's signed changes need after they land: a rotation
@@ -1,11 +1,13 @@
package mobi.giza.compose.managers
import co.touchlab.kermit.Logger
import com.vitorpamplona.mls.group.MlsGroup
import com.vitorpamplona.quartz.nip01Core.core.HexKey
import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
import kotlin.time.Clock
import kotlin.time.Instant
import mobi.giza.compose.database.GizaDatabase
import mobi.giza.compose.nostr.MarmotProfile
import mobi.giza.compose.database.model.MarmotInnerEvent
import mobi.giza.compose.nostr.frost.GovernanceSupportEvent
@@ -16,9 +18,15 @@ import mobi.giza.compose.nostr.frost.GovernanceSupportEvent
* The rule cannot be switched on while anybody in the room would be left behind
* by it: a device that does not know it applies the bare commits Giza drops and
* reads none of the envelopes, and is in a different group from the first change.
* So each device says, once per room, that it can follow -- and says it back when
* it hears another say it, which is how a member who never opens the room's screen
* still gets counted.
* So each device says, once per room, that it can follow: when it is welcomed in,
* when it starts, when the room's screen is opened, and back when it hears another
* say it.
*
* Joining has to be one of them. A member invited after the others said it cannot
* read what they said -- it was sent at an epoch before theirs -- so it never hears
* anybody to answer, and nobody says it again. Until it opened the room's screen
* the room waited on it, and nobody could be made an admin. See
* docs/remove-convenient-groups.md, "After the build".
*/
object GovernanceSupport {
@@ -59,4 +67,27 @@ object GovernanceSupport {
)
return true
}
/**
* [announce] for every room this device is in, for the members who joined
* before joining was one of the times it is said. Once per start, and a read
* with no write for a room that has it already. One room that will not open is
* logged and passed over.
*
* @return how many rooms it was said in now.
*/
suspend fun announceAll(database: GizaDatabase): Int =
database.chatRoomDao().getChatRoomIdsWithMlsState().count { chatRoomId ->
runCatching {
val room = database.chatRoomDao().findChatRoomById(chatRoomId) ?: return@runCatching false
if (room.chatRoom.leftGroupAt != null || room.chatRoom.marmotProfile() != MarmotProfile.CURRENT) return@runCatching false
val group = database.marmotEngine.groupFor(room.routingId) ?: return@runCatching false
announce(database, chatRoomId, group, room.chatRoom.userPublicKey)
}.getOrElse {
logger.e("Could not say $chatRoomId follows signed commits", it)
false
}
}
private val logger = Logger.withTag("GovernanceSupport")
}
@@ -256,6 +256,13 @@ interface ChatRepository {
*/
suspend fun reconcileAdminFlags(): Int
/**
* Says, in every keyed room this device is in, that it follows signed commits,
* for the rooms joined before joining said it. Once per start. See
* `GovernanceSupport.announceAll`.
*/
suspend fun announceGovernanceSupport(): Int
/**
* Takes every key ceremony [keyPair] coordinated from a key to a working room,
* until cancelled: asks the group to sign its key state (a subgroup's parent to
@@ -588,6 +595,8 @@ interface ChatRepository {
override suspend fun reconcileAdminFlags(): Int = 0
override suspend fun announceGovernanceSupport(): Int = 0
override suspend fun sendChatMessage(
text: String,
@@ -255,6 +255,12 @@ class SynchronizationViewModel(
// written. docs/robust-group-admins.md, Phase 6.
runCatching { chatRepository.reconcileAdminFlags() }
.onFailure { logger.e("Could not bring admin flags in line", it) }
// A member who joined a keyed room before joining said it
// follows signed commits, and never opened its screen, holds
// the room back from requiring them -- and so from making
// anyone an admin. docs/remove-convenient-groups.md.
runCatching { chatRepository.announceGovernanceSupport() }
.onFailure { logger.e("Could not say which rooms this device follows", it) }
launch(Dispatchers.IO) { observePendingBroadcastNostrEventRequests(keyPair) }
// Runs until cancelled rather than draining a queue, but it
// belongs here for the same reason the pumps do: it needs the