Files
giza-kmp/docs/confederation-dkg-inboxes.md
T
Kgothatso NgakoandClaude Opus 5.5 8ef02129ad test: a confederation formed over its groups' rooms and inboxes end to end, and the record (confederation-dkg-inboxes, Phase 8)
ConfederationNetworkJvmTest forms a confederation on three groups of three, each with a real inbox
and a real MLS room, with one group's first admin never carrying. All nine devices reach one key,
and none holds a NIP-17 room or a ceremony gift wrap. ConfederationTestGroups.pumpConfederation
takes devices that do not carry.

The record: the plan's progress and where the build chose differently, the report marked as
implemented, the README rows, and since notes in the coordinator-free, profile and room-removal
plans. Nothing has run on a device or a real relay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 14:22:04 +02:00

44 KiB
Raw Blame History

The confederation's key ceremony through its groups' inboxes

A phased plan to take the NIP-17 room out of the confederation's key ceremony. Each person's rounds go into the Marmot room of each group they hold a seat in. Each group's admins carry them, one at a time and in order, to every member group's inbox, which is how the confederation's signing already travels (confederation-room-removal.md). When this plan is done, no device makes a NIP-17 room for a confederation, and forming one and signing for it run on one transport.

The reasoning lives in the report this plan implements, confederation-dkg-without-nip17-room.md: why the room is only a transport, why a group can carry its admins' dealings but never combine them, the three ways to move a round and what each costs, and the size of a dealings round. Read it first. This document says what to build, in what order, and how each phase is checked. Where it says report D4, it means that report's decision D4.

Read confederation-without-coordinator.md D8 to D10 for the ceremony as it runs, and confederation-room-removal.md D2 to D4 for the bridge.

Written against 24991e1c, on 2026-11-23. Built, Phases 0 to 8, but for the device run, one commit a phase, behind ExperimentalFeatures.confederation and ExperimentalFeatures.groupInbox, both off in release. Nothing here has run on a phone, a desktop client or a real relay. Paths starting K/ are under composeApp/src/commonMain/kotlin/mobi/giza/compose/, and test paths starting T/ are under composeApp/src/jvmTest/kotlin/mobi/giza/compose/.

Development devices. Schema 54 changed while it was built (Phases 5 and 7 folded into it), so a device that ran a build from between the phases holds a 54 Room will not open; clear its data. A device at 53 upgrades.

phase commit what the NIP-17 room
0 6a6ce006 the report, this plan, and six checks: the budget is 26,000 bytes, not 32,000 working
1 c117995f five pins of today working
2 58442efd ConfederationCeremonyHeard and the carry's scope, schema 54 working
3 2be378cc every ceremony message signed, in a 30379 envelope; equivocation named with both events working
4 8bf7145f the bridge carries ceremonies, envelopes split by bytes; messages into seat groups' rooms as well working, beside the new path
5 266bee2a the switch: no NIP-17 room; the join's checks; lines into the seat groups' rooms gone from new ceremonies
6 1fd13942 the lines open the ceremony; the banner goes; "waiting to be passed on" gone from the screens
7 1a857e6d the ceremony rooms on devices go, and a founders' chat that was one stays gone from devices
8 this commit the network run and the record. No device run —
what the plan said what it turned out to be
a byte budget of 32,000 26,000: NIP-44 pads each layer to a step, and a wrap passes 64 KiB once its rumor pads past 28,672
Phase 3: record keeps its rules it also fails a ceremony on a second, different, signed message of one step from one person, naming them and both events
Phase 4: a new ConfederationBridgeJvmTest the split is a case in ConfederationCeremonyJvmTest, where the Phase 1 pin it flips was
Phase 4: GroupSealRoutingJvmTest gains a case nothing to add: it routes FROST seal batches, and the envelope is a rumor GroupInboxManager.open routes
Phase 5: lines in Phase 6 in Phase 5: the room announce wrote into was gone
Phase 5: the form refuses a roster too large refused at join and in joinable: the form cannot know who sits in several groups until the acceptances say
Phase 5: a 120-role round a 30-role round split in two; the 120-role refusal on one device's statements alone
Phase 6: three strings one: the two refusals stay sentences from the manager, as every reason a join is refused is
Phase 6: the lines' clicks tested in the transcript checked where they are written: no test renders ChatTranscript, here or before
Phase 7: delete payloads, then the room if empty and first clear ChatRoom.initialGiftWrapPayloadId, a key onto the payload that would have cascaded a founders' chat away
— ConfederationTestGroups.Group became a nested class: a clean compile left the inner one without the Compose $stable field its users read

What is settled before code

The report left four things open. This plan settles them, and Phase 0 checks each.

question settled as checked by
the ceremony envelope's kind (report D3) 30379, ConfederationRitualEvents.CARRIED. 30380 and 30383 are retired and stay retired; 30386, 30388 and 30389 are named in confederation.md for unbuilt things. 30379 is in no code, doc, NIP table or quartz at 24991e1c Phase 0 check 1
the byte budget (report D4) 26,000 bytes of envelope content (first planned as 32,000; Phase 0 measured it), ConfederationKinds.MAX_CARRIED_BYTES, for signing and the ceremony alike, beside the existing MAX_CARRIED count Phase 0 check 2
the schema 54, one auto-migration with a spec, with Phases 2, 5 and 7 folded in. Nothing at 54 ships between them, as confederation-room-removal.md folded 52 —
the fallback when a group's carriers are away (report D4) no new code. Every author is an admin holding the inbox key (report D8, Phase 5), so the author's own device already has a turn at carrying its own message, at its place in the order. The fallback is a test, not a feature Phase 5's tests

