Commit Graph
705 Commits
Author SHA1 Message Date
Kgothatso NgakoandClaude Opus 5 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>
2026-09-14 08:09:54 +02:00
Kgothatso NgakoandClaude Opus 5 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>
2026-09-14 07:53:21 +02:00
Kgothatso NgakoandClaude Opus 5 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>
2026-09-14 07:37:29 +02:00
Kgothatso NgakoandClaude Opus 5 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>
2026-09-14 00:16:10 +02:00
Kgothatso NgakoandClaude Opus 5 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>
2026-09-14 00:12:52 +02:00
Kgothatso NgakoandClaude Opus 5 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>
2026-09-14 00:04:39 +02:00
Kgothatso NgakoandClaude Opus 5 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>
2026-09-13 23:59:18 +02:00
Kgothatso NgakoandClaude Opus 5 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>
2026-09-13 23:43:11 +02:00
Kgothatso NgakoandClaude Opus 5 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>
2026-09-13 23:27:40 +02:00
Kgothatso NgakoandClaude Opus 5 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>
2026-09-13 23:20:02 +02:00
Kgothatso NgakoandClaude Opus 5 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>
2026-09-13 23:03:52 +02:00
Kgothatso NgakoandClaude Opus 5 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>
2026-09-13 22:46:22 +02:00
Kgothatso NgakoandClaude Opus 5 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>
2026-09-13 22:32:30 +02:00
Kgothatso NgakoandClaude Opus 5 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>
2026-09-13 22:15:13 +02:00
Kgothatso NgakoandClaude Opus 5 96a0c81341 build(marmot): quartz 1.15.2, with the two things it broke (v2 Phase 0)
The bump to 1.15.2 -- the release that carries the Marmot current profile --
breaks the compile in exactly two places, and the rest of the ~130 quartz
symbols the app imports are untouched.

CommitOrdering is gone from the library. Its inbound processor now settles
same-epoch commits through a convergence engine and calls the old rule
superseded "and deliberately": created_at and the event id are both transport
metadata the sender chooses and MLS never authenticates, so a member could win
every race by backdating. The app's pipeline does not go through that
processor -- it drives MlsGroup itself -- so the rule is vendored unchanged into
managers/CommitOrdering.kt, with a header saying why the library dropped it,
until Phase 5 of docs/marmot-v2.md replaces the pipeline. NostrDao and
MarmotInboundManager only change their import.

GroupEventResult gained AppMessageOnCandidateBranch and RefusedByLifecycle, so
the exhaustive when in ChatMessage.fromGroupEventResult needs both. Neither is a
delivery -- the first is a payload that decrypted only on a losing fork, which
the library is explicit must not be rendered, the second is input a disbanded
or unrecoverable group refuses -- so both get no chat line, the same as a
duplicate. The app never constructs either today.

Verified rather than assumed: the two sources jars were diffed file by file
against the app's imports; all 1,128 JVM tests pass on 1.15.2; the rewritten
Curve25519 field arithmetic matches the RFC 8032 and RFC 7748 vectors bit for
bit (the app persists raw MLS private keys, so this mattered); the app's own
KeyPackages sit inside the new 84-day lifetime ceiling at 30 days; no new
EventFactory kind collides with the app's.

One-way door: MlsGroupState's blob goes from version 2 to version 4 and 1.14.0
has `require(version in 1..2)`, so a room re-persisted under this build cannot
be opened by the previous one again.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 22:04:41 +02:00
Kgothatso NgakoandClaude Opus 5 8e502aa857 feat(groups): a new curated schema starts from one of curare.to's templates
"Add schema" opened the editor on the two fields every list has and left the
member to build the rest. curare.to's /new page does it the other way round:
a "Start a list" picker of four shapes -- links & text, discussion, catalogue,
custom -- and an editor seeded from the one chosen. The button now pushes
SelectCuratedSchemaTemplateScreen, that picker on a phone, and a card pushes
the editor with the template's key, the same word the site takes as
?template=. Back from the editor is the picker and another shape; when a new
list's proposal goes out the signing session replaces both.

CuratedSchemaTemplate is lib/protocol/templates.ts field for field, with
CuratedDeriveRule for the [rule:<key>] mark the site records in the
identifier field's hint -- its own convention, not the NIP's, and the thing
that lets that site's form derive an entry's d for a list the group starts
here. The hint is written byte for byte as the site writes it; the app still
composes no suggestions and applies no rule. Null or an unknown key seeds
Custom, which is the bare two fields the editor opened on before, so a
screen handed no template behaves as it did.

The picker's one departure from the site: its cards list a template's
fields by label, the way the group's schema cards do, rather than counting
them -- what an entry asks for is what the choice is made on.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 20:25:37 +02:00
Kgothatso NgakoandClaude Opus 5 272b631633 feat(ui): a member on the room's screen opens the profile preview
The member rows on the chat room detail were the last "Profile detail" stub
in the app: each pushed ImplementationPendingRoute. They now push
ProfilePreviewRoute by the member's public key, which the nav host already
serves, so a member arrives with the cached profile at once and the relays
refreshing it, and the bar's action opens the chat that exists with them or
starts one.

The preview rather than the profile detail, because the detail is keyed by a
kind 0's event id and a member whose profile has not arrived yet -- the
"LOADING..." row MemberProfileSync exists for -- has none. The public key is
the one thing every row has. A test pins both members opening the same
screen, the named one and the one still named by its key.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 14:44:57 +02:00
Kgothatso NgakoandClaude Opus 5 80735df86a feat(ui): the preview's action is the app's extended FAB
curated gained ExtendedFab while the preview was being built: every screen's
bottom-bar action, with an enabled that borrows the disabled colours, marks the
node disabled and drops the press. The preview had chosen a Button for exactly
the reason that widget removes -- a FAB had no disabled state -- so after the
merge it was the one screen whose primary action was shaped somewhere else.
Now it is that FAB in a bottom bar, the indicator in its icon slot while the
key package is still owed, and the reason line stays in the body above it.
Hidden, bar and all, for a read-only identity.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 13:43:20 +02:00
Kgothatso Ngako f4b0347e90 Merge branch 'curated' into claude/chat-creation-profile-preview-ae07be 2026-09-13 13:39:54 +02:00
Kgothatso NgakoandClaude Opus 5 ca6c16beb0 refactor(ui): one extended FAB for every screen's primary action, with a gap in it
Twenty screens end their bottom bar in an `ExtendedFloatingActionButton` --
twenty-one buttons, one screen having two -- and eighteen of those were built
from the content-lambda overload with an `Icon` directly followed by a `Text`.
That overload puts nothing between the two, so the icon touched the label on
every one of them: visible in any render, and unnoticed because every FAB in
the app looked the same. Thirteen of the eighteen also carried the same
twenty-line block for looking disabled, because M3 gives a FAB no `enabled`.

**`ExtendedFab`, once, in widgets/buttons.** A label, an icon slot, `enabled`
and `onClick`. It draws `space150` between icon and label, which is the 12dp
M3 names `ExtendedFabEndIconPadding`; it borrows the disabled colours every
other button in the app uses, marks the node disabled so a screen reader does
not announce a button it is happy to press, and drops the press -- so the
thirteen call sites lose their `if (!canX) return@…` guards along with the
block and the `buttonColors` each of them declared. An icon slot rather than
an image, because two screens put a progress indicator where the icon was
while the action they started is out, and they still do.

**Not M3's `text`/`icon` overload, which would have spaced them for free.**
Its source wraps the label in `clearAndSetSemantics {}`: the label leaves the
merged semantics tree, a screen reader is told only what the icon says, and a
test cannot find the button by what it says -- five screen tests do. The
three FABs that were on that overload move to the widget too, and two of them,
Home's "New chat" and "Start the key ceremony", had a decorative icon beside
the cleared label and so no accessible name at all until now.
`ReadOnlyEntrancesJvmTest` had gone to the unmerged tree to find "New chat"
for this reason; the habit is harmless and stays. Every icon's description is
as it was, since several tests reach their FAB by it.

`ExtendedFabJvmTest` pins the decision: found by its label in the merged tree,
the icon before the label with a gap between, and disabled both announced and
refusing the press. The two docs that recorded the old state -- the
conformance account's "left alone" and the npub plan's unmerged-tree note --
each say what superseded them.

Verified with :composeApp:m3Audit (all budgets met, 0 dp literals in spacing
positions), :composeApp:compileDebugKotlinAndroid and :composeApp:jvmTest
(1088 tests, 3 new).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 13:31:47 +02:00
Kgothatso NgakoandClaude Opus 5 d2a4298d25 feat(groups): broadcast every accepted entry from one button, each to where its own would go
The entries screen had one "Broadcast" under each card, and each opened
`BroadcastGroupSignedEventScreen` for that one entry: a group that has accepted
twenty entries into its lists sent them with twenty trips through the relay
picker. This is the other button. "Broadcast all", an extended FAB in a bottom
bar, sends every entry on the screen, newest first, one after another, and says
under each card what its relays answered. Behind no gate, like the button under
each card: sending what the group has already signed takes no share of the key.

**Each entry goes where its own broadcast screen would have started.** The list
that screen seeds -- `defaultRelaysFor`: the group's General write relays or the
app's publish set, plus the list's own relays, minus what the group has blocked
-- is what a member who reads nothing and presses the button sends to, and this
button is that member with twenty entries. The group's relay lists are read
into the loaded state for it; the list's relays come off the entry, which
carries its schema, so the rule is handed that one schema rather than all of
the group's. Nothing is shown before the press, which is the difference from
the one-event screen and the reason that screen stays: a refusal is answered
there, where the relay can be changed and the send tried again.

**One entry at a time, on purpose.** The rows fill in top to bottom, so the
member can see where the batch is; and a public relay sent twenty events in
one burst answers "rate-limited" to most of them, which would make the button
worse than the presses it saves. Each entry's send has the same ceiling as a
single broadcast and the batch has no other, since a long list is meant to
take a while. It goes to the pool directly rather than through the queue, for
the reason `BroadcastGroupSignedEventViewModel` gives, and it is only as
durable as the press: leaving the screen ends it where it is.

