**Built**, one commit per phase on `claude/ceremony-creation` (Phase 7 in two),
against the code as it stood at `e3839da5`. `CreateSharedKeyScreen` is the one
screen that starts a group's own ceremony, and `DkgRitualScreen` only ever shows
one. The phases are kept as written because they are the reasoning; where the
build chose differently it did so these times:
| what the plan said | what it turned out to be |
|---|---|
| Phase 7 deletes the 103 files, Phase 8 the tables | the line moved. The `Mantra*` entities convert to and from the nip30303 event classes, so the classes, entities and DAOs went in Phase 8 with the tables. Phase 7 removed the screens (part 1) and the inbound handling, `ProposedEvent`'s arms and the chronicle's document parts (part 2) |
| the group details' **Shared key** opens an existing ceremony itself, else the creation screen | it always opens `CreateSharedKeyRoute`, which hands over to an existing ceremony. One place decides, and back from the ceremony still returns to the details |
| only `DkgRitualRoute.dkgSessionId` becomes required | the three approval routes' too, and `DkgRitualUIState.Loaded.session` is non-null. Every approval was already named by the ceremony screen that opened it |
| the subgroup picker's quorum stepper and the shared-key one are one component | two. The picker's asks a different question ("how many admins have to approve a change"), so the shared-key one is `SharedKeyQuorumStepper`, private to the creation screen |
| `requestIfEmpty` keeps its "holds work" check | it had to change: the check read the dialect and artifact tables. A room now holds work if it holds a `GroupSignedEvent` of a chroniclable kind, and with none chroniclable it never asks |
| the chronicle's tests re-fixture | three of four did, with `TEST_KINDS` (a relay list, a profile, a post -- group-signed kinds whose arrival writes no row of its own, so the `GroupSignedEvent` rows are the observable). `ChronicleRoundTripTest` was entirely the rebuild through document rows and is deleted. The positive invite push could not take a test set -- `deliveryWelcome` calls `sendTo` with the app's kinds -- and became the "sends nothing" case |
| `SignedGroupKeyStateTest` and `GroupSignedEventDaoJvmTest` re-fixture in Phase 8 | Phase 7: they failed at runtime the moment document arms stopped writing rows. They sign posts now, and "the row a signed event becomes points back at it" is deleted -- no kept kind writes a row |
| a migration test with tables copied from `26.json` | built from the exported `26.json` at run time and compared with `27.json`, so it cannot drift from what Room expects |
| `CLAUDE.md`'s literal count goes to 20 | 19, after Phase 5 took another |
| 61 strings plus four already unused | 65 in all: the string catalogue test's two chapter strings went once it checked its escapes on `recovered_of_still_unreadable` instead |
| 13:17:00 | Charlie, Medium | record it, awaiting approval |
| 13:17:23 | Medium | approves joining; 2 of 3 host keys |
| 13:17:35 | Charlie | approves joining; now 3 of 3 host keys |
| 13:17:39 | Charlie | **proposes `8199d186`**: 2-of-3 over the whole room, **no `parent_group`**, subject `#Checkers` |
| 13:17:40 | Bob, Medium | record `8199d186` as a new ceremony awaiting approval |
| 13:17:53 | Medium | approves round 1 of Tapscript |
| 13:18:03 | Medium | approves joining `8199d186` |
Tapscript never failed. All three devices hold all three host keys, Medium has
sent its round-1 contribution, and Bob and Charlie are each waiting for their own
round-1 approval. No approval threw on any device. The "errors" seen while
joining and confirming were screens showing the wrong state, and one chat line:
on Bob and Charlie, Medium's round-1 contribution also appears as an
`unsupported` bubble of raw hex (`ChatMessage` rows 66 and 62), because kind
30312 is read as a nip30303 `SubmissionEvent` first. That is the
`Leading zeroes not allowed` warning in both logs at 13:17:53.
`8199d186` could only have come from `DkgRitualViewModel.startRitual()`. It is
the one caller of `proposeRitual` that passes no participants, no parent and no
subject, which is what produces a whole-room ceremony named after the room.
Charlie pressed **Start key ceremony** four seconds after approving, in the
place where **Review and join** had just been.
---
## The findings
| # | finding | where | fixed in |
|---|---|---|---|
| F1 | `proposeRitual` will open a group's own ceremony in a Marmot room. The key it makes can never be that room's, since a Marmot room's id is derived from the key it already has. `ChatRoomDetailScreen` hides the button there; nothing refuses the call | `ChillDkgRitualManager.kt:178` | Phase 1 |
| F2 | `DkgRitualScreen` shows progress, asks for approvals *and* starts ceremonies, and the approval button and the start button share one slot in the bottom bar | `DkgRitualScreen.kt:194-262` | Phases 3, 4 |
| F3 | `initiate()` runs again every time the screen comes back into view, because its `LaunchedEffect` checks the *parameter*`initialDkgRitualUIState`, which is always `Loading`. Each run resets the state to `Loaded(session = null)` and starts another set of collectors without stopping the last | `DkgRitualScreen.kt:344`, `DkgRitualViewModel.kt:136` | Phase 2 |
| F4 | Five coroutines on `Dispatchers.IO` each read `dkgRitualUIState`, copy one field and write it back. The session collector suspends on a database query between its read and its write. A write based on an old copy wipes out `session` and `pendingApproval`, and nothing re-sends them | `DkgRitualViewModel.kt:174-235, 251-347` | Phase 2 |
| F5 | `roomHasCeremony` counts only the room's *own* ceremonies (`observeLatestSessionForChatRoom` defaults `parentChatRoomId` to null), so in a parent room hosting a subgroup's ceremony it says there is none | `DkgRitualViewModel.kt:175` | Phase 4 (deleted) |
| F6 | The approval button calls `approve(step)` and then `onDone()` straight away. Popping the screen clears its view model and cancels the approval's coroutine, so a slow publish can be cut off. On the last approval of a round nothing arrives afterwards to resume it | `DkgApprovalScaffold.kt:205` | Phase 2 |
| F7 | A failed ceremony's **Try again** calls `startRitual()`, which opens a group's own ceremony whatever the failed one was for. A failed subgroup ceremony is retried as a whole-room ceremony in the parent's room, which is F1 again | `DkgRitualScreen.kt:239-251` | Phase 4 |
| F8 | There is no way to abandon a ceremony. `DkgApprovalScaffold.kt:191-195` says "Abandoning is on the ritual screen"; nothing implements it. A ceremony opened by mistake, like `8199d186`, can only be left running | `DkgApprovalScaffold.kt:191` | Phase 5 |
| F9 | `record()` accepts a FAILURE message from any sender. In a parent room, a member who is not in the subgroup can read its proposal and end it | `ChillDkgRitualManager.kt:636` | Phase 5 |
| F10 | In a Marmot room, `ChatMessage.applyInnerEvent` matches `TranslationContributorListEvent.KIND` (30310) and `TranslationEvent.KIND` (30311) before `in DkgRitualEvents.ALL`. A subgroup's proposal and host keys reach the translation arms first. It does nothing today only because one arm is an empty TODO and the other's parser returns null without translation tags | `ChatMessage.kt:1439-1493` | Phase 6 |
| F11 | Kind 30312 is both the ceremony's round 1 and nip30303's `SubmissionEvent`. `ChatMessage.fromGroupEventResult` checks for a submission *before*`applyInnerEvent` runs, tries to parse the round-1 hex as an event, fails, and writes an `unsupported` chat line with the raw hex. Reordering `applyInnerEvent` does not reach it. Seen on Bob and Charlie | `ChatMessage.kt:880, 986-1012` | Phase 6 |
| F12 | The comments that call the kind overlap safe are out of date: they say ceremony kinds only travel in NIP-17 gift wraps, which stopped being true with subgroups' Phase 10 | `FrostSigningEvents.kt:52-70`, `ChronicleEvent.kt:89-101`, `DkgRitualEvents.kt:15` | Phase 6 |
| F13 | The nip30303 document and translation feature is unreachable: nothing constructs `ArtifactDetailRoute`, `AddArtifactRoute` or `AddDialectRoute`, and the other six routes are only built from inside those screens. It is still wired into inbound dispatch, `ProposedEvent`, the chat transcript and 12 database tables | `nostr/nip30303/` and below | Phases 7, 9 |
| F14 | The member chronicle can carry only nip30303 kinds (`ChronicleEvent.APPLY_ORDER`), yet it is live: every room asks for one when it opens (`ChatMessageListViewModel.kt:206`) and every invite sends one (`MarmotOutboundDao.kt:1086`). Without nip30303 it has nothing it is allowed to carry | `managers/ChronicleManager.kt`, `nostr/chronicle/` | Phase 7 |
---
## Phase 0 — before any code
**An hour, to settle five things the phases assume.**
1.**Ceremonies start in exactly three places.** Group creation
(`SelectChatRoomTypeViewModel`) and the subgroup picker
(`SelectSubgroupAdminsViewModel`) already know what their ceremony is for and
stay as they are. The third is new: `CreateSharedKeyScreen`, for a NIP-17
group that has no key yet. `DkgRitualScreen` starts nothing.
2.**`DkgRitualRoute.dkgSessionId` becomes required.** Every caller that has a
ceremony to show knows which one it is. A caller that does not is asking to
*start* one, and goes to the creation screen instead.
3.**Abandoning is open to any participant, and only to participants.** ChillDKG
has no way to say no short of ending the ceremony, and any participant can
already end it by never approving. Making it explicit just lets the others
stop waiting.
4.**The whole nip30303 family goes, not only translation.** Artifacts,
versions, chapters, chunks, dialects and translations share one entry point,
and it is unreachable. Removing only the translation kinds would leave the
rest of the screens and the database tables behind them, and would leave
30312 colliding with round 1.
5.**The member chronicle stays, empty and quiet.** It was built to hand a late
member the group's signed document history, and `CHRONICLABLE_KINDS`
nostrPrivateKey)`: refuses unless this device is a participant and the
ceremony is neither complete nor failed; then calls `fail(...)` with this
device as the culprit and broadcasts `DkgRitualEvents.FAILURE`, exactly as a
local fault does today. `DkgRepository.abandon` wraps it.
- `record()`'s FAILURE arm ignores a sender who is not in
`participantsOf(session, room)`, with a warning like `isFromCoordinator`'s.
- `DkgRitualScreen` gets **Abandon ceremony** as a secondary action, shown while
the ceremony is running and this member is a participant. It opens a
confirmation dialog saying what happens: the ceremony ends for everyone, no
key is created, and it can be started again. That matches what the existing
`TYPE_DKG_FAILED` line already tells the room.
- `DkgApprovalScaffold.kt:191-195` then describes something that exists. The
approval screens keep **Not now** and do not get an abandon button: the
consequence belongs on the screen that shows the whole ceremony.
**Tests**, in `SubgroupCeremonyInParentRoomTest`: a participant's abandon fails
the session on every device; a FAILURE from a parent member outside the
subgroup is ignored; abandoning a completed ceremony does nothing.
**On the test devices**, once this lands: abandon `8199d186` from any of the
three. Tapscript (`89d4c4d0`) is untouched and finishes once Bob and Charlie
approve round 1. Until this lands, do not approve `8199d186` on Bob. Medium has
already joined it, so Bob's approval would complete a key for `#Checkers` that
the room can never use.
---
## Phase 6 — the kind overlap, closed first
**Two hours. Closes F10, F11 and F12 before the removal, so the removal is only
deletion, and so the fix can ship on its own if the removal waits.**
- In `ChatMessage.fromGroupEventResult`, decide on protocol kinds first: an
inner event whose kind is in `DkgRitualEvents.ALL` or `FrostSigningEvents.ALL`
is stored as a `MarmotInnerEvent` as now, never treated as a submission
envelope, and produces no chat line. Their managers are dispatched separately
from `NostrDao.fileGroupEventResult` and write their own transcript lines. A
real `SubmissionEvent` loses its envelope handling until Phase 7 removes it;
nothing can send one, because the screens that did are unreachable.
- In `ChatMessage.applyInnerEvent`, move `in FrostSigningEvents.ALL -> null` and
`in DkgRitualEvents.ALL -> null` to the top of the `when`. Protocol kinds are
never content, whatever else shares their number, and the first match wins.
- Rewrite the comments in `FrostSigningEvents.kt`, `ChronicleEvent.kt` and
`DkgRitualEvents.kt` to say what is true now: ceremony kinds travel as Marmot
inner events in a parent room, and they stopped colliding when the dispatch
order above was fixed. After Phase 7 they shrink again, to say 30300-30309 are
free and 30310-30316 are the ceremony's alone.
- Lower `NostrDao.fileGroupEventResult`'s `No app logic to handle` from info to
debug, or skip it for ceremony and signing kinds. It reads like a failure on
every application message and sent this investigation the wrong way.
- **Tests**, in a new `ProtocolKindDispatchJvmTest`: every kind in
`DkgRitualEvents.ALL`, arriving as a Marmot application message with a real
ceremony payload (round 1's hex content in particular), writes no chat line
and no row outside the DKG tables; the same for `FrostSigningEvents.ALL`.
The `unsupported` rows already on devices are cleaned up by Phase 8's
migration, which can find them by kind.
---
## Phase 7 — removing the nip30303 code
**A day and a half: a day of deletion, and half a day giving the chronicle's
tests a kind set of their own. Closes F13 and F14 in code; the tables go in
Phase 8.**
Paths below are under `composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/`
unless they say otherwise. Line numbers were right at `e3839da5`; confirm them
with a grep.
### Deleted outright (103 files)
| what | where | files |
|---|---|---|
| the 14 event classes and their 22 tags | `nostr/nip30303/`, `nostr/nip30303/tags/` | 36 |
| the 12 `Mantra*` entities, plus `MantraTranslationChunkProposal`, which is annotated `@Entity` but never registered | `database/model/Mantra*.kt` | 13 |
| the 12 table DAOs and `MantraDao` | `database/dao/Mantra*Dao.kt` | 13 |