LocalHeddleRevision
How far a LocalHeddle has come: the epoch it was started with, and how many calls that can change it have returned since, count. Ordered by epoch, then by count, like a LeaseId.
Two revisions that are equal mean the engine has not changed in between, so a caller can skip work whose inputs include the engine with one comparison, before copying anything. The converse does not hold: a call that changed nothing may still have moved it.
It is not persisted. A restored engine counts from zero again, under the higher epoch LocalHeddle.restore requires, so its revision is above every one the persisted engine had, and a caller holding one across a restart still sees a change. Two engines started under the same epoch can repeat each other's revisions, as they repeat each other's lease ids.
Samples
val tree = twoLanes()
val heavy = tree.groupId("heavy")
val light = tree.groupId("light")
val queued = setOf(heavy, light)
val policy = LocalPolicy(defaultReservation = 3L)
val (heddle, _) = LocalHeddle.fromTopology(tree, policy, epoch = 0L)
heddle.reconcileCapacity(totalSlots = 2L)
// The last pass saw this. Asking who goes next changes nothing, so the next pass can skip.
val seen = heddle.revision
heddle.previewPicks(mapOf(heavy to 1, light to 1), queued, listOf(3L))
check(heddle.revision == seen)
// A lease moves it, so the next pass looks again.
check(heddle.acquire(queued, queued, startedAt = 0L) is AcquireOutcome.Acquired)
check(heddle.revision > seen)
// It is not persisted, but a restore runs under a higher epoch, so the restored engine's
// revision is above every one the old engine had: a pass that saw the old one sees a change.
val restarted = LocalHeddle.restore(heddle.persist(), policy, epoch = 1L)
check(restarted.revision > heddle.revision)