Repository navigation
fix(batch): give a batch's permission preflight its own budget, capped at 15 s - #57
Merged
Merged
Conversation
A top-level batch ran the permission preflight with the default 5 s deadline, ahead of its own --timeout-ms budget (60 s by default). When that check is slow, as on a freshly started desktop session under load, the whole batch failed with TIMEOUT before its first entry. This is the cause of the batch_session_ended_* CLI test flake: the envelope captured by the diagnostic from PR #53 was a batch-level TIMEOUT after 5.0 s, kind deadline, not_delivered. main now takes the batch's budget before the preflight, and the batch spends from that inherited deadline instead of starting a fresh one, so --timeout-ms covers the preflight and every entry.
Review of the first version found that handing the batch budget to the context dropped the min with --timeout-ms, turned a budget spent in the preflight into a pre-dispatch TIMEOUT instead of not_started entries, and left the preflight with no cap of its own. This keeps the batch exactly as on main and changes only the preflight's deadline: a top-level batch's permission report gets its --timeout-ms budget capped at 15 s instead of the 5 s default. The context getter is removed.
gshost1
added a commit
that referenced
this pull request
Nov 8, 2026
gshost1
added a commit
that referenced
this pull request
Nov 8, 2026
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.
A top-level
batchran its permission preflight (adapter.permission_report, inmain.rs) with the default 5 sDeadline::standard(), although the batch itself has a--timeout-msbudget (60 s by default). When that check is slow (on Linux it touches D-Bus, AT-SPI and the X11 stale-input sweep; a freshly started desktop session under load is enough), the whole batch failed withTIMEOUTbefore its first entry.This is the cause of the
batch_session_ended_*CLI process test flake (four local gate failures on 2026-11-08). The diagnostic from PR #53 captured the envelope on the next failure:State before and after
What changed
src/main.rs:preflight_deadlinegives a top-level batch's permission report its--timeout-msbudget capped atBATCH_PREFLIGHT_CAP_MS(15 s). The batch's own execution and deadline semantics are unchanged.How tested
main_tests::a_top_level_batch_preflight_gets_the_batch_budget_capped_not_five_seconds:batch --timeout-ms 60000gets more than 10 s and at most 15 s;--timeout-ms 2000gets at most 2 s;statuskeeps at most 5 s. With the batch arm put back toDeadline::standard(), it fails.e04ed040(main9ea5d145): fmt, clippy-D warnings, source-rule and architecture scripts, core Windows check, Win32 leakage check,cargo tree, host-set tests 4901 passed, 0 failed. CI 13/13 green on that head.Review: a first version moved the batch budget into the command context; the medium review showed it dropped the min with
--timeout-ms, turned a budget spent in the preflight into a pre-dispatchTIMEOUTinstead ofnot_startedentries, and left the preflight uncapped. This version changes only the preflight's deadline.Performance
None; the preflight's work is unchanged, only how long it may take.
Risks
--timeout-ms(as before).statusandpermissionskeep the 5 s preflight and could still time out on a very slow session.What's left
Merge rule: rule 3.
mainmoved to45236e6a(fork PRs #12 and #6:tests/e2e/**,crates/macos/src/tree/element_bounds*.rs) after this head's CI; none of those files overlap this PR, and none is an always-overlap file. Prior art: none upstream.