docs: a confederation's profile, decided by its groups (confederation-profile, Phase 0)

The plan, and three of its premises as tests. A batch of seals with one
voucher is declined today, by refusals that are ours to change. A voucher
a group's quorum signs verifies under its npub with nothing else known. A
profile change carries the whole kind:0 in every group's seal, so it can
carry about 1.1 KB of profile to twelve groups and 13 KB to two: the plan
now says so, rather than "a few KB".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kgothatso NgakoandClaude Opus 5.5 committed 2026-11-22 23:18:57 +02:00
1 parent 50f73e1741
commit 3e05a28b65
3 files changed
+791

No files matched your search

@@ -0,0 +1,132 @@
package mobi.giza.compose.managers
import androidx.room3.Room
import com.vitorpamplona.quartz.nip01Core.core.Event
import com.vitorpamplona.quartz.nip01Core.core.hexToByteArray
import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
import com.vitorpamplona.quartz.nip01Core.crypto.Nip01Crypto
import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
import com.vitorpamplona.quartz.nip59Giftwrap.rumors.RumorAssembler
import kotlin.test.AfterTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
import kotlinx.coroutines.runBlocking
import mobi.giza.compose.database.GizaDatabase
import mobi.giza.compose.database.builder.getRoomDatabase
import mobi.giza.compose.extensions.toHex
import mobi.giza.compose.nostr.confederation.ConfederationKinds
import mobi.giza.compose.nostr.frost.FrostSigningEvents
import mobi.giza.compose.nostr.frost.GroupKeyStateEvent
import mobi.giza.compose.nostr.inbox.InboxAnnouncement
import mobi.giza.compose.nostr.inbox.InboxReplyManifest
import mobi.giza.compose.nostr.inbox.InboxSeal
import mobi.giza.compose.nostr.inbox.InboxWire
/**
* What docs/confederation-profile.md rests on, checked before anything is built on it (Phase 0,
* checks 2, 3 and 5). Check 1 is a reading of quartz and the app's kinds, and check 4 is
* `ConfederationSigningJvmTest`'s first case, which Phase 5 flips; both are recorded in the plan.
*/
class ConfederationProfilePremiseJvmTest {
private val databases = mutableListOf<GizaDatabase>()
private var network: ConfederationTestGroups? = null
@AfterTest
fun close() {
databases.forEach { it.close() }
network?.close()
}
private fun key(n: Int, tag: Int) = ByteArray(32).also { it[0] = tag.toByte(); it[30] = (n shr 8).toByte(); it[31] = n.toByte() }
private fun signed(secret: ByteArray, template: EventTemplate<Event>): Event {
val pubKey = InboxWire.publicKeyOf(secret)
val id = EventHasher.hashId(pubKey, template.createdAt, template.kind, template.tags, template.content)
return Event(id, pubKey, template.createdAt, template.kind, template.tags, template.content, Nip01Crypto.sign(id.hexToByteArray(), secret).toHex())
}
// ---- check 2: a batch of seals and one voucher, as the code stands ---------------------
@Test
fun `today a statement's batch holding anything but seals is declined as a shape this device does not sign`() = runBlocking {
val db = getRoomDatabase(Room.inMemoryDatabaseBuilder<GizaDatabase>()).also { databases += it }
val group = InboxWire.publicKeyOf(key(1, 0x41))
val seal = Event("aa".repeat(32), group, 1_790_000_000, InboxSeal.KIND, arrayOf(arrayOf("n", "ab".repeat(32))), "sealed", "")
val voucher = Event("bb".repeat(32), group, 1_790_000_000, 9438, arrayOf(arrayOf("profile", "cc".repeat(32))), "", "")
val carried = ConfederationRefusal.Carried(rumorJson = """{"kind":9435}""", invitationJson = null)
assertEquals(
ConfederationRefusal.SHAPE,
ConfederationRefusal.of(db, group, "dd".repeat(32), listOf(seal, voucher), carried, manifest = null),
"Phase 2 teaches the refusal a voucher beside the seals",
)
}
// ---- check 3: how big a profile change to N groups is -----------------------------------
/** The bytes a FROST proposal for one 9435 to [groups] groups carries, with a kind:0 of [profileBytes]. */
private fun changeBytes(groups: Int, profileBytes: Int): Int {
val npubs = (0 until groups).map { InboxWire.publicKeyOf(key(it, 0x51)) }
val confederation = InboxWire.publicKeyOf(key(0, 0x55))
val inboxSecret = key(0, 0x52)
val about = "a".repeat(profileBytes)
val profile = """{"pubkey":"$confederation","created_at":1790000000,"kind":0,"tags":[],"content":"{\"name\":\"Atlas\",\"about\":\"$about\"}"}"""
val tags = npubs.drop(1).map { arrayOf("p", it) } + listOf(
arrayOf("confederation", confederation), arrayOf("base", "ee".repeat(32)), arrayOf("expiration", "1790259200"),
)
val rumor = RumorAssembler.assembleRumor<Event>(npubs[0], EventTemplate(1_790_000_000, 9435, tags.toTypedArray(), profile))
val recipients = npubs.mapIndexed { i, npub ->
val announced = if (i == 0) InboxWire.publicKeyOf(inboxSecret) else InboxWire.publicKeyOf(key(i, 0x54))
val announcement = if (i == 0) null else signed(key(i, 0x51), InboxAnnouncement.keyTemplate(announced, 1_789_000_000))
Triple(npub, announced, announcement)
}
val seals = recipients.map { (_, announced, _) ->
val t = InboxSeal.template(rumor, inboxSecret, announced, 1_789_900_000)
val id = EventHasher.hashId(npubs[0], t.createdAt, t.kind, t.tags, t.content)
Event(id, npubs[0], t.createdAt, t.kind, t.tags, t.content, "")
}
val voucherTags = arrayOf(
arrayOf("confederation", confederation), arrayOf("profile", "ff".repeat(32)), arrayOf("e", rumor.id), arrayOf("expiration", "1790259200"),
)
val voucher = Event(EventHasher.hashId(npubs[0], 1_790_000_000, 9438, voucherTags, ""), npubs[0], 1_790_000_000, 9438, voucherTags, "", "")
val manifest = InboxReplyManifest(0, recipients.map { (npub, k, announcement) -> InboxReplyManifest.Entry(npub, k, announcement?.toJson()) }, 0)
return FrostSigningEvents.encodeProposal(seals + voucher).length + manifest.seal(inboxSecret).length + InboxSeal.rumorJson(rumor).length
}
/** The longest profile text, in steps of 50 bytes, a change to [groups] groups can carry. */
private fun largestProfile(groups: Int): Int =
(0..400).map { it * 50 }.lastOrNull { changeBytes(groups, it) <= ConfederationKinds.MAX_STATEMENT_BYTES } ?: -1
@Test
fun `a profile change carries the profile once per group, so the profile it can carry shrinks as the groups grow`() {
val at4k = (2..ConfederationKinds.MAX_SUPERGROUP_GROUPS).associateWith { changeBytes(it, 4_000) }
println("Profile change proposal bytes by groups, a 4 KB profile: $at4k")
val largest = (2..ConfederationKinds.MAX_SUPERGROUP_GROUPS).associateWith(::largestProfile)
println("Largest profile text that fits, by groups: $largest")
assertTrue(at4k.getValue(ConfederationKinds.MAX_SUPERGROUP_GROUPS) > ConfederationKinds.MAX_STATEMENT_BYTES, "a 4 KB profile does not fit twelve groups")
assertTrue(largest.getValue(ConfederationKinds.MAX_SUPERGROUP_GROUPS) >= 1_000, "a profile of a kilobyte fits twelve groups: $largest")
}
// ---- check 5: a voucher verifies on a device in neither the group's room nor its inbox ----
@Test
fun `a voucher the group's quorum signed verifies under its npub anywhere`() = runBlocking<Unit> {
val groups = ConfederationTestGroups(names = listOf("Agora", "Polis"), keySeries = 2).also { network = it }
groups.setUp()
val agora = groups.groups[0]
val now = kotlin.time.Clock.System.now().epochSeconds
val tags = arrayOf(arrayOf("confederation", "aa".repeat(32)), arrayOf("profile", "bb".repeat(32)), arrayOf("e", "cc".repeat(32)))
val sessionId = groups.signed(agora) { device ->
FrostSigningManager.proposeSigningBatch(
device.db, device.room(), device.publicKey, listOf(EventTemplate<Event>(now, 9438, tags, "")),
).id
}
val voucher = agora.devices[2].db.groupSignedEventDao().getByChatRoomIdAndKind(agora.roomId, 9438)
.single { it.frostSigningSessionId == sessionId }.toEvent()
// A device that knows only Agora's npub: no room, no inbox key, no share.
assertTrue(GroupKeyStateEvent.isSignedByRoom(voucher, agora.roomId), "Agora's quorum signed it as Agora")
val forged = Event(voucher.id, groups.groups[1].roomId, voucher.createdAt, voucher.kind, voucher.tags, voucher.content, voucher.sig)
assertTrue(!GroupKeyStateEvent.isSignedByRoom(forged, groups.groups[1].roomId), "and not as anyone else")
}
}
+1
View File
@@ -17,6 +17,7 @@ the [retired](./retired/) notes now.
| [subgroups.md](./subgroups.md) | a group making another group — the four ceremonies, what the parent's signature actually covers, and why the child's key is fresh rather than derived |
| [confederation.md](./confederation.md) | a group made of groups: a phased plan, built behind a flag that is off in release but for its device run and the room's governance. Agreeing to form (Part A), the key ceremony and room (Part B), and the confederation signing its profile, posts and charter (Part C). Groups with a public nostr profile propose, accept or reject a confederation in public, an acceptance carries the group's admins sealed to the coordinator in a way every signer recomputes, and the confederation's DKG and Marmot room follow. Covers why the public events are regular kinds, why nothing can be encrypted from or to a group's npub, how the coordinator is kept from substituting a roster, and why everything after the agreement waits on upstream publishing the distributed rounds. Its coordinator and its public statements have since been replaced (confederation-without-coordinator.md) |
| [confederation-without-coordinator.md](./confederation-without-coordinator.md) | a confederation nobody coordinates: a phased plan, built but for its device run and behind flags that are off in release. The proposal and every answer travel as NIP-17 messages between the groups' NIP-4E inboxes, each sealed by its group's quorum, so every admin of every group reads every admin list and computes the outcome, and the key ceremony derives its room and session seed and computes the coordinator's broadcast on every device. Covers why a group could be the DKG's coordinator and does not need to be, why the admin lists stop being a payload encrypted to one person, why a confederation names at most twelve groups, how a group that says different things to different groups is caught, and who makes the confederation's room when nobody is in charge |
| [confederation-profile.md](./confederation-profile.md) | a formed confederation's nostr profile, decided by its groups: a phased plan, not built. The confederation gets its own screen, reached from each member group's screen, and an edit there is a statement by the editing group, sealed by its quorum and sent to every member group's inbox, which the others endorse or object to by their own quorums. Once `T` groups have endorsed, each group's signed voucher is a role holder's consent, so the confederation signs and publishes the profile with nobody asked again. Covers why the rule is `T` of `N`, why a transferable voucher is needed beside the non-transferable seals, who starts the signing, and how the confederation's room and the key ceremony's room come to say what they are |
| [confederation-upstream.md](./confederation-upstream.md) | the work below Giza that unblocks the confederation's Parts B and C: a phased plan, not built, across secp256k1-zkp, secp256k1-kmp and bitcoin-kmp. Covers why the one-process DKG and signing cannot simply be exposed step by step (the coordinator derives everyone's key state, acknowledgment is signed before the share is stored, nonce randomness is derived from the session id), why every DKG step can stay stateless, the storage contract a device follows, and Prefractal as an all-groups-must-sign path that needs no upstream work |
| [automatic-key-ceremony.md](./automatic-key-ceremony.md) | joining is the only approval: a phased plan, built but for its device session, that makes a key ceremony run by itself after a member joins. Covers why contributing and confirming were never decisions a person could add to, the resume sweep that replaces the tap, the coordinator's follow-up steps and the one key state a device can sign without asking, and why abandon stays |
| [ceremony-creation.md](./ceremony-creation.md) | one place to start a key ceremony — how joining a subgroup's ceremony opened a second one for the parent room, the screen that showed a ceremony and offered to start one in the same button, and the removal of the nip30303 documents, whose kinds collided with the ceremony's, leaving the member chronicle with nothing to carry and nothing to say |
+658
View File
@@ -0,0 +1,658 @@
# A confederation's profile, decided by its groups
A plan to run a formed confederation's nostr profile (its kind:0) from the place where people
already understand a confederation: the group's own screen. From there, an admin opens
the confederation's screen, edits its profile, and the edit goes out as a **proposal from their group
to every other group's inbox**. The other groups endorse it or object, each by its own quorum.
Once enough groups have endorsed, the confederation signs the new profile and it is published.
Nobody is asked a second time.
Read [confederation.md](./confederation.md) (Parts B and C: the key, the room, the nested
signing), then [confederation-without-coordinator.md](./confederation-without-coordinator.md),
whose statements, seals and refusals this plan reuses for a new kind of statement, and
[group-inbox.md](./group-inbox.md), which carries them.
[group-nostr-profile-and-posts.md](./group-nostr-profile-and-posts.md) defines what a group's
profile is and how its form works. This plan reuses that form.
Written against `3b0b3c9a`, on 2026-11-22. **Being built** on `claude/confederation-profile`, one
commit per phase; each phase says under it what was built and where it differs from what it planned.
Paths starting `K/` are under `composeApp/src/commonMain/kotlin/mobi/giza/compose/`.
---
## What is wrong today
Traced through the code at `3b0b3c9a`, with the working tree's ceremony-room changes applied.
**The confederation's room does not show which groups are in it.** `ConfederationFollowThrough`
makes a Marmot room whose members are the people who hold roles: every admin of every group,
at the time it formed. The room's detail screen lists them as people. The confederation is made
of groups, and the room does not say which group each person belongs to. The device already
knows: `ConfederationRosterBuilder.Plan.seatsOf(person)` gives each person's seats, and each
seat names its group. Nothing reads it for display.
**The proposal screen is the only place that shows the confederation as groups.**
`ConfederationProposalScreen` lists every group, by name, with its answer. That is the right
view of a confederation, but it is framed as a proposal. Once the confederation has formed,
the card on `ConfederationsScreen` says "Formed" (`ConfederationsUIState.Item.formed`) and
still opens the proposal. That screen has nothing to say about a confederation after it
exists.
**The key ceremony's NIP-17 room has nothing to do once the ceremony ends.** The room is made
over the roster's people (`deriveChatRoomId(people)`, D8 of the coordinator-free plan), so it
appears in everyone's chat list. It carries 30381–30385 while the ceremony runs. After that it
receives nothing. The working tree adds a banner that links the room to its ceremony
(`ChatRoomMessagingUIState.keyCeremony`, `ConfederationRitualManager.proposalOfRoom`). After
formation, the banner has nothing to point to.
**The confederation's profile is edited by people, not groups.** Phase 15 of
[confederation.md](./confederation.md) opened the existing editors in the confederation's room.
`EditGroupNostrProfileViewModel` sees `canSignAsConfederation` and sends the kind:0 to
`ChatRepository.proposeAsConfederation`, which calls `ConfederationSigningManager.propose`. Every
role holder is then asked in that room (30391), as a person. The groups never decide anything as
groups, and their inboxes never hear of it. A group's members who are not admins never hear of
it either. Two admins from the same group can sign the confederation's profile with no one else
in their group knowing.
---
## What changes, in one table
| | today | this plan |
|---|---|---|
| where a profile is edited | the confederation's Marmot room, by a role holder | the **confederation's screen**, reached from any member group's screen, by an admin of that group |
| what an edit is | a signing attempt (30390) in the confederation's room | a **statement by a group** (9435), sealed by its quorum, sent to **every member group's inbox** |
| who decides | each role holder, as a person, in 30391 | each **group**, by its quorum: endorse (9436) or object (9437) |
| how many must agree | `T` groups' worth of role holders saying yes, one by one | `T` groups endorsing. The proposing group's statement counts as its endorsement |
| what a role holder is asked | to approve the attempt | **nothing.** Their device says yes for each seat whose group vouched (D5) |
| who starts the signing | the person who proposed | the first role holder in a fixed order who holds `T` vouchers, with a fallback (D6) |
| who publishes the kind:0 | nobody automatically (the broadcast screen) | the device that started the signing, owed until a relay takes it (D7) |
| what each group's room says | nothing, unless a member holds a role | a line when a change is proposed, endorsed, objected to, published (D8) |
| the confederation's room | members as people | members labelled by group, with a groups card (D9) |
| the ceremony's NIP-17 room after formation | an open chat with nothing in it | read-only, with a banner linking to the confederation's screen (D10) |
---
## Decisions
### D1. A formed confederation gets its own screen, reached from the group's
`ConfederationScreen` (route `ConfederationRoute(activeUserPublicKey, chatRoomId, confederationId)`,
where `chatRoomId` is the member group's room it was opened from) is the **confederation's detail
screen**. It is reached in two ways:
- from `ChatRoomDetailScreen`: one row per formed confederation the group is in ("Member of
Polis League"), placed above the existing Confederations row;
- from `ConfederationsScreen`: a card whose proposal has formed opens this screen instead of
the proposal. The proposal screen stays reachable from here, under "How it was formed".
It shows, top to bottom:
1. **The profile**: picture, name, about, website, nip05, npub. This is the newest valid kind:0
authored by the confederation's id (D7).
2. **The groups**: each member group by name, with the number of roles it holds. For a device
that holds the record, it also lists who holds those roles. This is the view the proposal
screen gives, but describing the confederation rather than the vote that made it.
3. **Profile changes**: each open change, and the most recent closed ones, with their state and
each group's answer (D4).
4. **Edit profile**, for a member who can put a statement to their group (D2).
5. Links to the confederation's room, when this device holds it, and to the proposal.
**Who sees what.** Every member of a member group's room can open the screen. Members who are
not admins hold no record and none of the statements between the groups, so for them it is
built from public data: the charter (9434) for the groups and the kind:0 for the profile.
Admins also see the changes, because those come through the group inbox, which only admins
read. The screen does not guess. A part it cannot fill shows an `EmptyState` that says why:
"Only the group's admins see proposed changes."
The confederation's groups come from the `Confederation` record when the device holds one, and
from a verified charter otherwise. The charter is the confederation's own signed list of its
groups. That is enough for a device that never took part to know whom a change must go to.
### D2. An edit is a statement by a group: kind 9435, to every member group's inbox
An admin edits the profile on `EditConfederationProfileScreen`. It is the existing profile form,
moved out of `EditGroupNostrProfileScreen` into a shared `NostrProfileForm` composable, with
its own view model. **Propose** does not ask the confederation to sign. It asks *the admin's
group* to sign a statement proposing the change. That statement goes through
`ConfederationManager.proposeStatement`, as the confederation's proposals and answers do now:
one seal per member group (this group's own copy included), sealed with the group's inbox key,
signed by the group's quorum through FROST, and wrapped to each group's 10050 relays.
```
9435 rumor, pubkey = the proposing group's npub
tags:
["p", <every other member group>] …
["confederation", <the confederation's id>]
["base", <id of the kind:0 this edits>] absent when the confederation has none
["expiration", "<unix seconds>"] default 3 days, at most 7
content: the unsigned kind:0, as JSON:
{"pubkey":"<confederation id>","created_at":<now>,"kind":0,"tags":[…],"content":"…"}
```
The kind:0's `created_at` is fixed when it is proposed, so its **id is fixed before anyone
answers**. Every endorsement, voucher and signing attempt names that id. Nothing that is signed
later can differ from what was endorsed.
**Who can propose:** a member of the group's room with a share in its active generation, who
holds the group's announced inbox key (an admin, as D5 of the coordinator-free plan requires).
Every member group must have announced an inbox. The form checks the same things
`ProposeConfederationScreen` checks before it allows **Propose**, and gives the same reasons:
"Set up the group's inbox first", or "Agora has no inbox, so it cannot be asked".
**An admin of two member groups** picks which group proposes, from a choice on the form that
appears only when there is more than one group to pick from. The group is the author. The person is not.
**Size.** One seal per group, each holding the whole kind:0, so the profile a change can carry
shrinks as the groups grow: about 13 KB of text to two groups, 4 KB to six, **1.1 KB to twelve**
(Phase 0, check 3). A name, an about of a paragraph, a picture URL, a website and a nip05 fit any
confederation. The check against `MAX_STATEMENT_BYTES` that `proposeSealed` already makes refuses a
larger one, and the form says why in a profile's terms: "This profile is too long to send to 12
groups. Shorten its about."
### D3. Answers: endorse (9436) or object (9437), each by the group's quorum
```
9436 rumor endorsement
tags: ["p", <every other member group>] …, ["confederation", <id>], ["e", <9435 rumor id>],
["profile", <the kind:0's id>]
content: empty
9437 rumor objection; from the proposing group, a withdrawal
tags: as 9436
content: an optional reason, plain text
```
An answer goes to **every** member group, not only the proposer. Every admin of every group sees
how every group answered, as with the formation statements. Each answer's signing session carries
the 9435's seal in `confederation_invitation`, as answers to a proposal already do. A signer
therefore does not depend on its own inbox having received the change.
`ConfederationProposalScreen`'s Accept/Decline pair becomes **Endorse** / **Object** on the change's
own screen (`ConfederationProfileChangeScreen`, opened from the confederation's screen and from the
line in the group's room). Under them is the change as a field-by-field difference from the
profile it edits:
```
Name Polis League → Polis League of the Coast
Picture (unchanged)
About (cleared)
```
The same difference appears in `ProposedEvent`'s summary on the FROST approval screen. A member
who opens the signing session from the room's transcript sees what their group is being asked to
say, not "Event of kind 13".
### D4. A change's state is computed from the statements held, on every device
`ConfederationProfileChange.State`, computed whenever it is read, as `ConfederationStatus` is for
proposals. `E` is the number of groups that endorsed (the proposer included), `O` the number that
objected, and `N` and `T` are the confederation's.
| state | when |
|---|---|
| `WITHDRAWN` | the proposing group's 9437 is held |
| `PUBLISHED` | a signed kind:0 with the change's id is held |
| `SUPERSEDED` | a signed kind:0 for the confederation with a later `created_at` is held |
| `ENDORSED` | `E ≥ T`: the signing is under way (D6) |
| `DECLINED` | `N − O < T`: it can no longer reach `T` |
| `EXPIRED` | past its expiry and not `ENDORSED` |
| `OPEN` | otherwise |
An answer counts only if its own `created_at` is at or before the expiry. This is the
existing rule ([confederation.md](./confederation.md) D8), so whether a change was endorsed in
time does not depend on when a device heard of it.
**The rule is `T` of `N`, not all of `N`.** `T` is what the groups agreed to when they formed
it ("2 of 3 groups to act"), and it is also what the signature needs. If an objecting group
could block a change that `T` groups endorsed, the confederation would be governed by unanimity
while its key works by threshold. An objection is still recorded and shown to every group.
**Changes may overlap.** Two open changes may exist at once. Whichever is published first wins,
and any change with an earlier `created_at` becomes `SUPERSEDED`, because relays keep only the
newest kind:0. A later change published first makes an earlier one pointless, and its signing
is refused (D6).
### D5. A group's endorsement makes a voucher, and a voucher is a role holder's consent
The sealed 9435 and 9436 are good evidence for the groups' admins, but they are not
**transferable**. A seal opens only with the inbox key it was sealed to (D3 of the
coordinator-free plan). The people who must act on an endorsement are the confederation's role
holders, in the confederation's room. Some of them are no longer admins of their group and
hold no inbox key, and none of them can show another group's seal to anyone. So the group's
signing session signs one more event in the same batch:
```
9438 voucher, signed by the group's npub (FROST, same session), never published
tags: ["confederation", <id>], ["profile", <the kind:0's id>], ["e", <9435 rumor id>],
["expiration", <the change's expiry>]
content: empty
```
A 9435 or 9436 batch is `N` seals plus one voucher. It is signed in the one FROST session the
group is already asked for, so this costs no extra question. When it completes, every device in
the group's room holds the signed voucher (`FrostSigningManager.complete` → `applySignedEvent`).
**Carried into the confederation's room.** Each role holder of the group whose device holds the
signed voucher posts it into the confederation's Marmot room as a new message, **30396**
(`ConfederationSigningEvents.VOUCHER`). Copies from several devices are deduplicated by the
voucher's id. A role holder's device that receives one verifies the group's signature against
the roster's group key, then files it.
**A voucher is consent.** `ConfederationSigningManager.acceptProposal` gains a path for an attempt
over a kind:0. The 30390 must carry vouchers (`["voucher", <signed 9438 JSON>]`) from at least `T`
distinct member groups. Each must verify under its group's npub, name exactly this event's id, and
not be expired. A device then sends its 30391 **without asking anyone**: yes for each of its seats
whose group vouched, no for each that did not. A seat in a group that objected never signs.
That moves the decision from each person to each group. A role holder who would have said no as
a person signs anyway if their group's quorum said yes. This is deliberate: the confederation
was formed with `t_g` set to each group's own threshold, and a role holder holds their share as
an admin of their group. The appendix covers asking each role holder as well.
**The direct path closes for kind:0.** `ConfederationSigningManager.refusalOf` refuses a kind:0
that carries fewer than `T` valid vouchers: "A confederation's profile changes through its groups."
`EditGroupNostrProfileViewModel` stops treating a confederation's room as a signer for kind:0.
The profile row on that room's detail screen opens the confederation's screen. Posts (kind:1) and
the charter keep the direct path for now (*Out of scope*).
### D6. Who starts the signing, and what happens when it fails
Once a role holder's device holds vouchers from `T` groups for one change, and no attempt for
that kind:0 is running:
- **The order** is the roster's people sorted bytewise, the same order D11 of the
coordinator-free plan uses for making the room.
- **Person `k`** starts an attempt if none for this kind:0 has arrived **`k × 10` minutes** after
the `T`-th voucher reached their device. One person away adds ten minutes of delay, not an
indefinite wait. Ten minutes rather than D11's hour, because signing needs devices online at
the same time and should run while the endorsing people still have their phones in hand.
- **Crossing attempts** over the same kind:0 both run until one finishes. The attempt whose id
sorts first continues everywhere. The other is ended out loud with "Another attempt is signing
this change", as crossing inbox ceremonies are.
- **A failed attempt is retried by the same rule**, from its failure: `RESTARTED` (a nonce lost
to a restart), or a selected device that stopped answering. The delay doubles each time, from
ten minutes up to two hours, until the change expires. The change's screen says "Signing:
waiting for Agora's admins", naming the groups whose roles have not yet said yes.
- **Refusals before starting:** the change is not `PUBLISHED`, `SUPERSEDED` or expired, and no
signed kind:0 for the confederation with a later `created_at` is held.
An attempt started this way does not announce "A proposal for the confederation to sign" in the
room as a question. It writes one line that names the change and the groups that vouched.
### D7. The signed profile is published, and every member group hears it
`ConfederationSigningManager.complete` already files the signed event as a `GroupSignedEvent` under
the confederation's id on every role holder's device. Added:
- **Owed to relays.** On the device that started the attempt, the signed kind:0 is marked owed,
and `ConfederationPublisher` sends it, as it sends the charter. It goes to the publish set and
to each member group's 10050 relays, and backs off from a minute up to half an hour until a relay
takes it. Any other role holder's device may publish the same event too. It is the same
event, so duplicates are harmless. It sends only if the event is still unpublished an hour
later, the same fallback idea as D6.
- **Heard by every member group.** `live-confederation` gains a filter
`{"kinds":[0], "authors":[every confederation id this device knows]}`. Known ids come from the
`Confederation` rows and from charters filed for this device's groups. A kind:0 that arrives
is verified and filed as a `GroupSignedEvent` under the confederation's id. That is how a member
who is not an admin learns of the new profile, and how the confederation's screen reads it.
- **Read** by a new `ConfederationProfile.newestOf(confederationId)`, which is
`GroupNostrProfile.newestAmong` over those rows.
### D8. Lines in each group's room, written by each device for itself
New `ChatMessage` types, written by each device into its own member groups' rooms, and sending
nothing. This is the pattern `ConfederationFormation` already follows.
| type | text | who writes it |
|---|---|---|
| `TYPE_CONFEDERATION_PROFILE_PROPOSED` | "Agora proposes a new profile for Polis League" | admins' devices, from the 9435 |
| `TYPE_CONFEDERATION_PROFILE_ENDORSED` | "Ekklesia endorsed Agora's change to Polis League's profile" | admins' devices, from each 9436 |
| `TYPE_CONFEDERATION_PROFILE_OBJECTED` | "Ekklesia objected to …: <reason>" | admins' devices, from each 9437 |
| `TYPE_CONFEDERATION_PROFILE_PUBLISHED` | "Polis League has a new profile" | **every** member's device, from the kind:0 off relays |
Each line carries the change id and opens `ConfederationProfileChangeScreen`. The published line
carries the confederation id and opens `ConfederationScreen`. Members who are not admins see
their own group's signing session through its existing line, and then the published line. That
is the same visibility they have for formation statements.
`NotificationClassifier` treats a 9435 from another group, received by an admin of a group that
has not answered, as needing attention, the way a signing session waiting for you does. The
other lines are quiet.
### D9. The confederation's room shows its groups
On a confederation's room, `ChatRoomDetailScreen`:
- labels each member with their groups, from `Plan.seatsOf(member)` named by
`ConfederationManager.nameOf`: "Thandi · Ekklesia, Agora". Someone who holds roles in two groups
is shown once with both names;
- gains a **Groups** card above the members, listing each group with its role holders. The card
links to the confederation's screen;
- states that the room is fixed at the people who held roles at formation, and what that means:
"Admins who joined a group after Polis League formed are not here."
### D10. The ceremony's room is closed once the ceremony ends
The NIP-17 room the ceremony ran in stays on the device. Its messages are the evidence the
genesis was built from, and a later attempt over the same roster meets there. After
`ConfederationFormation.onComplete`:
- the banner the working tree adds (`keyCeremony`) says "The key ceremony for Polis League is
complete" and links to `ConfederationScreen`;
- the composer is hidden, the same way it is for a room nobody can write to.
Anything typed there would reach only the founding people as people, which is what this plan
is trying to stop;
- the room moves below the active conversations in the chat list, ordered by its last message
like any other room. It is not hidden. A person who goes looking for it should find it.
If a ceremony is retried (D10 of the coordinator-free plan), the room opens again, because the
retry runs there.
### D11. Behind both flags; the kinds are rumors and a voucher, never public
Everything here needs `ExperimentalFeatures.confederation` and `ExperimentalFeatures.groupInbox`.
Kinds 9435–9437 are rumor kinds and 9438 is a voucher. **None joins `ConfederationKinds.ALL`**,
which drives the public subscription and `BROADCASTABLE_KINDS`. They go in a new
`ConfederationKinds.PROFILE_CHANGE_KINDS`. A FROST batch that tries to sign any of them as a
bare event, rather than as a voucher beside its seals, is declined by `ConfederationRefusal`. That
check runs even with the flags off, as every refusal does. A device that receives a 9438 on its
own, outside a 30390, files nothing.
---
## Who is asked what
| step | who is asked | what they decide | automatic after that |
|---|---|---|---|
| propose | one admin of group A, on the confederation's screen | the new profile | building the 9435, the seals, the voucher |
| A signs | A's quorum | that A proposes this profile | wrapping to every member group's inbox; A's role holders posting A's voucher |
| a change arrives | nobody | — | every admin's device in every group files it and writes a line |
| B answers | one admin of B, then B's quorum | endorse or object | wrapping to every group; B's voucher into the confederation's room |
| `T` groups have vouched | nobody | — | the first role holder in order starts the signing; every role holder's device says yes for its vouched seats |
| signed | nobody | — | published; every member's device files it and writes "has a new profile" |
People are asked twice in total, once per group, and both questions are group signing
sessions they already know how to answer.
---
## Phases
One commit per phase, in the repository's style (`feat: … (confederation-profile, Phase n)`).
Every phase leaves `./gradlew :composeApp:jvmTest` and `:composeApp:m3Audit` green, and `check`'s
brand and wallet audits at budget.
### Phase 0: land what is in flight, this document, five checks
The working tree's ceremony-room changes (`keyCeremonyOfRoom`, `joinablePlan`,
`ConfederationRitualUIState.Joinable`, the messaging screen's banner) are committed first, as
their own commit. D10 builds on that banner.
Then this document and its row in [README.md](./README.md), and before code:
1. **The kinds.** 9435–9438 appear in no NIP, nor in quartz, Curare or Bennu, and 30396 is unused
(30390–30395 and 30399 are signing's, 30410–30416 the inbox's).
2. **A mixed batch.** On the inbox's harness, a FROST batch of `N` kind-13 seals plus one kind 9438
proposes, passes `ConfederationRefusal`'s routing (by the `confederation_rumor` tag) and
`InboxRefusal`'s manifest check, signs, and leaves the signed 9438 on every member's device.
If the manifest check refuses a batch that is not all seals, the voucher is signed in a second
session started automatically on completion, and D5 says so.
3. **Size.** A 9435 for twelve groups with a 4 KB kind:0, against `MAX_STATEMENT_BYTES`. Record
the largest profile that fits.
4. **Pin today.** `ConfederationProfileTodayJvmTest`: a role holder's kind:0 through
`proposeAsConfederation` signs with no group asked; the confederation's room lists members
without groups. Both are flipped on purpose in Phases 5 and 7.
5. **A voucher verifies anywhere.** A 9438 signed by group B's FROST session verifies under B's
npub on a device that is in neither B's room nor B's inbox, given only the roster.
**Done when** all five are recorded here and checks 2, 4 and 5 are tests.
**Done**, on 2026-11-22. The in-flight work had already landed as `50f73e17`.
`ConfederationProfilePremiseJvmTest` keeps checks 2, 3 and 5:
| check | result |
|---|---|
| 1. the kinds | **free.** Neither 9435–9438 nor 30396 appears in quartz 2.20.1's sources or anywhere in the app; [confederation.md](./confederation.md)'s Phase 0 found nothing in the NIP table between 9321 and 9734 |
| 2. a mixed batch | **does not pass today, and both obstacles are ours.** `ConfederationRefusal.of` declines any batch with a non-seal in it as `SHAPE`, and `InboxReplies.wrapAndOwe` sends nothing when a session has more items than its manifest has seals. Phase 2 teaches both about the one voucher, rather than signing it in a second session: a second session is a second question to the quorum |
| 3. size | **a 4 KB profile does not fit twelve groups** (118 KB against 60 KB): every seal carries the whole kind:0. The largest profile text that fits, by groups: 13.6 KB for 2, 7.3 KB for 4, 4.1 KB for 6, 2.9 KB for 8, 1.8 KB for 10, **1.1 KB for 12**. D2 now says so, and the form gives the reason in a profile's terms |
| 4. pin today | `ConfederationSigningJvmTest`'s first case already pins it: a role holder's kind:0 through `ConfederationSigningManager.propose` signs with no group asked. Phase 5 flips it. The room's member list is pinned by Phase 7's own test |
| 5. a voucher anywhere | **holds.** A 9438 signed by a group's FROST session verifies under its npub through `GroupKeyStateEvent.isSignedByRoom`, given nothing but the npub, and not under another group's |
### Phase 1: the wire, and the storage
- `K/nostr/confederation/ConfederationProfileStatements.kt`: build and strictly parse 9435–9437
rumors and the 9438 voucher. The parser refuses an embedded event that is not kind 0, does not
have the confederation as its author, or is not a readable profile
(`GroupStatementRefusal.isUnreadableProfile`). `ConfederationKinds.PROFILE_CHANGE_KINDS`,
`ConfederationSigningEvents.VOUCHER = 30396` and the `voucher` tag.
- `ConfederationProfileChange.State` and the computation of D4, as a pure function over the held
statements, the vouchers and the newest kind:0. Tested exhaustively, since every screen and the
starter rule read it.
- Schema **50**, `AutoMigration(49, 50)`, new tables only:
- `ConfederationProfileChange`: rumor id, confederation id, proposing group, the unsigned
kind:0's JSON and id, base, expiry, `created_at`, and the seal that delivered it;
- `ConfederationProfileAnswer`: change id, group, kind, rumor id, reason, `created_at`, seal;
- `ConfederationVoucher`: voucher id, change id, group, signed JSON.
- `ConfederationRepository` gains `observeProfileChanges(confederationId)`,
`observeProfileChange(changeId)` and `observeProfile(confederationId)`, with `NO_OP` overrides.
Tests: `ConfederationProfileStatementsTest` (bytes pinned, every refusal),
`ConfederationProfileChangeStateTest`, `ConfederationProfileStorageJvmTest`.
### Phase 2: proposing and answering through the inboxes (D2, D3, D5's batch)
- `ConfederationProfileManager.proposeChange`, `endorse`, `object` and `withdraw`. Each builds its
rumor, resolves recipients from the confederation's groups (record, else charter), and goes
through `ConfederationManager.proposeStatement`, which gains an optional extra signed event
for the voucher.
- `ConfederationRefusal` gains arms for 9435–9437 in the four places it sits (arrival, approval,
decline reason, resend). A signer declines unless:
1. this device holds the group's announced inbox key (as today);
2. every seal holds `confederation_rumor` byte for byte, one per member group (as today);
3. the `p` tags are exactly the confederation's other groups, from the record or a verified
charter. Otherwise: "This device holds no record of that confederation";
4. for a 9435: the kind:0 is the confederation's, readable, its `created_at` within ten minutes
of now, the expiry at most seven days away, and **this device holds no kind:0 newer than its
base**. Otherwise: "Polis League's profile has changed since this was written". An unknown
base is a warning, not a refusal;
5. for a 9436 or 9437: the carried 9435 opens with this group's inbox key and verifies as its
author's, is `OPEN` here, and this group has not answered;
6. the voucher in the batch names exactly the kind:0 and change in the rumor, with the same
expiry. For a 9437 there is no voucher, and a batch that has one is declined.
- `ProposedEvent` summarises each kind with the field difference of D3.
Tests: `ConfederationProfileDeclineJvmTest`, one case per refusal, on `SigningProposalHarness`.
`ConfederationProfileProposeJvmTest`: a three-group fixture where A's admin proposes, A's quorum
signs, and every group's admins' devices hold the 9435.
### Phase 3: receiving (D4, D8)
- `GroupInboxManager` routes rumors of `PROFILE_CHANGE_KINDS` to `ConfederationProfileManager.record`
beside the existing `ConfederationManager.recordStatement` call, storing them with their seal.
A 9436 or 9437 that arrives before its 9435 is stored and gets its line once the 9435 arrives.
This is the same fix Phase 7 of [confederation.md](./confederation.md) needed.
- The lines of D8, and `NotificationClassifier`'s one new case.
Tests: `ConfederationProfileReceiveJvmTest`, covering out-of-order arrival, a seal from a group
that is not a member (dropped and logged), and a duplicate.
### Phase 4: the screens (D1, D2, D3)
- `ConfederationScreen` + `ConfederationViewModel` + `ConfederationUIState` (loading, error,
not held, loaded), with the parts and visibility rules of D1. The **Edit profile** button is
gated on D2's conditions, as `ConfederationsScreen` gates **Propose a confederation**.
- `EditConfederationProfileScreen`: `NostrProfileForm` extracted from
`EditGroupNostrProfileScreen` (both screens then use it), the group picker for an admin of
several groups, and **Propose to the groups**. On success it goes to the FROST signing session,
as answering a proposal does.
- `ConfederationProfileChangeScreen`: the difference from the base, every group's answer,
**Endorse** / **Object** (with an optional reason) / **Withdraw**, the open signing session if
there is one, and the signing state of D6 once endorsed.
- `ChatRoomDetailScreen`: one row per formed confederation. `ConfederationsScreen`: a formed card
opens `ConfederationScreen`.
- Routes in `GizaNavHost`, each with `NavigateBackButton`. Strings in the catalogue, sentence
case, with no "supergroup", "voucher", "rumor" or "NIP-4E" shown to a person. A voucher appears
in the interface only as "endorsed".
Tests: `ConfederationProfileScreensJvmTest`, covering each state, the gating of each button, and
the non-admin view built from the charter and kind:0 alone. `m3Audit` at budget, with no new
`.dp` spacing, colour literal or title-case string.
### Phase 5: from endorsement to signature (D5, D6)
- The 30396 voucher message: posted by each role holder's device when its group's 9435 or 9436
session completes, verified and filed on arrival, and deduplicated.
- `ConfederationSigningManager`: a 30390 over a kind:0 carries its vouchers. `acceptProposal` checks
them and answers 30391 per seat with no person asked. `refusalOf` refuses a kind:0 without `T`
vouchers. `SIGNABLE_KINDS` is unchanged.
- `ConfederationProfileFollowThrough`, run from the sweep `SynchronizationViewModel` already runs
and when a voucher arrives. It applies D6's order and delay, the crossing rule, and retry with
backoff, and it stops at expiry, `SUPERSEDED` or `PUBLISHED`.
- `EditGroupNostrProfileViewModel` stops routing kind:0 to `proposeAsConfederation`. The
confederation's room opens `ConfederationScreen` for its profile. Phase 0 check 4's first pin
is flipped.
Tests: extend `ConfederationSigningJvmTest`, three groups of three on nine devices with `T = 2`:
- A proposes and B endorses, so the signature is made with no role holder asked, and C's seats
say no;
- A proposes and B and C object, so the change is `DECLINED` and no attempt starts;
- the first person in the order is offline, so the second starts after ten minutes (on a test
clock);
- a restart between nonces and confirmations, followed by a retry that succeeds;
- crossing attempts, where the one whose id sorts first survives everywhere;
- a kind:0 proposed directly in the room, which is refused;
- a role holder who is no longer an admin of B still signs for B's seat on B's voucher.
### Phase 6: publishing and hearing (D7)
- The kind:0 owed on the starter's device, sent by `ConfederationPublisher` to the publish set
and every member group's 10050 relays. The other role holders' devices send it as a fallback
after an hour.
- `live-confederation`'s kind:0 filter by author. A kind:0 that arrives is verified and filed under
the confederation's id. `ConfederationProfile.newestOf`.
- `TYPE_CONFEDERATION_PROFILE_PUBLISHED` on every member's device, and the change moves to
`PUBLISHED`. Other changes with an earlier `created_at` move to `SUPERSEDED`.
Tests: `ConfederationProfileRelayTest`, with the relay as a copy, covering that a member of A who
is not an admin and holds no role sees the new profile on the confederation's screen, and that a
later change published before an earlier one supersedes it.
### Phase 7: rooms that say what they are (D9, D10)
- The confederation's room: members labelled by group, the **Groups** card, and the sentence about
admins who joined later. Phase 0 check 4's second pin is flipped.
- The ceremony's room after formation: the banner links to the confederation, the composer is
hidden, and the room moves below active conversations. It opens again for a retry.
Tests: `ConfederationScreensJvmTest` gains the labelled members and a person in two groups shown
once. The messaging screen's test covers a formed ceremony room with no composer.
### Phase 8: the network run
`ConfederationProfileNetworkJvmTest`, the plan end to end on `ConfederationNetworkJvmTest`'s
harness: three groups of three, real FROST and confederation signatures, and relays as copies.
A's admin edits the name from the confederation's screen. Every admin of B and C gets a line and
a notification. B endorses. The profile is signed with no further question, published, and read
back on all nine devices and on a non-admin member's device in each group. Then a second change
that C objects to and A withdraws.
### Phase 9: the record, and devices
This document's header and progress table, as the other confederation plans keep theirs, and a
row-by-row "where the build chose differently". Then a device run: two phones and the desktop
build, two real groups with inboxes, one change proposed, endorsed, signed and seen on a third
client by npub. Record what did not happen.
---
## What this does not do
- **Posts and the charter** still go through the direct path, with each role holder asked as a
person. The wire of D2 is general (the 9435 carries one unsigned event), so moving kind:1 and
9434 over is a refusal and a form each. That is the obvious next plan.
- **Admins who joined after formation** cannot sign for the confederation. They hold no role,
because the room and the roster are fixed at the founders until governance is built
([confederation.md](./confederation.md), Phase 15). They *can* propose and endorse, because
those are their group's statements, and a voucher is their group's.
- **A newly promoted admin cannot read changes proposed before their promotion**
([group-inbox.md](./group-inbox.md) D15). Their group's later answers still work, because each
carries the 9435 it answers.
- **Signing needs devices online together.** A voucher makes a role holder's consent automatic,
but their nonce still has to be made while the attempt runs. D6's retries carry the change
across gaps; nothing carries it past its expiry.
- **Not for value.** Upstream's warning on its confederation module stands.
## Risks
| risk | what to do |
|---|---|
| `InboxRefusal`'s manifest check refuses a batch that is not all seals | sign the voucher in a second session, started automatically on completion (Phase 0, check 2) |
| a profile too large for twelve seals | the existing size refusal, with the largest that fits recorded (check 3) |
| two groups each propose a change at once | both run; the newer `created_at` wins on relays, and an older one published second is refused (D4, D6) |
| no `T` groups' role holders are online together | retries with backoff until expiry, and the change's screen names the groups still being waited on |
| a group's quorum equivocates, sealing different 9435s to different groups | the change's id is the kind:0's id, which every voucher names. Groups endorsing different kind:0s produce vouchers for different ids, and neither reaches `T` |
| a role holder disagrees with their group's endorsement | by design their seat signs (D5); the appendix covers asking them as well |
| a stale voucher signed long after it was given | vouchers expire with their change, and nothing signs past expiry |
## Out of scope
- Moving posts (kind:1) and the charter (9434) onto group statements.
- Governance of the confederation's room and roster: admins added later, admins removed.
- A role holder's per-confederation setting to be asked each time (appendix).
- Threshold-ECDH member groups, as in the coordinator-free plan.
---
## Appendix: considered and not chosen
| idea | why not |
|---|---|
| keep the edit in the confederation's room, and only *notify* the groups' inboxes | the groups would hear about it without deciding it, and two role holders of one group could still speak for the confederation with their group unaware |
| every group must endorse (unanimity) | the confederation was formed as `T` of `N`, and its key signs that way. Unanimity would let one group stop everything forever |
| ask each role holder as well as each group | two questions per change per person. The group's quorum already is the role holders of that group, at its own threshold. Worth an opt-in per role holder if it is missed in practice |
| send the sealed 9436 into the confederation's room instead of a voucher | a seal is not transferable: only the group it was sealed to can open it |
| make the 9435/9436 rumors themselves signed | rumors are unsigned on purpose, and the seal already makes them binding between groups. The voucher is the one transferable statement, kept separate and never published |
| run the confederation's nested signing through the groups' inboxes | nonces, confirmations and partials are high-volume, person-to-person, and must stay in memory. The Marmot room already carries them |
| delete the ceremony's NIP-17 room after formation | its messages are the genesis evidence, and a retry needs the room |
---
## Order and size
| phase | rough size | depends on |
|---|---|---|
| 0 | the in-flight commit, scratch tests, this document | — |
| 1 | ~450 main, ~400 test, an auto-migration | 0 |
| 2 | ~450 main, ~450 test | 1 |
| 3 | ~200 main, ~250 test | 2 |
| 4 | ~900 main, ~400 test | 3 |
| 5 | ~500 main, ~600 test | 2 |
| 6 | ~250 main, ~250 test | 5 |
| 7 | ~250 main, ~150 test | 0 |
| 8 | ~400 test | 4, 6 |
| 9 | docs and a device session | all |
Phases 3 and 5 can be built side by side once 2 is in, and Phase 4 can follow 3 while 5 and 6 go on.
Phase 7 touches neither the statements nor the signing, so it can be built at any point after 0.
That makes it a good first piece to ship, since it fixes the "which groups are these people"
problem without waiting on the rest.
## Checking the work
```bash
./gradlew :composeApp:compileDebugKotlinAndroid :composeApp:jvmTest
```
```bash
./gradlew :composeApp:m3Audit
```
```bash
./gradlew check
```
The new tags (`confederation`, `profile`, `base`, `voucher`) are wire tags, not hash inputs, so
no `mantra/…` tag is added. Bennu is named nowhere but in comments, and no kind in `RetiredKinds`
is touched.