test(mobile): order each effect against the sends with a send count

Sender and effects are two independent lists, so a send reordered ahead of a
device write moved neither. Scheduling the codex journal write on a timer instead
of awaiting it left all 520 goldens byte-identical; with `sent` it moves two.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
This commit is contained in:
Jinwoo-H
2026-09-15 18:24:19 -04:00
parent 37754267d0
commit 7edf2c2bc9
@@ -22,11 +22,14 @@ export async function runRecording(
): Promise<Recording> {
scheduler.start()
const transport = new ScriptedRpcTransport(scheduler.elapsed)
const effects: { name: string; value: RecordedValue }[] = []
const effects: { name: string; value: RecordedValue; sent: number }[] = []
const settlements: Record<string, Settlement> = {}
const recording: Recording = { scenario: scenario.id, checkpoints: [] }
const effect = (name: string, value: unknown) => {
effects.push({ name, value: captureValue(value) })
// Why the send count: sender and effects are two independent lists, so a send reordered ahead of
// a device write moves neither of them. Stamping the count at push time orders them against
// each other, and that reordering becomes a golden diff.
effects.push({ name, value: captureValue(value), sent: transport.requests.length })
}
const stopUnhandled = recordUnhandledRejections(effect)
let mounted: MountedOperation | undefined