**The send is shared rather than copied.** What a relay's answer becomes -- an
OK, a rejection in the relay's words, a failure, or no answer when the whole
send runs out of time -- was decided inside `broadcast()` on the one-event view
model. It is now `sendToRelays` on that model's companion, beside
`defaultRelaysFor` and `wireEventOf`, and `broadcast()` keeps only the state
around it; the thirteen tests on it pass unchanged. The words for an answer
moved the same way, out of the relay row and into `RelayOutcome.label()`, which
both screens now use.

**What the member is told.** A line above the cards -- "Sending entry 3 of
12…", then "Accepted by every relay for 11 of 12 entries." -- persistent rather
than a snackbar, because it is the answer the member came for and a snackbar
would be gone before the last card had been read. Under each card, "Accepted
by n of m relays." in the one-event screen's words, and one line per relay
that did not say OK, named with its reason, because "blocked: not on the allow
list" is something a member can act on and a count of two out of three is not.
An entry with nowhere to go -- everything the seed would name blocked -- is
marked so rather than sent to nobody. The FAB looks disabled while a batch is
out, and a second press is refused.

`GroupCuratedEntriesViewModelJvmTest` pins where each entry goes, that the next
waits for the last to settle, what the answers become, and the refusals; the
screen test drives the button end to end and checks that each answer sits
between its card and that card's own broadcast. The shared fixture entry now
carries the `a` root a real entry has -- without it the seed rule could not
find the list's relays, which the first run of these tests found.

Verified with :composeApp:m3Audit (all budgets met),
:composeApp:compileDebugKotlinAndroid and :composeApp:jvmTest (1085 tests,
7 new).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 13:31:32 +02:00
Kgothatso NgakoandClaude Opus 5 d649098504 feat(chat): the preview's button knows whether it can be pressed
Phase 4 of docs/npub-profile-preview.md. Phases 1-3 moved the twenty-second
dead end one screen later: a person found on an indexer, a press, and
InitiatingNewChat waiting for a key package that someone who has never opened
Curare will never have published. The preview now reads the answer before the
press. A room that already exists opens; a key package that is here enables
"Start new chat"; one that is not, once the relays have had their time,
disables it with the reason under it and a try-again that asks the DM relays
alone.

The existing-room check was a loop with a TODO inside initiateNewChat; it is
ChatRepository.findDirectMessageRoom now -- a room whose members are exactly
the two keys, or the one key when they are the same -- read by both screens and
pinned by a test on an in-memory database. The old size-one branch would have
opened any room the peer sat in alone, whoever they were.

Both halves are observed together, as the chat screen does: a key package
arriving after the profile touches a different table, and a collect on the
profile alone would never see it. A room is read once up front, because a key
package is meant to be used once and the relays need not hold a fresh one for
someone you already talk to.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 13:19:51 +02:00
Kgothatso NgakoandClaude Opus 5 923b59ec32 feat(ui): the new-chat dialog opens the person, and no longer starts the chat
Phase 3 of docs/npub-profile-preview.md, and the user-visible change: "Direct
message via npub" now shows who this is before anything is created. The
dialog's button reads "Find profile" and pushes ProfilePreviewRoute; the chat
is started from there.

The field keeps what it parsed rather than whether it parsed. Its check and its
decode used to be two different functions, which is how "nostr:npub1…" passed
the one and failed the other, closing the dialog with nothing to show for it;
CredentialParser.npubOrNull is the sign-in decode exposed for an address field
-- an nsec is null there, because a field asking whom to write to must never
take a secret for an answer -- and the enabled button and the route it pushes
read the same key. The nip05 branch still lands on the placeholder, and the
test says so. "Start chat" goes with its only reader.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 12:59:26 +02:00
Kgothatso NgakoandClaude Opus 5 8973c0058e feat(ui): the profile preview screen, reachable by nothing yet
Phase 2 of docs/npub-profile-preview.md. ProfilePreviewRoute is keyed by public
key, because that is all the entrance has, and ProfilePreviewScreen draws the
four states over a constant bar: the npub above the indicator while the relays
are asked, the person -- avatar, name, nip05, the whole of the about, the npub
that was pasted -- and under them "Start new chat", which hands over the route
the dialog pushes today and creates nothing here. Not found is the sign-in
screen's sentence with a try-again; a read-only identity is shown the person and
nothing to do, and ReadOnlyEntrancesJvmTest gains the row.

Registered in the host with the room replacing the preview, as it replaces the
profile detail. No button navigates to it until Phase 3.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 12:55:19 +02:00
Kgothatso NgakoandClaude Opus 5 37c6f7eabb feat(chat): the lookup behind a profile preview, and the sync it shares with the chat screen
Phase 1 of docs/npub-profile-preview.md. No screen yet: a view model that finds
the person behind a pasted npub and says when it has stopped looking, over the
row the device already holds -- cached first -- and two asks of the relays.

The three-kind filter the chat screen queued privately is now
DirectMessagePeerSync.requests, and the kind 0 alone goes to the indexers as
profileRequests: a key pasted from elsewhere has lived elsewhere, and a
three-kind filter sent to an indexer comes back with the kind 0 and nothing
else. "A placeholder is not a profile" was spelled out twice as a comparison
against GENESIS_AT; it is Profile.isResolved() now, and both sites read it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 12:50:15 +02:00
Kgothatso NgakoandClaude Opus 5 9bb340042d feat(ui): leaving one profile among several
Phase 7 of docs/multiple-profiles.md. Small, because the forget sequence was
built right.

Sign out of a read-only identity and "forget this key" for a bare key both
run ForgetIdentity and then the tail -- re-list, clear the default since
Phase 3, show the selector with what remains or Landing if nothing does --
and that is the right behaviour with several profiles as well; nothing in
the sequence changes. A profile with a wallet attached answers
WalletAttached from Phase 1 and is offered neither exit: its sign-out row
stays the pending route, for the reason both sign-in plans gave, and it is
now also the only way such a profile can leave, since the repair would
write its credential back. What changes is that the user is no longer stuck
behind it -- "switch profile" is the row above.

The not-found screen learns about the others. It offers "try again" and,
for a read-only identity, "use a different key", which forgets it; with
another profile on the device it now offers "switch profile" as well, for
every kind, pushing the switcher -- which has a back button, so the screen
is still there if the user changes their mind. The identity that was not
found stays listed; forgetting it remains a separate decision. The nav host
passes the callback only when the listing holds more than one.

Tests: ReadOnlyEntrancesJvmTest -- with another profile on the device the
not-found state offers the switch beside the read-only exit and it calls
through once; a signing identity that was not found gets it above the
set-up form; with one profile there is nothing to switch to.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 01:44:44 +02:00
Kgothatso NgakoandClaude Opus 5 759199f2af feat(sync): a fetch queue per identity, and the inbox reopened on activation
Phase 6 of docs/multiple-profiles.md. The one data problem, closed from both
ends.

The two queues that fetch -- SynchronizeNostrEventRequest and
NegentropySynchronizeRequest -- gain a nullable ownerPublicKey, the identity
that asked, because what a fetch brings back is opened with the fetcher's
key. The pumps ask for their own: the head of the queue among this
identity's requests and the ones nobody owns, so that a request another
identity queued waits for that identity. Rows from before the column read
back null, meaning "the device's", which is what they were, and any identity
may drain them. The broadcast queue deliberately gets no owner: a signed
event is anyone's to carry, and holding A's outgoing message until A is
opened again would be a delivery failure the user would never be told about.
Room version 20, an AutoMigration for two nullable columns, with the schema
export committed beside its predecessors.

The stamp is the repository's, not the call site's. Eighteen view models and
two DAO paths queue requests, and every one of them does so as the active
identity -- a screen cannot queue anything as anyone else. DatabaseNostrRepository
takes the identity flow at construction, which meant moving the view model
above the repositories in the nav host, and stamps every request it queues
where the caller stamped nothing; a negentropy request carries its owner
into the REQ it becomes. The DAO's own requests -- the placeholder-profile
syncs it plants while indexing, and the participant syncs of a Marmot join
-- stay unowned, on purpose and against the plan's sketch: they fetch public
kinds that need no key to open, and any profile that is open may as well
fetch them.

The other end: wraps that were fetched under the wrong key -- before this,
or by a read-only identity whose nsec was pasted later, the case the npub
plan's DAO guard left with the words "the key that opens this one may be
signed in later" and no code behind them. storeNostrEvent never indexes an
event it already holds, so a wrap that arrived under the wrong key stayed
closed for good: the live subscription re-received it, the DAO saw a known
id, and returned. NostrDao.reopenInbox finds every wrap addressed to the
active key that no seal names and runs each through indexNostrEvent again
under the right key, one transaction per wrap so that one that cannot be
opened rolls back its own changes and the next is still tried; one pass,
since wraps do not depend on one another. It runs from the sync pumps'
collector once per activation, for an identity that can sign, before the
live inbox and the broadcast pump are launched -- so the sweep and the live
subscription are not opening the same wrap at once; both are idempotent by
event id.

Found on the way: GiftWrapSeal.giftWrapMessageId, a foreign key to the wrap
a seal came out of, existed and was never written, so nothing in the
database could say which wraps had been opened. decryptGiftWrapSeal now sets
it. A seal from before reads back null, is swept once, and comes back with
the link -- the reindex is idempotent, and persistInboundChatMessage already
files a message it has once.

