Skip to content

🤖 refactor: split createUnderTaskTreeLifecycleLock, part 5: request, parent, placement, agent and AI - #7706

Merged
ThomasK33 merged 3 commits into
refactor/task-create-split-4from
refactor/task-create-split-5
Oct 28, 2026
Merged

ThomasK33 merged 3 commits into
refactor/task-create-split-4from
refactor/task-create-split-5

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Summary

Part 5 of 5: splits the start of TaskService.createUnderTaskTreeLifecycleLock in place, with no behaviour change. The method drops from CC 61 to CC 2. On top of part 4. 423 changed lines.

Across the five parts, the method goes from CC 122 to CC 2, and every new function scores CC 8 or less.

Steps in this part

  • readTaskCreateRequest and the module function normalizeTaskCreateBestOf validate the input.
  • loadTaskCreateParent, readTaskCreateParent and refuseTaskCreateUnderParent load the parent and refuse a create under a wrong parent.
  • countAndPlaceTask, placeTaskWorkspace and the module function decideSharedTaskWorkspace count active tasks and place the workspace.
  • readTaskCreateParentBranch, describeRunnableTaskAgents (the former getRunnableHint closure), checkTaskAgentRunnable and resolveTaskCreateAiSettings handle the parent branch, the agent and the AI settings.

The method now holds only the lock and return await this.loadTaskCreateParent(...). That return await is the one await this split adds, and the await using rule requires it. A script compared the old and new code: every collaborator is called the same number of times.

Rules every part keeps

  • The method keeps await using _lock = await this.mutex.acquire(). Inside that scope, a bare return promise releases the global mutex before the promise settles. So every call from the method to a step is await or return await, and no step acquires the mutex, which is not reentrant.
  • The steps form a chain: each step calls the next one directly after its own last await. So no collaborator call runs a microtask later than in the inline code. Only the result of the method resolves later, at approximately 2 microtasks per chain level. The mutex therefore releases that much later, at the same logical point.
  • make crap-check against the parent commit reports 0 violations, with and without coverage. Every new function scores CC 8 or less.
  • bun test on the taskService, ledger, workspaceTurnManager, workflows, tools and workspaceService suites: 4,968 pass, 0 fail. These suites include the 27 tests from 🤖 tests: cover createUnderTaskTreeLifecycleLock paths before the split #7701.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $182.90

…parent, placement, agent and AI

Moves the start of TaskService.createUnderTaskTreeLifecycleLock into named
steps. Before the global mutex: readTaskCreateRequest with the module function
normalizeTaskCreateBestOf. Under it, a chain: loadTaskCreateParent
(readTaskCreateParent), countAndPlaceTask (refuseTaskCreateUnderParent,
placeTaskWorkspace, decideSharedTaskWorkspace), readTaskCreateParentBranch,
checkTaskAgentRunnable (describeRunnableTaskAgents, the getRunnableHint
closure) and resolveTaskCreateAiSettings, which queues or launches the task.
Values travel in the readonly TaskCreateRequest, TaskCreateParent,
TaskCreatePlacement and TaskCreatePlan records, each built on the last with
spread. Each step starts the next in the same tick as its own last await.
The method keeps its signature, the `await using` of the mutex and one
`return await this.loadTaskCreateParent`, so the mutex releases only after
the create result settles. CC 122 -> 2 across the parts.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 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-28T12:46:26.322288Z 748bbe9 Manual request
🔒 Security Review ✅ Completed 2026-10-28T12:47:18.759940Z 748bbe9 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 #7707 October 28, 2026 12:31
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 715c00bd48

ℹ️ 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: 715c00bd48

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 28, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e stories (Haiku): 14 passed

22 agent steps · 7 replayed from cache · 15 model calls · 46.2k tokens (28% cached)
Spend: $0.08 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 7.5s
🟢 a chat survives a restart of the server 1 step · 1 call 7.5s
🟢 compaction.e2e.ts · 1 passed 1 step · 1 call 4.5s
🟢 /compact replaces the old chat with a summary 1 step · 1 call 4.5s
🟢 pluginTrustRestart.e2e.ts · 1 passed 4 steps · 2 calls 10.3s
🟢 a trusted plugin hook stays trusted after the server restarts 4 steps · 2 calls 10.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 5.4s
🟢 a new workspace starts with its right sidebar collapsed while another keeps it open 4 steps · 1 call 5.4s
🟢 smoke.e2e.ts · 1 passed 2 steps · 1 call 2.4s
🟢 the agent opens the playground workspace 2 steps · 1 call 2.4s
🟢 streamErrors.e2e.ts · 1 passed 1 step · 1 call 7.4s
🟢 stream errors show in the chat, and the chat recovers 1 step · 1 call 7.4s
🟢 todoNudge.e2e.ts · 1 passed 1 step · 1 call 2.4s
🟢 the agent finishes open TODO items after the turn-end nudge 1 step · 1 call 2.4s
🟢 touchAlignment.e2e.ts · 6 passed 6 steps · 6 calls 23.5s
🟢 the Settings close button is level with the title on a touch screen 390px wide 1 step · 1 call 4.3s
🟢 the Settings close button is level with the title on a touch screen 768px wide 1 step · 1 call 4.3s
🟢 Backup settings checkboxes are small and level with their labels on a touch phone 1 step · 1 call 4.1s
🟢 the heartbeat checkbox is small and level with its label on a touch phone 1 step · 1 call 4.1s
🟢 a reply's model and time stay on one line on a touch phone 1 step · 1 call 4.2s
🟢 the workspace actions menu stays on the title row on a touch phone 1 step · 1 call 2.6s

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

🟢 e2e Electron stories (Haiku): 3 passed

3 agent steps · 3 model calls · 8.0k tokens (32% cached)
Spend: $0.01 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.4s
🟢 a deep link of a second launch starts a chat in the running app 1 step · 1 call 5.4s
🟢 electron/menuBar.e2e.ts · 1 passed 1 step · 1 call 9.8s
🟢 the workspace menu bar is the desktop title bar 1 step · 1 call 9.8s
🟢 electron/smoke.e2e.ts · 1 passed 1 step · 1 call 5.0s
🟢 Xum Electron opens the playground workspace 1 step · 1 call 5.0s

e2e 0.20.0 · 22.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. More of your lovely PRs please.

Reviewed commit: 52ade76849

ℹ️ 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: 52ade76849

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. Another round soon, please!

Reviewed commit: 748bbe91f6

ℹ️ 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: 748bbe91f6

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 28, 2026
Merged via the queue into main with commit cb756b2 Oct 28, 2026
33 of 34 checks passed
@ThomasK33
ThomasK33 deleted the refactor/task-create-split-5 branch October 28, 2026 19:47
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