def need.of
import cswap-bend-cli@0.1.0.0/policy/pick.bend as Pickimport Base
import cswap-bend-cli@0.1.0.0/policy/types.bend as T
44# The least headroom a target needs: at-limit and failover take any
45# headroom; proactive must land below the threshold and beat the active
46# account by the hysteresis margin.
47def need.of(+t: T.Trigger, +ah: Nat, +hy: Nat, +thr: Nat) -> Nat:
48 match t:
49 case T.Proactive{}:
50 Nat.max(Nat.add(ah, hy), Nat.add(Nat.sub(T.full(), thr), 1n))
51 case o:
52 1n