cd7aa36cd011733172f0132040804df5db0d8d35
741
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
cd7aa36cd0 |
Merge remote-tracking branch 'origin/bennu' into claude/group-chain-wallet-plan-93f0e1
Every conflict was the curated-lists removal on bennu meeting a wallet line added beside it: the removal is taken and the wallet lines kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
b8194a4ba3 |
refactor(wallet): GroupChainWallet is GroupOnchainWallet
And its registry, GroupChainWallets, is GroupOnchainWallets, with the files, the test and the plan's references following. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
f83fe35a45 |
feat(wallet): ship behind the rollout gates (Phase 10)
GroupWalletRollout holds the three gates, each with what lifts it. The flag is on, its condition met. Send-an-amount is off, so the form sends everything confirmed to one address and says so. A spend proposed from this device on mainnet may send at most 100,000 sats; test networks have no cap. The gates are on the composer and nothing else: a device behind them still accepts, shows and signs what another member proposes, through every check GroupSpend makes. The plan is marked built, with its table of where the build chose differently. Full JVM suite: 1474 tests, none failing; the Android target compiles; every M3 budget is met. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
0db1fe8fc8 |
feat(wallet): the group's spends on its wallet screen (Phase 9, part 2)
Every spend the room proposed, newest first, for every member whether or not they have a node: what it sends and where it has got to -- waiting for signatures, abandoned, signed, sent (reported back by Electrum, not merely broadcast), confirmed, or replaced by a later spend. A signed spend Electrum has not reported can be sent again; a signed, unconfirmed one can be bumped to twice its feerate, a new session over the same coins that whichever confirms settles. Each row opens its signing session. Full JVM suite: 1473 tests, none failing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
58da7c1285 |
feat(wallet): broadcast signed spends and settle what a confirmation decides (Phase 9, part 1)
GroupTransactionWatcher, one per identity beside its wallets: every signed spend still on its way is sent from this device too, sent again every ten minutes while Electrum has not reported it -- its broadcast reports success whatever the server said -- and followed to a confirmation. FrostSigningManager.recordConfirmed then settles every other spend of the same coins: one still collecting is abandoned as spent by another transaction, one already signed is marked replaced rather than failed, and the room gets one line saying it confirmed. GroupSpendBuilder.bump re-spends the same coins at a higher feerate, the extra taken from the change or, for a send-all, the one payment. The test caught a stale write: a pass followed each spend from the list it started with, so settling one spend was undone by writing the next back from its old copy. follow() reads its row again first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
b1d5963b53 |
feat(wallet): a form to propose a spend from the group's wallet (Phase 8, part 2)
GroupSendRoute and GroupSendScreen, behind a Send button on the wallet screen for a member who holds a share and has a node to see the coins with. Address, amount or send everything, and a feerate prefilled from Electrum's six-block estimate. The preview is GroupSpendBuilder over the same inputs the proposal is built from -- what leaves, the fee, what comes back as change, or why it cannot be built -- and proposing moves onto the signing session, replacing the form. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
6d066e19c0 |
feat(wallet): build a spend and show it for approval (Phase 8, part 1)
GroupSpendBuilder: send-all, as Phoenix's final wallet does, and an amount paid largest coin first with change to the next change address, or to fees when it would be dust. Confirmed coins only, never one an open spend already holds; the fee is exact before signing because every witness is 64 bytes. Every built spend passes GroupSpend.check. The signing screen draws a spend where it draws events: every output with its address and amount, change labelled, the fee and feerate, and the coins spent -- read from FrostSigningManager.checkedSpend, the stored PSBT checked again, and unsignable when this device cannot check it. The proposal list and the chat notice say "Spend from the group's wallet". FrostSigningRepository gains proposeSpend, checkedSpend and reservedOutPoints. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
a24c107b26 |
feat(wallet): the signing manager signs a spend from the group's wallet (Phase 7)
Kind 30332 opens a session over a PSBT, one item per input, each its own FROST instance over that input's BIP341 sighash with its own nonce seed and its own tweak cache. proposeSpend and acceptSpendProposal run the same GroupSpend checks: every input derives under the account the room's verified statement gives -- looked up under the ceremony's own key -- default sighash only, no script-path fields, replaceable, change only where its claim derives, and a fee under a ceiling. A second proposal under one id is ignored. completeSpend checks each signature against its coin's output key and the whole transaction with correctlySpends before writing it. An old build does not route 30332, so it never signs a transaction it cannot show. Resend repeats the PSBT byte for byte. Two-device test: a quorum spends two coins and both devices hold a transaction that correctlySpends; each check refuses a hand-built proposal outright. Full JVM suite: 1458 tests, none failing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
f7a9e05bbc |
feat(wallet): schema v26 for spends from a group's wallet (Phase 6)
FrostSigningSession.subject, NOT NULL with a default of EVENTS, says what a session's items are messages of; FrostSigningItem.inputIndex names the input a transaction item signs, with message and payload as getters over the existing columns. GroupTransaction holds a spend from proposal on: the PSBT, written once with IGNORE, the txid fixed before signing, and the signed transaction, broadcast, seen and confirmed. AutoMigration(25, 26) is three ADD COLUMNs and a CREATE TABLE -- no rebuild of either signing table, so no cascade fires. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
24d06d2eee |
feat(wallet): a screen to open a group's wallet and receive into it (Phase 5)
GroupWalletRoute and GroupWalletScreen, reached from a Group wallet row on the group's screen. A group that has not opened a wallet gets an empty state with, for a member who can sign, what opening one asks of everybody -- including that shares are unencrypted at rest -- and the button that proposes the statement. An open wallet shows the balance, confirmed and on the way said apart, the next receive address as a BIP21 QR code, selectable text and a copy button, the coins, and an export of the two watch-only descriptors with what they give away. The wallets are watched on the identity's own Electrum client and made per PhoenixBusiness in BennuNavHost; a profile with no node sees the wallet and is told it cannot watch the chain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
4ab47ba432 |
feat(wallet): watch a group's wallet on the identity's Electrum client (Phase 4)
GroupChainWallet is Phoenix's FinalWallet for a group: two ElectrumMiniWallets, one per BIP44 branch since a mini-wallet holds one generator, gap-limited at 10 for receive and 3 for change, on the shared client. GroupWalletState gives the coins with the derivation that spends each, the confirmed and pending balances, the next receive address and change index, and derivationOf -- bounded by the addresses the wallet has generated, which is how far a check of a claim will look. Tested against a fake IElectrumClient: a payment moves the receive address on, change is counted and never offered, and two groups on one client see only their own coins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
caddfdc107 |
feat(wallet): the group opens its wallet by signing a statement (Phase 3)
Kind 30331, inner only: the account xpub, the network, the account number and both descriptors. A reader believes one only when the room signed it and the room's threshold key rederives every value it carries -- GroupWallet.of, used by the repository and by the transcript arm alike. The broadcast screen refuses the kind twice, at the loader and in sendToRelays, because the xpub on a relay is the whole balance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
4330faacd7 |
feat(wallet): derive a group wallet's keys from its threshold key (Phase 1)
GroupWalletDerivation: a public account step -- a tagged HMAC over the threshold key, the network and an account number -- gives a depth-0 xpub, and below it BIP86's own unhardened tail, /<change>/<index>, with the key-path tweak on top. Each address is computed twice, as points and as tweaks on a FROST cache, and refused if the two disagree. Tests: BIP86's published vectors through the cache prove the tail; a pinned vector freezes the account step; a sweep covers both parities. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
56a942c610 |
Remove the curated-lists feature
Bennu no longer speaks curare.to's list protocol. The schemas, templates, entries and the suggestion queue go, with their six screens, routes, view models, strings and tests, and the hooks into the group screen, the paste proposal, proposal summaries, broadcast relay seeding, the chat repository and the transcript. The two transcript message types stay as private legacy names so rows already stored still render as system lines rather than chat bubbles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
b75d4b427f |
Rebrand Curare to Bennu under com.machankura.bennu
Move the packages to com.machankura.bennu.{compose,android,desktop}, the
Android applicationId to com.machankura.bennu.android and the iOS bundle
id to com.machankura.bennu.ios. The root project, launcher label, iOS
product, desktop window, user-facing strings, client tags and the
Curare* classes all say Bennu now.
Left alone on purpose: the mantra/ derivation tags, the `curated` desktop
data directory, the mantra.press relay and the curare.to references.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
72cfb561c4 |
feat(proposals): ask again about everything the filter is showing
The bulk control I argued against, built -- and the objection turned out to be solvable rather than fatal, so it is worth recording what happened to it. Half of it was already handled. Two resends in the same second do not collide on the outbound row id: `broadcast` hashes that id over the session's own tags and steps a second forward when it finds a collision rather than overwriting. Different sessions were never at risk. The other half was real. A resend publishes two messages, and `resend` keeps to two deliberately because "publishing in bursts is what the skipped-keys bug feeds on"; three proposals at once is six, in the same second that "two events published in the same second race, and exactly one survives" was written about. So the sessions are spaced rather than the budget quietly raised -- `resendAll` waits `RESEND_SPACING` between them, one second, which is the resolution the protocol works in because `created_at` is stored to the second. The pacing lives in the manager and not in the loop that wanted it, because everything that justifies it does: MLS generations, relay ordering, outbound ids. A caller that launched `resend` per session would put every burst into one second, and the call site is the wrong place to know why that matters. There is a test against the real manager that three sessions take longer than two spacings and claim three different seconds. What it acts on is `visible`, not the room: a bulk control reaching rows the reader cannot see is its one unforgivable move. A cooling-down row is left out of the count rather than included and skipped, because the count is what the button says out loud and offering three while able to send two is a lie told before the tap. Offered from two up: one is what the row's own button is for. Every covered row goes quiet for the whole run rather than for its own turn -- a paced run means a row whose turn has not come is still about to publish, and a row button offering to send it meanwhile would send it twice. A session already in flight on its own is left out of the run for the same reason. It is offered on any filter showing two it can act on, not only "being signed". That filter is where it earns its place -- three rows stalled for one reason -- but the rule is about what is on screen, not about which chip put it there. 1419 jvm tests pass, the Android target compiles, all audit budgets met. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
4330d718be |
feat(proposals): ask the quiet members again from the row
The offer the signing screen already makes, reached from the list. A coordinator whose room has stalled should not have to open each proposal in turn to find the button, and filtering to "being signed" now puts every stalled one in front of them at once. It is on the row and not on the chip, which is where it was asked for, for three reasons. A chip is a selection control, and giving it a second action would make the control that publishes the one you cannot undo. A chip stands for several proposals while `resend` takes one session, so a chip-level button means resending all of them -- and the manager caps itself at two messages per resend precisely because "publishing in bursts is what the skipped-keys bug feeds on", which three proposals at six messages would re-create. And the offer is the coordinator's alone and only exists while somebody owes, so on a chip standing for a mixed set it would be enabled for proposals it cannot act on. It is called "ask again" rather than "re-broadcast" for the same reason the list calls a review a review: somebody who found the button on the signing screen and then found this one should not have to work out that two labels are one button. Whether to offer it is asked of `membersOwing`, not derived from the signature count. Past the nonces a signer who refused has answered and is owed nothing while the count is still short by one, so a row reading `have < need` would offer to knock on a door that has already been shut. That is one query per row and the only one on this screen, so it is asked for as few rows as possible: not ours to send, nothing to send, and already ended all answer without touching the database. An ended session is left out although the manager would take it -- re-sending a completed one delivers the signature to a member who never applied it, which is worth a button on the one proposal's screen rather than a query per row on a list that only grows. The signing screen still offers it. Guarded per session rather than by one flag for the screen, because these rooms have several proposals open at once and a coordinator working down the list should not be locked out of the second by the first still publishing. The cooldown disables rather than hides, as it does on the signing screen: a control that vanishes after a tap reads as one that failed. 1396 jvm tests pass, the Android target compiles, all audit budgets met. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
1f82d66f57 | Merge branch 'curated' into claude/proposal-state-filters-8cc06c | ||
|
|
7c6e9b0a84 |
feat(proposals): say how far a proposal has got, not just what it is waiting for
A row said "waiting for 2 of 3 members to take part" on the day a proposal was made and on the day before it completed. That is the rule, not the progress. Now it says "1 of 3 members have offered to sign", and on the next stage "2 of 3 signatures are in" -- the fractions that actually move. Nothing is counted once it has ended, which is both endings and not only the happy one. A signed session has nothing left to gather; an abandoned one has counts frozen where they stopped, and "2 of 3" beside a failure invites the reader to wait for a third that is never coming. The failure reason is what that row has to say. The denominators are the ones the protocol gates on. `orderedNonces` returns nothing until `threshold` nonces have arrived and then takes the first `threshold` of them, so the threshold is both what is needed and what is used -- the room's size is a bigger number nothing waits for. Once the signer set exists it is the set being waited on, which is the same count from the other side. The numerator is the part that had to be got right. A nonce or a partial signature is recorded with no check on who sent it, unlike a refusal, and `orderedNonces` drops the ones from members holding no share when it aggregates. So the tally joins `DkgParticipantMessage` on HOST_KEY and counts members rather than rows: a count including strangers would have a row read ahead of the coordinator, saying the group has what it needs while the session sits still. That is the one direction a progress figure must never be wrong in, and there is a DAO test for it. A count that still runs ahead -- a nonce landing before this device runs `advance` -- is clamped, because a fraction over one reads as a bug rather than as a session about to move. The counts travel as their own `GROUP BY` flow, combined with the sessions in the view model. They change far more often than the rows do, and carrying the messages themselves would carry every nonce payload the room has ever exchanged to a screen that only wants to count them. The progress is its own line rather than a clause, so a reader scanning for the one that is nearly there does not have to read a sentence to find out. That left `statusOf` saying only who the reader is in the proposal, and since this adds user-facing text its remaining literals moved to the catalogue with it -- nine strings that had been raw in the screen since before the catalogue rule. 1367 jvm tests pass, the Android target compiles, all audit budgets met. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
f0cbb2785b | Merge branch 'curated' into claude/partial-signature-collection-d44dab | ||
|
|
a9532ff115 |
fix(frost): resume a session whose own turn was cut short
Every step a session takes is driven by a message arriving, and a device killed part way through its own pass is waiting on one that has already been delivered. The signer set is recorded, so it will never be processed again; the partial signature it would have produced was never made. The coordinator asking again cannot reach past it either -- what a resend asks a member for is the message this device believes it already sent -- so the session is a dead end on both sides, and in a room with several open proposals it is the one that was mid-pass that stops. So one sweep that no message drives: on opening a room, every session in it that is not settled and whose owner has answered is handed to `advance`, which does what it always does. It publishes nothing new -- each step asks whether its output exists rather than whether a stage says it ran -- and only answered sessions are passed in, so the approval gate is not approached, let alone reached past. A refusal counts as an answer for the same reason: a device killed between deciding and publishing says it on the next open rather than never. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
1e59fd2334 |
fix(frost): a knock past the nonces is for the signers, not the quiet
A resend had one idea of who it was for at every stage -- the share holders it had heard nothing at all from -- and that is a question only the first stage can answer. A session reaches COLLECTING_PARTIAL_SIGNATURES because enough members offered a nonce, so every member who could be holding it up has been heard from: the set came back holding the members who were never chosen and owe nothing, while the chosen signer whose partial signature went missing was named nowhere. Once the unchosen had answered or refused the set was empty, and the control gave up before it reached the branch written for the stall it was meant to repair. So the set asks what the stage can answer. Of the signers the coordinator chose, who has yet to send a partial signature -- which is the half of a resend only they can carry out, since a partial signature is read by nobody but the coordinator and no other device can repeat it. COMPLETE keeps the old reading, and correctly: the signature is the coordinator's own and nobody answers it. The screen now asks the manager who is owed rather than deriving it from the rows beside the button, the way it already asks about approvals: the same reading decides whether a resend publishes anything, and two copies of a rule that changes with the stage is a screen offering a knock the manager would refuse. The transcript line and the notice say what the members named are short of, since past the nonces they have answered once already. The test that looked like it covered this passed because it wrote the stage into the row with no nonce on file anywhere -- a state the protocol cannot produce, and exactly the state that hid the bug. It now reaches the stage by offering a real nonce. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
13ae0a1def |
feat(proposals): tell the two open stages apart, because they are not alike
"In progress" was one chip over two situations that ask different things of the reader, and collapsing them was the wrong call. Short of members, a proposal can still die of indifference: refusals are counted against `declinesThatAbandon`, so one more may end it, and a member who is offline is indistinguishable from one who has not looked. It is also the only stage the coordinator's resend is for. These are the proposals somebody may have to do something about. Once the signer set is written, none of that is true. `signerIds` is written once and never revised, so no further refusal is counted against it, and what is left is arithmetic the chosen devices have already committed to. Where one asks whether this will happen, the other says it is happening. So: WAITING_ON_MEMBERS and BEING_SIGNED, named for what the reader is waiting on rather than for the protocol step -- "collecting nonces" is true and says nothing. The icons carry it as well as the labels, people against machinery, which is the only signal a monochrome display has. What is *not* split, and the comments say why: whether this device was picked to sign, and whether the reader agreed or declined. Those are facts about the reader rather than states of the proposal, so they stay a sentence on the row. Splitting on them would be splitting every state by who is looking. The classification is now the stage plus one, which is the shape it was always going to take -- the one being NEEDS_YOU, which no stage can express. Six chips means the last two now sit past the fold at phone widths, so the screen test measures order only over what the viewport lays out and the full lifecycle order is pinned on the enum, where no viewport is involved. 1342 jvm tests pass, the Android target compiles, all audit budgets met. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
18c6245181 |
feat(proposals): open on the queue when that is what was asked for
The transcript's notice counts the proposals waiting on this member and says so. A tap on it that then showed the room's whole signing history would have the reader go and find the three it had just named for them, so the route carries a filter and the notice asks for the queue. `ProposalListRoute.filter` defaults to ALL, which is both the honest default and what every caller predating it reads back as -- the group's own Proposals row still means "show me the room". The transcript's other way in turns out to be two ways, not one, and they wanted different lists. A line too old to name its session could be about anything the group has ever signed, so it opens the room. A tap held back *because several decisions are waiting* was held back for those decisions, not for the history -- so it opens on them. That decision now lives in `proposalDestination` instead of in a condition nine levels down a LazyColumn, which is the only way anything could be held to it. Nine tests over the three branches, including that the queue is offered only for the proposal actually tapped -- a line about something already signed is history, and handing its reader the queue would invert what `hidesOtherDecisions` is for. The filter's ride on a type-safe route is pinned too: navigation reads an argument's NavType off the serial descriptor and takes an ENUM as a string, so the test fails if the filter ever becomes a shape navigation cannot place. The notice's own one-line wiring is not itself covered -- it builds a route inside the transcript's lambda -- so it rests on the route tests and on review. 1338 jvm tests pass, the Android target compiles, all audit budgets met. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
ef2b461c5c |
feat(proposals): a chip row over the list, and four ways of being empty
Five chips under the app bar, each carrying its count, scrolling sideways. The row is outside the list rather than its first item, because a control that scrolls away is a control the reader has to scroll back for -- and the list it filters is as long as the group's whole signing history. It scrolls rather than wraps for the same reason from the other side: five counted chips do not fit the sixty characters `readableContent` holds the column to at the largest text size a reader can ask for, and a row reflowing to a second line moves the list under the thumb about to tap it. Unfiltered, the two sections stay. Filtered, they go: "waiting for you" against "everything else" is a distinction the reader has already made by tapping, and heading a single-state list with it would answer a question nobody asked. A room with nothing in it gets no chips at all. Five chips reading 0 over an empty screen would be five ways of saying what the empty state says once. The screen also picks up the state widgets it never had -- `LoadingDataIndicator`, `ErrorState` with an explicit `onRetry = null` because a room missing from this device will not appear by looking again, and `EmptyState` with a message per filter. That last one is the point: one shared default is how five different absences here came to say one thing. A group never asked to sign and a queue the reader has worked through are not the same fact, and the second is not an absence at all -- it keeps the queue's own icon and reads as finished. `initialFilter` reaches the screen and is applied in the view model's `init`, so a `Loaded` handed in for a preview cannot open with its chips saying one thing and its rows showing another. Nothing passes it yet. Fourteen screen tests, and the audit's budgets all still met: 0 hardcoded colours, 0 dp literals in spacing positions, 0 title-case strings, both floors held. 1329 jvm tests pass; the Android target compiles. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
f42f4913c4 |
feat(proposals): a filter over those states, that a busy room cannot clear
`Loaded` gains the selection, the rows it selects and a count per state. The rows come from the selection and the numbers come from the room, on purpose: a chip reading its own count off the filtered list would say 0 for every filter but the one already chosen, which is the one number the reader does not need. Every state gets a chip, zero included. A row that gains and loses chips as sessions advance moves under the thumb of the person reading it -- and sessions advance while this screen is open, because someone else signing is exactly when a member comes to look. The selection lives on the view model and not only on the state drawn from it, which is the part worth the comment it carries. `observeSessionsForChatRoom` re-emits whenever any member's message moves any session in the room, and the collect block builds a whole new `Loaded` each time; one built with the field's default would snap the chips back to "all" mid-scroll, most often in the busiest rooms. Four of the seven view-model tests fail if that line goes, which was checked by removing it. `initialFilter` is threaded through the constructor and the factory so a caller can land on a filter -- the first emission is then already filtered, and the reader never sees the unfiltered list flash past. Nothing passes it yet. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
6a55889676 |
feat(proposals): name the four states a proposal can be in
The list screen asks "where has this got to" in four places -- the section split, the row's icon, that icon's description and its status line -- and each worked it out for itself from the stage and the approval timestamps. A filter over those states would have been a fifth derivation, and a fifth derivation is how a chip comes to count a proposal the row beneath it describes differently. So the question is asked once, on `Proposal`, and the four readers read it. The classification deliberately is not `FrostSigningStage`. The one state anybody opens this screen looking for -- waiting on me -- is not a stage at all: an open session waiting on this member and one waiting on everybody else are both COLLECTING_NONCES, and what separates them is `signApprovedAt` and `signDeclinedAt` being null. `awaitsYou` is tried first and wins; the stage decides only among the rest, exhaustively and with no `else`, so a stage added later fails to compile here rather than landing quietly in IN_PROGRESS. `statusOf` still switches on the stage, and has to: the three things it says about an open session -- you agreed, you declined, you were picked to sign -- are exactly the distinctions IN_PROGRESS collapses. Two behaviours are pinned rather than fixed, because both are parity with `isAwaitingApproval` and the signing screen gates its buttons on that: - a session whose proposal has not arrived yet classifies NEEDS_YOU, although the card says there is nothing in it to read; - a batch the group finished without this member is IN_PROGRESS until `advance` closes it, which is also what the row already said. The preview gains an in-progress and an abandoned sample, so the conformance sweep renders every icon and every status line in all six schemes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
daf8365a6e |
fix(frost): a resend names the whole room, because the p-tags are its identity
The resend narrowed its NIP-17 p-tags to the members it was for, on the reasoning that a wrap is sealed per recipient so repeating one for the whole room wastes wraps. Both halves of that were wrong. A receiver does not read the p-tags as a recipient list. It hashes them together with the sender to work out which room the payload belongs to -- `GiftWrapPayload.aggregatedParticipantsPublicKey`, via `ChatRoom.deriveChatRoomId`, which is what `GiftWrapSeal.decryptGiftWrapPayload` files an inbound payload under. Leave a member out and the id changes, so the resend is filed under a room that does not exist; `getOrCreateChatRoom` then mints that room rather than rejecting it. A repaired session would have become a phantom two-person conversation in the reader's list, and the session would have stayed stalled. There was no saving to trade against it either: `sealGiftWrapPayload` wraps for every participant of the room it looks up, not for the p-tags it was handed, so a narrowed payload cost exactly as many wraps as a full one. Who a resend is for travels in `frost_silent`, which is not part of that hash, so nothing is lost by naming everybody. Marmot was never affected -- a group event names nobody and is routed by its h-tag. The two tests that asserted the narrowing now assert the opposite, which is the property worth having: the p-tag set does not change between a publish and its repeat. The p-tags were the right thing to assert all along; they just mean something other than what they look like. Found while answering whether this is backwards compatible with older receivers. It is -- no new kind, an unknown tag that old builds ignore, and every duplicate-folding gate in `record` and `acceptProposal` predates this work. This bug was never a compatibility bug; it broke old and new receivers identically. 1279 tests, no failures. m3Audit: all budgets met. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
2edd05f3ca |
fix(frost): a broadcast that queued nothing records nothing
`broadcast` now says whether it queued anything, and `publishOwn` records the local copy only when it did. The copy is what stops `advance` from publishing that message again, so writing one for a message that never went out is a message the group waits on forever -- the exact opposite of the trade the queue-then-record order exists to make. The comment on `publishOwn` had that trade written down in one direction only. Reachable only through the id-collision guard added with the resend, which refuses after four tries rather than overwriting a sent row. Four consecutive seconds of the same message is not something a person with a button can do, but "unreachable" and "safe when reached" are different claims. Also brings the docs up to what was built: the resend note is in the index, the skipped-keys note points at it as the recovery for the failure it describes -- a new message is encrypted at a generation the receiver has not passed, which is the whole mechanism -- and the plan records the two things landing it turned up, plus `ask_again` being reused from the catalogue rather than duplicated. 1279 tests, no failures. m3Audit: all budgets met. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
aee19737f6 |
feat(frost): the knock, under the list of doors it is for
The resend gets its affordance on the signing screen, below the member list and above the approval block. The list is already the screen's answer to whose door to knock on; this is the knock. Coordinator only, and the state says why rather than leaving it to the button: `acceptProposal` takes a session's coordinator from the author of the proposal that opened it, so a resend from anybody else would have a member who was missing the session believe the resender coordinates -- and then drop the real coordinator's signer set. `silent` is derived on the UI state rather than collected. Everything it is made of is already there -- the share holders, who offered a nonce, who signed, who refused -- and a second flow would be a second thing that can disagree with the rows the screen draws. A member who refused is not silent: they answered. The cooldown disables the button rather than hiding the section, because a control that vanishes after a tap reads as one that failed, and what happened is that it worked. `resend` hands back whether anything went out, so the snackbar says which: asked again, or everyone has since answered and there was nobody left to ask. The transcript line gets its own icon. A resend must not read as a second proposal, which is the one thing a session can never have -- two proposals under one session id would be asking for two signatures out of one secret nonce. `ask_again` already existed in the catalogue for re-querying a list's relays and means exactly this, so it is reused rather than duplicated. m3Audit: all budgets met. jvmTest: 1260 tests, no failures. Plan: docs/frost-session-resend.md, Phases 5-7. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
01e022fdcc |
feat(frost): a proposer can resend a signing session
A session can sit in COLLECTING_NONCES forever waiting on a member who would have agreed, because the message asking them never arrived. MLS moved its ratchet past the generation it came in at, which is terminal at the receiver and invisible to the sender (docs/mls-skipped-keys.md); or a disappearing-message group expired it off the relay; or the member joined the room after the proposal was made, holding a share from an earlier ceremony. None of them heals on its own, and nothing asked the sender to resend. `FrostSigningManager.resend` repeats what the coordinator wrote -- the proposal, and whichever of the signer set or the signature the stage has reached. A resent message is a *new* message: new created_at, new id, encrypted at a generation the receiver has not passed, carrying a fresh expiry. That is why it works where the first copy did not. Two and never three. Publishing in bursts is what the skipped-keys bug feeds on, and a recovery for it that re-creates it is no recovery, so the stage table is a minimum rather than "send everything". The resent proposal names the members the coordinator has heard nothing from, and a named device republishes what *it* already sent -- the stored bytes, under its own key. That is the only half that can repair a nonce lost on the way *to* the coordinator: `advance` republishes a message it has no local copy of, so a device that published and recorded its nonce would never send it again. It publishes nothing new, so a nudge cannot talk a device into putting its share behind events its owner has not approved. Coordinator-only, both halves, and that is correctness rather than etiquette: `acceptProposal` takes coordinatorPublicKey from the proposal's author, so a non-coordinator resending to a member with no session row would have that member drop the real coordinator's signer set. Also fixes a bug `broadcast` had all along. An outbound row's primary key is a hash over its created_at, stored to the second, so a message re-published inside that second hashes to the id of the copy it repeats -- and the upsert put an already-sent row back on the queue with marmotGroupEventId cleared, double-sending it and losing its mapping to the group event it became. It now steps past a taken id rather than writing over it, and refuses after four tries. Schema 24 -> 25 for FrostSigningSession.resentAt, which is the cooldown and the second line of defence on that collision. Phase 4's column, pulled forward because Phase 2 needs it. Plan: docs/frost-session-resend.md, Phases 2-4. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
7bc00af304 |
feat(frost): a tag naming the members a resend is for
A proposer can resend what the proposer wrote and nothing else. A nonce or a refusal relayed by somebody else is filed under the relayer -- `record` keys a signer's message on the inner event's own pubkey -- and for a refusal that is a way to manufacture one, which in an n-of-n group abandons a session nobody refused. So a resent proposal names the quiet members instead, and their own devices republish what they already said, under the keys that said it. This is the tag that names them: `frost_silent`, all-or-nothing like `frost_signers`, because a list naming the wrong people is worse than no list at all. Additive on the wire. A build that does not know the tag ignores it and accepts the proposal it rides on, which is the half of a resend that fixes the common case -- a member who never saw the proposal because MLS dropped the generation it arrived at (docs/mls-skipped-keys.md) or a disappearing-message group expired it off the relay. Plan: docs/frost-session-resend.md, Phase 1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
b9140c6a27 |
fix(ios): build ktor clients on Darwin so wss/https work on a device
CIO has no TLS implementation on kotlin/native, so every secure connection died at the handshake with "TLS sessions are not supported on Native platform". Pick the engine per platform -- CIO on android and the desktop jvm, Darwin on ios -- and pin both the relay socket client and coil's image fetcher to it. |
||
|
|
987df2c8f6 |
feat(ios): declare publish cancellation and the Room constructor to swift
@Throws(CancellationException) on the publish path so swift sees a cancellation as one, @ConstructedBy so Room can build the database on ios, an unused import out of Platform.ios.kt, and the development TEAM_ID for signing. |
||
|
|
79ff9ee1fc |
fix(chat): the detail pane's view models are the selected room's, not the first one's
In an expanded window the transcript beside the room list showed the first room opened and stayed there: pick another room and the list moved on while the pane did not. HomeScreen wraps the pane in key(chatRoomId), which rebuilds the composition when the selection changes, but viewModel() does not read composition keys. It scopes to the nearest ViewModelStoreOwner, and in the pane that is the home destination's one back stack entry for every room, so the second room's viewModel(factory = ...) got the first room's ChatRoomMessagingViewModel and ChatMessageListViewModel back with its factory ignored. A phone never showed it because a pushed room is its own entry with its own store. The pane now provides LocalViewModelStoreOwner with rememberViewModelStoreOwner() under the room key: a store per room, cleared when the selection moves on, and parked in the home entry's store so that it survives a rotation. Keying the two viewModel() calls on the room would have unstuck the pane too, at the price of keeping every room ever opened -- four DB collectors each -- in the home entry's store for as long as the home screen lives. ChatPaneSelectionJvmTest opens two rooms and comes back to the first, told apart by what was said in them since a name is on the row as well as the bar; its third case checks the room left behind stops collecting, which is the case the keyed alternative fails. The conformance doc's account of the hand-built pair records the trap. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
30685924db |
feat(curated): the date field type, and an unknown type is kept aside rather than dropped
CuratedFieldType had no `date`, so a schema declaring one lost the field at parse: entries were read without it, the accept flow copied a suggestion into a canonical entry without it, validation never asked for it, and the entry published cleanly -- and was refused by every client that did know the type, for the required field it lacked. Fourteen of bitcoin.necropolis.report's entries went out that way without a `died`. `Date` is the NIP's tenth type: `YYYY`, `YYYY-MM` or `YYYY-MM-DD`, at whatever precision the record allows, with `min` and `max` bounding the year. `CuratedDate.parse` is the check -- month 1-12, day on the calendar for that month and year, leap days included -- and the value is kept as written. `checkValue` returns early the way the numeric branch does, so `max` is a year and never a length cap. The value is not numeric, so `isNumeric` stays false; `isBounded` is what the editor keys its min/max inputs off instead, labelled as years for a date. The root failure was wider than one type: any type this build does not know was dropped the same way. A `field` tag of an unknown type is now kept aside as CuratedUnsupportedField, the way CuratedFieldConfig.others keeps unknown config keys. Reading is unchanged -- an entry is checked against the fields a reader understands, which is the NIP's tolerance -- but the accept flow refuses to propose under a required one, naming the type, and the schema editor carries it through an edit and writes it back as it came, so re-signing a list here cannot change its rules unseen. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
984db0a180 |
Merge branch 'curated' into claude/quartz-1-15-2-compat-c8267f
Both sides had taken schema version 21: curated for the nullable FrostSigningSession.signDeclinedAt (one refusal takes a member out of the n), this branch for the Marmot current profile's three columns, with 22 and 23 behind it for the routing table and the publish obligations. Curated keeps 21. This branch's three migrations move up one -- 21->22, 22->23, 23->24 -- and the database is at 24; the comment on 22 says they moved and why. The exported schemas for 22 and 23 could not be hand-edited, since each is a snapshot of the whole entity set with an identity hash over it, and could not be produced from the merged tree, which only exports its own version. So each was regenerated the way the originals were: the tree of the commit that introduced it (Phase 3 for 22, Phase 4 for 23), with curated's entity change and its 21.json dropped in, the version bumped, and KSP run. The result is what a device on curated's 21 migrates through: 22 adds the three columns and nothing else, 23 adds MarmotRouting, 24 adds MarmotPublishObligation and MarmotOutboundGate together with MarmotCommitResult.obligationId, and every one of them carries signDeclinedAt. 24.json is the merged tree's own export. Everything else merged itself: ChatMessage's kinds and line types, the transcript's icons, the strings, the nav host. Full jvmTest 1220 green, Android debug compile, M3 audit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
9b404e2035 |
fix(frost): the signing screen lists the key's share holders, not the room
The members list on "Sign with the group's key" was the room's roster, and a room is not the set that can sign with its key. A member invited after the ceremony holds no share: the proposal they receive is dropped before it becomes a session on their device, and no nonce or refusal of theirs would count. The screen drew them a row anyway, in a list whose whole purpose is to say whose door to knock on. The list is now the ceremony's share holders -- the members who put a host key into it, read off DkgParticipantMessage through the new FrostSigningRepository.observeShareHolders. That is the same set FrostSigningManager places signer ids over, so what the screen lists cannot disagree with whose messages the session counts, and a ceremony cannot complete without every participant's host key, so for a completed one it is the whole participant set. Names still come off the room, in the room's order; a share holder the room no longer holds keeps a placeholder row, since their share did not leave with them. The view model follows the session to its ceremony with flatMapLatest, and the list is empty until the ceremony has been read rather than falling back to the room -- a fallback would flash everybody and then correct itself. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
a7f3917e65 |
fix(frost): one refusal takes a member out of the n; it takes n - t + 1 to abandon
"Don't sign" ended the session for everybody: decline() failed it locally and broadcast a FAILURE, which every other device failed on arrival. In a group whose whole reason for running a ceremony was that no one member is needed, one member's no was everybody's. A refusal is now its own kind, DECLINE (30330), and one FrostSignerMessage per member, like a nonce. Every device counts the refusals it has received from ceremony participants against the same arithmetic -- FrostSigningSession. declinesThatAbandon(), which is n - t + 1 -- and fails the session only on the refusal that leaves fewer than t who could still sign. Nobody broadcasts the abandonment, because nobody has to: each device reaches it the way each writes its own transcript, and a FAILURE sent to say so would blame one member for the group's arithmetic. In a 2-of-3 group the first refusal changes nothing the other two can do; the second ends it. FAILURE keeps meaning abandon-and-blame, for the faults no quorum can work around, and a build predating the new kind still sends its refusals that way and is honoured as it always was. decline() takes approve()'s shape: the decision goes on the row, as the new nullable signDeclinedAt (Room v21, an AutoMigration), and advance() publishes it whenever the row says so and no copy is on file -- so a device killed between deciding and sending says it on the next message rather than never. A member who refused is not asked again, but the session stays open around them and closes when the group's signature arrives. Refusals from a member holding no share of the key are turned away at the door. fail() now leaves a COMPLETE session alone. A member who refused before their device had seen the signature has refused something that no longer needed them, and a late FAILURE used to flip a signed session to failed. The transcript gets a TYPE_FROST_DECLINED line for a refusal the session survives, with the count -- "declined to sign. It takes 2 of 3 members, and 2 could still sign." -- and the tipping refusal is written as the FAILED line in that member's name, saying both that they declined and that it was the one that ended it. A reader's own refusal settles their request line, and only theirs; nothing earns a tick. The signing screen marks who declined and says how many could still sign, and the proposal list says "You declined." where it said "You agreed." Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
de5b2bd4a6 |
docs(marmot): the v2 plan is built -- where the build chose differently, and where the rollout stands (v2 Phase 9)
docs/marmot-v2.md, Phase 9. The phase has no code in it; it is the rollout, and the rollout is a flip and a retirement that wait on the people this app's users invite. What the phase owes the document is the repo's convention for a plan that has been built: the status paragraph, the table of where the implementation chose differently, the thing found on the way that belongs to nobody's phase, and the commit the account was written against. All four are here now, and the phases themselves are kept as written, because they are the reasoning and the code reads better against the argument it came from than against a summary of itself. The table has twenty-two rows, and the first is the one to read before any of the code: the plan said the library's engine replaces the app's pipeline, and the build made a room's profile pick its pipeline instead -- legacy rooms keep the app's path, comparator and cache included, and retire with the profile; current-profile rooms go through `MarmotEngine`. The library's processor has no carve-out for the bare gift wrap a legacy direct message is carried in, so under it every one of those would have stopped decrypting, and the legacy pipeline is frozen anyway. Most of the other rows follow from that one: one store rather than four, no message-id column, the rotation manager constructed and unused, the engine hanging off the database rather than an identity's scope. The rest record the smaller turns -- the envelope's kind, the chronicle cap measured escaped, the KeyPackage not last-resort, the admin refused before a leave is attempted, captions from the participants diff rather than a snapshot column, no rename, the two non-chat kinds only, the four Phase 8 scenarios spread over four tests -- and the three follow-ups that closed lines the phases' own commits had missed: the outbound hold while a pass is open, the rejected commit discarded, and the 1210/1009 bubbles. The thing found on the way is quartz 1.15.2's: its convergence rebuilds a candidate branch by replaying its commits against the retained parent, and a member cannot replay a commit it authored, so a fork this device is half of is scored with its own branch stale and two committers swap branches rather than agree. Every device that only observed still agrees, which is the case the app depends on and the first fork test holds; the second pins the swap and says what to do the day it fails. The paragraph says the practical exposure is small and why, and that the Phase 5 follow-up on withdrawing a losing branch's rows waits on the same fix. Phase 9's own section gains "Where it stands": everything ships built and unflipped -- `DEFAULT_FOR_NEW_ROOMS` is legacy, both slots are published, no room is on the current profile unless a caller asked by name -- so the first of the three one-way doors is behind us and the other two wait on the flip. The README's row and reading-order paragraph now say the plan has been built and point at the table's first and last rows. One code change, a comment: the plan's Phase 5 asked that the two library gaps the rewrite does not close -- the retained-epoch decrypt without sender verification, and the skipped keys that do not survive `saveState` -- be said where the new code is, rather than let the rewrite look like it closed them. `MarmotEngine`'s class doc now says both. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
2bbe1fc9bc |
feat(marmot): a commit every relay refuses is discarded, and the room is free again
docs/marmot-v2.md, Phase 6: "a terminal rejection resolves FAILED, discarding the pending state with the live group already correct." The phase's commit built the CONFIRMED half and left every other outcome pending, on the grounds that the broadcast queue reported a timeout and a relay's refusal the same way -- both were "failed" -- and a timeout must stay pending, since its retry re-sends the same bytes and may yet be accepted. The cost of that was a room whose commit a relay refused outright: its obligation never resolved, `canPrepareLocalCommit` stayed false, and every later invite, removal or disband was refused with "try again in a moment" for as long as the room existed. The refusal was re-sent on every launch and refused again. The two are distinguishable, and now are. `RelayPool` already surfaces an `["OK", id, false, reason]` as a `NostrPublishException` carrying the relay's reason, apart from socket errors and timeouts; `BroadcastStatus.of(error)` turns that into a status. A reason a relay will keep giving -- `blocked:`, `invalid:`, `pow:`, `restricted:` -- is the new "rejected", which the requeue on launch leaves alone: the same bytes to the same relay get the same answer. A `rate-limited:` or `error:` refusal is "failed" like a timeout, because those change. And a `duplicate:` refusal is "published": the relay is saying it has the event, which is what published means, and it is the answer a byte-identical retry gets from a relay that took the first copy. The four statuses that were string literals across the sync pump, the navigation gate and the DAO are named on the same object. `DatabaseNostrRepository.broadcastProcessed` gains the relay's reason and a "rejected" branch. One relay's refusal decides nothing -- another may still accept, and a timeout on another is retried -- so the obligation is discarded only when every request row for the event is "rejected": `MarmotEngine.discardRejected` resolves it FAILED, the gate drops the clone, the live group having never advanced, and the room can prepare a commit again. Nothing is told to convergence, since a commit no relay carries is not a branch any member will see. The room says what happened, in the relay's words, because the screen that asked closed when the commit was made: an invite gets the existing `TYPE_MEMBER_INVITE_FAILED` line, and a removal or a disband step gets a new `TYPE_CHANGE_REJECTED` line, since the caption written when it was asked for would otherwise stand uncorrected. `PublishBeforeApplyJvmTest` gains the plan's third case: with a two-relay scope, one refusal leaves the obligation, a timeout on the other leaves it, the other's refusal discards it -- epoch unchanged, the peer not a member, the line naming the reason -- and the same peer can be invited again. 1187 tests green, Android debug compile, M3 audit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
0b3780c604 |
feat(marmot): nothing goes out against a state that may lose
docs/marmot-v2.md, Phase 5, the last line of "Welcome and outbound", which the phase's commit left out: before encrypting or committing, read `convergenceStatus(groupId).allowsOutboundWork`. While a convergence pass is open the room's canonical state is provisional -- two members committed against the same epoch and the pass has not picked between them -- and a message keyed under the branch that loses is one no peer will ever read, while a commit against it makes a three-way fork out of a two-way one. The library defines the flag and nothing in it reads it; the app is where the outbound work is, so the app reads it. `MarmotEngine.awaitSettled(routingId)` is the read. It is a short wait rather than a refusal because a pass settles at the quiescence window -- one quiet second, five at the outside -- so a caller that waits gets its work done in order, whereas one that threw would hand its row back to a queue that re-emits only when its table changes, which a pass settling does not do. The wait ticks `settleDueConvergence` itself rather than relying on `settleLater` having been armed, and gives up after three ticks with `MarmotConvergencePendingException`, whose message the add-member screen shows like the other two refusals; the bound is short because most of the callers hold a Room transaction while they wait. Five callers: the message send in `encryptAndSendMarmotInnerEvent` (the current-profile branch; a legacy room has no convergence to wait for), the invite past the founding Add, `publishGatedCommit` (so removal and both disband steps), and `leave`, each after the publish gate's own check and before the manager stages anything. The observer fork test now settles the app's side through `awaitSettled` instead of resolving it directly -- asserting outbound work is refused before and allowed after -- and finishes with what settling is for: a message the app sends once settled is an `ApplicationMessage` on Dana's side. 1186 tests green, Android debug compile, M3 audit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
437fd3e18b |
fix(marmot): a received kind:1210 or kind:1009 is not a bubble
docs/marmot-v2.md, Phase 7, the line the phase's commit missed: "a received kind:1210 or kind:1009 gets no bubble". Both are kinds the current profile defines as not-chat. A 1210 is a group system row -- member added, member left -- and the profile is explicit that one arriving over the wire is one member's assertion rather than a fact; this device derives its own from the commit it applied (`TYPE_MEMBER_ADDED` and its siblings, written by `processGroupMembershipChanges`), so the received one adds nothing it can trust. A 1009 is an in-place edit, which the app does not apply. Until now either fell off the end of `applyInnerEvent`'s `when` into `unsupported()`, which is the raw-JSON bubble, so a White Noise member leaving a room would have put their client's system row into the transcript as a block of JSON under the caption this device wrote for the same fact. Both kinds now return null: no line. The bubble stays for every other unknown kind, which is narrower than the plan's "neither does any other unknown kind". Two reasons. The `TextNoteEvent` arm reaches `unsupported()` deliberately -- a kind:1 the room did not sign is a member's own note travelling through the room and has always rendered as this -- and the bubble is the only trace an unrecognised payload leaves; retiring it would make the next new kind a silent drop, which is the failure mode the chronicle note complains about from the other side. The Phase 9 table records the narrowing. `MarmotSystemRowJvmTest` holds both: the two kinds make no row, and kind 31337 is still the bubble. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
c4a46e892f |
feat(marmot): leaving, removal, disbanding, and captions derived from the state (v2 Phase 7)
The lifecycle of a current-profile room, through the publish gate. docs/marmot-v2.md, Phase 7. Leaving used to be a local flag and a "Left group" chat line: the group never learned of it, and the leaf stayed in the tree holding the group's keys. A current-profile room is now left the way v2 leaves: a standalone SelfRemove proposal on the wire as a kind:445, the LEAVING gate raised first and durably, the local state dropped, the room closed on this device with its own line. It is not a commit, so it waits on no relay -- there is no state of ours it would make canonical. An admin's device that receives the proposal commits it on receipt, as the library expects, so a leaver is out of the tree without anyone pressing anything; the commit goes through the gate like every other. The library refuses a SelfRemove from an admin outright -- an admin self-demotes first -- so an admin's leave is refused here before anything is raised or dropped, in words a person can act on: hand over admin, or, for the only admin, disband. Legacy rooms leave the way they always did. An admin removes a member with stageRemoveMember through the gate; the library's admin-depletion guard refuses a commit that would leave no admin. An admin disbands with stageEnableDisbanding and stageDisband -- two commits when the group predates the lifecycle component, one otherwise -- under the DISBANDING gate, which is durable so a crash between raising it and publishing does not lose the request; the second step is taken by continueDisband when the first is accepted. Both are on the room detail screen, for a device that administers a current-profile room: a remove action on every member row but its own, and a disband button beside leave, with an explainer that says nobody rejoins. A disbanded room says so and hides every write entrance. The captions are derived, never received. v2 spells them as kind-1210 system rows and is explicit that a row arriving over the wire is one member's assertion, not a fact; here they are written by processGroupMembershipChanges from the difference between the room's members before a commit and after it -- "X joined the group", "X left the group", "The group was disbanded", "You were removed from the group" -- on every device that applies the commit, including the one that made it, which is why an admin's own removal no longer writes a line of its own: every device says the same thing at the same point. A commit that removed our own leaf, or disbanded the group, closes the room here as well. A commit this device made is applied at the relay's OK, where the room now follows the state it gained. MarmotCommitResult.NO_INVITEE marks a commit that invites nobody, so the OK sends no Welcome for it. Tests: GroupLifecycleJvmTest, with quartz's own managers standing in for the other member, covers an admin committing a member's leave on receipt and the room saying they left; a removal applied on both sides once the commit lands; a disband ending the group for everyone, closing the room and refusing what follows; an admin's leave refused with its reason; and a member's leave sending the proposal the other side stages, dropping the state and closing the room. The stand-in is now one fixture, MarmotStandIn, shared with the interop test. Full JVM suite: 1,182 tests pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
f617560cf9 |
feat(marmot): publish before apply (v2 Phase 6)
A commit this device makes into an established current-profile room is no longer applied and then broadcast. It is prepared on a clone by the manager, recorded as a durable obligation before anything is broadcast, sent, and installed only when a relay in its scope accepts it. docs/marmot-v2.md, Phase 6. The library's gate explains why apply-and-roll-back is not the same thing: between applying a local commit and undoing it on failure there is a window in which this client's canonical state is an epoch no peer has, and a crash inside it makes the fork permanent. Recording the obligation before the broadcast closes the mirror-image window -- a commit peers accepted that this device has no memory of preparing, and would mint a replacement for at the next start. Two new tables (schema 22 -> 23), MarmotPublishObligation and MarmotOutboundGate, back RoomPublishObligationStore; MarmotEngine holds a MarmotPublishGate over it and restores it after the groups. MarmotCommitResult -- the row that already held a commit's Welcome until the relay's OK -- carries the obligation id, and DatabaseNostrRepository.broadcastProcessed resolves it on "published" through MarmotEngine.confirmPublished, which installs the pending state, tells convergence of the commit we authored (without which a peer's competing commit would look like an orphan rather than a fork we are half of), and only then lets the Welcome go out: the MIP-02 ordering enforced by sequence rather than by hope. A second OK for the same event from another relay finds no obligation and changes nothing. The founding Add keeps its exception. A group that is only its creator has no peer a failure to publish could fork, so it installs at once -- the library's satisfyEmptyObligation draws the same line, "creation and its immediately following founding Add, never a later commit". While an obligation is pending the room cannot prepare another commit: a second invite is refused with MarmotCommitPendingException, shown as itself on the confirmation screen, rather than forked; the membership note's batching closed the race inside one invite, and this closes it between invites. The broadcast queue's requeue re-sends the same signed event, which is the byte-identical retry the rule demands, and a "failed" from the pump -- a timeout or a relay's refusal, which the pump does not tell apart -- leaves the obligation pending rather than discarding a state some relay may have taken. Legacy rooms are unchanged. Tests: PublishBeforeApplyJvmTest pins the founding Add installing at once, a later commit prepared and queued but not applied, the second Welcome held back, a concurrent invite refused, the OK installing the state and queueing the Welcome, a second OK changing nothing, and an obligation restored by an engine rebuilt over the same database and installed by a late OK. Full JVM suite: 1,177 tests pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
8e1037dff1 |
feat(marmot): the library's engine over Room, for current-profile rooms (v2 Phase 5)
A current-profile room is now read and written by quartz's own managers: MlsGroupManager holds its live group and persists through a store over the app's tables, MarmotInboundProcessor reads its kind:445s -- settling same-epoch commits through the convergence engine and recognising redelivery by the Marmot message id -- and MarmotOutboundProcessor builds the ones this device sends. Everything in docs/marmot-v2.md's "v2 says" column that is not a wire shape lives in those three, and the app no longer carries its own copy of their logic for these rooms. Where the build chose differently from the plan: **a room's profile picks its pipeline**. The plan had one engine for every room. Two things stood against that once the code was open. The library's processor has no carve-out for the bare gift wrap a legacy room carries a direct message in -- it would refuse every legacy DM as an author that is not the sender -- and the manager's installState declines a state whose group context matches the live one, so a legacy path that mutates the manager's instance and then asks it to persist would persist nothing, while its own retained-epoch list would drift from the manager's. So legacy rooms keep MarmotInboundManager over MlsGroupCache, unchanged, and retire with it; current-profile rooms go through MarmotEngine. A room is on one profile for life, so the two never hold the same group, which is what keeps the manager's live instance the single writer of a current-profile room's state. For the same reason the library's KeyPackage rotation manager is constructed but not fed: Welcomes are matched to this device's bundles by the app's own profile-aware table, by reference, and the processor reads the rotation manager only on its own Welcome path. The vendored CommitOrdering therefore stays, for legacy rooms. RoomMlsGroupStateStore resolves the library's key -- the routing address -- through MarmotRouting to the room, keeps the state in ChatRoom.mlsGroupState as before, and keeps the retained epochs as MarmotRetainedEpochSecret rows, which until now were written by the outbound path and read back by nothing: every epoch the inbound path retained was a map in an object, gone at the next launch. The engine is owned by the database (CurareDatabase.marmotEngine), because the DAOs that need it are made by Room from that instance and can be handed nothing else; it restores every group once, seeds convergence with each, and loads a room made or joined later from its row on first ask. Inbound, NostrDao.indexMarmotGroupEvent branches on ChatRoom.marmotProfile() -- read off the stored state's group context without rebuilding the group -- and the result handling every kind:445 shares (membership changes, the chat line, the signing and ceremony dispatch) is one function for both pipelines. The processor names the group by its address; the result is re-addressed to the room once. A pass a commit opened is driven to its cutoff by a ticking coroutine, since a quiet group has nothing else to drive it. Outbound, an application message in a current-profile room is built by the outbound processor over the engine's group, and an invite or batched add is staged on a clone by the manager and installed at once -- retained, persisted -- with the callers' own state writes skipped for these rooms; installing on a relay's OK rather than at once is what Phase 6 changes. A reindex closes the room's open convergence pass before replaying. Tests: CurrentProfileInteropJvmTest puts two implementations in one group -- the app's engine over a CurareDatabase and a bare library stand-in playing Amethyst -- and has the stand-in invite the app through a gift-wrapped Welcome, messages cross in both directions (the app's read by the stand-in as a canonical payload), a commit from the other side move the room's membership and epoch, and a second engine over the same database read a message from the epoch before that commit -- the case the old pipeline could not pass. RoomMlsGroupStateStoreJvmTest pins the store's contract. Full JVM suite: 1,175 tests pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
9b5e4c95fc |
feat(marmot): current-profile rooms, and a routing address apart from the room id (v2 Phase 4)
After this the app can create rooms on the current profile -- behind MarmotProfile.DEFAULT_FOR_NEW_ROOMS, which stays legacy until the rollout flips it -- and every path keyed on the `h` tag reads the room through its address. docs/marmot-v2.md, Phase 4. The room's id is a key. A room built around a threshold key is keyed on the id derived from that key -- the one it signs as and every chronicle is verified against -- and every member can compute it unaided. v2's routing component says of `nostr_group_id` the opposite: random, never derived from any public key, because a derivable address lets a relay link a group's traffic to the identity behind it, which here is the key that authors the group's published entries. Both are right about their own value, so they are two values now. A new MarmotRouting table (schema 21 -> 22) maps an address to its room; a current-profile room this app creates mints a random one, and every other room -- legacy, or made by another client -- has a row whose address is its own id, or no row at all and is addressed by its own id, which every reader falls back to. The inbound ingest, the reindex, the negentropy answer for a `#h` filter, the chat list's sync request and the live subscriptions all resolve or emit addresses; LocalChatRoom carries its routings as a relation so the subscription planner needs no query; the outbound commit, application and Welcome templates are stamped with the room's address rather than its id. A joiner keys a room on the group's `nostr_group_id`, which for a current-profile room would be the address, and the creator, the joiner's own DKG session and every chronicle know the room by its derived id. The components carry no field for it, so it rides in the group profile's description as one line -- `Room id: <hex>` -- the way the derivation path already does, and MlsGroup.roomId() reads it back first. It is a claim by the creator, exactly as the legacy `nostr_group_id` was, and is trusted no further. MarmotGroupFactory is now the one place a group is minted. The three sites -- a direct message, the convenient room, and the derived room MarmotGroupCreation builds -- say what the room is, and the factory decides the profile: a legacy group is the 0xF2EE extension as before; a current-profile group is quartz's own CurrentProfileGroupFactory with the admin policy, routing, profile and the creator's proof-bearing leaf, and no 0xF2EE at all, because RFC 9420 requires every member to support every GroupContext extension and an MDK leaf does not advertise it. Creating a direct-message room reads the identity from the chat repository, which now takes it, so the creator's leaf can carry its proof. A peer's KeyPackage is picked by the room's profile rather than by age: a current-profile room takes the newest current-profile package or none, since the legacy package is deliberately the newest a peer publishes. A leaf on the wrong profile is refused a step before the library refuses it, with a reason the member can act on -- their package is from an older profile -- shown on the confirmation screen and in the room's line rather than as "try again". Tests: MarmotGroupFactoryJvmTest pins both profiles' shapes, the address minted apart from the room id, the room id riding in the description, the read-only creator refused on the current profile, and which leaves fit which groups; MarmotGroupCreationJvmTest adds a current-profile room keeping its derived id with a routing row, a legacy room unchanged, and a kind:445 under the address filed in the room; MarmotRoomIdentityTest the description line; LiveSubscriptionPlanTest the addresses watched. Full JVM suite: 1,166 pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
99dba546d8 |
feat(marmot): identity proofs and the current-profile KeyPackage (v2 Phase 3)
After this a peer on Amethyst 1.15.2 or White Noise can add this app's users to their current-profile groups, and the app joins. docs/marmot-v2.md, Phase 3. A current-profile leaf carries an app data dictionary with three components: the component ids it supports, an explicitly empty safe_aad list, and the 104-byte account identity proof -- the account's Nostr key signing a kind-450 template that is never published and names this leaf's own Ed25519 signature key. MLS never checked that the account in a credential agreed to the signature key beside it; the proof is what makes a leaf unforgeable, and a current-profile group refuses a leaf without one at add time. Only the account signer can make it, and it has to exist before the leaf is built, so publishMarmotKeyPackageBundle now takes the KeyPair rather than the public key it used to. The current-profile package comes from quartz's own CurrentProfileGroupFactory -- the same leaf shape Amethyst publishes, including the agent-text-stream component the reference client requires of every leaf it invites -- and its kind:30443 from KeyPackageEvent.buildCurrentProfileFrom: framed content, the 0x0006 extension, the 0x0008 and 0x000a proposals, an app_components tag, no encoding and no relays tag. KeyPackageUtils.isValid checks all of it, and the tests run that validator because it is the one a peer runs on ours. The legacy package is still published, in a second slot, for as long as builds that decode kind:30443 content as a bare KeyPackage are inviting people (Phase 9 retires it). It is stamped one second after the current-profile package, every time both are published: an inviter picks a peer's newest package by created_at, and an old build then fails on a framed one, so the legacy package has to stay the newest. Each profile now has a slot whose d-tag is minted once and reused on every rotation, so a replacement supersedes the previous event on relays instead of accumulating beside it -- the "TODO: Persist this" on the random d-tag. Schema 20 -> 21, an AutoMigration: MarmotKeyPackageBundle.profile and .dTag, and MarmotKeyPackage.profile filled at ingest from KeyPackageEvent.isCurrentProfile(). Rows from before read back null, which every reader takes as legacy. The notary keeps one publishable bundle per profile rather than any bundle at all, because a current-profile peer consumes only the current-profile package and the legacy one still being active would otherwise mean nothing was republished for them. The key-package screen takes the identity, not just its public key, and refuses to publish for one that cannot sign rather than reporting "published". KeyPackages now also go to the account's NIP-65 write set, unioned with the default DM relays -- transports/nostr.md has a conformant peer look there and nowhere else, "there is no dedicated KeyPackage relay list" -- and the member and peer sync requests ask for kind 10002 alongside the legacy 10051 hint. Tests: CurrentProfileKeyPackageJvmTest pins one package per profile with the legacy one a second later, both passing the peer's validator, the proof binding the leaf to the account, a rotation reusing its slot, and the join: a group made by quartz's own factory standing in for Amethyst adds the app's package, the Welcome arrives as a NIP-59 gift wrap through the sync funnel, and the app lands in a room keyed by the routing id from the 0x8004 component with the inviter as admin. The npub round-trip test now waits for both bundles. Full JVM suite: 1,153 tests pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
3cdce6a908 |
feat(marmot): send the canonical app payload, and an envelope for direct messages (v2 Phase 2)
What goes into MLS is now the Marmot app event the spec defines: six members and no `sig`. The rumor serialised as an Event carried `"sig":""`, which a conformant decoder refuses outright -- a payload with a signature would be a standalone relay event, republishable as a signed statement by its author. The id does not move, because NIP-01 never hashed the signature, so every row filed under an inner event's id stays valid; and the build already in the field reads the new shape, because Event.fromJsonOrNull defaults a missing signature. This switch alone needs no gating and is made everywhere at once. The `encoding` tag comes off the application kind:445 while here -- transports/nostr.md forbids it on every shape. docs/marmot-v2.md, Phase 2. A direct message could not make that switch as it was. Its payload is a NIP-59 wrap signed by a throwaway key, which a conformant peer refuses twice over: for the sig member and for an author that is not the MLS sender. In a current-profile room the wrap now travels inside an envelope -- an unsigned app event of kind 30330 authored by the sender, one `p` tag for the recipient, the wrap's JSON as content. The envelope passes the author check like any payload, so the carve-out in mip03Rejection that admitted bare wraps is confined to legacy rooms by a new `legacyRoom` flag: in a current-profile room a bare kind:1059 is refused as every other conformant client refuses it. Every property the throwaway key was chosen for survives -- the envelope is unsigned and so a claim rather than a proof, the wrap inside is still signed by nobody, and the seal-to-leaf binding in classify still decides who wrote the words. The line for a message this device cannot read now hangs off the row the payload was filed under (the envelope's id in a current-profile room), which ChatMessage's foreign key requires. The envelope is gated, and the gate is the room's profile: an old build renders it as a raw-JSON bubble, so a legacy room keeps sending the bare wrap, and a current-profile room -- which admits only leaves carrying an identity proof, which only a build past Phase 3 can make -- never holds an old build. That is the flag for every wire change after this one. A conformant decoder bounds the whole app payload at 64 KiB, and a chronicle page rides inside one as JSON-escaped content. The new bounds test caught what the arithmetic missed: dense JSON payloads escape to half again their size, so a 48 KiB page became a 70 KiB app event. The packer now measures a page by ChronicleEvent.escapedByteSize -- the bytes it will occupy inside the envelope -- against MAX_PAGE_BYTES, lowered from 64 to 48 KiB, and MAX_PAGE_EVENTS drops from 128 to 96 so the count cap still binds under it, as the comment on the two caps insists. The receiver's raw-bytes check is unchanged and now holds by construction. Tests: MarmotMip03CarveOutTest becomes the test that the exemption is confined to legacy rooms and that an envelope passes the ordinary check; MarmotDirectMessageTest round-trips the envelope through the strict decoder and opens the wrap inside; MarmotPayloadBoundsTest asserts the largest chronicle pages and an envelope are conformant app events, including the dense-content page measured the way the packer measures it. The ingest test's tamper case flips a decoded byte rather than the base64 tail, which could change nothing but padding. Full JVM suite: 1,148 tests pass. The direct-message and chronicle notes record the changes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
a68cad06a4 |
feat(marmot): read both Marmot profiles (v2 Phase 1)
After this the app can be a member of a current-profile group and can invite a current-profile peer -- an Amethyst 1.15.2 user -- into one of its own legacy rooms. Nothing it sends changes. docs/marmot-v2.md, Phase 1. Seventeen sites read `currentMarmotData()`, which is the legacy 0xF2EE extension and is null on a current-profile group: ten for the room id, and the Welcome path threw MarmotMissingNostrGroupDataExtension on that null, so a v2 Welcome was not a room the app could not read but an exception it could not get past. The others read the admins -- SubgroupManager's "only an admin can make a subgroup" and processGroupMembershipChanges' adminAt stamp both saw no admins at all on a v2 group -- the relays, the name and the retention. MlsGroupProfile.kt writes the fallback once per field (current profile first, 0xF2EE second) and the sites read roomId(), roomName(), roomDescription(), roomRelays(), retentionSeconds() and the library's currentAdminIdentities(). The retention one is the bug the library's own outbound processor had: read only 0xF2EE and disappearing messages simply did not disappear in v2 groups. A current-profile kind:30443 frames its KeyPackage in an MLSMessage, and the invite decoded whatever the ingest stored as a bare KeyPackage, taking the frame's version and wire-format words for the package's own. The ingest now validates with KeyPackageUtils.isCryptographicallyValid -- the check a conformant peer runs on ours, covering tags, signature, lifetime and on the current profile the identity proof; nothing checked any of it before -- and stores the package bare, so MlsGroup.proposeAdd and every other consumer of the row read the same bytes whichever way it was published. The inbound author check decodes the canonical payload strictly first (MarmotAppEvent: six members, no sig, an id that rehashes) and falls back to Event.fromJsonOrNull only for the legacy rumor shape every build before Phase 2 sends. The fallback would accept the canonical shape too, but by defaulting the signature rather than checking anything. A Welcome is matched to this device's bundle by the KeyPackageRef the Welcome itself names, in RFC 9420 order, before the `e` tag is consulted: the tag is what the inviter thinks it used, and MDK stamps the id of a cached copy, so a peer who rotated while an inviter kept inviting from cache was unjoinable by the tag alone. WelcomeBundleMatch is pure and scans the handful of bundle rows rather than adding a column. The exception the tag-only path threw when the tag was missing has no caller left and goes. Tests: MarmotKeyPackageIngestJvmTest runs both published shapes through the sync funnel, invites a current-profile package into a legacy room and sees the member in the tree, and refuses a tampered package; WelcomeBundleMatchJvmTest picks the addressed bundle in either candidate order, none when none is ours, and survives an unreadable row; MarmotAppPayloadTest pins that the legacy rumor and its canonical form share an id, that the strict decoder refuses a sig member and a forged id, and that the fallback reads both. The KeyPackage test fixture's lifetime drops from 90 days to the app's own 30 because 1.15.2 caps it at 84 and the ingest now checks. Full JVM suite: 1,140 tests pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |