Add adaptive_timeout: derive a wait timeout from observed durations#438
Merged
Conversation
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.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 29 |
| 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
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.
utils/adaptive_timeout/:recommend_timeout(thepercentile_q-th percentile of observed durations × safetyfactor, clamped to[min_s, max_s];default_scold-start when empty) andtimeout_stats(same +{n, p50, p_high, recommended, floored, capped}). Both pure, reusestats.percentile.__all__;AC_adaptive_timeout/AC_timeout_statsexecutor commands (durations accept a JSON list); matching read-onlyac_*MCP tools; Script Builder under Flow.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_statspercentiles + capped flag + empty, plus JSON-list executor coercion and facade + executor/MCP/builder wiring. All 12 green;ruff+radonclean;pytest.approxthroughout (no float==); package stays Qt-free.