Two names this plan uses throughout:

  • The scope. What the bridge carries for. Today that is only a formed confederation, keyed by its id. This plan adds a running key ceremony, keyed by its proposal id, since attempts share one carrier set. ConfederationBridge takes a CarryScope:

    sealed interface CarryScope {
        val id: HexKey
        data class Signing(override val id: HexKey) : CarryScope    // a confederation's id
        data class Ceremony(override val id: HexKey) : CarryScope   // a proposal's id
    }
    
  • The carry plan. What the bridge needs to know about a scope: the groups to carry to, and who holds a seat in which group. For signing it is ConfederationSigningManager.held(...).plan. For a ceremony it is ConfederationRitualManager.planFrom(basisFor(proposalId)), which every admin of every group can build once the proposal is accepted on their device, whether or not they have joined (report D2). A carrier never needs a ceremony row.


Phases

One commit per phase in the repository's style (feat: … (confederation-dkg-inboxes, Phase n)). Every phase leaves these green:

  • ./gradlew :composeApp:jvmTest
  • :composeApp:m3Audit
  • compileDebugKotlinAndroid
  • the brand and wallet audits in check

Until Phase 5, the NIP-17 room is the channel that works. Each phase before it adds the new path beside the room without removing anything, so Phase 5 can switch without a gap.

Phase 0: this document, and six checks

This document, its row in README.md, and a line at the top of the report pointing here. Then scratch tests, kept as pins where they stay true, in T/managers/ConfederationDkgInboxesPremiseJvmTest.kt:

  1. 30379 is free. It appears nowhere in RetiredKinds, ConfederationKinds, ConfederationSigningEvents, ConfederationRitualEvents, quartz's kind constants or Bennu's kinds.

  2. The byte budget. On ConfederationReachableJvmTest's roster builder, deal a round for 12 groups of 10 (R = 120, t_g = 6, T = 7). Seal and wrap envelopes of 32,000 bytes of content the way ConfederationBridge.carryOut does. Record:

    • the wrap's serialized size against 64 KiB;
    • the seal's plaintext against NIP-44's 65,535.

    If 32,000 overflows either, lower MAX_CARRIED_BYTES until it fits, and record the number here.

  3. The largest single message. Record the size of one person's 30382 at 1, 2 and 3 seats in that roster, as:

    • a NIP-17 wrap today;
    • an MLS application message into a group's room (MarmotJson.MAX_INPUT_BYTES, 64 KiB);
    • a 30379 envelope of one event.

    The largest roster whose single messages all fit is the limit Phase 5's eligibility enforces (ConfederationKinds.MAX_CEREMONY_MESSAGE_BYTES). Record the seat and role counts where it breaks.

  4. The founders' chat shares the room's id. createNip17ChatRoom over the roster's people, and a plain NIP-17 group chat started by one of them over the same people, give the same ChatRoom.id. This is what Phase 7's migration must respect (report D9).

  5. A seat's inbox key at join. On ConfederationTestGroups, every admin of every group holds an ANNOUNCED inbox key once the inbox ceremony is done (ConfederationManager.announcedInboxKey). Then promote a member in one group's harness without running the rotation, and record whether their device holds one. This is the case Phase 5's join check exists for.

  6. The hops. Count the legs a ceremony takes on the new path: four per-person rounds, each going room → carrier → inbox. Write down the worst-case extra delay at k = 0 and at k = 2, for the device run to beat.

Done when all six are recorded here, and checks 1, 2, 4 and 5 are tests.

Done, on 2026-11-23. ConfederationDkgInboxesPremiseJvmTest keeps checks 1 to 5.