Tests: ReadOnlyGiftWrapDaoJvmTest -- a wrap for us stored under another
profile's key is stored and not opened, a re-delivery under our key changes
nothing, the sweep opens it once and finds nothing the second time; the
other profile's sweep and a read-only pair open nothing; a wrap stored
read-only is opened once the key is here. OwnedRequestQueueJvmTest -- A's
request is offered to A and not to B, nobody's to both, oldest first; the
repository stamps what it queues with the identity that is open, nothing
when none is, and keeps an owner a caller named.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 01:41:14 +02:00
Kgothatso NgakoandClaude Opus 5 2f42023081 feat(identity): adding a profile from inside, as a key and not a second wallet
Phase 5 of docs/multiple-profiles.md. The two entrances, and the two things
that were only safe with one profile.

Under the list, on the switcher and on the startup selector alike, two rows:
"sign in with a key", to the sign-in screen, and "create a new profile", to
the create screen. Both push a screen that has a back button. Landing is not
one of them -- it has no back button and clears the stack on its way out,
because it is the first-run screen, and pushing it from inside would make it
a pushed screen on some days and a root on others. A device with one profile
can now be given a second, which it could not: Landing showed only when the
device held nothing.

A profile created from inside is a bare key. CreateProfileScreen generated
twelve words behind its form -- a seed, a node, a wallet, and at the NIP-06
path the key that becomes the profile -- which is right for the first
profile on a device, the one the wallet will belong to, and wrong for the
second: a user who wants another profile has not asked for another
Lightning node, another set of channels, or a second phrase with funds
behind it. The screen now takes a NewProfileWriter and does not know which
it was given: seedProfileWriter from Landing, bareKeyProfileWriter from the
switcher, thirty-two random bytes written the way a pasted nsec is.
CreateProfileRoute carries the choice. The view model writes the secret
first, then the six bootstrap events for the key it derives, then hands the
id to the tail -- so the events are only ever queued for a key the device
holds, and they are in the database before the tail activates the identity,
an ordering the sign-in screen documents as load-bearing and the create flow
used to get away with by luck. The tail gains the popUpTo(0) the sign-in
tail has. A second wallet is not offered from inside; a pasted recovery
phrase still brings its own.

"End this" goes. It wiped the database -- every profile's rooms, MLS state,
key packages and queues -- from the screen whose purpose is to add a
profile; it was only ever a development exit, and with several profiles on
a device it was a way to lose the others. wipeDatabase leaves the view model
and stays on the repository for the tests that use it.

A key already on the device is refused with the id it is listed under.
WriteNostrCredentialResult.AlreadyExists and WritingSeedState.Error.
SeedAlreadyExists carry it -- the wallet's id where a seed derives the key
-- and the sign-in screen's error state gains one action, "switch to it",
which is the sign-in tail with that id. From Landing "already on this
device" was the whole message; from inside it is a sentence with an obvious
next step, and a duplicate paste becomes the fastest switch in the app.

Found on the way, and fixed in the jvm actuals: DataStoreManager caches one
GlobalPrefs per process behind an unsynchronised check-then-set, and
DataStore refuses a second instance over the same file. Two first calls at
once -- the listing on IO and a sign-in's write, or the startup screen on
Main -- could both see the empty cache and both build one, and the loser
threw "multiple DataStores active for the same file" at first use. The test
for this phase hit it one run in three. JvmGlobalPrefs is now the one way
the jvm target reaches the prefs, under a lock; Android goes through the
Application's single instance and never raced; the library's own callers
come at node start, when the cache is long populated.

Tests: AddProfileFromInsideJvmTest, through the real view models on an
in-memory database -- A open, B's nsec committed and switched to, and back,
both accounts intact with their own kind 0; A's key pasted again refused
with A's id; a profile made through the bare-key writer lists as a bare key
with the kind 0 first of its six bootstrap rows, none signed yet, and no
node ran. SignInToProfileViewModelJvmTest and IdentityWriterJvmTest assert
the ids the three refusals carry. ProfilesScreenJvmTest: the two rows call
their callbacks and switch nothing, under the caption that the open profile
stays. CreateProfileScreenJvmTest: the state that carried "end this" is
composed and the words are not there.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 01:24:14 +02:00
Kgothatso NgakoandClaude Opus 5 25464595f4 feat(ui): the switcher, showing the nostr profile and what the device holds for it
Phase 4 of docs/multiple-profiles.md. One pushed screen, and the startup
selector brought up to match it.

ProfilesRoute, reached from the profile tab's row -- "Switch profile", where
it said "Change account" and went to the pending screen -- and drawn by
ProfilesScreen: a top app bar with a back button, and WalletsSelector as its
whole content with the open profile above the divider and the others below.
Tapping another row is switchToIdentity and nothing else; the observer
restarts the app as that identity through its lock gate, so the screen is
never around to see the result. Tapping the open row does nothing. Three
states, said so: loading while the list is read, which in practice is never
seen; an unreadable key file, through ErrorState with a retry that re-lists;
and the list. Empty cannot happen while something is signed in and the screen
does not pretend it can. One column at every width. The row is offered to
every kind: a read-only identity can leave for another profile the same way
a signing one can.

ProfilesViewModel joins the flows the app already holds -- the listing state,
the identities, the active identity, the wallet metadata -- to the profile
rows for the listed keys, through NostrRepository.observeProfilesOf, one map
that moves when any of them does. Nothing in it writes.

What a row shows changes. WalletsSelector showed "Default name" over a random
emoji for every row, because nothing in this app writes the wallet metadata's
name, and two profiles side by side both called Default name and told apart
by a bech32 string is not a switcher. The row now takes the nostr profile --
humanReadableNameOrPubkey over ProfileAvatar, the widgets the profile tab
draws itself with -- with the npub on the second line, and falls back to the
npub over the metadata's emoji for a key the device has no kind 0 for yet:
one just created, or a read-only one that was never found. And it says what
the device holds for the profile before the tap: "Wallet" for a seed
attached, beside the "Read only" that was already there, and nothing for the
plain case of a bare key. It is the difference between a profile that can be
signed out of and one whose sign-out is a wallet question, and between two
profiles with the same name. The startup screen draws the same widget and
gets the same map through rememberProfilesOf, so both lists look the same.
The selector's dead globalPrefs parameter goes with the rewrite.

Tests: ProfilesScreenJvmTest, on the unmerged tree, with a wallet-attached A
open, a bare B and a read-only C -- A by its nostr name with its npub and
"Wallet" under it, B and C by their npub with only C labelled, no "Default
name" anywhere, the open one drawn above the others; tapping A calls
nothing and tapping B calls the switch once with B's id; an unreadable key
file is an error whose retry is counted; the bar has a back button.
ReadOnlyEntrancesJvmTest asserts "Switch profile" for both kinds.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 00:50:37 +02:00
Kgothatso NgakoandClaude Opus 5 00fc996995 feat(identity): which profile opens, on launch and after a switch
Phase 3 of docs/multiple-profiles.md. The startup screen learns to agree with
the switch.

The table that picks what to open is lifted out of the screen's remember into
StartupChoice.resolve, where it can be read and tested, because its order was
the whole decision and it was wrong in the one way a switch would hit:
"!startWalletImmediately -> null" sat above "desiredWalletId != null", and
nothing ever set the flag back to true. So after the first visit to the
selector, every sign-in on that device landed on the selector instead of the
profile it had just signed in. Two rows move: what a switch or a sign-in
named goes above the user's earlier "show me the list", since it is the more
specific instruction; and the single-identity row drops below it, since when
both are set they name the same thing.

The default is written. GlobalPrefs.getDefaultWallet has been read by startup
since Phoenix and saved by nothing in this app, so a cold boot with two
profiles was the selector every time with no memory of which one was open.
setActiveIdentity now saves the id it activates -- every activation goes
through it, startup for all three kinds and the two tails through startup --
so the default is always the profile most recently open. The two forget tails
clear it, since the default is the one memory of an identity that would
otherwise outlive it. Both writes are wrapped: a default that could not be
recorded is a selector on the next boot, not a crash now. The screen reads
the saved value as a default only when it names a wallet, which is the one
thing left to decide at the call site.

The startup screen's literals go to the catalogue, and "wallet" goes with
them except in the one place a wallet is what is starting: "Starting wallet"
is shown from StartupViewState.StartingBusiness, which only the branch with
a wallet attached reaches, and stays. The rest become "Preparing profiles",
"Opening profile", "Decrypting", "Loading preferences", "Unlock to continue"
and "Could not load the profiles on this device"; the selector's title is
"Choose a profile", and select_a_wallet goes.

Tests: StartupChoiceTest in commonTest, one case per row and the two
orderings this phase is for -- a desired id opens even after the user once
asked for the list, and one identity with the list asked for still shows it.
IdentitySwitchJvmTest gains the cold boot: activate A then B, and a fresh
view model over the same directory resolves B without asking; forget the
default, and it resolves nothing. Found on the way and recorded in the test:
DataStoreManager caches the global preferences once per process, bound to
whichever directory was current when the first test in the JVM asked -- the
same trap the nsec plan recorded for user preferences -- so the test reads
the default through the view model's own instance rather than one of its
own.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 00:43:21 +02:00
Kgothatso NgakoandClaude Opus 5 9b3a19278f feat(identity): a switch that tears down what it should
Phase 2 of docs/multiple-profiles.md. The transition, made correct, with
nothing yet calling it from a screen: the view model, one manager, and three
one-line actuals.

switchToWallet becomes switchToIdentity, and does what a switch is: remember
which one, set startWalletImmediately back to true -- a switch is the user
saying which one, and the flag was only ever the user saying "show me the
list"; nothing set it back before because nothing could switch -- clear the
active identity, and stop the node of the profile being left, if it had one.
The identity is cleared before the node is stopped, so that every collector
that could reach the business is cancelled before the stop runs. The test is
business != null, not the kind: whether the profile being left has a node
behind it is the fact, and the kind is how it currently comes to be true.
stopPlatformBusiness is an expect beside updateBusinessActiveInUI, for the
reason that one is: BusinessManager is a per-platform object. Its three
actuals call stopBusiness, which existed on every platform and nothing
called. The manager is injected into the view model as a function so that
the branch can be pinned without a node.

