Phase 4 settled the blob and left the database alone, because there was nothing
to settle: the state is opaque to Room and its version is inside it. Phase 8 added
a table, and that turns "does an existing install still open?" from a question
about MLS into a question about Room. They fail differently. A blob the engine
cannot read costs one room; a migration Room cannot find costs the app, on every
device that has ever had it, on the first launch after the update.
That second one is also the easiest here to ship by accident, because a fresh
install never migrates anything. Measured rather than assumed: with
`AutoMigration(from = 36, to = 37)` commented out, 32 database tests ran and 4
failed -- all four of them the new ones.
ShippedProfileUpgradeJvmTest builds a v36 database on disk from the exported v36
schema, down to its indices, its room_master_table identity hash and its
user_version, puts a profile and two rooms in it with the Phase 4 blob in one, and
opens it with the app's own getRoomDatabase. Four claims: it reaches v37 with
Room's own identity hash stamped and every table's columns and indices equal to
37.json's; the legacy room's bytes come back unchanged and MarmotEngine.groupFor
restores a group with its 0xF2EE metadata and a 32-byte kind:445 key; opening the
profile rewrites nothing, which is asserted only after checking the restore held
the room; and the new table takes a row keyed to a ChatRoom that predates it.
Room opens lazily, so a test that builds a database and closes it migrates
nothing. The first version of this did that and failed on user_version still
reading 36.
The blob itself moves to OldEngineBlob in commonTest, read by both tests. The
only thing those bytes are worth is that they are old ones, and a blob living in
two files can be regenerated in one of them.
1171 tests across 157 classes, 0 failures; the four audits unchanged.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
C1 is the constraint the whole move hangs on: ChatRoom.mlsGroupState is a
MlsGroupState.encodeTls() blob written by quartz 1.15.2 on every device that has ever been
in a group, and a blob the new engine cannot read costs a user every room they are in --
there is no in-place migration from a legacy group.
The argument was checkable before a test was written. quartz 1.15.2's own sources, in the
sources jar beside the artifact in the gradle cache, declare STATE_VERSION = 4; mls-kmp
1.3.0 declares 10 and accepts 1..10, appending only. So every blob in the wild is version
4 and the window covers it six times over.
The measurement is docs/tools/old-state-blob, whose only dependency is
com.vitorpamplona.quartz:quartz:1.15.2 -- it prints a real 1033-byte blob for a legacy
MIP-01 group at epoch 0, which is the shape every room in the wild started as. It is
checked in because once it is gone nothing in the hex says whether the fixture came from
the old engine or the new one, and a fixture written by the new engine would pass while
testing nothing.
MlsGroupStateCompatibilityTest pins it six ways: the fixture is still version 4 (asserted
alone, so a fixture that drifted to 10 cannot make the rest pass vacuously); mls-kmp
decodes it; the group rebuilds from it with 0xF2EE, its nostr_group_id and its name
intact, still reading as legacy; the kind:445 outer key off a restored old group is 32
bytes, which is Phase 1's policy finding pinned against real pre-migration bytes; a
re-save lands on version 10 and still decodes, same group id and epoch; and
RetainedEpochSecrets still round-trips the five fields RoomMlsGroupStateStore stores it as.
No schema change: the blob is opaque to Room and the version is inside it, so 36 stands.
Not done, and not automatable here: one manual upgrade of a profile with real rooms in it.
A fixture is one member at epoch 0; the rooms that matter have epochs, members and a
retained window behind them. That is the last thing between this and a release.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>