diff --git a/docs/quartz-mls-marmot-update.md b/docs/quartz-mls-marmot-update.md index 944ec80c..865b3a05 100644 --- a/docs/quartz-mls-marmot-update.md +++ b/docs/quartz-mls-marmot-update.md @@ -398,6 +398,74 @@ Then quartz's behavioural deltas that reach the app, both small: recorded here. A test that needed its assertions edited to pass is a finding, as in marmot-kmp.md's Phase 2. +**Built.** The existing suite needed nothing: it was already green on 1.3.1 in Phase 2, with +no assertion moved. + +**`OldEpochZeroGroupJvmTest`**, two tests, both green. The first draft of the first one +was wrong, and the way it was wrong is worth keeping. + +mls-kmp's commit `6a1ba88` says a creator's epoch-0 state saved by 1.3.0 or older "is +repaired on restore", and the test asserted that. It failed. The *released* 1.3.1 has no +repair: its audit commit, `125614a`, took it out ("repairing only the creator forked the two +apart" from a PublicGroup saved beside it). The library's upgrading guide says what ships: +"an older release['s epoch-0 group] keeps the old hash, so external joins into it fail until +its first commit". So the test now pins both sides of that: + +- an old epoch-0 room keeps its empty interim hash across a restore; +- a room created now gets the §11 hash; +- the old room still adds its first member, and the joiner and the creator agree on the + epoch authenticator and the kind:445 key and read each other. + +A future mls-kmp that brings the repair back fails the first assertion, and its KDoc says +to re-read the upgrading guide before inverting it. The app has no `externalJoin`, so the +one thing an old epoch-0 room cannot do is something this app never asks of it. + +**`docs/tools/engine-interop/`** is the probe, built as two programs rather than an +extension of `old-state-blob`, for two reasons: + +- That tool's whole job is provenance for one blob, and should stay that small. +- The probe cannot be one build. Both halves depend on the `com.vitorpamplona.quartz` + group, at 1.15.2 and 2.20.0, and Magpie serves that group exclusively from a relay with + nothing older than 2.19.0. So `old/` is quartz 1.15.2 from Central and nothing else, + answering one command per line on stdin, and `new/` is the app's versions through + Magpie, driving it as a child process. + +Each scenario goes three epochs: + +1. the Welcome; +2. two further adds by the room's creator, which the other engine applies, checking each + confirmation tag against a transcript it computed itself; +3. a message each way at every epoch. + +The first draft had the joiner commit an add too, and both engines refused it on MIP-03's +rule that only an admin may. That was correct of them, and the scenario was wrong. Across +the two scenarios each engine authors commits and each applies the other's. The run: + +``` +== the new engine creates the room, the old one joins + ok after the Welcome: both at epoch 1 with the same kind:445 key + ok epoch 1: the old engine reads the new one / the new engine reads the old one + ok after the new engine's first commit past the Welcome: both at epoch 2 … + ok after its second: both at epoch 3 … (and both ways at 2 and 3) +== the old engine creates the room, the new one joins + …the same ten checks, with the old engine committing… +ALL PASSED +``` + +That is 20 checks, 20 green. So a room either engine creates, at either epoch-0 shape, works +with the other through three epochs. **What it does not say** is which engine Bennu ships +today. Its repository is not readable without signing in, so quartz 1.15.2 is +marmot-kmp.md's last record of it, not a fresh one. If Bennu has moved, the probe's `old/` +pins that version instead, and Phase 8's real-peer check covers whatever it is. + +**quartz's two behavioural deltas**, both checked: + +- **`GiftWrapEvent.create`** is called at 16 sites with the same signature. The NIP-17, + Welcome-wrapping and `MarmotClientInteropJvmTest` suites pass unchanged, and the last + of those has the library's `MarmotWelcomeSender` wrap a Welcome the app opens. +- **`EventFactory`'s new subclasses** are for kinds 30078, 30100 and 30102. + `grep -rnE '\b(30078|30100|30102)\b' composeApp/src` finds nothing. + ## Phase 4 — C1, and the fork, measured again No new code expected. This phase runs the tests marmot-kmp.md left as tripwires and records diff --git a/docs/tools/engine-interop/README.md b/docs/tools/engine-interop/README.md new file mode 100644 index 00000000..717c3c43 --- /dev/null +++ b/docs/tools/engine-interop/README.md @@ -0,0 +1,32 @@ +# engine-interop + +The MLS engine the app ships against the one it shipped before, in two JVMs. +[docs/quartz-mls-marmot-update.md](../../quartz-mls-marmot-update.md), Phase 3. + +- `old/` is one Marmot member played by quartz 1.15.2's engine, the one a Bennu peer + on that version still runs. It reads one command per line on stdin and answers on + stdout (see `OldPeer.kt`). +- `new/` is the app's engine at the versions in `gradle/libs.versions.toml`: + marmot-kmp over mls-kmp, through Magpie. Its driver starts the old peer as a child + process and runs two scenarios: the new engine creates the room and the old one joins, + then the reverse. In each, the creator commits two more adds after the Welcome, and + both sides must land on the same epoch and kind:445 key and read each other's + messages at every epoch. + +They are two builds because they cannot be one: both depend on the `com.vitorpamplona.quartz` +group, at 1.15.2 and 2.20.0. Magpie serves that group exclusively, and its relay has nothing +older than 2.19.0, so `old/` resolves from Maven Central with no Magpie at all. + +Not part of `./gradlew check`. It is a probe to run by hand when the engine moves. + +```bash +../../../gradlew -p old installDist +``` + +```bash +../../../gradlew -p new run --args="$PWD/old/build/install/engine-interop-old/lib" +``` + +It prints `ok` per check and `ALL PASSED`, or `FAIL` with the step and exits 1. Move +`new/build.gradle.kts`'s versions with the catalogue's, and let the first run add them to +`new/gradle/magpie.lock`. diff --git a/docs/tools/engine-interop/new/build.gradle.kts b/docs/tools/engine-interop/new/build.gradle.kts new file mode 100644 index 00000000..1584dd21 --- /dev/null +++ b/docs/tools/engine-interop/new/build.gradle.kts @@ -0,0 +1,16 @@ +plugins { + kotlin("jvm") version "2.4.10" + application +} +dependencies { + // What the app resolves. Keep these at gradle/libs.versions.toml's versions: the point of + // this probe is the engine the app ships against the one it shipped before. + implementation("com.vitorpamplona.marmot:marmot:2.3.0") + implementation("com.vitorpamplona.mls:mls:1.3.1") + implementation("com.vitorpamplona.quartz:quartz:2.20.0") + implementation("com.vitorpamplona.crypto:crypto:2.1.1") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.11.0") + runtimeOnly("fr.acinq.secp256k1:secp256k1-kmp-jni-jvm:0.24.0") +} +kotlin { jvmToolchain(21) } +application { mainClass.set("DriverKt") } diff --git a/docs/tools/engine-interop/new/gradle/magpie.lock b/docs/tools/engine-interop/new/gradle/magpie.lock new file mode 100644 index 00000000..d1082d3a --- /dev/null +++ b/docs/tools/engine-interop/new/gradle/magpie.lock @@ -0,0 +1,21 @@ +# Magpie lock file. Commit it: it pins the key each group's domain vouched for and the +# manifest each resolved version came from. A change to either fails the build. +version 1 +publisher com.vitorpamplona.crypto e9867c970848e300d6fca32bbd600c2fd4bd92c760ae5707355058720991955c nip05:releases@vitorpamplona.com +publisher com.vitorpamplona.marmot e9867c970848e300d6fca32bbd600c2fd4bd92c760ae5707355058720991955c nip05:releases@vitorpamplona.com +publisher com.vitorpamplona.mls e9867c970848e300d6fca32bbd600c2fd4bd92c760ae5707355058720991955c nip05:releases@vitorpamplona.com +publisher com.vitorpamplona.negentropy e9867c970848e300d6fca32bbd600c2fd4bd92c760ae5707355058720991955c nip05:releases@vitorpamplona.com +publisher com.vitorpamplona.quartz e9867c970848e300d6fca32bbd600c2fd4bd92c760ae5707355058720991955c nip05:releases@vitorpamplona.com +publisher com.vitorpamplona.schnorr256k1 e9867c970848e300d6fca32bbd600c2fd4bd92c760ae5707355058720991955c nip05:releases@vitorpamplona.com +release com.vitorpamplona.crypto:crypto-jvm:2.1.1 1012859c6c4548599c203c41f2126fcc0ca2138feae1f2acf84f42222f96825e 1c993cfd7b8b034a12ce66b20b1910a88f2c1816a39f3c284155fd8831acf80d +release com.vitorpamplona.crypto:crypto:2.1.1 1012859c6c4548599c203c41f2126fcc0ca2138feae1f2acf84f42222f96825e 1c993cfd7b8b034a12ce66b20b1910a88f2c1816a39f3c284155fd8831acf80d +release com.vitorpamplona.marmot:marmot-jvm:2.3.0 a24c22b76974376bb4c271e3dc973b12478d88af76b326ce55ca23ca66ce0aa0 b9498111dfc41c27fdb152869aa6d3f04052e2588ca9aac7a301a7dc7eb40341 +release com.vitorpamplona.marmot:marmot:2.3.0 a24c22b76974376bb4c271e3dc973b12478d88af76b326ce55ca23ca66ce0aa0 b9498111dfc41c27fdb152869aa6d3f04052e2588ca9aac7a301a7dc7eb40341 +release com.vitorpamplona.mls:mls-jvm:1.3.1 afaee9458cfea00107297adeb93ef7315543288cdd008b4ed2dcf08d67f2c162 1b6b39440116e65adce199f237c878fbc3821d2e09946550af6b3852218fe086 +release com.vitorpamplona.mls:mls:1.3.1 afaee9458cfea00107297adeb93ef7315543288cdd008b4ed2dcf08d67f2c162 1b6b39440116e65adce199f237c878fbc3821d2e09946550af6b3852218fe086 +release com.vitorpamplona.negentropy:kmp-negentropy-jvm:v1.2.3 d005ae7d13d4fc0b5b498d554a880366554edef8c39ba123248676f360df3635 c4dfe76b4bdaa3442c5b8223778b0347e9bd9ab63f71a4b183ea42087353fdf5 +release com.vitorpamplona.negentropy:kmp-negentropy:v1.2.3 d005ae7d13d4fc0b5b498d554a880366554edef8c39ba123248676f360df3635 c4dfe76b4bdaa3442c5b8223778b0347e9bd9ab63f71a4b183ea42087353fdf5 +release com.vitorpamplona.quartz:quartz-jvm:2.20.0 893d9b079b98f3aead17fbbceaa46902beb6707bdac2fea136cbe08a66c686b6 5b125908669198513ef9eae94c337280dd81b75cd55789bcd7ccbe1f7e3a8d66 +release com.vitorpamplona.quartz:quartz:2.20.0 893d9b079b98f3aead17fbbceaa46902beb6707bdac2fea136cbe08a66c686b6 5b125908669198513ef9eae94c337280dd81b75cd55789bcd7ccbe1f7e3a8d66 +release com.vitorpamplona.schnorr256k1:schnorr256k1-kotlin-jvm:1.0.3 c8b474acf88c25958132495167bc27613f0db8492871fdced6bd4ac51a2a660e 004147e4e84462d3f867001b45e41b16eec93f0e00ca3668741c085be7af5c21 +release com.vitorpamplona.schnorr256k1:schnorr256k1-kotlin:1.0.3 c8b474acf88c25958132495167bc27613f0db8492871fdced6bd4ac51a2a660e 004147e4e84462d3f867001b45e41b16eec93f0e00ca3668741c085be7af5c21 diff --git a/docs/tools/engine-interop/new/settings.gradle.kts b/docs/tools/engine-interop/new/settings.gradle.kts new file mode 100644 index 00000000..5215b5e7 --- /dev/null +++ b/docs/tools/engine-interop/new/settings.gradle.kts @@ -0,0 +1,25 @@ +rootProject.name = "engine-interop-new" +pluginManagement { + repositories { + gradlePluginPortal() + mavenCentral() + } +} +// The same groups, plugin and versions as the app's own settings and catalog. +plugins { + id("com.vitorpamplona.magpie") version "0.2.3" +} +magpie { + group("com.vitorpamplona.quartz") + group("com.vitorpamplona.marmot") + group("com.vitorpamplona.mls") + group("com.vitorpamplona.crypto") + group("com.vitorpamplona.negentropy") + group("com.vitorpamplona.schnorr256k1") +} +dependencyResolutionManagement { + repositories { + google() + mavenCentral() + } +} diff --git a/docs/tools/engine-interop/new/src/main/kotlin/Driver.kt b/docs/tools/engine-interop/new/src/main/kotlin/Driver.kt new file mode 100644 index 00000000..109d320c --- /dev/null +++ b/docs/tools/engine-interop/new/src/main/kotlin/Driver.kt @@ -0,0 +1,129 @@ +import com.vitorpamplona.marmot.appComponents.CurrentProfileGroupFactory +import com.vitorpamplona.marmot.groups.MarmotGroupPolicy +import com.vitorpamplona.mls.group.MlsGroup +import com.vitorpamplona.quartz.nip01Core.core.hexToByteArray +import com.vitorpamplona.quartz.nip01Core.core.toHexKey +import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair +import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal +import java.io.BufferedReader +import java.io.File +import kotlin.system.exitProcess +import kotlinx.coroutines.runBlocking + +/** + * The engine the app ships (marmot-kmp 2.3.0 over mls-kmp 1.3.1) against the one it shipped + * before (quartz 1.15.2), both ways round, one commit past the Welcome each way. + * + * mls-kmp 1.3.1 changed what a new group's epoch 0 is -- a random epoch secret and the + * RFC 9420 §11 interim transcript hash where quartz 1.15.2 left it empty -- so a room one of + * them creates starts from an epoch 0 the other would not have built. The Welcome carries the + * confirmed transcript, which argues that nobody notices; the commits after it are where a + * disagreement would surface, because the joiner checks each one's confirmation tag against a + * transcript it computed itself. So in each scenario the room's creator -- its only admin, and + * under MIP-03 the only member who may commit an Add -- commits two more adds, and the other + * engine applies them. Between the two scenarios each engine authors commits and each applies + * the other's. + * + * Usage: `run --args=