retryBackoffLadderStep function

Duration retryBackoffLadderStep(
  1. int attempt
)

The doubling ladder for attempt (1-based): 5 → 10 → 20 → 40 s, then the ceiling holds (retryBackoffCeiling, 60 s — this module owns both the steps and the cap, so the pair cannot drift).

Coordination (#1395): the stall ladder runtime consumes this step function AND the ceiling — it must not re-derive either locally, or the two ladders drift apart. No stall* symbol is defined here on purpose: the naming/taxonomy surface is #1395's lane.

Implementation

Duration retryBackoffLadderStep(int attempt) {
  final clamped = attempt < 1 ? 1 : attempt;
  final seconds = 5 << (clamped - 1).clamp(0, 4);
  final ceiling = retryBackoffCeiling.inSeconds;
  return Duration(seconds: seconds > ceiling ? ceiling : seconds);
}