diff --git a/composeApp/src/commonMain/kotlin/mobi/giza/compose/database/dao/NostrDao.kt b/composeApp/src/commonMain/kotlin/mobi/giza/compose/database/dao/NostrDao.kt index 08c87844..f950bb2e 100644 --- a/composeApp/src/commonMain/kotlin/mobi/giza/compose/database/dao/NostrDao.kt +++ b/composeApp/src/commonMain/kotlin/mobi/giza/compose/database/dao/NostrDao.kt @@ -877,12 +877,13 @@ abstract class NostrDao( ChatRoom( id = nostrGroupId, userPublicKey = userPublicKey, - // Under the same rule as a room this device - // makes, whoever made this one: an older Giza or - // a Bennu peer wrote `#name`, another client a - // bare name. The group's own state keeps what its - // creator wrote. docs/group-name-prefix.md, D4. - subject = group.roomName()?.let(MarmotGroupName::of), + // Bare, as a room this device makes is, whoever + // made this one: an older Giza wrote `&name`, a + // Bennu peer `#name`, another client a bare name. + // The braces are drawn, never stored, and the + // group's own state keeps what its creator wrote. + // docs/group-name-braces.md, D4. + subject = group.roomName()?.let(MarmotGroupName::bare), description = group.roomDescription(), initialGiftWrapPayloadId = decryptedGiftWrapPayload.id, createdAt = decryptedGiftWrapPayload.createdAt, diff --git a/composeApp/src/commonMain/kotlin/mobi/giza/compose/database/migrations/MarmotGroupNameMigration.kt b/composeApp/src/commonMain/kotlin/mobi/giza/compose/database/migrations/MarmotGroupNameMigration.kt index 9d5e4dec..442712af 100644 --- a/composeApp/src/commonMain/kotlin/mobi/giza/compose/database/migrations/MarmotGroupNameMigration.kt +++ b/composeApp/src/commonMain/kotlin/mobi/giza/compose/database/migrations/MarmotGroupNameMigration.kt @@ -14,7 +14,7 @@ import mobi.giza.compose.managers.MarmotGroupName * the only thing the app ever shows, becomes `&name`. A room joined after this has the rule * applied as its Welcome is processed, so nothing has to run twice. * - * The rule runs here in Kotlin, through [MarmotGroupName.of], rather than as an `ltrim` in + * The rule runs here in Kotlin, through [MarmotGroupName.bare], rather than as an `ltrim` in * SQL, so this is the same function the rest of the app names rooms with and not a copy of * it that can drift. A room with a bare name, from a client that marks nothing, gets the * mark here for the same reason a Welcome gives it one. @@ -32,7 +32,7 @@ class MarmotGroupNameMigrationSpec : AutoMigrationSpec { buildList { while (statement.step()) { val subject = statement.getText(1) - val named = MarmotGroupName.of(subject) + val named = MarmotGroupName.bare(subject) if (named != subject) add(statement.getText(0) to named) } } diff --git a/composeApp/src/commonMain/kotlin/mobi/giza/compose/database/model/ChatMessage.kt b/composeApp/src/commonMain/kotlin/mobi/giza/compose/database/model/ChatMessage.kt index ddda5d36..2e336b53 100644 --- a/composeApp/src/commonMain/kotlin/mobi/giza/compose/database/model/ChatMessage.kt +++ b/composeApp/src/commonMain/kotlin/mobi/giza/compose/database/model/ChatMessage.kt @@ -1436,9 +1436,11 @@ data class ChatMessage( // The name is the one the parent certified, which is the only one // that was ever put to this room -- the child may since have been // renamed, and this line is a record of what was agreed rather - // than a view of what is. It is written under today's mark, - // though: a certificate signed as `#name` before - // docs/group-name-prefix.md certified the name, not the `#`. + // than a view of what is. The name is drawn into the sentence + // in braces as it is written, whatever mark the certificate was + // signed under: it certified the name, not the punctuation. The + // one place braces reach the disk, inside a sentence and never in + // a name column (docs/group-name-braces.md, D6). SubgroupBirthCertificateEvent.KIND -> { SubgroupManager.record( database = database, @@ -1446,7 +1448,7 @@ data class ChatMessage( innerEvent = event ) ?: return null - val name = SubgroupBirthCertificateEvent.parseName(event.tags)?.let(MarmotGroupName::of) + val name = SubgroupBirthCertificateEvent.parseName(event.tags)?.let(MarmotGroupName::display) val admins = SubgroupBirthCertificateEvent.parseAdminPublicKeys(event.tags).size ChatMessage( diff --git a/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/CeremonyFollowThrough.kt b/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/CeremonyFollowThrough.kt index 430c9e06..ee8a37c3 100644 --- a/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/CeremonyFollowThrough.kt +++ b/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/CeremonyFollowThrough.kt @@ -91,8 +91,8 @@ object CeremonyFollowThrough { /** * What a ceremony's room is called: the name the coordinator gave a subgroup, - * or the name of the group an admin room administers. The bare name; the - * room puts it under `MarmotGroupName`. + * or the name of the group an admin room administers. The bare name, as the + * room stores it; the braces are drawn (docs/group-name-braces.md). */ fun roomName(session: DkgSession): String = session.subject ?: if (session.parentChatRoomId != null) "Subgroup" else "Group" diff --git a/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/ChillDkgRitualManager.kt b/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/ChillDkgRitualManager.kt index 33163336..fe2e92f6 100644 --- a/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/ChillDkgRitualManager.kt +++ b/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/ChillDkgRitualManager.kt @@ -376,10 +376,12 @@ object ChillDkgRitualManager { /** * Whether two group names are the same name, as far as folding a repeated ask - * goes: trimmed, and without regard to case. Names are not identities, so this - * decides nothing but whether an ask is a repeat. + * goes: bare, and without regard to case. Bare, so a room still stored under an old + * mark (`&Ekklesia`) is the same name as an ask for `Ekklesia` + * (docs/group-name-braces.md, D8). Names are not identities, so this decides + * nothing but whether an ask is a repeat. */ - private fun sameName(name: String): String = name.trim().lowercase() + private fun sameName(name: String): String = MarmotGroupName.bare(name).lowercase() /** * Feeds one inbound ritual message in and advances the ritual as far as it diff --git a/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/MarmotGroupCreation.kt b/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/MarmotGroupCreation.kt index c5cfb7e6..c248607d 100644 --- a/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/MarmotGroupCreation.kt +++ b/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/MarmotGroupCreation.kt @@ -97,10 +97,11 @@ object MarmotGroupCreation { * the verified value off the child's own key state -- never a claim off a * proposal. * - * [name] is put under [MarmotGroupName] here rather than trusted from the - * caller. Every Marmot room on a device is an `&name`, and this is the funnel - * both flows that make one already go through, so it is the one place the - * convention cannot be forgotten. + * [name] is made [MarmotGroupName.bare] here rather than trusted from the + * caller: the room is stored and sent under its bare name, and drawn in + * braces (docs/group-name-braces.md). This is the funnel both flows that make + * one already go through, so it is the one place a stray mark -- one typed, or + * one carried over from a name minted under `&` -- cannot get in. */ suspend fun create( database: GizaDatabase, @@ -121,7 +122,7 @@ object MarmotGroupCreation { // A confederation has no room of its own (docs/confederation-room-removal.md, D11). if (ConfederationFormation.isConfederation(database, groupId)) return Outcome.Failed("A confederation has no room of its own") - val groupName = MarmotGroupName.of(name) + val groupName = MarmotGroupName.bare(name) val peers = adminPublicKeys.filterNot { it == userPublicKey } val keyPackages = keyPackagesFor(chatRepository, peers, keyPackageLookupTimeout, profile) diff --git a/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/MarmotGroupName.kt b/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/MarmotGroupName.kt index dd876d18..593b6dfa 100644 --- a/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/MarmotGroupName.kt +++ b/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/MarmotGroupName.kt @@ -33,12 +33,6 @@ object MarmotGroupName { /** Drawn after the name, and shown at the trailing edge of a name field. */ const val SUFFIX = "}" - /** - * The mark stored in front of a Marmot room's name before docs/group-name-braces.md. - * Still written by [of] until the writers store the bare name. - */ - private const val LEGACY_PREFIX = "&" - /** * Every mark a Marmot room's name has been stored with: the `&` of * docs/group-name-prefix.md and the `#` before it. Rooms minted under them still @@ -53,6 +47,11 @@ object MarmotGroupName { * what lets one function name the rooms a Welcome brings in, the rooms already on a * device, and the names old certificates carry. * + * Idempotence matters for one more reason. A subgroup's name is made bare twice from + * the same subject by two unrelated callers -- once into the birth certificate the + * parent's quorum signs, once onto the room itself -- and those two have to be the + * same string, or the room is not called what its parent certified. + * * Only a *leading* mark is a mark: `Arts & crafts` keeps its `&`. A blank name, or one * that is only marks, is handed back trimmed rather than made up. */ @@ -67,18 +66,4 @@ object MarmotGroupName { val bare = NameMarks.strip(name, LEGACY_MARKS) return if (bare.isEmpty()) name.trim() else PREFIX + bare + SUFFIX } - - /** - * [name] under the stored `&` of docs/group-name-prefix.md: what the writers still - * store until docs/group-name-braces.md's Phase 2 has them store [bare]. - * - * Idempotent on purpose. A subgroup's name is normalised twice from the same bare - * subject and by two unrelated callers -- once into the birth certificate the - * parent's quorum signs, once onto the room itself -- and those two have to be the - * same string, or the room is not called what its parent certified. - */ - fun of(name: String): String { - val bare = NameMarks.strip(name, LEGACY_MARKS) - return if (bare.isEmpty()) name.trim() else LEGACY_PREFIX + bare - } } diff --git a/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/SubgroupManager.kt b/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/SubgroupManager.kt index c8eb0fc3..2e787088 100644 --- a/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/SubgroupManager.kt +++ b/composeApp/src/commonMain/kotlin/mobi/giza/compose/managers/SubgroupManager.kt @@ -229,10 +229,10 @@ object SubgroupManager { require(name.isNotBlank()) { "A subgroup has to be called something" } // The certificate is a signature over the name, so it has to be the name - // the room ends up with. `MarmotGroupCreation` normalises again on the - // way in and `MarmotGroupName.of` is idempotent, so the two agree by + // the room ends up with. `MarmotGroupCreation` makes it bare again on the + // way in and `MarmotGroupName.bare` is idempotent, so the two agree by // construction rather than by both callers remembering. - val subgroupName = MarmotGroupName.of(name) + val subgroupName = MarmotGroupName.bare(name) // One certificate per child. A second is a `d`-tag replacement of the // first rather than a second subgroup, and spending a quorum's attention @@ -444,11 +444,11 @@ object SubgroupManager { chatRoomId = chatRoomId, parentChatRoomId = parentChatRoomId, certificate = signed, - // Under today's mark: a certificate signed before - // docs/group-name-prefix.md says `#name`, and the room it - // names is `&name` on this device. What was agreed is the - // name, not the punctuation. - name = SubgroupBirthCertificateEvent.parseName(event.tags)?.let(MarmotGroupName::of), + // Bare, as every stored name is: a certificate signed before + // docs/group-name-braces.md says `&name`, or `#name` before + // that. What was agreed is the name, not the punctuation, and + // the screen that lists it draws the braces. + name = SubgroupBirthCertificateEvent.parseName(event.tags)?.let(MarmotGroupName::bare), adminPublicKeys = SubgroupBirthCertificateEvent.parseAdminPublicKeys(event.tags), room = database.chatRoomDao().findChatRoomById(chatRoomId), keyState = database.groupKeyStateDao().getByChatRoomId(chatRoomId), diff --git a/composeApp/src/commonMain/kotlin/mobi/giza/compose/text/ProposedEvent.kt b/composeApp/src/commonMain/kotlin/mobi/giza/compose/text/ProposedEvent.kt index eea602db..9702a8a1 100644 --- a/composeApp/src/commonMain/kotlin/mobi/giza/compose/text/ProposedEvent.kt +++ b/composeApp/src/commonMain/kotlin/mobi/giza/compose/text/ProposedEvent.kt @@ -69,11 +69,12 @@ object ProposedEvent { SubgroupBirthCertificateEvent.KIND -> Summary( label = "A new subgroup of this group", detail = listOfNotNull( - // Verbatim, not through `MarmotGroupName.of`: this is what the - // signer is about to approve, and a certificate proposed before - // docs/group-name-prefix.md says `#name`. The summary of a - // signature shows the bytes being signed, even where the rest - // of the app would show the name under today's mark (D5). + // Verbatim, neither made bare nor drawn in braces: this is what + // the signer is about to approve, and a certificate proposed + // before docs/group-name-braces.md says `&name` (or `#name`, + // before docs/group-name-prefix.md). The summary of a signature + // shows the bytes being signed, even where the rest of the app + // draws the name in braces (docs/group-name-braces.md, D5). SubgroupBirthCertificateEvent.parseName(event.tags), SubgroupBirthCertificateEvent.parseAdminPublicKeys(event.tags) .size diff --git a/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/view/model/SelectSubgroupAdminsViewModel.kt b/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/view/model/SelectSubgroupAdminsViewModel.kt index fc669e65..8814d942 100644 --- a/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/view/model/SelectSubgroupAdminsViewModel.kt +++ b/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/view/model/SelectSubgroupAdminsViewModel.kt @@ -74,11 +74,11 @@ class SelectSubgroupAdminsViewModel( /** * What the coordinator typed, bare. * - * The `&` is drawn beside the field rather than pushed into this state: - * normalising on every keystroke would move the caret out from under somebody - * halfway through a word. It is added by `MarmotGroupName.of` where the - * subgroup's name is actually used -- in the certificate the parent signs and - * on the room itself -- which is idempotent, so the two agree. + * The braces are drawn around the field, never pushed into this state, and + * never stored: what is typed is the name. Any mark somebody types anyway is + * taken off by `MarmotGroupName.bare` where the subgroup's name is used -- in + * the certificate the parent signs and on the room itself -- which is + * idempotent, so the two agree (docs/group-name-braces.md). */ val name: MutableState = mutableStateOf("") @@ -266,11 +266,11 @@ class SelectSubgroupAdminsViewModel( return@launch } - // The bare name goes on the ceremony, and the `&` is added where the - // name is used: `proposeBirthCertificate` normalises the name the - // parent signs and `MarmotGroupCreation` normalises the name the room - // carries, both reading it back off this session. - // `MarmotGroupName.of` is idempotent, so those are the same string -- + // The bare name goes on the ceremony, and on everything after it: + // `proposeBirthCertificate` makes bare the name the parent signs and + // `MarmotGroupCreation` the name the room carries, both reading it + // back off this session. + // `MarmotGroupName.bare` is idempotent, so those are the same string -- // which they have to be, or the room is not called what its parent // certified. // diff --git a/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/view/state/SelectQuorumUIState.kt b/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/view/state/SelectQuorumUIState.kt index 9df208dd..2a7c92cc 100644 --- a/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/view/state/SelectQuorumUIState.kt +++ b/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/view/state/SelectQuorumUIState.kt @@ -1,6 +1,7 @@ package mobi.giza.compose.ui.view.state import mobi.giza.compose.database.model.Profile +import mobi.giza.compose.managers.MarmotGroupName sealed interface SelectQuorumUIState { data class Loaded( @@ -16,9 +17,13 @@ sealed interface SelectQuorumUIState { */ val existingGroups: List = emptyList(), ): SelectQuorumUIState { - /** Whether the group being made would share its name with one of [existingGroups]. */ + /** + * Whether the group being made would share its name with one of [existingGroups]: + * compared bare, so a room still stored under an old mark (`&Ekklesia`) is the same + * name as a typed `Ekklesia` (docs/group-name-braces.md, D8). + */ fun sharesNameWith(name: String): Boolean = - existingGroups.any { it.name?.trim()?.equals(name.trim(), ignoreCase = true) == true } + existingGroups.any { it.name?.let(MarmotGroupName::bare)?.equals(MarmotGroupName.bare(name), ignoreCase = true) == true } } /** A group already made by the same people: its name, or null if it has none. */ diff --git a/composeApp/src/commonTest/kotlin/mobi/giza/compose/managers/MarmotGroupNameTest.kt b/composeApp/src/commonTest/kotlin/mobi/giza/compose/managers/MarmotGroupNameTest.kt index 21c66914..f5302e4e 100644 --- a/composeApp/src/commonTest/kotlin/mobi/giza/compose/managers/MarmotGroupNameTest.kt +++ b/composeApp/src/commonTest/kotlin/mobi/giza/compose/managers/MarmotGroupNameTest.kt @@ -70,13 +70,4 @@ class MarmotGroupNameTest { assertEquals(expected, MarmotGroupName.display(input), "display($input)") } } - - @Test - fun `the stored mark is still the old one until the writers store bare`() { - assertEquals("&Ekklesia", MarmotGroupName.of("Ekklesia")) - assertEquals("&Ekklesia", MarmotGroupName.of("#Ekklesia")) - assertEquals("&Ekklesia", MarmotGroupName.of("&Ekklesia")) - assertEquals(MarmotGroupName.of("Translators"), MarmotGroupName.of(MarmotGroupName.of("Translators"))) - assertEquals("&", MarmotGroupName.of("&")) - } } diff --git a/composeApp/src/commonTest/kotlin/mobi/giza/compose/ui/view/state/SelectQuorumNameTest.kt b/composeApp/src/commonTest/kotlin/mobi/giza/compose/ui/view/state/SelectQuorumNameTest.kt new file mode 100644 index 00000000..d08cc21c --- /dev/null +++ b/composeApp/src/commonTest/kotlin/mobi/giza/compose/ui/view/state/SelectQuorumNameTest.kt @@ -0,0 +1,32 @@ +package mobi.giza.compose.ui.view.state + +import kotlin.test.Test +import kotlin.test.assertFalse +import kotlin.test.assertTrue + +/** + * A group's name is taken whatever mark it was stored under (docs/group-name-braces.md, D8). + * + * The `&` and `#` names are on purpose: rooms made before the braces were drawn were stored + * under them, and a device that has not run v55 yet still holds them. + */ +class SelectQuorumNameTest { + private fun loaded(vararg names: String?) = + SelectQuorumUIState.Loaded(members = emptyList(), existingGroups = names.map { SelectQuorumUIState.ExistingGroup(it) }) + + @Test + fun `a name stored under an old mark is the same name typed bare`() { + assertTrue(loaded("&Ekklesia").sharesNameWith("Ekklesia")) + assertTrue(loaded("#Ekklesia").sharesNameWith("ekklesia")) + } + + @Test + fun `a name typed in braces is the same name stored bare`() { + assertTrue(loaded("Ekklesia").sharesNameWith("{Ekklesia}")) + } + + @Test + fun `a different name is not taken`() { + assertFalse(loaded("Ekklesia", null).sharesNameWith("Agora")) + } +} diff --git a/composeApp/src/jvmTest/kotlin/mobi/giza/compose/database/migrations/MarmotGroupNameMigrationJvmTest.kt b/composeApp/src/jvmTest/kotlin/mobi/giza/compose/database/migrations/MarmotGroupNameMigrationJvmTest.kt index 19587f64..f88e99d8 100644 --- a/composeApp/src/jvmTest/kotlin/mobi/giza/compose/database/migrations/MarmotGroupNameMigrationJvmTest.kt +++ b/composeApp/src/jvmTest/kotlin/mobi/giza/compose/database/migrations/MarmotGroupNameMigrationJvmTest.kt @@ -14,6 +14,10 @@ import kotlin.test.assertEquals * The `#` subjects here are on purpose: they are what every Marmot room made before * docs/group-name-prefix.md was called, and what this migration exists to rename. * + * v53 applies the *current* rule, so since docs/group-name-braces.md it stores the bare + * name: a device upgrading from v52 or before goes straight to bare, and v55 then has + * nothing to do. + * * Run against the spec on a bare connection, the way `ChronicleRenameMigrationJvmTest` is: * the schema does not change, so Room's half of the migration is empty and this covers the * whole of what v53 does. The `ChatRoom` table is v52's, verbatim from `schemas/52.json`, @@ -66,27 +70,27 @@ class MarmotGroupNameMigrationJvmTest { migrate() - assertEquals("&Ekklesia", subjectOf("ekklesia")) + assertEquals("Ekklesia", subjectOf("ekklesia")) } @Test - fun `a group another client named without a mark gets one`() { + fun `a group another client named without a mark is left as it is`() { createV52() insertRoom("polis", "Polis", marmot = true) migrate() - assertEquals("&Polis", subjectOf("polis")) + assertEquals("Polis", subjectOf("polis")) } @Test - fun `a group already under the mark is left as it is`() { + fun `a group under the newer stored mark is made bare too`() { createV52() insertRoom("atlas", "&Atlas", marmot = true) migrate() - assertEquals("&Atlas", subjectOf("atlas")) + assertEquals("Atlas", subjectOf("atlas")) } @Test @@ -96,7 +100,7 @@ class MarmotGroupNameMigrationJvmTest { migrate() - assertEquals("&Agora", subjectOf("agora")) + assertEquals("Agora", subjectOf("agora")) } @Test @@ -128,7 +132,7 @@ class MarmotGroupNameMigrationJvmTest { migrate() migrate() - assertEquals("&Ekklesia", subjectOf("ekklesia")) + assertEquals("Ekklesia", subjectOf("ekklesia")) assertEquals("#topic", subjectOf("topic")) } } diff --git a/composeApp/src/jvmTest/kotlin/mobi/giza/compose/database/repository/CurrentProfileKeyPackageJvmTest.kt b/composeApp/src/jvmTest/kotlin/mobi/giza/compose/database/repository/CurrentProfileKeyPackageJvmTest.kt index ed77f309..750f501c 100644 --- a/composeApp/src/jvmTest/kotlin/mobi/giza/compose/database/repository/CurrentProfileKeyPackageJvmTest.kt +++ b/composeApp/src/jvmTest/kotlin/mobi/giza/compose/database/repository/CurrentProfileKeyPackageJvmTest.kt @@ -212,10 +212,10 @@ class CurrentProfileKeyPackageJvmTest { // The room is keyed on the routing id from the group's 0x8004 component, and its // restored state is a current-profile group that names the inviter as admin. The - // client named it without a mark, and it is joined with one, as every Marmot room is - // (docs/group-name-prefix.md, D4). + // client named it without a mark, and it is stored bare, as every Marmot room is + // (docs/group-name-braces.md, D4). val room = assertNotNull(db.chatRoomDao().findChatRoomById(routingId.toHexKey()), "no room was made for the routing id") - assertEquals("&made elsewhere", room.chatRoom.subject) + assertEquals("made elsewhere", room.chatRoom.subject) val restored = assertNotNull(room.chatRoom.toMlsGroup(), "the joined state does not restore") assertTrue(restored.currentGroupState().isCurrentProfile, "the restored group is not on the current profile") assertEquals(setOf(inviterHex), restored.currentAdminIdentities()) diff --git a/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/MarmotGroupCreationJvmTest.kt b/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/MarmotGroupCreationJvmTest.kt index dc081f6a..5e314acd 100644 --- a/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/MarmotGroupCreationJvmTest.kt +++ b/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/MarmotGroupCreationJvmTest.kt @@ -156,10 +156,11 @@ class MarmotGroupCreationJvmTest { val room = assertNotNull(db.chatRoomDao().findChatRoomById(groupId)) val group = assertNotNull(room.chatRoom.toMlsGroup()) - // Both, and the same string in each: the row is what this device draws in - // its room list, and the group's own name is what every other member reads. - assertEquals("&Ekklesia", room.chatRoom.subject) - assertEquals("&Ekklesia", group.roomName()) + // Both, and the same bare string in each: the row is what this device draws + // in its room list, and the group's own name is what every other member + // reads. The braces are drawn, never stored (docs/group-name-braces.md). + assertEquals("Ekklesia", room.chatRoom.subject) + assertEquals("Ekklesia", group.roomName()) } /** @@ -270,7 +271,7 @@ class MarmotGroupCreationJvmTest { ) val created = assertIs(outcome) assertEquals(groupId, created.room.chatRoom.id, "the room is not the one the key derives") - assertEquals("&Ekklesia", created.room.chatRoom.subject) + assertEquals("Ekklesia", created.room.chatRoom.subject) val group = assertNotNull(created.room.chatRoom.toMlsGroup()) assertEquals(founders, group.currentAdminIdentities(), "${owner.pubKey.toHexKey().take(8)}'s room") diff --git a/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/MarmotGroupNameWelcomeJvmTest.kt b/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/MarmotGroupNameWelcomeJvmTest.kt index c288e343..4e3dcca9 100644 --- a/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/MarmotGroupNameWelcomeJvmTest.kt +++ b/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/MarmotGroupNameWelcomeJvmTest.kt @@ -15,12 +15,13 @@ import mobi.giza.compose.database.builder.getRoomDatabase import mobi.giza.compose.database.repository.DatabaseMarmotRepository /** - * A room joined from a Welcome is called by the same rule as a room this device made. + * A room joined from a Welcome is stored by the same rule as a room this device made: bare. * - * The name a Welcome carries is whatever its creator wrote: `#name` from an older Giza or a - * Bennu peer, a bare name from a client that marks nothing, `&name` from a Giza on the - * current rule. Each of them is a Marmot room, and each lands as `&name`, so the mark on a - * row says the same thing whoever made the room. docs/group-name-prefix.md, Phase 2. + * The name a Welcome carries is whatever its creator wrote: `#name` from a Bennu peer, + * `&name` from an older Giza, a bare name from a client that marks nothing or from a Giza + * on the current rule. Each of them is a Marmot room, and each is stored as `name` and drawn + * as `{name}`, so the mark on a row says the same thing whoever made the room. + * docs/group-name-braces.md, Phase 2. * * The group is made and the invite sent by the library's own client, so the name reaches the * app through the same Welcome path a real peer's would. @@ -49,19 +50,25 @@ class MarmotGroupNameWelcomeJvmTest { } @Test - fun `a room named under the old mark is joined under the new one`() = runBlocking { - // `#` on purpose: what an older Giza or a Bennu peer still mints. - assertEquals("&Ekklesia", joinedAs("#Ekklesia")) + fun `a room Bennu named under the oldest mark is joined bare`() = runBlocking { + // `#` on purpose: what a Bennu peer still mints. + assertEquals("Ekklesia", joinedAs("#Ekklesia")) } @Test - fun `a room another client named without a mark is joined with one`() = runBlocking { - assertEquals("&Ekklesia", joinedAs("Ekklesia")) + fun `a room an older Giza named under its mark is joined bare`() = runBlocking { + // `&` on purpose: what a Giza from before docs/group-name-braces.md mints. + assertEquals("Ekklesia", joinedAs("&Ekklesia")) } @Test - fun `a room already under the mark is joined as it is`() = runBlocking { - assertEquals("&Ekklesia", joinedAs("&Ekklesia")) + fun `a room named without a mark is joined as it is`() = runBlocking { + assertEquals("Ekklesia", joinedAs("Ekklesia")) + } + + @Test + fun `braces in a room's name are drawn, not stored`() = runBlocking { + assertEquals("Ekklesia", joinedAs("{Ekklesia}")) } @Test diff --git a/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/SubgroupManagerJvmTest.kt b/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/SubgroupManagerJvmTest.kt index 2b6712c9..d414b179 100644 --- a/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/SubgroupManagerJvmTest.kt +++ b/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/SubgroupManagerJvmTest.kt @@ -126,7 +126,7 @@ class SubgroupManagerJvmTest { assertEquals(childRoomId, subgroup.chatRoomId) assertEquals(parentRoomId, subgroup.parentChatRoomId) - assertEquals("&Translation team", subgroup.name) + assertEquals("Translation team", subgroup.name) assertEquals(listOf(user, alice, bob), subgroup.adminPublicKeys) // The whole point of reading certificates rather than rooms: this device @@ -148,7 +148,7 @@ class SubgroupManagerJvmTest { val signed = certificate(name = "#Translation team") record(signed) - assertEquals("&Translation team", SubgroupManager.subgroupsOf(db, parentRoomId).single().name) + assertEquals("Translation team", SubgroupManager.subgroupsOf(db, parentRoomId).single().name) // The kind:445 it arrived in, stored as sync stores one, so the inner event the line // is written from has a group event to hang off. @@ -198,7 +198,7 @@ class SubgroupManagerJvmTest { ) ) assertEquals(ChatMessage.TYPE_SUBGROUP_CERTIFIED, line.messageType) - assertEquals("The group made &Translation team a subgroup, run by 3 of its members", line.content) + assertEquals("The group made {Translation team} a subgroup, run by 3 of its members", line.content) } @Test @@ -268,7 +268,7 @@ class SubgroupManagerJvmTest { val subgroups = SubgroupManager.subgroupsOf(db, parentRoomId) assertEquals(1, subgroups.size) - assertEquals("&Second name", subgroups.single().name) + assertEquals("Second name", subgroups.single().name) assertEquals( "Second name", SubgroupBirthCertificateEvent.parseName( @@ -538,10 +538,10 @@ class SubgroupManagerJvmTest { // A quorum is being asked to sign a name, and `MarmotGroupCreation` // will name the room by the same rule from the same subject. If only - // one of the two applied it, the parent would certify "Translation - // team" and the room would be called "&Translation team". + // one of the two applied it, the parent could certify "{Translation + // team}" and the room be called "Translation team". assertEquals( - MarmotGroupName.of("Translation team"), + MarmotGroupName.bare("Translation team"), SubgroupBirthCertificateEvent.parseName(proposed.tags) ) }