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
2026-09-09 17:04:09 +02:00
2026-03-24 04:47:19 +02:00
2026-03-23 01:41:39 +02:00
2026-03-23 01:41:39 +02:00
2026-03-23 01:41:39 +02:00

This is a Kotlin Multiplatform project targeting Android, iOS, Desktop (JVM).

  • /composeApp is for code that will be shared across your Compose Multiplatform applications. It contains several subfolders:

    • commonMain is for code that’s common for all targets.
    • Other folders are for Kotlin code that will be compiled for only the platform indicated in the folder name. For example, if you want to use Apple’s CoreCrypto for the iOS part of your Kotlin app, the iosMain folder would be the right place for such calls. Similarly, if you want to edit the Desktop (JVM) specific part, the jvmMain folder is the appropriate location.
  • /iosApp contains iOS applications. Even if you’re sharing your UI with Compose Multiplatform, you need this entry point for your iOS app. This is also where you should add SwiftUI code for your project.

Build and Run Android Application

To build and run the development version of the Android app, use the run configuration from the run widget in your IDE’s toolbar or build it directly from the terminal:

  • on macOS/Linux
    ./gradlew :composeApp:assembleDebug
    
  • on Windows
    .\gradlew.bat :composeApp:assembleDebug
    

Build and Run Desktop (JVM) Application

To build and run the development version of the desktop app, use the run configuration from the run widget in your IDE’s toolbar or run it directly from the terminal:

  • on macOS/Linux
    ./gradlew :composeApp:run
    
  • on Windows
    .\gradlew.bat :composeApp:run
    

Build and Run iOS Application

To build and run the development version of the iOS app, use the run configuration from the run widget in your IDE’s toolbar or open the /iosApp directory in Xcode and run it from there.


Learn more about Kotlin Multiplatform…

Languages
Kotlin 99.9%