Add retry_budget: deadline + jitter over resilience retries#436
Merged
Conversation
resilience.RetryPolicy retries a fixed attempt count with plain exponential backoff, but can't express a wall-clock deadline (give up after N seconds total) or jitter (randomized backoff against thundering herds). RetryBudget adds both, bounded by attempts and/or a deadline, never sleeping past it; uniform/clock/sleep are injectable so every delay and giveup decision is deterministic in tests.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 42 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
First feature of the ROUND-15 input-fidelity lane.
resilience.RetryPolicyretries a fixed attempt count with plain exponential backoff but can't express a wall-clock deadline or jitter — exactly what flaky, contended UI automation needs.utils/retry_budget/:RetryBudget(bounded bymax_attemptsand/ordeadline_s),run_with_budget(honours whichever bound is hit first; never sleeps past the deadline; caps the final sleep to the remaining time),backoff_delay(pure capped exponential backoff),jittered_delay(full/equal/none strategies). The randomness (uniform),clockandsleepare all injectable → every delay and giveup decision is deterministic in tests.RetryPolicy(doesn't duplicate it) — adds the deadline + jitter it lacks.__all__;AC_retry_delay/AC_plan_retry_delaysexecutor commands (pure backoff schedule,jitterdefaults tononefor determinism); matching read-onlyac_*MCP tools; Script Builder under Flow.run_with_budget(wraps a callable) is the Python-API surface.v209_features_doc.rst+WHATS_NEW.md.Test
test/unit_test/headless/test_retry_budget_batch.py— pure backoff/jitter (full/equal/none with injecteduniform), schedule,run_with_budgetsuccess / attempts-exhausted / deadline-giveup / unlisted-exception-propagation / sleep-capped-to-deadline, plus facade + executor/MCP/builder wiring. All 14 green;ruff+bandit(B311 non-crypto jitter, matchedchaos.pysuppression) +radonclean;pytest.approxthroughout (no float==); package stays Qt-free.