Repository navigation
🤖 refactor: split sendTreeMessage, part 1: park, dispatch and settle - #7709
Conversation
Moves the tail of sendTreeMessage, from the pre-dispatch recheck to the result, into named private steps: dispatchPeerSend, refuseStalePeerSendBeforeDispatch, queuePeerSendBehindParked, parkPeerSendForDelegatedTurn (was the park closure), waitForDelegatedTurn and settlePeerSendResult. No behaviour change. Adds the records the later parts use: PeerSendRoute and PeerSendAdmission (read-only facts) and PeerSendAttempt, the one mutable record that the admission probe and the sendMessage callbacks read when they run. The admission probe is still a closure in sendTreeMessage in this part and is passed to dispatchPeerSend. sendTreeMessage drops from CC 133 to CC 109. Every new step is CC 8 or less.
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. Chef's kiss. 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.5k tokens (27% cached) All 14 tests in 9 files
e2e 0.20.0 · 1m 33s · web · run artifacts 🟢 e2e Electron stories (Haiku): 3 passed3 agent steps · 3 model calls · 7.9k tokens (33% cached) All 3 tests in 3 files
e2e 0.20.0 · 23.4s · electron · run artifacts 🟢 e2e agent repros (Haiku): no tests selectedSpend: $0.00 of the $1.00 cap (proxy ledger) e2e 0.20.0 · 6.9s · 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. |
Summary
Part 1 of 5: splits the tail of
TaskService.sendTreeMessage(park, dispatch and settle) in place into named steps, with no behaviour change. The method drops from CC 133 to CC 109. On top of the test PR #7708. 460 changed lines.The parts go from the end of the method to its start, as in the two earlier stacks (#7697 to #7699, #7702 to #7706). The code that stays inline must be the start of the method, so it can call the extracted tail with one call.
Steps in this part
dispatchPeerSendmakes the dispatch.refuseStalePeerSendBeforeDispatchruns the recheck before dispatch.queuePeerSendBehindParkedqueues the send behind a parked one.parkPeerSendForDelegatedTurnis the formerparkclosure, andwaitForDelegatedTurnwaits for the delegated turn.settlePeerSendResultkeeps the refusal order: the delegated-turn refusal, then the admission refusal, thensend_failed.PeerSendRequest,PeerSendRouteandPeerSendAdmission, and the mutablePeerSendAttempt. In this part the admission check is still a closure, anddispatchPeerSendgets it as a parameter.Rules every part keeps
sendTreeMessagedo not change. No step callsthis.sendTreeMessageagain, so the spy intaskService.delegatedTurnPeerDelivery.test.tsstill sees every call.withPeerAdmissionLock(targetId, ...), which is the peer delivery lock plus the target's event lock. No step takes either lock, and the callback returns the chain, so both locks release when the chain settles.sendMessageand the workspace service run later (admissionStale, park,onCanceled,onAccepted) read and write one mutablePeerSendAttemptrecord when they run:delegatedTurnCorrelation,admissionRefusal,refusedAtRegistrationEpoch,parkedThisAttemptandaccepted.admissionStalestays a plain synchronous function.make crap-checkagainst the parent commit reports 0 violations, with and without coverage. Every new function scores CC 8 or less.Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high• Cost:$198.09