check result
1. the kind free. 30379 is in no confederation kind set, no ritual or signing kind, no retired wallet kind, and none of 30380, 30383, 30386, 30388 or 30389
2. the budget 26,000, not 32,000. NIP-44 pads its plaintext to the next step before each base64, so a wrap's size jumps rather than grows. A wrap stays under a relay's 64 KiB only while the rumor's JSON pads to 28,672 bytes or less, and its seal then pads to 40,960. Envelopes of 32,000 bytes and of 28,700 bytes both made wraps of 66 KB or more; one of 23,941 made a wrap of 55,121. NIP-44's own 65,535 is never the binding limit. MAX_CARRIED_BYTES = 26,000, leaving room for the escaping real dealings carry
3. one message one role's 30382 is exactly 2 · (210 + 33T + Σ_g (4 + 33(t_g − 1)) + 32R) + 89 bytes: 1,439 at 9 roles, 6,491 at 60, 12,707 at 120. At 120 roles one person's signed message is 13,053 bytes at one seat, 25,760 at two (wrap 55,121) and 38,467 at three (wrap 76,965). Three seats at 120 roles fail on NIP-17 today as well. MAX_CEREMONY_MESSAGE_BYTES is the same 26,000: an envelope of one event is that event and two brackets. Phase 5 computes each person's largest message from the formula, before anyone deals
4. the founders' chat holds. The ceremony room's id is ChatRoom.deriveChatRoomId(people), whatever its subject, so any NIP-17 conversation among exactly the roster's people is the same room. Phase 7 has to leave such a room standing
5. inbox keys every admin of every group holds an ANNOUNCED inbox key once ConfederationTestGroups has set up. The promoted-admin half is a reading, not a test: the three-group harness cannot promote. InboxRotation rotates on every admin change (group-inbox.md D14), and until it reaches a new admin's device that device holds no announced key. That is the gap Phase 5's join check closes
6. hops four per-person rounds, each room → carrier → every inbox: four relay legs against today's four, plus one MLS leg a round. At k = 0 the extra is one MLS round trip a round, about four in all; at k = 2, also 4 × 40 s = 160 s at worst. Nothing in the ceremony is lost to the wait, since every step is rebuilt from stored messages

Phase 1: pin today

Written to pass now, and each flipped on purpose by a later phase. These go in T/managers/ConfederationCeremonyJvmTest.kt beside the cases they will replace, since they need its nine devices:

pin flipped by
a ceremony message leaves as one GiftWrapPayload, p-tagged to every other person, in the room whose id is deriveChatRoomId(people) Phase 5: it leaves as an envelope in each seat group's room, and nothing is p-tagged to a person
an unsigned ritual rumor from a person in the roster is recorded Phase 3: dropped
ConfederationBridge.heardInRoom carries nothing for a proposal that is not yet a confederation Phase 4: the ceremony scope carries it
ConfederationBridge.sweep puts every due event into one envelope, whatever its bytes Phase 4: split at MAX_CARRIED_BYTES
a ceremony row cannot be written without a ChatRoom row (the foreign key) Phase 5: the column goes

Done when all five pass on the current code, each with a KDoc line naming its phase.

Done. The five are in ConfederationCeremonyJvmTest under a Phase 1 heading, each named "today …" and with a KDoc line naming the phase that flips it. The sweep pin runs on a formed confederation with withGroupRooms: forty 2 KB events go out as one envelope, a wrap to each of the three groups. ConfederationCeremonyJvmTest 19/19.

Phase 2: storage, schema 54

AutoMigration(53, 54, spec = ConfederationCeremonyInboxMigration::class). Phases 5 and 7 add to the same spec.

ConfederationCeremonyHeard (K/database/model/ConfederationSigningAttempt.kt, beside ConfederationSigningHeard, its twin):

@Entity(indices = [Index("proposalId"), Index("sessionId"), Index("heardAt")])
data class ConfederationCeremonyHeard(
    @PrimaryKey val id: HexKey,      // the signed event's id
    val proposalId: HexKey,
    val sessionId: String,           // the ceremony: ConfederationAttestation.ceremonyId(proposal, attempt)
    val kind: Kind,
    val pubKey: HexKey,
    val eventJson: String,
    val heardAt: Instant = Clock.System.now(),
)

It has no foreign key, because a round can arrive before its owner joins, and so before the ceremony row exists. ConfederationCeremonyDao gains:

  • insertCeremonyHeard, with IGNORE;
  • getCeremonyHeardForSession(sessionId);
  • deleteCeremonyHeardForSession;
  • getCeremonyHeardOlderThan(at).

ConfederationCarry.scope, a TEXT NOT NULL DEFAULT 'SIGNING' column, with values SIGNING and CEREMONY. Rows written before it are signing's, which is all of them. The confederationId column keeps its name and now holds the scope's id: a proposal id for a ceremony. Its KDoc says so. A rename would touch every signing query for nothing.

Retention. ProtocolRetention / DisappearingMessageSweeper release a ConfederationCeremonyHeard row in either case:

  • the ceremony named by its sessionId exists on this device and is not running;
  • no ceremony with that id exists here, and the row is older than DisappearingMessages.CEREMONY_FLOOR.

This is the rule ConfederationSigningHeard follows, with the ceremony's floor.

Filed from today's path too. ConfederationRitualManager.process files every message it is handed into ConfederationCeremonyHeard before record. replayStoredMessages reads getCeremonyHeardForSession first and falls back to GiftWrapPayload by kind. The fallback goes in Phase 5. Today's messages are unsigned rumors, so eventJson holds the rumor with an empty sig until Phase 3.

Tests:

  • T/managers/ConfederationStorageJvmTest.kt:
    • a heard row is filed with no ceremony row;
    • it is released once its ceremony fails;
    • it is released after the floor with no ceremony.
  • T/database/migrations/ShippedProfileUpgradeJvmTest.kt comes out at 54.
  • A new T/database/migrations/ConfederationCeremonyInboxMigrationJvmTest.kt opens a v53 database holding a ConfederationCarry row and reads it back as SIGNING.
  • ConfederationCeremonyJvmTest passes unchanged.

