Skip to content

🤖 refactor: split maybeStartQueuedTasksFromReservations, part 1: launch CAS, bookkeeping and plans - #7745

Merged
ThomasK33 merged 3 commits into
refactor/task-queue-start-testsfrom
refactor/task-queue-start-split-1
Oct 30, 2026
Merged

ThomasK33 merged 3 commits into
refactor/task-queue-start-testsfrom
refactor/task-queue-start-split-1

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Summary

Part 1 of 3 of the maybeStartQueuedTasksFromReservations split (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 markTaskLaunchFailed messages. Each new step has CC 8 or less, with 100 % line coverage. The method keeps the _unlaunchedLeases disposer, 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

  • leaseQueuedTaskLaunch holds the launch lease before the CAS. On a refusal it still calls armQueuedLaunchLeaseRetry() before it skips the task.
  • claimQueuedTaskLaunch runs the CAS. The updater keeps the isShuttingDown() check, and moveQueuedRowToStarting picks the attempt from the fresh row and writes taskPromptSendId in the same updater call. The step reads launch and shuttingDown only after the edit, as before, because editConfig can run the updater twice.
  • Every exit without a plan releases the lease. The shutdown exit still breaks the loop, and the plans collected before it still launch.
  • recordQueuedLaunch pushes into the same plans array 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

…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 -->
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T06:42:11.235950Z f5ea690 Manual request
🔒 Security Review ✅ Completed 2026-10-30T06:43:39.436865Z f5ea690 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ThomasK33
ThomasK33 added this pull request to stack #7748 October 30, 2026 03:42
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 37f56e6171

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 37f56e6171

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e stories (Haiku): 14 passed

22 agent steps · 7 replayed from cache · 15 model calls · 46.2k tokens (24% cached)
Spend: $0.09 of the $1.00 cap (proxy ledger)

All 14 tests in 9 files
Test Agent Time
🟢 chatRestart.e2e.ts · 1 passed 1 step · 1 call 5.4s
🟢 a chat survives a restart of the server 1 step · 1 call 5.4s
🟢 compaction.e2e.ts · 1 passed 1 step · 1 call 4.3s
🟢 /compact replaces the old chat with a summary 1 step · 1 call 4.3s
🟢 pluginTrustRestart.e2e.ts · 1 passed 4 steps · 2 calls 9.3s
🟢 a trusted plugin hook stays trusted after the server restarts 4 steps · 2 calls 9.3s
🟢 settingsRoundTrip.e2e.ts · 1 passed 2 steps · 1 call 8.7s
🟢 a chat survives trips through Settings 2 steps · 1 call 8.7s
🟢 sidebarPerWorkspace.e2e.ts · 1 passed 4 steps · 1 call 4.2s
🟢 a new workspace starts with its right sidebar collapsed while another keeps it open 4 steps · 1 call 4.2s
🟢 smoke.e2e.ts · 1 passed 2 steps · 1 call 2.2s
🟢 the agent opens the playground workspace 2 steps · 1 call 2.2s
🟢 streamErrors.e2e.ts · 1 passed 1 step · 1 call 6.9s
🟢 stream errors show in the chat, and the chat recovers 1 step · 1 call 6.9s
🟢 todoNudge.e2e.ts · 1 passed 1 step · 1 call 2.8s
🟢 the agent finishes open TODO items after the turn-end nudge 1 step · 1 call 2.8s
🟢 touchAlignment.e2e.ts · 6 passed 6 steps · 6 calls 24.2s
🟢 the Settings close button is level with the title on a touch screen 390px wide 1 step · 1 call 7.1s
🟢 the Settings close button is level with the title on a touch screen 768px wide 1 step · 1 call 3.7s
🟢 Backup settings checkboxes are small and level with their labels on a touch phone 1 step · 1 call 4.5s
🟢 the heartbeat checkbox is small and level with its label on a touch phone 1 step · 1 call 3.1s
🟢 a reply's model and time stay on one line on a touch phone 1 step · 1 call 2.9s
🟢 the workspace actions menu stays on the title row on a touch phone 1 step · 1 call 2.9s

e2e 0.20.0 · 1m 11s · web · run artifacts

🟢 e2e Electron stories (Haiku): 3 passed

3 agent steps · 3 model calls · 7.9k tokens (22% cached)
Spend: $0.02 of the $1.00 cap (proxy ledger)

All 3 tests in 3 files
Test Agent Time
🟢 electron/deepLink.e2e.ts · 1 passed 1 step · 1 call 5.5s
🟢 a deep link of a second launch starts a chat in the running app 1 step · 1 call 5.5s
🟢 electron/menuBar.e2e.ts · 1 passed 1 step · 1 call 6.2s
🟢 the workspace menu bar is the desktop title bar 1 step · 1 call 6.2s
🟢 electron/smoke.e2e.ts · 1 passed 1 step · 1 call 4.8s
🟢 Xum Electron opens the playground workspace 1 step · 1 call 4.8s

e2e 0.20.0 · 18.5s · electron · run artifacts

🟢 e2e agent repros (Haiku): no tests selected

Spend: $0.00 of the $1.00 cap (proxy ledger)

e2e 0.20.0 · 5.3s · 2 targets (web, phone) · run artifacts

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 4efad2bc1f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 4efad2bc1f

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: f5ea690213

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: f5ea690213

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@ThomasK33
ThomasK33 added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit 5e3bc61 Oct 30, 2026
66 of 91 checks passed
@ThomasK33
ThomasK33 deleted the refactor/task-queue-start-split-1 branch October 30, 2026 07:41
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