Kgothatso Ngako 521a4f5690 test: pin the epoch secret retention window
A retained epoch secret is what lets a member read a message sent under an epoch
the group has since moved past. Both ways of getting the policy wrong are quiet:
keep too few and old messages become permanently unreadable, keep too many and
secrets that should have been dropped stay on disk. The entire policy is one
strict `<` in a query and an IGNORE on an insert.

The cutoff is strict, and that matters more than an off-by-one usually does.
This query feeds a delete, so an epoch wrongly reported as droppable is not a
stale read -- it is the messages of that epoch becoming undecryptable, with
nothing to recover them from. Covered with three epochs either side of the
boundary: only strictly older ones are droppable, the epoch equal to the cutoff
is still inside the window, and a cutoff at or below every retained epoch drops
nothing.

Room scoping, for the same reason. Rooms advance epochs independently, so a
sweep driven by one room's cutoff must never reach another's -- a leak here
costs the other room its history. Asserted from both ends: the sweep returns
only the sweeping room's rows, and the other room's secret is still there
afterwards.

Insert is IGNORE over the composite key (chatRoomId, epoch), which is what makes
re-processing a commit safe. A redelivery or a replay re-derives the secret, and
overwriting the stored one with that re-derivation would replace the value that
actually decrypts the messages already on disk. Covered by inserting a second,
different secret for the same epoch and asserting the first survives -- and
alongside it, that the same epoch number in two different rooms is two rows
rather than a conflict, since the composite key is what separates them.

Also covered: defenestrate removes exactly the rows the sweep selected and
leaves the rest, and a room's retained epochs are all readable back, which is
what a rejoin or a full replay reads before deciding what it can still decrypt.

Verified by mutation: relaxing the cutoff to `epoch <= :epochCutOffPoint` fails
three of these, including the boundary test. The mutation was reverted; no
production source is touched by this commit.

7 tests.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 03:11:58 +02:00
2026-07-05 23:21:02 +02:00
2026-07-28 09:10:20 +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 thats 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 Apples 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 youre 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 IDEs 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 IDEs 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 IDEs toolbar or open the /iosApp directory in Xcode and run it from there.


Learn more about Kotlin Multiplatform

Description
Mantra as a kotlin multiplatform project
https://mantra.press
Readme 8.2 MiB
Languages
Kotlin 100%