RelaysSocketManager.observeActiveUserId becomes a child of collectLatest --
the shape the pumps and the notary already had. It used to keep one job per
pubkey on its own scope and cancel only the job for the pubkey being
started, which meant a switch left the previous identity's observer running:
two observers feeding updateRelayPools, and the one pool following whichever
relay list emitted last. The map goes; a null identity closes nothing, since
the pool is shared by pumps a null identity has already cancelled, and the
next identity's list replaces it through changeRelays as it always did. The
scope is injectable and relayUrls is exposed, both for the test.

The sign-in and create tails keep their own navigate beside the observer's,
now with a comment saying why: the navigation state is a StateFlow, an
update to a state equal to the current one emits nothing, and the explicit
navigation is what guarantees the stack moves even on the day the state
does not.

Tests: IdentitySwitchJvmTest, through the real SovereignWalletViewModel with
a real notary and navigation machine on an in-memory database -- A open and
a kind 1 queued for A is signed; switch to B, the identity clears, the
machine goes to startup, B is activated the way startup does and routed from
its account; a kind 1 queued for A now waits three seconds unsigned, and
goes out when A is back. Leaving a profile with a PhoenixBusiness behind it
-- constructible without a node, since everything in it is lazy -- stops
that node once; leaving nothing, or a bare key, stops nothing.
RelaysSocketManagerSwitchJvmTest over a fake relay repository and fake
sockets: after the switch the pool holds B's relays, a re-emission of A's
list changes nothing -- the line that fails against the old observer -- and
an identity whose list is still empty leaves the pool as it was, which is
the behaviour updateRelayPools has always had for an empty list.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 00:27:06 +02:00
Kgothatso NgakoandClaude Opus 5 3008137e3f feat(identity): a seed's key is a credential, and the seed is the wallet attached to it
Phase 1 of docs/multiple-profiles.md. No library change: the file format, the
encrypted writer and the manager all exist, and the app already wrote the
credentials file from the seed writer -- to delete a public entry a seed
superseded. This changes what it writes there, and what the listing believes.

Until now a seed's nostr key was never in nostr-credentials.dat. It was
derived from the words at listing, to know which npub to show, and from the
running node at activation, to know which key to sign with -- so a seed-backed
profile existed only as a derivation, and the app had to start a Lightning node
to find out who it was. Both sign-in plans made "one key, one file" an
invariant, and it was the wrong one: it said a wallet is a profile. Now the
credentials file is the list of profiles and a seed is a wallet attached to the
entry its key derives.

writeMnemonic writes two things, credential first: a Secret for the derived key
under its x-only pubkey, replacing a public entry where there is one, and then
the seed. Credential first because a crash between the two leaves a bare-key
profile the phrase completes, which is a valid thing to hold and says the model
out loud -- the profile exists, then a wallet is attached to it. The one
refusal it drops is the phrase of a key held as a bare secret, SeedAlreadyExists
under the nsec plan: the device did not have that wallet, so this is the
profile acquiring the wallet that derives it. The entry stays a secret for the
same key, the id becomes the wallet's, and the bare key's preference files go
with the old id -- the profile's preferences are the wallet's now, fresh, which
is right since there is a new secret to back up. The same seed twice is still
refused, by wallet id, and is the only way a profile with a wallet attached is
offered its phrase again.

SeedCredentials.reconcile is the repair for every seed already on a device,
beside migrateFromNostrKeys in listIdentities and shaped like it: a named,
idempotent write, one file write for however many seeds are missing, nothing at
all on a device with none or one already repaired. A failed write is a result,
not a throw, and carries the map that was read: the listing goes on with it and
merge derives the key of a seed that has no credential, so a seed this could
not repair is still listed. A failed write must never hide a wallet. The plan
had the repair running before the credentials file was read; it runs after,
and hands the listing what it returns, so the file is decrypted once -- the
doc now says so.

StoredIdentity.merge inverts: the credentials are the list, and each seed is
attached to the Secret its key derives -- listed once, as Mnemonic under the
wallet's id, carrying the credential's key -- where before the seeds were the
list and a secret for a seed's key was listed twice under two ids. Mnemonic
gains privateKey. A Public for a seed's key is skipped with a log line, since
the next repair upgrades it; a seed with no credential is listed by derivation,
with a log line. IdentityKind.Mnemonic's doc changes to what the kind now
means: the name records the attachment, not the source.

setActiveWallet takes the StoredIdentity.Mnemonic and builds the identity from
the credential's key, with the node's derivation as a cross-check -- a check(),
because a node disagreeing with the credentials file is the one corruption
worth refusing to run under, and it cannot fail for a file the repair wrote.
The node still starts for a profile with a wallet attached: not for the key any
more, but for what startNewBusiness does besides -- metadata, preferences,
last-used build, and on Android the channel watcher a restored Phoenix phrase
may need. Making it lazy is now one branch and is named as its own decision.

forgetNostrCredential refuses a second thing: a key a seed derives. The seed
would derive it again and the next repair would write it back, so a forget
that succeeded would undo itself. NotACredential becomes WalletAttached in the
writer's result and ForgetIdentity's outcome, since that is now the only reason
a signing profile cannot be forgotten -- a key not in the file at all can, since
the repair, only be a seed's key the repair could not write.

The two sign-in docs' tables each gain a row pointing here for the invariant
this supersedes.

Tests: SeedCredentialsJvmTest against a device from before -- seed.dat written
directly, no credentials -- writes exactly what is missing in one write; a
device already repaired is not written to again, checked by the file's bytes
since a rewrite would carry a fresh iv; a public entry for a seed's key is
upgraded; bare keys are untouched; and a write that fails, with the key store
locked, is reported with the map that was read and the wallet is still listed.
IdentityWriterJvmTest drives the callback-shaped seed writer through a
CompletableDeferred on a real Main dispatcher, since it reports after a real
one-second delay: a phrase writes both files, its nsec and npub are then
duplicates and its forget is WalletAttached; the same phrase twice is refused;
the phrase of a bare key attaches, under the wallet's id, with the bare key's
preferences gone; the phrase of a key held read-only attaches and the entry
becomes a secret. StoredIdentityJvmTest lists a secret-plus-seed once with the
credential's key, a seed without a credential by derivation, and a public entry
for a seed's key as the wallet only. Not under test: the activation's
cross-check, because a PhoenixBusiness cannot be built without a node.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 00:20:22 +02:00
Kgothatso Ngako 86cb876b77 Merge branch 'claude/npub-readonly-signin-ec4398' into curated 2026-09-12 22:24:40 +02:00
Kgothatso NgakoandClaude Opus 5 a586b7c116 feat(identity): two exits for an identity that holds no key
Phase 6 of docs/npub-sign-in.md. Leaving: one sequence, two doors.

ForgetIdentity is NostrSecretViewModel.forgetKey's sequence lifted out --
the credential out of the file, the metadata hidden, the account rows
gone, in that order so a failure partway leaves the credential on disk
rather than an identity the selector lists but nothing can open. Since the
credentials file the first step is the same call for both credential
kinds, so it is one function; a mnemonic identity is refused at the first
step, because removing a seed is a wallet question this does not answer.
The nsec view model calls it now and keeps only its own state.

Sign out on the profile tab does, for a read-only identity only, what its
colour has been promising: a confirmation naming the npub -- this device
holds no key for it, so there is nothing to lose; the profile stays on the
relays -- then the identity leaves the device and the nav host's tail
re-lists and clears the active identity, which shows the selector or, if
this was the last one, Landing. It is the first real sign out in the app.
For the other two kinds the button keeps its pending route. SignOutViewModel
owns the confirmation and the in-flight state; SignOutDependencies bundles
what the screen needs so that a caller with none of it -- previews, tests
-- passes nothing.

The not-found screen had, for a read-only identity, no exit: Phase 5 hid
the set-up form (a kind 0 has to be signed), the profile tab is not
reachable before ProfileLoaded, and a user whose npub was found on no relay
could try again for ever. So a third action, shown only where the second is
not: use a different key, which is the same sequence behind the same
dialog, reached from the other end of the identity's life.

Tests: the sequence and where it stops, the view model's states around it,
and the two screens composed as each kind -- the profile's sign out asking
first and naming the npub, the not-found screen offering the form to one
kind and the other key to the other.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 20:45:34 +02:00
Kgothatso NgakoandClaude Opus 5 e31033e857 feat(ui): what a read-only identity is shown, and what it is not
Phase 5 of docs/npub-sign-in.md -- the half the nsec plan called a
product.

One question, asked in one way. LocalCanSign is a composition local for the
snackbar host's reason: screens do not receive the identity,
MetadataEventDetail -- where follow and send message live -- is several
composables below anything that could be handed more, and a parameter
threaded through twenty-six lists is forgotten in the twenty-seventh.
ProvideSigningCapability sits once above the navigation suite. The default
is true rather than an error, the one way this differs from the snackbar
host: the provider cannot be forgotten per screen, so the only things
composed outside it are previews and tests. And it is a capability, not a
kind -- "can this identity sign?", not "is this an npub?" -- so that a
remote signer is not a fourth value in every when.

The inventory, hidden rather than disabled because the empty state beside
each says why: HomeScreen's New chat in both layouts, its sheet and its
npub dialog; MetadataEventDetail's follow, unfollow, follow back, edit
profile and send message (the "follows you" state still shows -- a fact,
not an action); ActiveProfileScreen's key package management and key
recovery; ShareProfileScreen's re-broadcast, which signs nothing but
queues a copy for the finder relays, and a read-only identity puts nothing
on a relay; SocialPreconditionScreen's invite and view invites, pending
today and writes when they exist; and the not-found screen's set-up form,
since a kind 0 has to be signed. Everything else that writes is behind a
chat room, which a read-only identity can never open.

