Repository navigation
🤖 refactor: split maybeStartQueuedTasksFromReservations, part 1: launch CAS, bookkeeping and plans - #7745
Conversation
…ch CAS, bookkeeping and plans Part 1 of 3 of the maybeStartQueuedTasksFromReservations split (tail first). It moves the tail of the per-task loop body into steps: the launch lease hold, the queued -> starting CAS, the bookkeeping after the CAS, the plan, and the launch of the plans after the mutex is released. The method's CC goes from 76 to 56. Each new step has CC 8 or less. - leaseQueuedTaskLaunch holds the launch lease (a refusal arms the retry and skips the task), then calls claimQueuedTaskLaunch right after its await. - claimQueuedTaskLaunch keeps the CAS closure with the shutdown check and the status gate, and the `launch` and `shuttingDown` variables the closure writes. It reads them only after the edit, as before. Every exit without a plan releases the lease. - moveQueuedRowToStarting is the closure's write on the fresh row (the attempt pick, `starting`, the brief's send id). Only the closure calls it, so no await separates it from the shutdown check. - recordQueuedLaunch publishes the rotation, begins the owned attempt and pushes the plan that buildQueuedTaskLaunchPlan builds into the same `plans` array that the method's disposer reads. - launchReservedPlans is the Promise.allSettled launch. The steps return "reserved", "skipped" or "shutdown". The loop breaks on "shutdown" and counts a slot on "reserved". The count now runs after the plan push instead of before it. Only the loop head reads it, so the change is not observable. 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. Hooray! 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.2k tokens (24% cached) All 14 tests in 9 files
e2e 0.20.0 · 1m 11s · web · run artifacts 🟢 e2e Electron stories (Haiku): 3 passed3 agent steps · 3 model calls · 7.9k tokens (22% cached) All 3 tests in 3 files
e2e 0.20.0 · 18.5s · electron · run artifacts 🟢 e2e agent repros (Haiku): no tests selectedSpend: $0.00 of the $1.00 cap (proxy ledger) e2e 0.20.0 · 5.3s · 2 targets (web, phone) · run artifacts |
|
@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. |
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 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 1 of 3 of the
maybeStartQueuedTasksFromReservationssplit (stack 9, tail first). It moves the tail of the per-task body into steps: the launch lease hold, the queued → starting CAS, the bookkeeping after it, the plan build and the launch of the plans after the mutex is released. The method's CC goes from 76 to 56. Changed lines: 317.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
leaseQueuedTaskLaunchholds the launch lease before the CAS. On a refusal it still callsarmQueuedLaunchLeaseRetry()before it skips the task.claimQueuedTaskLaunchruns the CAS. The updater keeps theisShuttingDown()check, andmoveQueuedRowToStartingpicks the attempt from the fresh row and writestaskPromptSendIdin the same updater call. The step readslaunchandshuttingDownonly after the edit, as before, becauseeditConfigcan run the updater twice.recordQueuedLaunchpushes into the sameplansarray that the disposer reads.Risks
Queued task launches. A wrong lease release would leave a task's lease held until the process exits. The tests in #7744 cover the shutdown, lost-CAS and lease-retry exits.
Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high• Cost:$313.07