Done. As planned. Retention lives in the DAO rather than ProtocolRetention: sweepCeremonyHeard, run by DisappearingMessageSweeper with the ceremony floor, beside signing's sweepHeard. ConfederationRitualManager.process files every message it is handed before it looks for a ceremony, and replayStoredMessages reads the heard store and the stored gift wraps together, by id. ConfederationStorageJvmTest 11/11, ConfederationCeremonyInboxMigrationJvmTest 1/1, ShippedProfileUpgradeJvmTest 4/4 at 54, ConfederationCeremonyJvmTest 19/19. Full jvmTest 2,026, all passing, and m3Audit at budget.

Phase 3: every ceremony message signed, in an envelope (report D1, D3)

K/nostr/confederation/ConfederationRitualEvents.kt:

  • CARRIED: Kind = 30379, with a KDoc saying it is the ceremony's sibling of ConfederationSigningEvents.CARRIED and why it is a kind of its own: the expiry floor.
  • ALL gains CARRIED. A new SIGNED = PER_PERSON + FAILURE is the set an envelope may carry.
  • encodeCarried and decodeCarried, delegating to ConfederationSigningEvents' pair. The format is the same: a JSON array of events.
  • PROPOSAL_TAG goes on the envelope as well as on each event inside it, so an envelope says which scope it is for without opening its events.

K/nostr/DisappearingMessages.kt: CARRIED goes into CEREMONY_KINDS through ConfederationRitualEvents.ALL, so it needs no edit there. DisappearingMessagesTest (in commonTest) fails if it did not.

K/managers/ConfederationRitualManager.kt:

  • broadcast signs the event with NostrSignerSync(KeyPair(nostrPrivateKey)). It keeps the session, proposal and attempt tags and the expiry stamp, and drops the p tags. It then queues one 30379 envelope of that one event as the room's GiftWrapPayload, p-tagged as today, since the NIP-17 room is still the channel. publishOwn and failOut pass the key through. abandon and fail take it, since they sign a 30387. DatabaseConfederationRepository.abandonCeremony passes it.
  • process reads only 30379 envelopes. It drops a bare ritual rumor with a warning (the Phase 1 pin flips). For each event in the envelope it:
    1. verifies the signature;
    2. checks the kind is in SIGNED and the proposal tag matches the envelope's;
    3. files it in ConfederationCeremonyHeard;
    4. calls record.
  • record keeps its rules, applied to event.pubKey. They now hold for a signed author, where before they held for a seal's.
  • replayStoredMessages builds events from eventJson and verifies them again, since what was stored as heard could be from before this phase.

K/database/dao/NostrDao.kt:1095: the ritual branch already matches by isRitualKind, which now includes 30379, so it needs no change but its comment.

Tests (ConfederationCeremonyJvmTest, on ConfederationPeople): every existing case passes unchanged, which shows the signatures cost the protocol nothing. Three new cases:

  • an event whose content was changed after signing is dropped on every device, and the ceremony waits on its author;
  • an event signed by someone outside the roster is dropped;
  • one person's two different 30382s, both signed, for one attempt: the first heard is recorded, and the second is kept in ConfederationCeremonyHeard as evidence. The failure names the person and the two event ids instead of only "received different dealings". This is the provable-equivocation point of the report: record checks a second signed message of a kind it already holds from that person and fails out naming them (ConfederationRitualManager.describeEquivocation).

Done. As planned, but for the equivocation check, which runs in record itself: a second message of a step from one person, different from the first and signed by them, fails the ceremony there, naming the person and both event ids (describeEquivocation). It needs the honest message first. A changed dealing that arrives first is caught earlier, by the dealer's own record signature, as before. record, replayStoredMessages, failOut, publishOwn, broadcast and abandon take the key, since each may sign a 30387; DatabaseConfederationRepository.abandonCeremony passes the identity's. The envelope also carries the session, proposal and attempt, so ProtocolRetention releases a stored envelope with its ceremony as it did a bare rumor. Two existing cases had to change. "Two devices that were dealt different things" now has the liar sign the false authorization, since a changed one is dropped. "A message from someone outside the roster" now sends an outsider's own signed failure, since the old one changed only a gift wrap's author, which no longer says who wrote anything. ConfederationCeremonyJvmTest 21/21; full jvmTest 2,028, all passing; m3Audit at budget.

Phase 4: the bridge carries ceremonies, and the seat groups' rooms carry them too (report D2, D4)

The bridge's second scope (K/managers/ConfederationBridge.kt):

  • heardInRoom, heardInInbox and markCarried take a CarryScope in place of confederationId. The carry plan comes from a new private planOf(database, scope):

    • Signing: ConfederationSigningManager.held(...)?.plan;
    • Ceremony: ConfederationRitualManager.carryPlan(database, proposalId), a new internal function returning planFrom(basisFor(...)) or null.

    Only the scope decides which; every rule after it is the same.

  • sweep groups due rows by (groupRoomId, scope, id, direction), reading scope from the row.

  • Byte-aware envelopes. sweep fills an envelope in createdAt order until adding the next event would pass MAX_CARRIED_BYTES of encoded content, or MAX_CARRIED events, and starts another. An event larger than the budget on its own goes alone and is logged. Phase 5's eligibility keeps such rosters out, and signing never makes one. This applies to signing too, which never neared the budget.

  • carryOut takes the envelope's kind and scope tag from the scope:

    • Signing: 30398 with ["confederation", id], as today;
    • Ceremony: 30379 with ["confederation_proposal_id", id].

    The expiry stamp follows from the kind. The recipients are the carry plan's groups, as today.

  • carryIn takes the scope, and for Ceremony queues through ConfederationRitualManager.queueEnvelope. The bridge's rule already sends nothing in when every seated person is an admin, which in a ceremony is always. The code path is kept so the rule stays one rule.