The Messages tab, for a read-only identity, is an EmptyState where the
rooms would be -- one column at every width, since a two-pane layout is a
list beside a detail and there is no list -- whose message says which
absence it is and whose action is the upgrade: Sign in with the nsec,
which opens the same screen as landing's, hits the credentials file's
upgrade rule, and comes back through startup with rooms in it.
ChatRoomListViewModel is not composed, so the inbox sync and the MLS
negentropy it would queue are not queued.

Tests: ReadOnlyEntrancesJvmTest composes the home and profile screens
under each value of LocalCanSign and looks for the controls by text, on
the unmerged tree so that "does not exist" is not vacuous. The M3 audit's
budgets hold.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 20:38:18 +02:00
Kgothatso NgakoandClaude Opus 5 bfad1f39a2 feat(sign-in): an npub, recognised, confirmed as read-only, then written
Phase 4 of docs/npub-sign-in.md. The field accepts a third thing.

CredentialParser recognises npub1... and nostr:npub1... as
SignInCredential.NostrPublicKey: thirty-two bytes under the npub prefix
that name a point on the curve -- the counterpart of the isValid() a
secret is checked with, since not every x coordinate has a point above it.
PublicKeyOnly goes, and its string with it; an npub that does not decode,
or names no point, is InvalidKey. Hex stays a secret: a private key and an
x-only public key are the same size, the confirm step shows the derived
npub so a public key pasted as hex is visible for what it is, and guessing
would never fire when it mattered, since an x coordinate is almost always
also a valid scalar. The test pins the vector's own public key, pasted as
hex, landing on a different npub.

The confirm step's third arm says what the user is about to get and not
get, once, before the choice: this profile and the people it follows;
messages closed and nothing sent; paste the nsec later to open it. The
landing caption, the field's label and its placeholder name the third
input, the last with "to look around" for a user who does not know the
word read-only. The view model takes the third writer the way it takes the
other two and commits through one shared write-and-map.

signInToProfile is idempotent by pubkey. Until now nothing called it twice
for one key -- the writers refused a second sign-in before it got there.
Pasting the nsec of a key held read-only is the first path that signs in a
pubkey whose account already exists, and a second placeholder would be two
kind-0 rows for one pubkey, two accounts disagreeing about which is this
one. A repository test signs in twice and counts one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 20:32:54 +02:00
Kgothatso NgakoandClaude Opus 5 7db863e392 feat(identity): list, start and read as an identity that holds no key
Phase 3 of docs/npub-sign-in.md.

listIdentities runs the migration from nostr-keys.dat before its read --
there rather than inside the reader, so a listing that writes is a named
step and not a surprise, and from init, before anything else touches
either file. An old file that cannot be read is left where it is and
reported the way an unreadable credentials file is, so the user sees an
error rather than silently losing every imported identity. The selector
says "read only" under the npub of a public-key identity, before the tap:
two identities can share an avatar and a name, and only one of them will
let the user send a message.

Identity.toKeyPair is now the one place a quartz KeyPair is built from an
identity. With a secret it is the pair as before, the public key a
cross-check; without one it is quartz's read-only constructor. What it
must never be is KeyPair(privKey = null) with nothing else -- that is
quartz's "make me a new key" -- and decryptGiftWrapSeal builds exactly that
from a forwarded pair, which is why the helper has the trap on it.

The synchronization view model runs the two pumps that read for every
identity and the two that write only for one that can sign. Stated as a
rule because Phase 5 leans on it: a read-only identity never sends
anything to a relay, not a signature and not a copy. The broadcast pump
would find nothing, and the live subscriptions are the gift-wrap inbox and
the group-membership follow, both fetching what this identity cannot
open.

One guard in NostrDao.indexNostrEvent, after the isAddressedTo check: a
wrap addressed to a key the pair does not hold is kept, event and wrap,
the way someone else's mail already is. storeNostrEvent is @Transaction
and indexes inside it, so before this the unseal ran with a key nobody has,
threw, and the throw took the event with it while logging as a decryption
failure. Verified both ways: the new DAO test fails on exactly that case
with the guard removed and passes with it, and the same wrap opens once
the pair holds its key.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 20:28:57 +02:00
Kgothatso NgakoandClaude Opus 5 5efeae769f feat(identity): one credentials file, with a read-only kind and the upgrade in one write
Phase 2 of docs/npub-sign-in.md: the library half is lightning-kmp-app
01962f3 (claude/nostr-credentials), bumped in here; this is the app half.

nostr-keys.dat becomes nostr-credentials.dat, one typed entry per public
key -- a secret, or only the public key -- so that a profile signed in to
read-only and the same profile with its nsec pasted later are one entry in
one file. StoredIdentity gains NostrPublic, whose id is the one its secret
would have (hash160 of the x-only key), and merge reads the typed map. It
keeps the one precedence it needs: a public entry for a key a seed already
derives lists the wallet only, which is the state the seed writer's two-file
upgrade can leave behind if it dies between its writes. A secret for a
seed's key is still listed twice, as before -- that is a duplicate the
writers refuse, not a state the listing hides.

IdentityWriter: writeNostrPublicKey beside writeNostrKey, both refusing a
duplicate by public key against the seeds and the credentials, with the one
exception that is the point of the file -- the nsec of a key held read-only
is not a duplicate, since the device does not have that secret. writeNostrKey
replaces the public entry with a secret one in a single write, under the id
it already had, so the read-only identity's preferences are the ones the
signing identity keeps. writeMnemonic has to span two files for the same
upgrade and removes the credential first, then writes the seed: a crash
between the two loses the read-only identity, which the npub pasted again
restores, rather than listing one npub twice under two ids. forgetNostrKey
becomes forgetNostrCredential and removes an entry of either kind;
NotABareKey becomes NotACredential and still means a mnemonic.

The startup screen's third branch is here rather than in Phase 3 because
StoredIdentity is sealed and the compiler asked for it: a read-only
identity is active the moment it is read, as the nsec one is.
NostrSecretViewModel reads the secret entry and answers a public one with
"no key for this identity", which the screen it belongs to will never show
once Phase 5 hides the row.

Tests: the writer's upgrade in both directions -- the nsec of a read-only
key accepted under the same id, the npub of a secret refused -- and forget
of either kind; merge listing all three kinds, the shared id of a public
key and its secret, and the seed-over-public precedence.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 20:25:18 +02:00
Kgothatso NgakoandClaude Opus 5 15766596e4 feat(identity): a key the identity may not have
Phase 1 of docs/npub-sign-in.md. A type change and nothing a user can see.

Identity.nostrPrivateKey becomes nullable and nostrPublicKey becomes a
constructor field, because the kind this plan adds -- NostrPublic, a bare
public key -- has nothing to derive a pubkey from. A data class would let
the two disagree, so two checks in init refuse an identity whose kind and
key disagree about whether there is one, and one whose key does not derive
the public key it was given. Identity.signing derives the pubkey and refuses
the read-only kind; Identity.readOnly builds the other; nothing else
constructs one now. The id of a read-only identity is toWalletId() of the
x-only key -- the same id its nsec would have -- which is what will let a
read-only identity become a signing one and keep its preferences.

canSign is a property of the identity rather than nostrPrivateKey != null
at each site, so that a signer with no local key has one place to answer.

Every reader of the key already reached it through ?. on a nullable
identity, so the compiler forces nothing here; the sites that need a
decision are the plan's Phase 5, found by reading. The one site that did
change is KeyRecoveryScreen, whose two whens branched on NostrSecret with an
else that meant "mnemonic": both are exhaustive now, so the new kind is not
handed the phrase option by default.

Tests: NavigationIdentityRoutingJvmTest gains a read-only fixture with the
same id and pubkey as the secret one, the routing case for it (by its
account, like any other), and the three refusals plus the factory's own.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 20:14:29 +02:00
Kgothatso NgakoandClaude Opus 5 55664cc7d4 feat(groups): a row per kind of signed work on the group's screen, each opening its own
The nostr profile, the relay lists, the posts, the curated schemas and the
curated entries were five sections of cards on the group's screen, every card
with a button under it, which made the screen as long as everything the group
had ever said, with its members and its subgroups somewhere underneath. Each
section is now a row -- a card with an icon and a chevron, the shape of the
signing key row above them -- carrying the one line a member wants at a
glance: the group's name and address, how many of the four lists it has
agreed, and a count of posts, schemas and entries. The row opens a pushed
screen holding what the section held, unchanged: the cards, the broadcast
under each signed event, the queue under each schema, and the gated ways into
the editors, which sit inside the empty state where there is nothing yet. The
paste stays on the group's screen at the end of the block, since it is about
the block rather than any one row, and the whole block is still absent in a
NIP-17 room for the reason it always was.

Five routes, screens, view models and states, each reading only what its
screen shows plus whether this device can sign. The broadcast button becomes a
widget, since five screens draw it, and inComparableGroups moves to the key
extensions beside shortened, with the doc comment that had been orphaned from
it. The section tests become a fixture object and six tests: one for the rows
-- their order, what each says, which route each opens, their absence in a
NIP-17 room -- and one per screen for what the sections' tests used to check.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 20:08:44 +02:00
Kgothatso NgakoandClaude Opus 5 fedbe72481 Merge branch 'curated' into claude/curated-suggestion-accept-flow-9e5c3d
The back-button fix landed on curated while the accept flow was being built.
One import conflict in the queue screen, resolved by keeping NavigateBackButton
and dropping the notifier the sheet no longer uses; and the accept screen
converted to the widget, so it is not the one screen spelling the button the
old way.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 15:27:57 +02:00
Kgothatso NgakoandClaude Opus 5 732a4527c6 feat(groups): the entries the group has accepted, under the schemas on its screen
A section for the kind 31890s the group signed, read off GroupSignedEvent the
way the profile, the posts, the relay lists and the schemas are. The reading
gate is theirs -- the room as author, the room's real signature -- plus two of
its own: an entry is matched to the list it replies to by the coordinate in
its a root, and checked against that list's fields exactly as the queue checks
a copy off a relay, so what this section calls accepted is what the queue will
mark curated once the entry is broadcast and read back. Newest per coordinate,
since re-curating is a newer event under the same d.

