AlgorithmHarness

Replay a recorded trace through an algorithm and score the result.

This is the part that turns "algorithm A is better than algorithm B" from an argument into a measurement. Without it, every threshold in the system is a number somebody once felt good about, and every change is unfalsifiable.

The whole harness is pure and synchronous because MileageAlgorithm.process is: no device, no emulator, no coroutines, no clock. A trace replays identically on a laptop, in CI, and in a browser preview.

Functions

Link copied to clipboard
fun compare(candidates: List<MileageAlgorithm>, trace: List<Fix>): List<RunReport>

Run every candidate over the same trace, so the comparison is genuinely like-for-like.

Link copied to clipboard
fun run(algorithm: MileageAlgorithm, trace: List<Fix>, session: SessionContext = SessionContext(startedAtMs = trace.firstOrNull()?.timeMs ?: 0L)): RunReport

Feed trace through algorithm in order and collect a report.

Link copied to clipboard
fun snapshotRoundTrips(factory: () -> MileageAlgorithm, trace: List<Fix>, breakAt: Int): Boolean

Verify that resuming from a snapshot mid-trace yields the same totals as an uninterrupted run — minus the one leg deliberately dropped across the resume boundary.