Writing into the seat groups' rooms (K/managers/ConfederationRitualManager.kt):

  • roomsFor(database, plan, userPublicKey): the room of every group the person holds a seat in, that this device holds with MLS state. It is the signing manager's function of the same name, lifted to a shared helper in ConfederationFormation.
  • broadcast also writes the signed event, in a 30379 envelope tagged with the room, into each of those rooms as a MarmotInnerEvent, the way ConfederationSigningManager.carry does. It then calls ConfederationBridge.heardInRoom(..., CarryScope.Ceremony(proposalId), ...). The NIP-17 copy still goes. Duplicates are harmless: ConfederationCeremonyMessage and ConfederationCeremonyHeard both insert with IGNORE.
  • processFromRoom(database, groupRoom, envelope, user, key): verify, file as heard, tell the bridge, then record and advance for the ceremony this device's owner has joined, if any. A device whose owner holds no seat and is not one of the group's admins files nothing. That is a member who is not an admin, who has nothing to do with the ceremony (report D7).
  • receiveFromInbox(database, inboxRoom, envelope, user, key?): the same, from the inbox, telling the bridge it crossed. Without a key it only files.
  • queueEnvelope(database, groupRoomId, proposalId, user, events), for the bridge's carry-in.

Routing:

  • K/database/dao/NostrDao.kt, the MLS application-message branch near :1732: a new arm, ConfederationRitualEvents.isRitualKind(inner.kind) -> ConfederationRitualManager.processFromRoom, behind ExperimentalFeatures.confederation, beside the signing arm.
  • K/managers/GroupInboxManager.kt open, near :107: rumor.kind == ConfederationRitualEvents.CARRIED goes to ConfederationRitualManager.receiveFromInbox and is marked opened, before the statement arm. T/managers/GroupSealRoutingJvmTest gains the case.

Tests:

  • T/managers/ConfederationSigningJvmTest: passes unchanged on the bridge's new signature.

  • A new case in T/managers/ConfederationBridgeJvmTest.kt (new file): a round of 40 events of 2 KB splits into three envelopes, each under the budget, and every event arrives once. This is the Phase 1 sweep pin, flipped.

  • T/managers/ConfederationCeremonyJvmTest, on ConfederationPeople.withGroupRooms():

    • each person's messages appear in each seat group's room on every device of that group;
    • the group's first admin carries them;
    • every device holds every message twice over, once by NIP-17 and once by inbox, and forms one key.

    The Phase 1 bridge pin flips.

  • Lift the signing test's pump. ConfederationSigningJvmTest's private pump(at, away, hold), which ferries group rooms, runs every admin's turn and delivers inbox wraps, moves into T/managers/ConfederationPeople.kt as pumpGroups(at, away, hold), taking the envelope kinds to ferry. The signing test calls it unchanged, and the ceremony tests use it from here on.

Done. As planned, with three differences. The byte split is checked in ConfederationCeremonyJvmTest (forty 2.4 KB signing events go as four envelopes, every wrap under 64 KiB, every event once and in order), not in a new ConfederationBridgeJvmTest. GroupSealRoutingJvmTest gains nothing: it routes FROST seal batches, and a ceremony envelope is a rumor the inbox opens, routed in GroupInboxManager.open. And processFromRoom reads an envelope only on the device of one of the group's admins, which every seated person is, so a member who is not an admin files nothing. Every ceremony message received by any path goes through one receive, which fails out on the ceremony's NIP-17 room while that is still the channel a failure goes back on. ConfederationPeople.pumpGroups is the signing test's pump, ferrying both envelope kinds, and ConfederationSigningJvmTest calls it. ConfederationCeremonyJvmTest 23/23, including the groups' rooms and inboxes forming the key with no NIP-17 pump at all, each group's part carried by its first admin and nobody else. ConfederationSigningJvmTest 25/25, ConfederationSharedSeatsSigningJvmTest 3/3, ConfederationProfileNetworkJvmTest 3/3. Full jvmTest 2,030, all passing; m3Audit at budget; compileDebugKotlinAndroid builds.

One thing outside the plan: the first clean compile of the test source set in this worktree left ConfederationTestGroups.Group, an inner class, without the Compose $stable field the classes that hold one read in their static initializers, and ConfederationDeclineJvmTest and ConfederationNetworkJvmTest failed to load. Earlier runs had used test classes from the build cache. Group needs nothing of its outer instance, so it is a nested class now, which Compose handles.

Phase 5: the switch (report D5, D8, D10)

