Repository navigation
🤖 refactor: split createUnderTaskTreeLifecycleLock, part 5: request, parent, placement, agent and AI - #7706
Conversation
…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.
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. 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. |
🟢 e2e stories (Haiku): 14 passed22 agent steps · 7 replayed from cache · 15 model calls · 46.2k tokens (28% cached) All 14 tests in 9 files
e2e 0.20.0 · 1m 15s · 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 · 22.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. More of your lovely PRs 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. |
|
@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 5 of 5: splits the start of
TaskService.createUnderTaskTreeLifecycleLockin 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
readTaskCreateRequestand the module functionnormalizeTaskCreateBestOfvalidate the input.loadTaskCreateParent,readTaskCreateParentandrefuseTaskCreateUnderParentload the parent and refuse a create under a wrong parent.countAndPlaceTask,placeTaskWorkspaceand the module functiondecideSharedTaskWorkspacecount active tasks and place the workspace.readTaskCreateParentBranch,describeRunnableTaskAgents(the formergetRunnableHintclosure),checkTaskAgentRunnableandresolveTaskCreateAiSettingshandle the parent branch, the agent and the AI settings.The method now holds only the lock and
return await this.loadTaskCreateParent(...). Thatreturn awaitis the one await this split adds, and theawait usingrule requires it. A script compared the old and new code: every collaborator is called the same number of times.Rules every part keeps
await using _lock = await this.mutex.acquire(). Inside that scope, a barereturn promisereleases the global mutex before the promise settles. So every call from the method to a step isawaitorreturn await, and no step acquires the mutex, which is not reentrant.make crap-checkagainst the parent commit reports 0 violations, with and without coverage. Every new function scores CC 8 or less.bun teston 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