Each card names the list, gives the queue row's glance of what the entry is,
credits the suggester, and dates the group's decision; under it, the same
broadcast button every signed event in the block has, gated on nothing. There
is no way to add one here, because an entry is accepted from the queue on the
schema's card above, and the empty state says so.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 15:23:33 +02:00
Kgothatso NgakoandClaude Opus 5 fcc19f9500 feat(groups): accept a suggestion into the list, edited, as an entry for the group to sign
The queue's sheet used to end in the suggestion's JSON and a button to copy
it. Now it ends in the one thing a member can do about a suggestion: take it
into the list. That opens a form seeded from the suggestion -- an input per
field the schema asks for, enums as chips, one input per value where a field
repeats -- and a button that proposes a kind 31890 for the room's quorum to
sign, pointing back at the suggestion it came from.

The write side of the NIP is ported for it: CuratedEntryEvent.canonicalTemplate
follows bitcoin.mov's buildCuratedCanonicalTemplate tag for tag, and walks the
same field list as the reader, so what the form proposes is what the queue
reads back. The one deviation is that nothing is clipped on the way through; a
value the schema refuses is named under its input instead, by the queue's own
verifier, before a quorum is spent on it. The d is kept whatever field writes
it, so accepting twice revises one entry rather than making two, and derived
fields are kept as the suggester's client filled them in, since this app
derives nothing.

After the quorum signs, a 31890 has somewhere to land: the signing screen says
which entry and who suggested it, the transcript gets a line naming the list,
and the broadcast screen seeds the schema's relays, which the NIP makes a MUST
and which the entry only names by coordinate.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 15:23:17 +02:00
Kgothatso NgakoandClaude Opus 5 ccbdbf7a4f Merge branch 'curated' into claude/missing-navigate-button-d5552f
curated moved by one commit while the back button was being added: the broadcast
button under each signed event (6ae5a967) landed first. No conflicts -- the four
shared files (strings.xml, ChatRoomDetailScreen, CurareNavHost, and the profile
section test) merged cleanly, each side having touched different lines.

One change on top of the merge itself. That commit added a pushed screen,
`BroadcastGroupSignedEventScreen`, with its back button written inline -- a
twentieth copy of the thing this branch collapsed into `NavigateBackButton`. It
is converted here, the same mechanical rewrite the other nineteen had, so that
curated has one spelling of the button and not one-and-a-twentieth.