No room. In K/managers/ConfederationRitualManager.kt:

  • join no longer calls createNip17ChatRoom or ensureProfiles. It throws, with a reason a person can read, when this device holds the room of none of its owner's seat groups.
  • broadcast writes only into the seat groups' rooms (Phase 4's write). The GiftWrapPayload queue goes, and the localChatRoom parameter goes from advance, publishOwn, failOut and broadcast.
  • advance, resumeRunning, abandon and join stop looking up a room. A seat group whose room this device does not hold is a failure said out loud ("This device no longer holds Agora's room"), not a silent return.
  • process (the NIP-17 entry) goes. replayStoredMessages reads ConfederationCeremonyHeard only.

The column goes. ConfederationCeremony.chatRoomId and its foreign key go: @DeleteColumn in ConfederationCeremonyInboxMigration, folded into 54. Room rebuilds the table without the key. Every reader is updated:

  • ConfederationCeremonyDao queries by chatRoomId;
  • DatabaseChatRepository.keyCeremonyOfRoom, which Phase 6 deletes; until then it returns null;
  • anything else a grep for ceremony.chatRoomId and ConfederationCeremony( finds.

The Phase 1 foreign-key pin flips.

Eligibility (report D8). eligibility adds two checks:

  • this device holds the announced inbox key of every group its owner has a seat in ("This device can't read the groups' messages yet; set up the group's inbox first");
  • no single message of this roster would pass MAX_CEREMONY_MESSAGE_BYTES (Phase 0 check 3): "This confederation has too many admins for one person in several groups to send their part".

The second is also checked in ProposeConfederationViewModel, so the form refuses the roster before anyone signs. It does that from each group's admin count, which the form already fetches.

The NIP-17 branch. K/database/dao/NostrDao.kt:1095-1125 stops calling the manager. A ritual kind in a gift wrap is dropped with a warning, and the room is not made. The feature has never been on in a release, so no peer sends one (report D9).

Tests. ConfederationCeremonyJvmTest moves entirely onto pumpGroups:

case change
three groups of three make one key as before, and no device holds a NIP-17 room over the roster (the Phase 1 room pin, flipped)
nobody opens it, no 30380 or 30383 unchanged
a person who is an admin of two groups writes into both rooms, both groups' carriers may carry, one role each recorded
an admin who never joins stalls it unchanged
a member who has not joined finds the ceremony from the room replaced: finds it from the proposal (joinable), and joining replays what their group's room and inbox already heard
an abandoned attempt is tried again unchanged
a group that told two groups different things unchanged
two devices dealt different things now named by the two signed 30382s (Phase 3)
admins changed; not every acceptance unchanged
messages before joining are replayed from ConfederationCeremonyHeard
outside the roster unchanged
new: a carrier away the first admin of Agora is away; the second carries after 20 s on the test clock, and not before
new: every admin of a group away but the author each author's own turn carries their own message; the ceremony forms, slower
new: a seat without the inbox key Phase 0 check 5's promoted admin cannot join, with the reason
new: a 120-role dealings round on a roster at MAX_ROLES − 8, dealings split into several envelopes per group and reassemble; one key forms
new: a roster past MAX_CEREMONY_MESSAGE_BYTES refused at eligibility and on the form

ConfederationProfileNetworkJvmTest.formed() forms its confederation through ConfederationTestGroups.pumpConfederation, over real inboxes, instead of its own NIP-17 pump. Its three cases pass.

Done. As planned, with four differences:

  • The lines moved here from Phase 6. announce wrote into the ceremony's room, which no longer exists, so it writes into each seat group's room now, carrying the proposal's id in frostSigningSessionId. Phase 6 keeps the transcript's handling of those lines.
  • The form does not check size. ProposeConfederationViewModel knows each group's admin count but not who sits in several groups, which only the acceptances say. So the roster is refused at join, from largestMessageBytes, which joinable reports to the proposal screen before anyone is asked.
  • The large round is 3 groups of 10. The case is a 30-role roster, whose dealings round of about 33 KB a group splits into two envelopes, rather than one near MAX_ROLES: 120 devices are more than a unit test should start. The 120-role refusal is checked on one device's statements alone.
  • The fallback is two cases. One runs with a group's first admin not carrying; the other with two of its three not carrying, where the last carries everything at its turn. In the second, those two are the other authors, which is the plan's "every admin away but the author".

ConfederationPeople gives every device its groups' rooms and inbox keys in setUp, and pump is pumpGroups. GroupInboxHarness ferries 30379. ConfederationProfileNetworkJvmTest forms its confederation over real MLS group rooms and real inboxes, with no NIP-17 room. The signing test's "the key ceremony's room leads to the confederation" went with the room, and its count of who carried looks only at signing envelopes, since the ceremony is carried the same way now. Schema 54's export loses ConfederationCeremony.chatRoomId. ConfederationCeremonyJvmTest 27/27. Full jvmTest 2,033, all passing; m3Audit at budget; compileDebugKotlinAndroid builds.

Phase 6: the screens and the lines (report D6)

Lines. ConfederationRitualManager.announce writes into each seat group's room, by this device for itself, never sent. It sets frostSigningSessionId = proposalId, the way signing's lines carry the id they open, and senderPublicKey = this device's owner. The started, failed and complete lines keep their types.

In K/ui/composable/widgets/chat/ChatTranscript.kt:

  • a new callback, onOpenKeyCeremony: (proposalId: HexKey) -> Unit;
  • the three ceremony types become a RitualNotice that opens it;
  • ChatRoomMessagingScreen passes ConfederationRitualRoute(activeUser, proposalId).

NotificationClassifier keeps the three types where they are.

Removed:

  • ChatRepository.keyCeremonyOfRoom and its implementation;
  • KeyCeremonyLink and FormedConfederation in ChatRoomMessagingUIState, if nothing else reads them;
  • KeyCeremonyBanner and the keyCeremony field;
  • ConfederationRitualManager.proposalOfRoom;
  • the ceremony room's composer hiding from confederation-profile.md D10, wherever it reads keyCeremony;
  • the strings only they used. the_key_ceremony_for_is_complete is one; a grep finds the rest.

The ritual screen's carrying wait. ConfederationRitualUIState.Step gains waitingToCross. It lists the names of the groups this device belongs to that have a person's message for this step in their room with no ConfederationCarry row done, read through a new ConfederationCeremonyDao query on the carry table by scope id. The screen shows "Sent; waiting for an admin of Agora to pass it on" under the step. A device cannot see what another group has not yet carried, so the line is only ever about the device's own groups. That is the honest scope of what it knows.

Strings, in composeResources/values/strings.xml, sentence case, none saying "inbox", "envelope", "carry" or "room" to a person:

  • confederation_ritual_waiting_to_cross: "Sent; waiting for an admin of %1$s to pass it on"
  • confederation_ceremony_needs_inbox: "This device can't read the groups' messages yet. Set up the group's inbox first."
  • confederation_ceremony_too_large: "This confederation has too many admins for one person in several groups to send their part"

The two refusals are read in the composable and shown where join's exception is shown today.

Tests:

  • T/ui/ConfederationScreensJvmTest:
    • the lines in each seat group's room open the ritual screen;
    • the waiting-to-cross line appears while a carry is due, and goes once it is done;
    • no screen offers a ceremony room.
  • ChatRoomMessagingViewModel's tests lose the banner case.
  • m3Audit stays at budget.

Done. As planned, but for three things. The lines themselves were written in Phase 5. The two refusals stay sentences from ConfederationRitualManager, as every other reason a join is refused is, and are shown where join's exception already is: only the new waiting line went into the catalogue. And no test renders ChatTranscript, here or before. So the ceremony's lines are checked where they are written: started and finished, in each of a person's seat groups' rooms, each carrying the proposal's id, and nothing in a room the person holds no seat for. Their opening is the new onOpenKeyCeremony, wired to ConfederationRitualRoute. Removed: ChatRepository.keyCeremonyOfRoom, KeyCeremonyLink, FormedConfederation, KeyCeremonyBanner, the composer gate that hid a finished ceremony room's composer (confederation-profile.md D10), ConfederationRitualManager.proposalOfRoom, DatabaseChatRepository.homeGroupOf, and four strings: this_room_runs_a_key_ceremony, this_room_waits_for_you_to_join, open_the_key_ceremony and the_key_ceremony_for_is_complete. The waiting line reads ConfederationRepository.observeWaitingToCross, which reads the ceremony's carries not yet done. ConfederationCeremonyJvmTest 28/28, ConfederationScreensJvmTest 15/15. Full jvmTest 2,035, all passing; m3Audit at budget; compileDebugKotlinAndroid builds.

Phase 7: the ceremony rooms already on devices (report D9)

Added to ConfederationCeremonyInboxMigration.onPostMigrate, still 54. The column is gone by the time onPostMigrate runs, so ceremony rooms are found by what they hold, not by the column:

  1. Every ChatRoom id that holds a GiftWrapPayload of a kind in ConfederationRitualEvents.ALL (30381 to 30387, and 30379 from development builds of Phases 3 and 4) is a ceremony room.
  2. In each, delete those GiftWrapPayload rows, the ChatMessage lines of the three ceremony types, and any ChatMessage pointing at a deleted payload.
  3. Delete the ChatRoom row only if nothing else remains: no ChatMessage and no GiftWrapPayload of any other kind. A founders' plain chat that shared the id keeps its room, its messages and its members (Phase 0 check 4). The room row goes the way confederation-room-removal.md's did: by walking PRAGMA foreign_key_list from ChatRoom and deleting dependents children first, since Room migrates with foreign keys off.
  4. ProtocolRetention's rule for GiftWrapPayloads of ritual kinds goes. None is written any more, and the migration removed the ones that were.

Tests (ConfederationCeremonyInboxMigrationJvmTest): a v53 database holding:

  • a completed ceremony's room, with its payloads and lines;
  • a second ceremony room whose id is also a plain chat among the founders, holding two written messages;
  • a running ceremony.

It opens at 54 with:

  • the first room gone;
  • the second room present with its two messages and no ceremony payloads;
  • every ConfederationCeremony row present without chatRoomId;
  • the confederation's record untouched.

Done. As planned, with one step the plan missed. ChatRoom.initialGiftWrapPayloadId is a key onto GiftWrapPayload, and a room made by the first ceremony message to arrive names that message. Following the key, deleting the ceremony's payloads would have taken a founders' chat with it, messages and all. So the migration clears that reference first. Removing that one statement makes the new test fail on "the founders' chat stays". ForeignKeyCascade is ConfederationRoomRemovalMigration's cascade, lifted out so both migrations use one copy. ProtocolRetention loses its rule for ceremony gift wraps. ConfederationCeremonyInboxMigrationJvmTest 2/2, ConfederationRoomRemovalMigrationJvmTest 2/2. Full jvmTest 2,036, all passing; m3Audit at budget; compileDebugKotlinAndroid builds.

Phase 8: the network run, the record, and devices

  • The network run. In T/managers/ConfederationNetworkJvmTest, three groups of three, each with a real inbox ceremony (ConfederationTestGroups), go end to end with no NIP-17 room on any device:
    1. propose, accept and form;
    2. sign the confederation's profile with nobody asked;
    3. one founder away for the whole ceremony, whose group's other admins carry for everyone else.
  • The record. This document's header and a progress table, and a what the plan said / what it turned out to be table. Add the README row's status. Add since notes pointing here in confederation-without-coordinator.md D8, confederation-profile.md D10 and Phase 7, and confederation-room-removal.md's Out of scope line about the key ceremony. Mark the report "implemented by" this plan.
  • Device run, three groups of three on at least five devices or emulators, each group with an inbox, one person an admin of two groups:
    1. propose and accept; every admin is offered Join;
    2. join on every device; no NIP-17 room appears in any chat list; the lines appear in each group's room;
    3. close the phone of each group's first admin mid-ceremony; it still forms, and the delay is within Phase 0 check 6's number;
    4. a development device that ran a ceremony before this plan upgrades, its ceremony room goes, and a plain chat among the same people stays.

The record done; the device run not. ConfederationNetworkJvmTest gains the end-to-end case on three groups of three, each with a real inbox ceremony and a real MLS room: Agora proposes, Polis and Ekklesia accept, all nine admins join, and the confederation forms with Polis's first admin never taking a turn at carrying. All nine devices reach one key and hold the record; no device holds a NIP-17 room over the people or a ceremony gift wrap; Polis's first admin owed nothing. The profile and the post signed with nobody asked are ConfederationProfileNetworkJvmTest's, which forms its confederation the same way since Phase 5. ConfederationNetworkJvmTest 8/8; full jvmTest 2,037, all passing; compileDebugKotlinAndroid builds. Brand, wallet, Magpie and M3 audits pass. Nothing has crossed a real relay, and twenty seconds a place is still a guess for the ceremony as it was for signing.


Who is asked what

Nothing a person is asked changes.

step who is asked what they decide automatic after that
ceremony each admin of each group to join every round; writing into their seat groups' rooms
carrying nobody — each group's admins' devices, in order, k × 20 s
a retry any person in the roster to try again as above

Risks

risk where it is handled
26,000 bytes is wrong for real relays Phase 0 check 2 measured it on the app's own sealing; the constant is one place
a roster whose single message cannot fit anywhere Phase 0 check 3 sets MAX_CEREMONY_MESSAGE_BYTES; Phase 5 refuses it at the form and at join
the bridge's new scope breaks signing Phase 4 runs every signing test unchanged on the new signature before anything else uses it
dual delivery in Phase 4 hides a bug in one path Phase 5's tests run on the new path alone; the NIP-17 path is gone by then
the migration deletes a founders' real chat Phase 7 step 3, and its test with exactly that room
a development device between Phases 2 and 7 holds a 54 that later phases changed the header says to clear its data, as confederation-room-removal.md said for 52
a wrap lost on another group's relays stalls a round as today; out of scope here, and named in the report as a follow-up (Send again)

Out of scope

  • Send again for a ceremony: re-carrying every heard message to a group being waited on.
  • Changing the dealings' encoding from hex to base64.
  • The group's own ChillDKG ceremony, which stays on NIP-17.
  • Threshold-ECDH member groups, as in every confederation plan.

Order and size

phase rough size depends on
0 scratch tests, this document —
1 ~150 test 0
2 ~200 main, ~200 test, an auto-migration with a spec 1
3 ~200 main, ~250 test 2
4 ~450 main, ~550 test, ~150 moved 3
5 ~250 main net, ~600 test 4
6 ~250 main, ~200 test, removing ~150 5
7 ~150 main, ~200 test 5
8 ~250 test, docs, a device session all

About 1,750 lines of main code and 2,400 of tests. Phases 6 and 7 can be built side by side once 5 is in. Everything else is in order:

  1. storage before anything writes it;
  2. signatures before anything carries them;
  3. the new path beside the old before the switch.

Phase 4 is the one to review closely, since it changes the bridge signing already depends on.

Checking the work

./gradlew :composeApp:compileDebugKotlinAndroid :composeApp:jvmTest
./gradlew :composeApp:m3Audit
./gradlew check

One new kind, 30379, in no RetiredKinds and in CEREMONY_KINDS through ConfederationRitualEvents.ALL. No new mantra/… tag: the envelope is wire, not a hash input, and the ceremony's attestation, seed and host-key tags are unchanged. Bennu is named nowhere but in comments.