Spend one end-to-end deadline across retries
Independent timeout values can accidentally multiply the latency of one request. An end-to-end deadline limits the whole operation, including attempts and backoff. Before admitting another attempt, reserve enough time for that attempt instead of checking only whether the sleep fits.
This planner accepts elapsed time and deterministic candidate delays. It schedules full attempts only and never sleeps. Equality at the budget boundary is accepted by contract. Production jitter, retryable error classification and idempotency are independent decisions. Retrying every error until a timer expires is not a resilience strategy.
budget=1.0
elapsed=0.4
delay=0.2
attempt=0.3
print(elapsed+delay+attempt<=budget)Review the design
A real request uses an absolute monotonic deadline and measures actual elapsed time. The pure planner isolates the arithmetic contract; it is not a claim that real operations always consume their estimated duration.
Your task
Implement retry_plan(budget,attempt,delays). The initial attempt consumes attempt seconds; each listed retry consumes delay+attempt. Return admitted delays in order, stopping at the first that would exceed budget. Reject negative values.
The explanation opens here once every check passes.