giza brought rotation-waits-for-key-state, built in parallel from the
same base, and robust-group-admins. The first overlaps this branch, and
the two agreed on not asking the proposer. Where they met:
- The proposer's dialog is this branch's, read from the proposal's own
plan with its refusal, under giza's title and caveat; giza's dialog,
which listed stale members from the summary, went. The preview's
refusal carries rotationHold's reason, and ChatRoomDetailSharesJvmTest
asks its question of the kept dialog.
- The proposer is approved to take part only; giza also set
confirmApprovedAt, which nothing reads.
- The Shares section keeps both: giza's held button, its reason and
'Ask the group to sign', and this branch's running card and abandon.
- giza's hold tests left the new key state unsigned by not signing it.
It signs itself now, so they hold the signing messages after the
proposal (signingHeldOpen). This branch's test of two rotations opened
at once gave way to giza's, which asserts more.
jvmTest 1281/1281, compileDebugKotlinAndroid, m3Audit at its budgets,
brand and wallet audits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every founding member of a robust group is its admin, phases 0-7
(docs/robust-group-admins.md). Two conflicts, both adjacent additions:
the detail screen's strings read outside the click handlers, and the
view model's companion constants. Both sides kept. jvmTest 1261/1261,
compileDebugKotlinAndroid, audits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AdminFlags.reconcileAll runs AdminFlags.reconcile over every room this
device holds MLS state for, and the sync start calls it once, through
ChatRepository.reconcileAdminFlags, beside the ceremony resume. A room
joined before Phase 2 flags nobody on the joiner's device until some
commit arrives, and a robust group's admin room may never get one.
No stored "done" flag: a room whose rows already agree is a read and no
write, so a second start costs one decode per room. A room that will not
decode is logged and passed over.
RobustGroupAdminsJvmTest: a joiner's cleared flags are restored on both
profiles, and a second pass changes nothing. jvmTest 1250/1250,
compileDebugKotlinAndroid, audits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The member list labels admins, from the flags AdminFlags keeps. Two
cards on the error container, under the signing key and the parent:
founding members the room's policy does not list as admins, with "Make
them admins" for an admin of a current-profile room; and founding
members the founding invite never reached, with "Invite them" on the
device that holds the room at epoch 0. Founders are named through their
profiles, since an uninvited one is not in the room to read a row off.
A robust group's NIP-17 room has no admins of its own, so its details
link to the admin room its ceremony made (ChatRepository.adminRoomOf),
saying every member is an admin there.
Strings in the catalogue, sentence case; colours from the error
container roles; spacing from the scale; the actions guard a second tap.
m3Audit: all budgets met. jvmTest 1249/1249, compileDebugKotlinAndroid.
Not looked at in a running app.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarmotGroupCreation.finishFoundingInvite invites the founders a room's
founding invite never reached, in one commit, every key package first as
at creation. It acts only on a room still at epoch 0: the founding
invite is the commit that ends epoch 0, and leaving is a commit too, so
a founder without a leaf there is one nobody ever invited -- never one
who left. CeremonyFollowThrough takes it as step 4 once the room exists,
on the coordinator's device; the repository exposes it by room for the
detail screen, with the set it would invite.
Also fixes what Phase 0 found. MarmotGroupCreation invited the founders
through a room read before its routing id was recorded, so on the
current profile the engine adopted a second copy of the group under the
room id, and the copy at the real address still held only its creator:
every later invite took the founding path, with no commit and nobody
already in the room told. It now reads the room again first.
RobustGroupAdminsJvmTest: a room left without its invite is finished and
every founder joins as an admin, on both profiles; a room past its
founding invites nobody; a later member on the current profile now gets
a real commit. CeremonyFollowThroughJvmTest: step 4's outcomes.
jvmTest 1249/1249, compileDebugKotlinAndroid, audits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Removing the second approval took away the only abandon button a member
who had taken part could reach: it lived on the approval row. A running
rotation is now a card above the members -- the step it is on (dealing,
storing, the group signing the new key state), who it waits on and since
when, and Abandon, behind a confirmation, for any member taking part.
It counts as running until the new generation's key state is signed,
while that signature is open, because the old shares wait on it. A
rotation that ended without completing says why until the next one.
The taking-part row now says what it decides: who is left out and as
what, and that nothing more will be asked. REFRESH_CONFIRM and its
string are gone from the UI state.
ShareRefreshManager.progress reads the step and who is missing from
stored messages. Those are now stored once, on first arrival, in record
and publishOwn: a redelivery rewrote the row and reset the stall clock.
Tests: the row names the withheld; the withheld member sees the rotation
run and cannot abandon it; the waiting-on names at dealing and storing;
the signing step, which nobody abandons; an abandoned rotation says why.
The stall-clock test backdates the messages first, and fails with the
old store-every-time behaviour put back. jvmTest 1250/1250; m3Audit at
its budgets; brand and wallet audits.
Not seen on a device.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FoundingAdmins.check compares a key-backed room's admin policy with the
participants of the ceremony that made its key, as this device's own
DkgSession row has them -- and, for a subgroup, with the admins its
parent's birth certificate names. NotKeyBacked, CannotCheck (a later
joiner, who holds no ceremony), Matches, or Missing with who.
At the Welcome, after the key state is adopted, a room missing founders
gets one transcript line naming them (TYPE_FOUNDING_ADMINS_MISSING, a
membership line). The detail screen reads the check on every load into
ChatRoomDetailUIState.missingFoundingAdmins.
The repair is MarmotOutboundDao.addAdmins: one gated commit on the
current profile that writes the policy the group holds now plus the
missing founders -- additions only, never a list built elsewhere. The
legacy profile has no governance commits in this app, so a legacy room
gets the warning without the repair.
FoundingAdminsJvmTest: each Check, the pre-column fallback, the line
written once and only when someone is missing, and the repair on the
current profile through a relay's OK. jvmTest 1245/1245,
compileDebugKotlinAndroid, audits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GroupKeyStateManager.vouchesFor refused every key state naming a share
generation (fc437d05), so each recipient was asked to sign the new
generation before anyone's old share was deleted. vouchesForGeneration
now accepts the one state a rotation this device completed implies: the
generation it signs with and holds a share of, the rotation named and
complete here, its own table's hash, the ids its roster retires, a
session at that generation, and the path and parent of the room's
signed state. Rule 7 becomes 'nothing signed at h or later'. A state
that binds an id to a new identity is still never vouched for.
Vouching was decided once, on the proposal's arrival, and the
coordinator proposes the moment its own certificate verifies -- often
before a recipient's. resumeAt, which the rotation already calls on
activation, now asks again; resumeVouched does the same from the sync
sweep for a state an older build left asking.
Tests: one approval each and the group signs generation 1 and wipes the
old shares; a state heard before the certificate is vouched for once it
arrives; each rule broken on its own leaves the state asked; a withheld
member does not vouch; the sweep answers a state left asking, once. The
cutover test holds the proposal to keep checking that nothing is wiped
before the signature. jvmTest 1245/1245.
One earlier full run died on a SIGSEGV in SQLite's native code, in a
background key-package write unrelated to this change; the rerun was
clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Participant.adminAt had three writers and the Welcome was not one of
them: a joiner's rows came from Participant.fromMlsGroup with no flag, so
on every device but the creator's a robust group's admin room showed no
admins until some later commit happened to arrive.
AdminFlags.reconcile is now the one writer. It reads the room's rows
fresh and flags them from the group's own admin policy, both ways, and
writes nothing about membership. The Welcome path calls it after the
participant upsert; MarmotGroupCreation calls it in place of
stampAdmins, off the group it just made rather than its own list; and
processGroupMembershipChanges calls it in place of its three inline
computations.
Phase 0's ignored test passes. MarmotGroupCreationJvmTest: flags follow
the policy both ways, and a second pass changes nothing.
jvmTest 1237/1237, compileDebugKotlinAndroid, audits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ChatRepository.createMarmotGroup now takes the ceremony and the room it
ran in instead of a list of admins, and MarmotGroupCreation.createFor
derives the room's id, name, description and admins from it. The two
callers -- CeremonyFollowThrough's step 3 and the ritual screen's button
-- stop computing a set of their own. A room's epoch-0 admin list is
fixed for good at an address the key derives, so the one place the
founding set is read is now the one place a room is made.
A device that was not in the ceremony is refused rather than listed as
the room's creator.
MarmotGroupCreationJvmTest: the coordinator's device and a member's make
a room with the same admins, the ceremony's participants; an outsider
makes none. jvmTest 1236/1236 (1 skipped, Phase 2's),
compileDebugKotlinAndroid, audits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The proposer was asked like anyone because the button committed them to
a withheld list they were never shown. Now Rotate shares opens a dialog
naming who takes part and who is left out -- the stale members proposing
withholds again automatically included -- and why it would be refused,
before anything is sent. Pressing it is the proposer's agreement: the
session is created with dealApprovedAt set, and the proposer deals at
once.
ShareRefreshManager.plan is the one recipient/withheld split behind both
proposeRefresh and the new preview, so the dialog shows what the
proposal will say. The removal dialog names the stale members too.
Tests: the proposer's half of 'nothing goes out before they approve'
flips; the preview equals the proposal with nobody stale and with one;
a removal's preview names the removed for good and the stale until they
are back; a refused preview says why and sends nothing. jvmTest
1241/1241, m3Audit, brand and wallet audits.
Not seen on a device.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RobustGroupAdminsJvmTest states the promise and shows where it breaks.
Three app phones: one creates the admin room through MarmotGroupCreation
with all three as admins, the others join by a real Welcome, gift wrapped
and stored through the sync funnel.
On every device the admin policy names the founders and isLocalAdmin is
true, on both profiles. The rows do not: a joiner's Welcome writes no
adminAt, so its own rows flag nobody -- ignored until Phase 2. A member
invited later is not an admin. The ceremony half checks that every device
that took part agrees on the founding set, for a group and a subgroup.
The later-member case runs on the legacy profile only: on the current
profile MarmotGroupCreation invites the founders through a room read
before its routing id is recorded, so a later invite skips its commit.
Phase 4 fixes that.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ShareRefreshManager.resumeRunning advances every rotation this user is in
that has not finished, through a new ShareRefreshDao.getRunningSessionsFor.
resumeRunningCeremonies runs it after the ceremony sweep, under the same
lock as the inbound path, once the live subscription is open. Behind the
rotation flag.
Without it, Phase 2 strands a rotation an older build paused at 'store
your new share': the sum is on file and nothing more will arrive.
Tests: that upgrade case resumes from the sweep alone and completes, and
two more sweeps send nothing; a member who has not taken part is looked
at and sends nothing, asked once; a build without rotation resumes
nothing. ShareRefreshRitualJvmTest 26/26.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ShareRefreshManager.advance no longer stops before round 2 for its owner.
The gate's two reasons never needed a person: participantStep2 is the
check that stops a substituted table, and it fails the rotation out loud
before any prompt could appear; ShareRefreshConfirmation is the one
confirmation per generation, claimed with the pending share in one
transaction. pendingApproval now only answers DEAL.
No migration: confirmApprovedAt and ShareRefreshApprovalStep.CONFIRM stay
so rows written before still decode, documented as read by nothing.
Tests: the pinned gate flips (taking part alone completes the rotation,
asked once); the last to take part deals and confirms with nothing more
asked; a tampered sum fails the rotation on every device with nobody
asked; two rotations opened at once never split the group.
ShareRefreshRitualJvmTest 23/23.
Must ship with Phase 3: a rotation paused at the old second approval has
nothing left to arrive and needs the sweep to move.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three tests pin where a rotation stops for its owners, so the phases that
remove those stops flip an assertion rather than pass by accident:
taking part alone leaves every recipient asked to store the new share;
a recipient is asked to take part, to store, and to sign the new key
state (the proposer the first two); and a completed rotation keeps the
old shares until the owners sign. answerEverything records each ask.
ShareRefreshRitualJvmTest 20/20.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tapping Rotate shares put "Take part in rotating the shares" in front of
the person who had just tapped it, and "Store your new share" after.
The button now asks first, in a dialog naming every member the rotation
leaves out -- the stale, withheld again -- and proposeRefresh approves
the proposer at both gates. DEAL is the decision about who is withheld,
which the dialog just took; CONFIRM guards against a coordinator
substituting a table, and the proposer is the coordinator. Every other
recipient is asked as before.
A test now shows two proposals crossing on the wire end with neither
running and every device on one table.
ShareRefreshRitualJvmTest 25/25, ChatRoomDetailSharesJvmTest 3/3,
m3Audit, compileDebugKotlinAndroid.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The room detail screen read the shares summary once, and again only
after one of its own actions, so a key state signed in the background
left Rotate shares disabled until the screen was reopened.
ChatRepository.observeSharesInputs emits when the room's key state,
signing sessions or refreshes change; the view model reads the section
again once they settle, and nothing else on the screen.
ChatRoomDetailSharesJvmTest 2/2, m3Audit, compileDebugKotlinAndroid.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SharesSummary.canRotate becomes Rotation: Unavailable, Available, or
Held with a reason -- a rotation in progress, the group's signature on
the new shares still owed, or this device behind. The button stays,
disabled, with the reason beneath it.
While the key state is owed and nobody here is asking for it, the
section offers to ask the group to sign it
(ShareRefreshManager.proposeOwedKeyState), so a coordinator who is gone
does not hold every later rotation; while somebody is asking, it links
to the proposal. The offer to rotate without a removed member is made
only when a rotation could start now, and says so otherwise.
The section's actions run one at a time, through isActionPending.
ShareRefreshRitualJvmTest 24/24, m3Audit, compileDebugKotlinAndroid.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A rotation is over when the group has signed the key state at the new
generation, not when its refresh completes. ShareRefreshManager.rotationHold
says why this device must not propose one now: a refresh still running,
a key state the group has not signed (or a key-state proposal still open
here, unless this device declined it), or a device behind the group.
proposeRefresh, and so proposeWithout, refuses on it.
The recovery walk test ran three rotations back to back with nothing
signed between; it signs each key state now. ShareRefreshRitualJvmTest
22/22.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The automatic ceremony lets a device sign, without asking its owner, the
one key state that can be true for a ceremony it finished
(GroupKeyStateManager.vouchesFor). Its seventh condition -- no state for
the room already signed here -- was what kept a share rotation's key
state out, and only in rooms that already had one. An eighth makes it
explicit: a state naming a share generation or a member binding says
more than the ceremony did, and its owner is asked.
Found by ShareRefreshRitualJvmTest after the merge: its devices hold no
first state, and the generation-1 state signed itself. jvmTest
1229/1229, compileDebugKotlinAndroid, audits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ShareGenerations.recover rebuilds a device's share of every generation
from its host secret key alone: ChillDKG's recovery data gives generation
0, and each refresh's recovery data, applied to the generation before,
gives the next. It stops at a generation the host key was withheld from,
since a repaired share leaves no recovery data. Nothing calls it yet.
Tested three refreshes on, against every device's live share and each
generation's table. With the release-build test, jvmTest 1200/1200,
compileDebugKotlinAndroid and the audits pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The room detail screen shows a key share by share: the generation the
group signs with, who holds a share, who waits to be brought back and who
was removed for good; what this device is being asked (take part in a
rotation, store the new share, help bring a member back), with approve
and abandon; and the two things it may start -- rotate the shares, or ask
to be brought back. The copy says what a rotation does not do.
ExperimentalFeatures.shareRefresh gates all of it (D4): on in debug and
development builds, off in release until the zkp modules are reviewed.
Off, nothing is offered, and a rotation this device is asked into is
declined out loud. The desktop build can opt in with
-Dgiza.experimental=true. The iOS actual was not built.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ShareRepairManager brings back a participant id a refresh left stale, with
FrostReducedEnrollment in repair mode, on kinds 30346-30349. t live helpers
approve and run it; their round-1.1 shares and round-1.2 sums are raw
additive shares, so each goes NIP-44-encrypted between the two parties'
ChillDKG host keys. The target checks the result against the public share
the group signed -- never one the helpers supply -- stores it, and proves
it with a Schnorr signature by the share, which every device checks before
marking the id live. The share is a point of the new polynomial that the
old device never had.
10b: a new identity at an id -- a lost device, a compromised account -- is
bound by a group-signed key state first (frost_member, GroupKeyState
.memberBindings, schema 40), applied only to an id that is not live. Until
then its request waits, with nothing sent. A key state amending one at the
same generation is stamped a second later, so a binding can never tie with
the state it adds to.
jvmTest 1198/1198, compileDebugKotlinAndroid, audits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A removal takes a member out of the room, not out of the key: their share
still helps sign. After an admin removes a member who holds a live share,
the room screen offers to rotate without them -- a second act, never
folded into the removal, since it needs every remaining holder.
ShareRefreshManager.proposeWithout withholds them for good (RETIRED); the
refusals say when that would leave fewer than t holders (the group could
not sign at all) or not a majority (remove fewer at a time).
Tested in the ritual harness: in a 2-of-3, the other two sign at
generation 1 and the removed member's old share signs nothing with a new
one. jvmTest 1195/1195, compileDebugKotlinAndroid, audits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a refresh completes the coordinator asks the group to sign the key
state at the new generation -- the same room, key, path and parentage, plus
frost_generation, a hash of the public-share table, the refresh and any
retired ids. It is the new shares' first signature, and what D6 waits on:
a device that files that state, holds the generation active and agrees
with the group's table fails every signing session left at an older
generation, out loud, and deletes the older shares, the ceremony's
randomness that rebuilds generation 0's, and the WAL's page images of them.
A key state at a higher generation wins whatever its timestamp, in the
DAO and among signed events. A proposal at a generation this device has
confirmed and is still waiting on the certificate for waits instead of
declining, and resumes when the generation activates.
jvmTest 1193/1193, compileDebugKotlinAndroid, audits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
For a ceremony a device finished there is one true statement of what
its room signs with: its key, at the admin path, naming the room that
derives, with the parent's certificate for a subgroup. A signing
proposal that is exactly that statement is approved on arrival.
GroupKeyStateManager.vouchesFor checks it with the rules stateFrom
applies to a signed state, minus the signature; anything else, a key
state included, is asked about as before.
SignedGroupKeyStateTest's two approval-gate tests now assert the new
rule. CeremonyNetwork relays signing messages, so a ceremony runs from
the joins to a signed key state with nobody asked.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ShareRefreshManager runs a FROST share refresh in the Marmot room the key
derives, on kinds 30340-30345, in the image of ChillDkgRitualManager:
every inbound message stored, every step recomputed from stored inputs,
nothing of a member's own published before they approve, at two gates
(DEAL, CONFIRM). Recipients are at least t and a majority of the ids not
retired, and a device confirms one refresh per base generation --
ShareRefreshConfirmation, written in the same transaction as the pending
generation it confirms -- so two refreshes from one generation cannot both
complete. The certificate activates the new generation; a withheld device
learns its table from the recovery data and files it with no share.
Schema 39 (AutoMigration): ShareRefreshSession, ShareRefreshMessage,
ShareRefreshConfirmation. Transcript lines as system lines; dispatch in
the Marmot inbound path.
ShareRefreshRitualJvmTest: three devices with real host keys refresh
through bitcoin-kmp's FrostRefresh and then sign at generation 1 as the
same room. jvmTest 1190/1190, compileDebugKotlinAndroid, audits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CeremonyFollowThrough asks a subgroup's parent to certify it, asks the
group to sign the key state, and creates the room, from stored rows and
one step at a time. It runs beside the live subscription, outside the
inbound lock, since creating a room waits on key packages the inbound
path delivers. It looks again when a ceremony finishes, a certificate
or key state is signed, or a key package arrives.
Only the coordinator's device acts on its own, and never again after a
signing session failed; the ladder keeps the buttons for both. Once the
room exists the ladder's last rung opens it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Once everyone has joined nothing is asked, so a ceremony that sits still
is waiting on a device that is not answering. After a day without a new
message, the ritual screen names who it is waiting on and since when,
with the abandon action beside it. Nothing abandons on its own.
A ceremony message is now stored once, on first arrival, so its time is
when it first came and a relay's redelivery does not restart the clock.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The join screen carries what the round-one screen showed, the members
in particular, and says the device takes it from there. The round-one
and round-two screens, their routes and their strings are gone; the
ritual screen offers only the join, and the ladder describes each round
as something the device does.
Old request lines still read as answered: the automatic round writes
the same line a tapped one did.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A ritual moved on an arriving message or a member's tap. Without the
tap, a ceremony holding every message it needs -- one an older build
left waiting to be told to contribute, or one interrupted between
storing a message and acting on it -- would never move.
resumeRunning advances every ceremony this user has joined. Sync runs
it once per activation, after reopening the inbox.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
advance no longer stops at rounds 1 and 2. Contributing follows from
having joined, and confirming is ChillDKG's own check, which refuses a
substituted result whether or not anybody is looking. pendingApproval
returns the join or nothing, and approving a round is a no-op.
ROUND_1 and ROUND_2 stay in the enum, and their timestamps in the
schema, so rows written by older builds keep decoding.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Schema 38 (AutoMigration): KeyShareGeneration and KeyShareMember for every
generation a refresh makes, FrostSigningSession.generation, and
GroupKeyState.generation and publicSharesHash. Generation 0 has no row: it
stays where ChillDKG wrote it, with ids derived from the host keys as
before.
ShareGenerations is the one door signing reads a share through.
FrostSigningManager fixes a session to the generation the group signs with
when it is proposed, carries it as frost_generation from generation 1 (a
generation-0 proposal is byte for byte what it was), and a device holding
no share of the named generation declines out loud with
GENERATION_REFUSAL instead of waiting or signing with the wrong share.
ShareGenerationsJvmTest refreshes a 2-of-3 group's shares by hand with a
zero-constant polynomial; the new shares sign and the signature verifies
as the unchanged room. jvmTest 1183/1183, compileDebugKotlinAndroid, and
the M3, brand and wallet audits pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CeremonyNetwork gives each member a database of their own and relays
what each queues to the others, stored first the way the inbound path
stores it. No test ran the rounds before: the others stop at the host
key or take a dealer's key.
Pins today's gates: members who have only joined stop at round 1.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every connection opens with PRAGMA secure_delete = ON (SecureDeleteDriver),
and GizaDatabase.scrubFreedPages truncates the write-ahead log, which keeps
whole page images of a share after its row is gone. Android backups and
device-to-device transfers carry none of the app's data: aux.db holds FROST
shares in plaintext, and a share copied somewhere the app cannot reach
cannot be rotated away from.
SecureDeleteJvmTest reads the database's files byte by byte; its two
controls find the share with secure_delete off and before the scrub.
jvmTest 1176/1176.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Phase 4 settled the blob and left the database alone, because there was nothing
to settle: the state is opaque to Room and its version is inside it. Phase 8 added
a table, and that turns "does an existing install still open?" from a question
about MLS into a question about Room. They fail differently. A blob the engine
cannot read costs one room; a migration Room cannot find costs the app, on every
device that has ever had it, on the first launch after the update.
That second one is also the easiest here to ship by accident, because a fresh
install never migrates anything. Measured rather than assumed: with
`AutoMigration(from = 36, to = 37)` commented out, 32 database tests ran and 4
failed -- all four of them the new ones.
ShippedProfileUpgradeJvmTest builds a v36 database on disk from the exported v36
schema, down to its indices, its room_master_table identity hash and its
user_version, puts a profile and two rooms in it with the Phase 4 blob in one, and
opens it with the app's own getRoomDatabase. Four claims: it reaches v37 with
Room's own identity hash stamped and every table's columns and indices equal to
37.json's; the legacy room's bytes come back unchanged and MarmotEngine.groupFor
restores a group with its 0xF2EE metadata and a 32-byte kind:445 key; opening the
profile rewrites nothing, which is asserted only after checking the restore held
the room; and the new table takes a row keyed to a ChatRoom that predates it.
Room opens lazily, so a test that builds a database and closes it migrates
nothing. The first version of this did that and failed on user_version still
reading 36.
The blob itself moves to OldEngineBlob in commonTest, read by both tests. The
only thing those bytes are worth is that they are old ones, and a blob living in
two files can be regenerated in one of them.
1171 tests across 157 classes, 0 failures; the four audits unchanged.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The piece Phase 7 deferred, in both directions, because they are one question:
a group's state is a few kilobytes of ratchet tree, group context and epoch
secrets, and the app was rewriting all of it to record things that moved a
counter.
Sending an application message advances exactly one thing -- this leaf's entry
in the secret tree (RFC 9420 §9) -- so the library carries the position as its
own record, `MlsGroupStateStore.saveSenderRatchet`, in the spirit of OpenMLS
keeping `message_secrets` apart from `group_state`. Giza defaulted that to
false, which sent the manager back to a full save per message. It is now a
`MarmotSenderRatchet` row, one per room, schema 36 -> 37 with an AutoMigration.
The bytes are stored as the library wrote them -- the `MarmotPublishObligation`
precedent, not the retained-epoch one -- because a record whose whole job is to
never go backwards is safest when nothing here re-encodes it; the epoch, leaf
and generation sit beside it, read off those same bytes, so they cannot drift.
The hazard this introduces is an ordering, and it is in the app's code, not the
library's. `MlsGroupManager.restoreAll` applies the record itself. A room joined
after the engine restored is loaded from its row by `MarmotEngine.groupFor`
instead, and that has to apply the record BEFORE `adoptGroup`, because adopting
persists and persisting rewrites the row from the group being adopted. The other
way round, the next restart re-emits generations already published, under AEAD
keys and nonces already used.
Finding the test that could tell the two orders apart took two goes. The first
asserted the row after a lazy load and passed with the order inverted: a state
saved before this leaf ever sent has no ratchet entry, `exportOwnSenderRatchet`
returns null, and the adopt writes nothing. The order cannot matter until the
stored state holds a position of its own behind the record's, and a received
message is what puts one there. With one receive in the middle the inverted
order fails with expected:<2> but was:<1>.
The receive side is a full save, from `MarmotEngine.processGroupEvent`, which
`NostrDao` now reads inbound events through so a second caller cannot forget it.
And a correction to Phase 5, which said an unwritten row still lost the late
message. It does not: mls-kmp writes the skipped keys beside the positions they
belong to, so an unwritten row is an older COHERENT state, and a position that
has not passed the late generation derives it forward. quartz's engine saved the
positions and dropped the keys -- that pair is what lost messages. The cost of
an unwritten row is the re-deriving, against SecretTree's thousand-step cap. The
reason the write lands now is the send side: until this change every send wrote
the whole state, so the row could not fall far behind inside an epoch.
1167 tests across 156 classes, 0 failures; Android and JVM compile clean; the
four audits unchanged. docs/mls-skipped-keys.md loses its mitigation claim and
gains the correction; docs/marmot-kmp.md gains Phase 8.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
marmotAudit runs docs/scripts/marmot-kmp-imports.sh --check from `check`, beside the M3,
brand and wallet audits. Verified both ways: silent on a clean tree, and on a tree with
one import put back it names the file and the line and fails with a pointer to the note.
That is C2 made enforceable -- a cherry-pick from a Bennu still on quartz 1.15.2 brings
the old spelling back, and "re-run the rule" is advice until a build failure makes it a
step.
The other three items of this phase are named in the note rather than done, each for a
reason:
- The app's own copies: nothing to delete. CommitOrdering is still live in NostrDao's
reindex sweep and MarmotInboundManager's epoch tracker, and marmot-kmp has no
CommitOrdering at all -- the convergence engine replaced the idea, not the class. Under
D4 the legacy pipeline keeps its behaviour, so the comparator retires with the profile.
- The sender ratchet record wants a new table, so schema 36 -> 37 and an AutoMigration,
and the interface says the write MUST be durable before it returns or a lost position
reuses an AEAD key and nonce pair. A per-message write path with a correctness hazard
does not belong in the tail of a migration whose discipline was D5. It is the obvious
next task, and it is the same shape as the receive-side write Phase 5 pinned: one piece
of work that decides how often this app persists a group, in both directions.
- Durable ingest dedup is taken by MarmotManager, not by MarmotInboundProcessor, so it
needs the client D1 deferred. Phase 3 is where that stopped being hypothetical.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Phase 6 is a probe with no code of its own, so it rides along: both fork tests pass
unchanged, which means marmot-kmp 2.2.1 still scores a fork this device is half of the way
quartz 1.15.2 did. The assertion whose message is "the two sides agree -- the library has
been fixed" did not fire. What changed is that the fix docs/marmot-v2.md predicts is now a
first-class thing on the library's side -- MlsGroup.stageCommit, with the staged commit in
MlsGroupState from its STATE_VERSION 9 -- so it is a choice in MlsCandidateStateEngine
between replaying a branch and taking the state that was kept. Both notes say so.
Phase 5 is the skipped keys, and it is half closed. mls-kmp's state carries them:
skippedApplicationSecrets and skippedHandshakeSecrets, exported by saveState and imported
by restore, arriving at STATE_VERSION 5 so a version-4 blob reads them as an empty map.
That is steps 1 to 3 of the fix docs/mls-skipped-keys.md proposed. Step 4 is not done:
consumedGenerations, the replay guard, is still one SecretTree's field.
The app does not benefit yet, and the first draft of this test claimed it did.
MlsGroupManager.decrypt persists only when the message was a commit that advanced the
epoch, so the secret reaches the live group and never the row. The draft delivered
generation 1, rebuilt the engine, delivered generation 0 and asserted it decrypted -- and
it did, for the wrong reason: a rebuilt engine restores a blob whose sender ratchet never
moved, so generation 0 is simply the next one it expects. A green test proving nothing,
caught by the assertion beside it that looked redundant.
So the three tests say what is true: the secret is in the state the engine would save, a
group rebuilt from those bytes reads the late message, and the stored state does not carry
it. The last one is pinned in the style of the authored fork, with its KDoc saying what to
invert when the receive path starts persisting -- deliberately not done here, because it
is a write per inbound message that re-encodes the ratchet tree, the group context and
every epoch secret. saveSenderRatchet is the library's answer to that cost on the send
side.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
C1 is the constraint the whole move hangs on: ChatRoom.mlsGroupState is a
MlsGroupState.encodeTls() blob written by quartz 1.15.2 on every device that has ever been
in a group, and a blob the new engine cannot read costs a user every room they are in --
there is no in-place migration from a legacy group.
The argument was checkable before a test was written. quartz 1.15.2's own sources, in the
sources jar beside the artifact in the gradle cache, declare STATE_VERSION = 4; mls-kmp
1.3.0 declares 10 and accepts 1..10, appending only. So every blob in the wild is version
4 and the window covers it six times over.
The measurement is docs/tools/old-state-blob, whose only dependency is
com.vitorpamplona.quartz:quartz:1.15.2 -- it prints a real 1033-byte blob for a legacy
MIP-01 group at epoch 0, which is the shape every room in the wild started as. It is
checked in because once it is gone nothing in the hex says whether the fixture came from
the old engine or the new one, and a fixture written by the new engine would pass while
testing nothing.
MlsGroupStateCompatibilityTest pins it six ways: the fixture is still version 4 (asserted
alone, so a fixture that drifted to 10 cannot make the rest pass vacuously); mls-kmp
decodes it; the group rebuilds from it with 0xF2EE, its nostr_group_id and its name
intact, still reading as legacy; the kind:445 outer key off a restored old group is 32
bytes, which is Phase 1's policy finding pinned against real pre-migration bytes; a
re-save lands on version 10 and still decodes, same group id and epoch; and
RetainedEpochSecrets still round-trips the five fields RoomMlsGroupStateStore stores it as.
No schema change: the blob is opaque to Room and the version is inside it, so 36 stands.
Not done, and not automatable here: one manual upgrade of a profile with real rooms in it.
A fixture is one member at epoch 0; the rooms that matter have epochs, members and a
retained window behind them. That is the last thing between this and a release.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`MarmotStandIn` moved to marmot-kmp's managers in Phase 1 with nothing but its imports
changing, and it stays as it is: the convergence and lifecycle tests need a processor they
can reach into -- `recordLocalCommit` with a state snapshot of their own, `buildAppEvent`
with a payload they wrote -- which a `MarmotManager` would take away.
So the second stand-in is additive. `MarmotClientStandIn` is a `MarmotManager` over an
`InMemoryMlsGroupStateStore` and a publisher that says yes, with no message store and no
KeyPackage store because both are nullable and a client that persists nothing is all a
test wants from one. It is what Amethyst, its desktop app and the `amy` CLI drive.
The two are not redundant, and the difference is the difference between the two questions
this migration has to answer. In CurrentProfileInteropJvmTest the test's own code decides
how the Welcome is sealed and what an application payload looks like, and asks whether two
engines agree. Here the library decides -- `addMemberInvites` picks the commit's shape,
`MarmotWelcomeSender` wraps the Welcome -- and the question is whether the app's own
orchestration, `MarmotEngine` and the DAOs and the outbound queue, reaches the same group
as the orchestration the library ships. It does, on the first run: the app joins a group
the client made and invited it to, under the routing id the client minted; it files and
attributes a `buildTextMessage` from it; and the client decrypts what the app's outbound
path sends and decodes it as a canonical payload.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Most of this phase was answered by Phase 1 rather than built. `GroupEventResult` still has
exactly nine variants -- `MarmotEngine.inRoom` is an exhaustive `when` used as an
expression, so the compiler says so rather than a reading of the source. The convergence
and lifecycle surface takes and returns what `settleLater` and `awaitSettled` already
expected, `allowsOutboundWork` included. `stageAddMember` -> `StagedCommit` ->
`gate.prepare` -> `installState` needed no edit. And no test's assertions moved: seven
fixtures now build their group with `MarmotGroupPolicy` as the app does, which is a
construction-site change, not a weakened expectation.
What was left is the six classes quartz 2.x renamed to match what the NIPs call the kinds,
and kept deprecated typealiases for: SealedRumorEvent -> SealEvent, ChatMessageRelayListEvent
-> DmRelayListEvent, RelayFeedsListEvent -> FavoriteRelayListEvent, LnZapEvent ->
ZapReceiptEvent, LongTextNoteEvent -> LongFormContentEvent, ChannelListEvent ->
PublicChatListEvent. 104 references in 25 files; same packages, so each is an identifier
rename. None reaches a string the app persists -- no Room column, no string resource, no
kind number -- and after it the build has no quartz deprecation warnings left.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
quartz 1.15.2 -> 2.7.3, and the engine it used to carry from marmot 2.2.1 over mls 1.3.0
over crypto 2.1.0. docs/scripts/marmot-kmp-imports.sh --apply moved 187 lines by the rule;
42 `quartz.marmot` imports stay, which are the event classes quartz kept.
The 854 non-Marmot quartz imports came through the major bump without an edit. All 45
compile errors were in the engine seam, and 44 were one thing: five accessors that were
members of `MlsGroup` in quartz's engine are extension functions in marmot-kmp
(`currentGroupState`, `currentMarmotData`, `currentNostrGroupId`, `currentAdminIdentities`,
`isLocalAdmin`), so 14 files import one now. The 45th, `buildCurrentProfileFrom`, likewise.
No constructor the app drives changed shape, and `GroupEventResult` still has exactly nine
variants -- `MarmotEngine`'s exhaustive `when` compiling is the proof there is no tenth to
drop on the floor.
One change here is not a rename. `MlsGroupPolicy` is new in mls-kmp: quartz's engine
hardcoded Marmot's rules, mls-kmp made them an argument, and every factory defaults it to
`Permissive` -- so the eleven places this app builds a group itself were building a
non-Marmot group. The loud half is that `commitExporter` is then null, `preCommitExporterSecret`
comes back empty and `GroupEventEncryption.encrypt` refuses it ("Group key must be 32
bytes"), which is the one test that failed. The silent half matters more: `Permissive`
greases the leaf's capabilities, which MDK has never been tested against; it knows neither
`0xF2EE` nor the app-data dictionary, so RFC 9420 13.4 refuses a GroupContextExtensions
proposal in a group we are a member of; and it authorizes every commit, proposal and
SelfRemove without a check. So `MarmotGroupPolicy` goes in at all eleven. The
current-profile paths needed none -- `CurrentProfileGroupFactory` and every
`MlsGroupManager` entry point pass it themselves.
1149 tests, 0 failures; compileDebugKotlinAndroid clean; the three audits unchanged.
Import blocks were re-sorted in the touched files only: 253 further files in composeApp
have blocks that were already out of order, and C2 is the reason to leave them be.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The 23 wallet notes move to docs/retired/ with a banner; every link between
notes is rewritten for the move and checked. The index lists them as one
Retired paragraph, and seven kept notes carry a line on what changed. The
README and CLAUDE.md describe a Giza with no wallet.
brand-audit.sh loses its "bennu/ exception: every such tag was a wallet's,
so one now is a wallet coming back. wallet-audit.sh --check, in check and
in CI, fails on a retired kind in the app's code, a lightning-kmp import,
a file named for a wallet's pieces, or sats in a string.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
W3: a Lightning invoice in a note is a card that opens a lightning: link
in the device's own wallet app, undecoded -- decoding was lightning-kmp's,
and paying from the card was never wired. The dead pay and zap hooks go.
Lightning.randomBytes becomes quartz's RandomInstance; the tests'
LocalKeyManager becomes PhraseKeys; NodeParamsManager.chain becomes
PROFILE_CHAIN, the mainnet constant every profile's preference files are
named under.
What is left of the library is storage (keystore, credentials, seed file,
preferences). Moving it into the app and off the composite build is
Phase 7b, which needs an iOS build and a device to check, and is left for
its own branch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PhraseKeys derives a phrase's nostr key (NIP-06, m/44'/1237'/0'/0/0) and
its profile id (hash160 of m/50'/0', the old node key) with bitcoin-kmp's
DeterministicWallet. ForkCompatibilityTest's Phase 0 pins pass unchanged
through it, so the same phrase is the same person with the same
preference files.
No profile starts a node: Identity.business, startupNode and its state
machine, the platform start/schedule/stop actuals, LightningApplication,
BusinessManager.initialize, the NFC hooks and POST_NOTIFICATIONS go. A
switch is clearing the identity and nothing else. Copy that promised funds
or a wallet is reworded, and the switcher's badge says Recovery phrase.
Forgetting a phrase profile is still refused (now PhraseAttached): the
phrase would derive the key again, and offering it is new UI.
iosMain was edited without an iOS build.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MIGRATION_35_36, by hand: the wallets' chat lines; GroupTransaction; every
signing session over a transaction or a sweep, with its items and its
members' messages; the other fifteen wallet tables, children first; and
FrostSigningItem.inputIndex, DkgSession.guardianDelay and
ChatMessage.lightningFactKey. DkgSession.walletPolicy stays: the join
screen reads a Bennu ceremony's tag from it. The 36 schema is committed.
The wallet line-type constants and the transcript's arms for them go with
the rows they named.
jvmTest: 1,150 run, 0 failed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wallet/ (Electrum included), nostr/wallet/, the policy and guardian tags,
GroupWalletDerivation, GroupWalletManager, GuardianDerivation,
GuardianManager, ProposedSpend, three screens with their view models,
states and routes, and FROST's spend half.
FROST is back to signing events. Every transaction proposal from a Bennu
peer is filed declined without being read, and the decline goes out
through advance(). Certificates and ceremonies carry no wallet tag; a
guarded subgroup's ceremony is filed and not joined, and its join screen
says why (W5). A key state carrying a wallet's certificate is declined.
The last bennu/ derivation tag leaves the code, and the last wallet pins
with it.
jvmTest: 1,148 run, 0 failed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The member-wallet events, MemberWalletManager, MemberWalletDerivation, the
repository and DAO, five screens with their view models, states and routes,
and the 74 strings only they read. GuardianManager stops reading member
certificates. The entities stay until Phase 5's migration.
Guardians and the subgroup wallet policy move to Phase 4: they are built
into the group's on-chain wallet and cannot leave before it and compile.
jvmTest: 1,311 run, 0 failed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>