Skip to content

Add adaptive_timeout: derive a wait timeout from observed durations#438

Merged
JE-Chen merged 1 commit into
devfrom
feat/adaptive-timeout-batch
Jun 25, 2026
Merged

Add adaptive_timeout: derive a wait timeout from observed durations#438
JE-Chen merged 1 commit into
devfrom
feat/adaptive-timeout-batch

Conversation

@JE-Chen

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

Copy link
Copy Markdown
Member

Summary

Third feature of the ROUND-15 input-fidelity lane. Hard-coded waits flake either way — too short races a slow machine, too long makes every failure pay the full timeout. Learn the timeout from how long the step has actually taken.

  • Headless core utils/adaptive_timeout/: recommend_timeout (the percentile_q-th percentile of observed durations × safety factor, clamped to [min_s, max_s]; default_s cold-start when empty) and timeout_stats (same + {n, p50, p_high, recommended, floored, capped}). Both pure, reuse stats.percentile.
  • 5 layers wired: facade __all__; AC_adaptive_timeout / AC_timeout_stats executor commands (durations accept a JSON list); matching read-only ac_* MCP tools; Script Builder under Flow.
  • Docs: EN + Zh v211_features_doc.rst + WHATS_NEW.md.

Test

test/unit_test/headless/test_adaptive_timeout_batch.py — percentile×factor scaling, factor, floor-to-min, cap-to-max, empty→default→min, None-sample skipping, timeout_stats percentiles + capped flag + empty, plus JSON-list executor coercion and facade + executor/MCP/builder wiring. All 12 green; ruff + radon clean; pytest.approx throughout (no float ==); package stays Qt-free.

Hard-coded waits flake either way — too short races a slow machine, too
long makes every failure pay the full timeout. Learn the timeout from
how long the step actually takes: a high percentile scaled by a safety
factor, clamped to a sane band. recommend_timeout is the number to feed
a wait/GateConfig; timeout_stats exposes the percentiles and clamp flags.
Pure, reuses stats.percentile.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 29 complexity · 0 duplication

Metric Results
Complexity 29
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 f269e43 into dev Jun 25, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/adaptive-timeout-batch branch June 25, 2026 22:40
@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