Commit Graph
7 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 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 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 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 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 e6aee79282 refactor: rebrand curated to curare, and the one name that stays on disk
`com.it.curated.{compose,android,desktop}` becomes `to.curare.{compose,android,desktop}`
across 700 file moves, and the app is Curare everywhere a user can read it. This is the
third rename this tree has been through, so the question was never how to spell the new
name but which of the 5074 occurrences of the old one were the brand. `3bc8be53` and
`d26cf6c7` had already sorted most of that, which is why this rename is mechanical where
those two were not -- and why the interesting part is the one place it is still not.

**`APP_DIR_NAME` keeps the old brand, and is the only thing that does.** It names the
desktop app's data directory -- `~/.local/share/curated`, `Application Support/curated`,
`%LOCALAPPDATA%\curated` -- and that single directory holds the Room database, the marmot
group state and the phoenix wallet. Renaming it does not move an install: it silently
starts an empty one beside it and leaves the old chat history and the old seed sitting
where nothing reads them any more. That is the same class of silent failure as the
`mantra/` hash prefixes, so it gets the same treatment -- it stays, with a comment saying
what renaming it would cost and that doing it properly is a first-run migration rather
than a rebrand. The desktop app is `curated` on disk and `Curare` everywhere a user can
read.

**The applicationId and the namespace are one value again, at `to.curare.android`.**
`3bc8be53` split them precisely so `com.it.curated` could land verbatim as the store
identity while the namespace kept `.android`; the decision here was to collapse them, so
both read `to.curare.android` and the manifest's relative `android:name=".CurareApplication"`
and `BuildConfig` resolve against the same package they always did. Debug is
`to.curare.android.debug` through the existing suffix. Worth stating plainly because
nothing in the build will: an applicationId *is* the app's identity to Play, so this is a
new listing rather than an update, and no installed Curated can update into it.

**`CuratedDatabase` -> `CurareDatabase` moves a directory, never a table.** The `@Database`
class name picks the schema *directory*, so
`composeApp/schemas/com.it.curated.compose.database.CuratedDatabase/` becomes
`to.curare.compose.database.CurareDatabase/` and its 19 files move unmodified. What makes
that safe has not changed since last time: the 12 entity classes are still `Mantra*` and
still declare no `tableName`, so Room still takes their class names as the SQLite table
names -- and this rename does not touch one of them. The check is that Room found all 19
schemas at the new directory and generated no twentieth.

**The generated resources package moved because `rootProject.name` did, again.** Compose
Resources derives it from the root project, so `Curated` -> `Curare` silently turns
`curated.composeapp.generated.resources` into `curare.composeapp.generated.resources` and
breaks 72 files' imports at once. Rewritten with them: the two string keys that carried
the brand -- `curated` and `sign_in_is_not_yet_available_while_curated_is` -- their three
call sites, and the eight `docs/scripts/` tools that hardcode the UI source path. The
audit reporting 582 `stringResource` sites and 178 `Icon(` call sites is the evidence
those tools still see the whole tree rather than an empty directory.

**A global rename edits the sentences that describe the previous rename, and two of them
came out false.** `material-design-conformance.md` recorded that `TorchTheme` became
`CuratedTheme` and that `UserAgent` was moved off Torch "when the app was rebranded to
Curated" -- which a blanket sweep turns into a claim about a change that had not happened
when it was written. Same in `HomeScreen`, where "the brand before that one" meant Torch
while Curated was current, and quietly came to mean Curated while still naming
`TorchTheme`. Both now say what happened, in order. The three deliberate Torch records --
the finding at :278, that note, and `NavigationRoutingTest`'s fixture -- are intact.

**What was protected stays protected, and now says "two rebrands".** `TWEAK_TAG`,
`HOST_KEY_DERIVATION_TAG` and `wss://ephemeral.mantra.press` are byte-identical; only the
prose around them moved, because "survived the rebrand to Curated" had stopped being the
whole story. The tree's 1668 `Mantra` and 17 `Torch` tokens differ from the 1666 and 16
before this change only by the words those comments added.

**iOS is `Curare` / `to.curare.ios`**, with the three pbxproj product references renamed
to match, and is unverified here for the same reason as last time -- the build gates the
ios targets behind `isMacOsX` and this was built on linux. The bundle id takes a platform
segment rather than the bare base it translates from, so that it reads alongside an
android applicationId that now carries one: `to.curare.android` and `to.curare.ios`, and
`to.curare` left as the base neither store claims.

1226 tests pass -- 787 in `:composeApp:jvmTest`, 439 in `:composeApp:testDebugUnitTest` --
`:composeApp:compileDebugKotlinAndroid` is clean, and `m3Audit` meets every budget.

Three stale things are left alone, because none of them is branding.
`.gitea/workflows/material-design-conformance.yml` still triggers on `branches: [mantra]`,
which stopped naming a branch that exists somewhere before this change and is now two
brands out; the three `torch_*` string keys still carry a brand two renames old, though
every value they hold reads Curare; and `androidMain/res/values/strings.xml` has opened
`<resources>a` since well before this. Each wants its own change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-10 13:33:47 +02:00