Verified with :composeApp:compileDebugKotlinAndroid, :composeApp:jvmTest (956
tests, both branches' suites) and docs/scripts/m3-audit.sh --check.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 14:05:23 +02:00
Kgothatso NgakoandClaude Opus 5 0634487e12 fix(ui): a back button on every pushed screen, and one spelling of it
Eighteen screens drew a back arrow in their app bar's leading slot and twenty-two
pushed screens did not. On Android the system back stood in for it and on iOS the
edge swipe, but the desktop target has neither, and a screen reached by
`navigate(...)` with no way to pop it is a dead end there: seven group forms, six
chat screens, five DKG screens, and four screens with no app bar at all.

**One widget, `NavigateBackButton`, rather than a nineteenth inline copy.** The
eighteen that had the button spelled it four ways -- `Icons.Filled.ArrowBack`, the
auto-mirrored one, `ArrowBackIosNew`, and a `"Back"` literal against a
`stringResource`. The widget decides twice: the icon is the auto-mirrored one,
because "back" points at the leading edge and the leading edge is on the right in an
RTL locale, which is what `Icons.Filled.ArrowBack` is deprecated for; and the
description is the catalogue's, because it is text. All forty-one sites use it now,
the eighteen converted mechanically with the imports they no longer need dropped.

**Each screen takes `onNavigateBack` and the host passes `popBackStack()`.** Hoisted
rather than read from a controller in the screen, so every one stays previewable
and testable without a nav host, which is how the twenty-two were fixed without a
nav host in a single test.

**Four screens had no bar to put it in, and got one.** `ChatRoomCreationScreen` is
"New chat", after the button that opens it. `CreateProfileScreen` is "Create
profile", and the two body headlines that repeated the name are gone, which is the
shape `SignInScreen` beside it on the landing page already has. `WriteNewNoteScreen`
is "New note" whether it is a reply, a quote or neither, one new string. The
"coming soon" placeholder's bar is titled with the name of what was tapped.
`AddMemberToChatRoomConfirmationScreen`'s bar had been commented out; it is back,
titled "Invite new member" since the body already names who and which room.
`NostrEventDetailScreen`'s repost and unknown-kind branches were the last two
placeholders without a bar.

**Two screens are reached two ways, and only the caller knows which.** Their
callback is nullable, and null draws no button. `ChatRoomMessagingScreen` is a
destination on a phone and the home screen's detail pane in an expanded window;
in the pane the room list is beside the transcript and a button that popped would
pop the home screen, so the pane passes null. `ImplementationPendingScreen` is
pushed from "learn more" and "edit profile" and is also where the navigation
observer lands with `popUpTo(0)` on an error; the host reads
`previousBackStackEntry`, remembered at first composition because the departing
screen reads it again after the stack has moved on. The DKG approval screens reuse
their existing `onDone`, which "Not now" already called -- the bar makes the same
leave reachable from the loading and error states, which had no other way off.

**Left alone on purpose.** The three top-level destinations have the navigation
bar, which phase 6 put there instead of app-bar icons. The onboarding and loading
screens cleared the stack to get where they are and have nothing under them.
`SearchScreen` and `SearchResultScreen` keep their `ArrowBackIosNew`: it is a search
bar's collapse control in a `leadingIcon` slot, not a navigation icon.

`NavigateBackButtonJvmTest` covers the two conditional screens by the description a
screen reader would announce: present and popping when pushed, absent in the pane
and at the root. The rule is recorded in CLAUDE.md beside the others a new screen has
to follow.

Verified with :composeApp:compileDebugKotlinAndroid, :composeApp:jvmTest (938
tests, 4 new) and docs/scripts/m3-audit.sh --check, all budgets met.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 13:55:42 +02:00
Kgothatso NgakoandClaude Opus 5 6ae5a9676e feat(groups): a broadcast button under each signed event, and the relays it goes to
Until now nothing a group signed reached a relay. `FrostSigningManager.complete`
files the batch as `GroupSignedEvent` rows and applies it locally, and the profile,
the relay lists, the posts and the schemas are all read off those rows -- the docs
on each said so, and the only way out was the copy button on the key-state sheet.
This is the way out: a "Broadcast" button under every signed event in the identity
block, opening `BroadcastGroupSignedEventScreen`, where the member sees and edits
the relays it will go to, presses once, and reads what each relay answered. The raw
JSON is at the bottom for anyone who would rather use another tool.

**The send goes to the relay pool directly, not through the broadcast queue.**
Everything the app publishes as itself goes through `BroadcastNostrEventRequest`,
which is durable and retried, and it is not used here on purpose. The queue hangs
off a `NostrEvent` row, and a row for the group's event is more than a queue entry:
the home feed selects by kind, so the group's post would appear in it as anybody's;
and the sync loop offers every local event id to the relays it reconciles with, so
the event would reach relays the screen never named -- which would make "edit the
relays" a fiction. `GroupSignedEvent` already explains at length why it is not a
`NostrEvent`; this keeps that true. `EventPublishTransport` is the slice of
`RelaysSocketManager` the screen needs, cut the way `LiveSubscriptionTransport` is
and for the same reason: the manager cannot be stood up in a test. The cost is that
a broadcast is only as durable as the button press. Each row says what its relay
said, and a relay that did not answer is sent to again by pressing again.

**Behind no gate.** Every other button in the block is hidden from a member holding
no share of the key, because each proposes a signature by the group. Sending what
the group has already signed takes no share: the signature is the group's whoever
repeats it, and any member could paste the JSON into another client today. So the
button is there for whoever is looking, the way the suggestion queue is.

**Where it goes before anyone says otherwise** is `defaultRelaysFor`: the group's
General list where it has agreed one -- its write relays, and nothing from the app's
set beside them, since a member who edited the relays meant them -- and the app's
publish set where it has not. A relay list also goes to the indexers, because a list
sent only to the relays it names is circular; a curated schema also goes to the
relays it names for its own replies, so a client reading suggestions there finds
what they answer. Nothing goes to a relay the group has blocked. The seed happens
once, so a list the member emptied stays empty.

**Each relay's answer is shown in the relay's words.** The pool answers once per
relay in three shapes -- an OK, a rejection wrapped in `NostrPublishException`, and
any other error -- and the rows keep them apart, because "blocked: not on the allow
list" is something a member can act on and a red icon is not. A relay still
unanswered when the whole send runs out of time reads "No answer", which is not the
same as refused. Answers are matched by host, since the pool names a relay by the
URL it first opened a socket with.

The relay-list rows get their button inside the shared card, under the row and at
the end, because the four rows share one card and "under the event" has to mean
under the row. An agreed empty list gets one too: a withdrawal is a statement, and
relays still holding the old list need to hear it. The key-state event and the
subgroup certificates get none -- `ChronicleManager` keeps the key state off even
the members-only path, and a public relay is a bigger audience than that.

`BroadcastGroupSignedEventViewModelJvmTest` pins the seed rules, the once-only
seeding, the three answer shapes and the host matching, and that what goes on the
wire is the seven fields the group hashed. `BroadcastGroupSignedEventScreenJvmTest`
presses the button against a fake pool and finds each answer under its relay with
the sum above them. `GroupNostrProfileSectionJvmTest` counts five buttons on a group
with a profile, two agreed lists, a post and a schema, each under its own card, and
finds them still there for a member with no share.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 13:55:29 +02:00
Kgothatso NgakoandClaude Opus 5 c8de3a1f19 Merge branch 'curated' into claude/nsec-import-nostr-restore-da0a9a
curated moved while the nsec sign-in work was being merged into it: the
curated-schema-suggestions branch landed first. One conflict, in strings.xml,
where both branches appended their new strings at the end of the catalogue --
kept both, theirs first, no names in common. The other three shared files
(NostrRepository, DatabaseNostrRepository, CurareNavHost) merged cleanly.

Verified with :composeApp:compileDebugKotlinAndroid, :composeApp:jvmTest (934
tests, both branches' suites) and :composeApp:m3Audit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 13:01:45 +02:00
Kgothatso NgakoandClaude Opus 5 1e52fc8f25 feat(groups): the queue of a list the group curates, read off the relays it named
`930d37c8` gave a group the schema: the definition of a list, signed by the room's
own key, for strangers to answer. This is the answers. Under every schema card on the
group's screen there is now a "View suggestions" button, and it opens the list's
*queue* -- every kind 31888 anyone has published in reply to the schema's coordinate,
newest first, whoever signed it, with a mark on each one the group has already taken
up into the list. It is the second half of the curated-list NIP in this app, the
read side of it: suggestions (31888) and canonical entries (31890) are now read and
checked here. They are still not written; that is the third half.

The screen is bitcoin.mov's `/suggestions` page, which does the same thing for that
site's one list: one row per suggestion event rather than one per film, so that a
reader can see what is waiting before anything is added and whether the curator has
taken it up. `SuggestionList.tsx` and the store behind it, `useVideos.ts`, are the
reference for everything the screen decides -- one row per event, the newest
version per coordinate, "Curated" where a canonical entry shares the `d`, and a
timer standing in for an answer that never comes.

**The button is behind no gate, and it is per card.** Every other button in the
identity block is hidden from a member holding no share of the key, because each of
them proposes a signature by the group. The queue is the one thing in the block the
group did not write. A schema exists to be answered by strangers, and reading the
answers takes no share of anything, so the button is there for whoever is looking
-- `GroupNostrProfileSectionJvmTest` puts a member with no share in front of a
schema and finds it. It sits under its own card rather than once for the section,
in the same `item {}` as the card, because each list has its own queue and a button
between two cards would say nothing about which one it opened.

**The protocol is ported rule for rule, and the fixtures are the NIP's own.**
`nostr/curated/CuratedEntryEvent` is the reference module's `verifyEntry`,
`verifyCuratedCanonical`, `checkValue` and `valuesOf`, in the NIP's order: the kind
is the one the schema names; every required field is present; no field without
`repeat` appears twice; every value matches its field's type and config; every
`require-any` group is met; the `a` root names this schema and no other; and the
author is somebody the visibility admits. A canonical entry gets two rules on top --
its author is the schema's author, because curation is the one power a schema does
not delegate, and a source pointer, when there is one, is a well-formed suggestion
coordinate, because a malformed one credits the wrong person. `CuratedEntryEventTest`
takes *The Rise and Rise of Bitcoin* as `eebb74ab…` suggested it in the NIP's
example, and the curator's sign-off on it, and checks both against the bitcoin.mov
schema from the same document; then the doc's own minimum suggestion, which has an
IMDb link and no watch link and satisfies `require-any` that way; then every
rejection the doc lists and says why it matters -- an unknown type, a year outside
1900--2100, a non-https poster, a `javascript:` link, a title over 200 characters, a
`d` with a space in it -- plus the reply rules, the repeat rule, the closed-list
rule and the two canonical rules.

**Rejected, not repaired, and read by field.** The NIP says a client MUST verify an
entry against its schema and MUST reject one that does not satisfy it rather than
showing it with the bad parts blanked out; relays carry malformed, partial and
hostile events from other applications. So `suggestion` and `canonical` return the
entry whole or return null, and `verifySuggestion` and `verifyCanonical` return the
reasons as typed problems -- a field name and a `Reason`, the way `CuratedSchema.
problems` is an enum rather than a sentence -- so that a form later can show them
inline. What comes back is a `CuratedEntry` keyed by the schema's *field names*
rather than by tag, because a field is what a form and a screen know an entry by and
the tag is only where it was kept: the two `r` tags of the example land on
`watchUrl` and `imdbUrl` by their markers, the two `t` tags on `hashtags`, the body
on `description`. The `director`, `i` and `lang` tags on the NIP's example are on no
field of the NIP's schema and are not in the reading -- "tags the schema does not
define MAY be present and MUST be ignored".

**A pattern this platform cannot compile counts as not matched.** The reference
builds `new RegExp('^(?:' + pattern + ')$')` and would throw out of its verifier on
a bad one; JavaScript and Kotlin regex dialects also differ at the edges. Ignoring
an uncompilable pattern would accept entries the site refuses; refusing them is the
conservative reading, and it is documented at the check.

**A coordinate splits on the first two colons only.** A `d` may itself contain
colons -- `imdb:tt2821314` does, and it is the identifier the NIP's example uses --
so `CuratedCoordinate.parse` is the reference's regex rather than a `split(":")`,
and the test pins the identifier surviving its own colon and the pubkey being
lowercased on the way through.

**The queue is a reading over stored rows, with three things to close and one to
add.** `CuratedSuggestion.queueOf` takes whatever the local table holds for the
coordinate -- kinds 31888 and 31890 with an `a` tag naming it -- and reads the
queue out of it. Closed: an event that does not satisfy the schema; a kind 31890
signed by anybody but the group, which is somebody else's list and marks nothing;
and an older version of an entry its author has since replaced, since both kinds
are addressable and different relays hold different latest versions, so the merge
that realises an edit happens here, newest per `kind:pubkey:d` with the event id
breaking ties. Added: `isCurated`, true where a canonical entry the group signed
shares the suggestion's identifier -- the coordinate both land on, and the
reference page's rule. Newest first, because that is the order a queue is read in.

**A stranger is named by their profile, and by their key until one arrives.** The
indexer writes a placeholder profile named "LOADING..." the moment a pubkey is
first seen, and a queue full of that would be a queue of nobody.
`suggesterName` reads the profile only when it is a real one -- `createdAt` past
`GENESIS_AT` -- and otherwise the short key, which is at least stable and
distinguishing. The row's avatar is tinted from the key like every avatar here, so
two suggestions by one stranger read as one stranger.

**Read from where the schema says, and the screen says where.** The schema's
`relay` tags are signed into the event for exactly this: a client that finds the
list anywhere knows where its replies live and cannot be sent elsewhere by an
unsigned config. A schema naming none -- the NIP allows it and lets a client pick
-- is read from the group's general relay list, the *read* relays of it, since this
is a read; and failing an agreed, non-empty one, from this build's own relay, the
same fallback the schema editor seeds from. Spellings are normalised so one relay
written two ways is one request. The header names the relays asked, because a
queue read from the wrong relays and a list nobody has written to look exactly
alike from here, and a member should be able to tell them apart.

**Nothing here talks to a relay; it is a pull like every other one-off read.**
`CuratedSuggestionListViewModel` queues one `SynchronizeNostrEventRequest` per relay
for the sync pump to drain, carrying the NIP's two queries as one request's two
filters -- everything anyone published in reply to the coordinate, and what the
*group* published in reply to it, the second scoped by `authors` to spare the relay
the work `queueOf` does regardless -- and watches the local table for what comes
back. That watch needed a way to observe an arbitrary NIP-01 filter, which the
repository did not have: `observeNostrFeed(filter)` recognises a handful of shapes
and falls back to text notes for the rest, and none of its shapes is "these kinds
with this `a` tag". `observeNostrEventsMatching` applies the filter whole through
`NostrEventFilterQuery`, the builder negentropy already uses, so the `#a` match is
anchored and escaped rather than a substring scan; the DAO method behind it names
its observed tables explicitly, the events and the profiles joined onto them, so a
row whose author's kind 0 arrives after the row does re-emits with the name filled
in. What the screen shows is therefore what this device has *stored* for the
coordinate -- which is also what it shows with no network at all, and what it
showed last time until the relays answer again. `NostrEvent.toEvent` is the small
conversion the reading needs to hand a stored row to a verifier written against
the wire shape, beside `GroupSignedEvent.toEvent` which does the same for the
group's own.

**"Still looking" is bounded by time, because nothing else bounds it.** The pump
marks a request sent when the REQ goes out and processed when an event comes back.
A relay holding nothing for the coordinate answers with an EOSE the pump does not
record, so there is no signal for "asked and empty", and a screen that showed the
local table's first, empty read would call every list empty for the second before
its rows arrived -- which teaches a member not to believe it. So the queue is
"being asked" from the request going out until either something lands or ten
seconds pass, and only after that is an empty queue empty. The reference store does
the same with a six-second timer; ten here because the request queues behind the
pump's four subscription slots before it goes out. Rows arriving end it early, a
late arrival after it is still shown, and `withQueue` -- the one state merge --
pins all three in `CuratedSuggestionListViewModelJvmTest`. The empty state offers
"Ask again", which re-queues the same requests: the one thing the watch cannot do
on its own is make more arrive.

**The row shows what an entry is, not where to find it.** The screen is driven by
a schema it has never seen, so what goes on a row is a decision rather than a
layout: the title as the headline, since every list has one; a glance line of the
form fields that say what the entry is, as `Label: value`, because a bare
"2014 · en" says nothing to somebody who does not know the list's fields; the body
where the list has one; and who suggested it, when. Links are left to the sheet --
a URL on a row is a line of noise. "Curated" sits on the row as the one thing on it
a member might act on: it says the group already took this up, and re-curating it
would revise the entry rather than add one.

**The sheet has the whole entry and the event it came as.** Every field the entry
answered, labelled as the schema labels it and in the schema's order, so it reads
as the form would have; the title not repeated, since it is the heading; tokens and
links monospaced because those are compared and copied rather than read. Then the
signed event, byte for byte, with a copy button -- the way the key state sheet
shows the group's own statement and for the same reason: a prettier rendering is a
different string to the one whose id was hashed. It is also the thing a canonical
entry is built from, when that half arrives.

**Four states, and the transition between them.** Loading while the room and the
schema are read; an error, with nothing to retry, for a schema this device does
not hold, since the identifier came from a navigation argument and reading it
again fails the same way; and a loaded state that is either the rows, or looking,
or empty with something to do. `ScreenStateTransition` wraps the `when`, which is
the Scaffold's whole content.

**The audit's proper-noun list grows by two films.** The preview suggests *The Rise
and Rise of Bitcoin* and *Magic Money*, both title case for the correct reason, and
`m3-title-case.py` excludes sample data by name rather than by pattern.

**Still nothing has reached a relay, and it bites once more.** Group-signed events
are not yet published, so a group's schema has not been where a suggester could
find it, and its queue is empty until it has. The screen reads the coordinate
`31889:<group>:<d>` all the same and shows whatever a relay holds for it; the
suggestions on bitcoin.mov's relay reply to *that* curator's coordinate and are
correctly not a group's. `GroupCuratedSchema`'s caveat now says so and points at
the reading.

32 new tests. `CuratedEntryEventTest` (15) works from the NIP's example suggestion
and canonical entry against the NIP's schema: the reading by field, the minimum
suggestion, the source pointer and its absence, curation not being delegated, a
malformed source, the wrong kind, the reply rules, a missing required field, the
repeat rule both ways, every value rule the doc lists, `require-any`, the closed
and private lists, `checkValue` on durations, patterns and https, and the
coordinate split. `CuratedSuggestionTest` (4) reads a queue out of stored rows:
verified suggestions newest first with the broken, the foreign and the wrong-kind
ones dropped, an edit collapsing to its newest version, the curated mark placed by
the group's canonical entry and not a stranger's, and the naming of a suggester
with a profile, a placeholder and nothing. `CuratedSuggestionListViewModelJvmTest`
(6) covers the relay order and the read-only filter, one request per relay carrying
both queries and the watch covering both kinds, the three outcomes of `withQueue`,
an `initiate` run end to end against fakes -- the relays asked, the filter watched,
the rows shown, the looking ended -- and a missing schema being an error rather
than an empty queue. `CuratedSuggestionListScreenJvmTest` (6) renders the header,
the row's glance line with the link kept off it, the mark on the right row and only
that row, looking against empty, and the sheet with its fields, its link and its
event. One new case and one extended in `GroupNostrProfileSectionJvmTest` put the
button under each card in turn and in front of a member with no share.

1398 tests pass -- 893 in `:composeApp:jvmTest`, 505 in `:composeApp:testDebugUnitTest`
-- `:composeApp:compileDebugKotlinAndroid` is clean, and `m3Audit` meets every budget.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 12:54:34 +02:00
Kgothatso NgakoandClaude Opus 5 e3cc23ae31 feat(recovery): the key behind an identity that has no phrase, and the way to forget it
Phase 6 of docs/nsec-sign-in.md. KeyRecoveryScreen offered one backup, the
recovery phrase, whose screen reads userWallet.words out of the seed map. For
an identity signed in with a bare key there are no words, and the honest
answer that screen would give is "this device holds no phrase for the
profile". So:

KeyRecoveryScreen branches on the active identity's kind. A mnemonic identity
keeps the phrase option. A NostrSecret identity gets a nostr secret key option
in its place, routing to NostrSecretRoute, with its own status line ("you said
you stored it") and a header that no longer promises coins. The backup flags
underneath are the same two per-identity preferences the phrase screen
writes; they already mean "this identity's secret is not backed up" for
whichever secret it is.

NostrSecretScreen is RecoveryPhraseScreen with the word grid replaced by the
nsec: hidden until revealed, revealed in monospace, selectable, with a copy
action -- nobody transcribes sixty-three characters by hand -- the same two
checkboxes, hidden again on leaving. The view model reads the key from
nostr-keys.dat at reveal time, by the identity's public key, not off the
active identity, so the screen's contract -- nothing secret held longer than
it is shown -- is the phrase screen's. The disclaimer is a new string: the
old one said "...and the funds in its wallet", and this identity has no
wallet to warn about.

Forget this key. An import needs an inverse, and this is the first real "sign
out" in the app; ActiveProfileScreen's button still routes to a pending
screen, and the general case stays there, because removing a seed is a wallet
question with funds behind it. Behind a dialog that names the npub and says
the profile stays on the relays, four effects in an order that matters: the
key out of nostr-keys.dat and the identity's preference files off the disk
(IdentityWriter.forgetNostrKey, which refuses a key that is not in the file
-- a wallet's nostr key lives in the seed); the metadata entry hidden, since
the metadata store has no delete and isHidden is what the selector filters
on; the account's unsigned rows deleted (forgetLocalAccount -- the kind 0
that made it a local account and anything queued that can now never be
signed, with the requests that hang off them cascading; published events
and the profile cache stay, as anyone else's would); and only then the
caller told, which re-lists identities and clears the active one so the
navigation observer sends a null identity to startup. A failure at the first
step leaves the rest untouched -- an identity the selector lists but nothing
can open is worse than one that is still there.

Tests. IdentityWriterJvmTest runs both bare-key writers against the jvm key
store and a real directory: a key written once and refused the second time
by public key, with its preferences file created; forgetting one key leaves
the other and takes its preferences with it; a key that is not in the file is
not forgotten. Its keys are fresh per test rather than fixed, because
DataStoreManager caches each id's preferences in a companion object for the
life of the process, and a fixed key was served the UserPrefs an earlier test
had created in an earlier temp directory -- worth knowing about that cache.
NostrSecretViewModelJvmTest records the four effects and asserts their order,
and that a key that could not be removed stops the sequence at one.
ForgetLocalAccountJvmTest, against Room, asserts the account and its cascaded
requests go while an unrelated account stays.

Verified with :composeApp:compileDebugKotlinAndroid, :composeApp:jvmTest (901
tests) and :composeApp:m3Audit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 12:27:54 +02:00
Kgothatso NgakoandClaude Opus 5 d61d3560a0 feat(sign-in): ask the relays that would know, and say when none of them did
Phase 5 of docs/nsec-sign-in.md. Not nsec-specific: a restored recovery phrase
whose profile was never published, or a device offline at sign-in, sat on the
same spinner. An imported nsec is the first path that hits it routinely --
many nostr keys are made in a client that never wrote a kind 0.

Ask the relays that would know. The sign-in sync fanned its REQ out over
Relays.DefaultDMRelayList, which is listOf(ephemeral): our own relay, alone.
The right answer for a profile this app created; an identity that has lived
on Damus for three years has never heard of it. SignInSync now holds the one
definition three call sites want -- the kinds, the request builder and the
bootstrap set, which is every indexer relay plus ours. Indexer relays exist
to hold everyone's kinds 0, 3 and 10002; that is exactly what the sync asks
for.

Then follow the answer, once. When a level-0 sign-in request brings back the
user's own kind 10002, the sync pump queues the same request at level 1 at
the relays that list says they write to, less the bootstrap set already
asked. The outbox model doing what it is for: the indexers know *where* the
user publishes, and the user's own relays are where the rest of their lists
are authoritative. Write relays, not read relays -- asking a user's inbox for
their own events is the mistake the split exists to name. One hop per
account per session, because every bootstrap relay that holds the list
answers with it; and a level-1 request never re-enters, because past the
user's own relays lies the feed, not the profile.

Say when none of them did. A request went pending -> sent when its REQ was
dispatched and sent -> processed only if an event arrived for it; a relay
that answered with EOSE and nothing else left its row at `sent` for good, so
"still searching" and "searched, found nothing" were the same row and the
screen waiting on the sync had no way to say the second thing. The pump's
finally block -- every exit: EOSE, CLOSED, the bounded timeout -- now records
`complete`, conditionally in SQL on the row still being `sent`, because the
event handler that writes `processed` runs in its own coroutine and can land
after the subscription has closed, and a completion that overwrote it would
turn "found" back into "found nothing".

UnsyncedProfileViewModel reads that. Its one decision, `decide`, is a pure
function of the account: a kind 0 indexed or a Profile row means the route is
about to move, so still searching; any request still pending or sent is a
relay that has not finished; only when every request has finished and
nothing came is the answer not-found. The screen's not-found state offers
two exits. Try again re-queues the bootstrap, and the new in-flight requests
put the screen back to searching on their own. Set up a profile is the
six-event bootstrap a fresh key gets, without a fresh key:
setUpProfileForExistingKey writes the kind 0 *over* the placeholder row,
under its own id with signedAt back to null, rather than beside it --
getLocalAccounts is every kind-0 row, and two for one pubkey would be two
accounts disagreeing about which is this one. The rows change under
observeLocalAccount, NavigationViewModel sees an unsigned kind 0, and the
notary, which already holds this key, signs it. createNewProfile now builds
its events through the same bootstrapUnsignedEvents.

Tests. SignInSyncTest pins the bootstrap set (every indexer, ours, no
duplicates, more than one) and the outbox reading of a relay list: write and
unmarked relays in, read relays and malformed tags out, already-asked
removed. UnsyncedProfileDecisionTest walks pending -> sent -> complete and
asserts the answer flips only on the last, that a request answered with
something other than a profile still counts as finished, that an arrived
kind 0 is never not-found. SynchronizeNostrEventRequestCompletionJvmTest
pins the conditional update against a real Room database: sent becomes
complete, processed and pending are left alone. SetUpProfileForExistingKeyJvmTest
runs signInToProfile then the set-up against the repository and asserts one
kind-0 row, the same id, unsigned, carrying the name, with five events beside
it.

Verified with :composeApp:compileDebugKotlinAndroid, :composeApp:jvmTest (895
tests) and :composeApp:m3Audit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 12:16:06 +02:00