Skip to content

Add retry_budget: deadline + jitter over resilience retries#436

Merged
JE-Chen merged 2 commits into
devfrom
feat/retry-budget-batch
Jun 25, 2026
Merged

Add retry_budget: deadline + jitter over resilience retries#436
JE-Chen merged 2 commits into
devfrom
feat/retry-budget-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 25, 2026

Copy link
Copy Markdown
Member

Summary

First feature of the ROUND-15 input-fidelity lane. resilience.RetryPolicy retries 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.

  • Headless core utils/retry_budget/: RetryBudget (bounded by max_attempts and/or deadline_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), clock and sleep are all injectable → every delay and giveup decision is deterministic in tests.
  • Composes over RetryPolicy (doesn't duplicate it) — adds the deadline + jitter it lacks.
  • 5 layers wired: facade __all__; AC_retry_delay / AC_plan_retry_delays executor commands (pure backoff schedule, jitter defaults to none for determinism); matching read-only ac_* MCP tools; Script Builder under Flow. run_with_budget (wraps a callable) is the Python-API surface.
  • Docs: EN + Zh v209_features_doc.rst + WHATS_NEW.md.

Test

test/unit_test/headless/test_retry_budget_batch.py — pure backoff/jitter (full/equal/none with injected uniform), schedule, run_with_budget success / 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, matched chaos.py suppression) + radon clean; pytest.approx throughout (no float ==); package stays Qt-free.

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.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 42 complexity · 0 duplication

Metric Results
Complexity 42
Duplication 0

View in Codacy

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.

@JE-Chen JE-Chen merged commit dbf0ebb into dev Jun 25, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/retry-budget-batch branch June 25, 2026 22:06
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant