explain
Why leaf is not, or is, what the next LocalHeddle.acquire on these same arguments picks. Changes nothing, not even the wake memory.
The reasons are checked in WaitExplanation.Kind order, and the first that holds is the answer: leaf is not in waiting, not in eligible, cannot be reached (the same test the pick applies, so a leaf behind a closing edge, a group with an active child, and a group that is not leasable are each WaitExplanation.NoLiveLineage), is beneath a group at its concurrency ceiling (WaitExplanation.AtCeiling, naming the one nearest the root), or the root cannot fund reservation. Past those, the answer is the pick itself, run on a throwaway engine with the wake memory, so a group back from idle is placed here exactly as the acquire would place it: WaitExplanation.WouldBePickedNext when the pick ends at leaf, and otherwise WaitExplanation.BehindAtLevel at the first group where it goes another way.
Throws
as LocalHeddle.acquire does: reservation out of range, or eligible not a subset of waiting.
when a WaitExplanation.BehindAtLevel front does not fit an exact Rational, whose numerator carries the least common multiple of the sibling weights' denominators (see "Failure surface" on LocalHeddle). Never on how far a child has climbed: each position is read inside its window, so a child past its ceiling reads at the ceiling and one a cancel walked back below its floor at the floor, the penalty side (#3353).
Samples
val tree = twoLanes()
val root = tree.groupId()
val heavy = tree.groupId("heavy")
val light = tree.groupId("light")
val (heddle, booted) = LocalHeddle.fromTopology(tree, LocalPolicy(defaultReservation = 3L), epoch = 0L)
check(booted.refusals.isEmpty())
heddle.reconcileCapacity(totalSlots = 2L)
val queued = setOf(heavy, light)
// Light is behind at the pool: at twice the weight, heavy's turn comes due sooner.
val why = heddle.explain(light, waiting = queued, eligible = queued)
check(why is WaitExplanation.BehindAtLevel && why.parent == root && why.nextChild == heavy)
check(heddle.explain(heavy, waiting = queued, eligible = queued) == WaitExplanation.WouldBePickedNext)
check((heddle.acquire(queued, queued, startedAt = 0L) as AcquireOutcome.Acquired).lease.leaf == heavy)
// While both stay queued, heavy is owed 2 slots of every 3 and light 1.
check(heddle.entitlement(heavy, waiting = queued, totalSlots = 3L) == Rational.of(2L))
check(heddle.entitlement(light, waiting = queued, totalSlots = 3L) == Rational.ONE)
// A group with nothing queued is simply not waiting.
check(heddle.explain(light, waiting = setOf(heavy), eligible = setOf(heavy)) == WaitExplanation.NotWaiting)