Repository navigation
🤖 refactor: split maybeStartQueuedTasksFromReservations, part 3: drain preamble - #7747
Conversation
…n preamble Part 3 of 3. It moves the head under the mutex into steps: the reads, the inactive-workflow prepass, the stale-turn sweep bookkeeping and the capacity gates. maybeStartQueuedTasksFromReservations ends at CC 8 (from 76 before the stack). It keeps the lease disposer, the mutex block, the per-task loop and the launch of the plans after the mutex. - openQueuedDrain reads the config, the task settings, the task index and the queued tasks, runs the prepass, and re-reads all three when the prepass interrupted a task. Then it calls countQueuedDrainSlots right after the prepass's last await. - countQueuedDrainSlots reads staleTurnSweepGeneration before the turn count, completes the sweep only when the scan saw every owner, and returns "idle" (nothing queued, or no free slot) or "open" with the drain record the loop reads. The turn count still runs after the prepass. - listQueuedAgentTasks is the former listQueuedTasks closure, now a method because both reads in openQueuedDrain call it. No behaviour change: same awaits on collaborators, same calls in the same order (compared with a script), same log messages and fields. --- _Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_ <!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=xhigh -->
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
🟢 e2e stories (Haiku): 14 passed22 agent steps · 7 replayed from cache · 15 model calls · 46.3k tokens (28% cached) All 14 tests in 9 files
e2e 0.20.0 · 1m 16s · web · run artifacts 🟢 e2e Electron stories (Haiku): 3 passed3 agent steps · 3 model calls · 8.0k tokens (32% cached) All 3 tests in 3 files
e2e 0.20.0 · 18.9s · electron · run artifacts 🟢 e2e agent repros (Haiku): no tests selectedSpend: $0.00 of the $1.00 cap (proxy ledger) e2e 0.20.0 · 6.4s · 2 targets (web, phone) · run artifacts |
…ueue-start-split-3
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
…ueue-start-split-3
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Summary
Part 3 of 3. It moves the drain's preamble under the mutex into
openQueuedDrain(config, settings, queued list and the inactive-workflow prepass) andcountQueuedDrainSlots(the stale-turn sweep bookkeeping and the capacity gates).maybeStartQueuedTasksFromReservationsends at CC 8 (from 76 before the stack). Changed lines: 172.No behaviour change: same awaits, same calls to other methods in the same order (checked with a script that inlines every step), same
markTaskLaunchFailedmessages. Each new step has CC 8 or less, with 100 % line coverage. The method keeps the_unlaunchedLeasesdisposer, the mutex block and the per-task loop. No step takes the mutex or starts a drain, and every step call inside the mutex block is awaited.Implementation
countQueuedDrainSlotsreads the sweep generation before the turn count and does the sweep bookkeeping only when the scan saw every owner.Risks
Queue drains run after every task state change. The split adds microtasks between tasks inside the mutex block (up to 7 before the next task's first call), as the merged
recoverInterruptedTaskssplit did. All 5019 targeted tests pass at every part. A mutation pass over the new code left 33 survivors: equivalent mutants, assertions for impossible conditions, empty-string edge cases, one debug log, and two test gaps (an extra coalesced drain, and a worktree parent's runtime project path).Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high• Cost:$313.07