Repository navigation
improve(gateway): defer worker workspace execution imports - #143496
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 2:00 PM ET / 18:00 UTC (Revision 6). ClawSweeper reviewWhat this changesDefers worker execution and sandbox imports until needed, extracts shared workspace-settlement helpers, and adds admission and loading regression coverage. Merge readiness✅ Ready for maintainer review This PR remains useful: current main and the latest release still eagerly import worker execution. No blocking defect was found in the introduced changes. Priority: P3 Review scores
Verification
How this fits togetherThe Gateway's worker launcher routes admitted session turns to local or remote execution. Placement and turn claims control execution authority, while workspace settlement preserves completed file results before releasing ownership. flowchart TD
A[Session turn] --> B[Placement admission]
B --> C[Local execution]
B --> D[Load selected worker execution]
D --> E[Recheck admission and exact claim]
E --> F[Worker or remote execution]
F --> G[Settle workspace and release claim]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +27, Tests +465. Total +492 across 10 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep execution loading behind admitted placement selection while preserving the existing claim, recovery, and workspace-settlement owners. Do we have a high-confidence way to reproduce the issue? Not applicable as a user-facing bug reproduction: source inspection confirms the eager-import boundary, and the added tests target its removal and admission preservation. Is this the best way to solve the issue? Yes. The PR reuses the existing lazy-runtime utility and extracts shared settlement code without creating a competing execution or persistence owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 201f11afefdb. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
* commit '2d87daf04b78992382299d552f15ac84a86a23ed': (1815 commits) fix(ui): distinguish tool activity with semantic icons (#147207) fix(linux): recover completed Quick Chat replies without resending (#146048) feat(desktop): unify Tauri title bar and window controls (#147097) refactor(test): share plugin fixture server shims (#147225) perf(gateway): defer worker workspace execution imports (#143496) fix(gateway): post-ack webhook work fails with "Async work scope is closed" (#144801) refactor(scripts): centralize upgrade survivor version floors (#146975) fix(ci): check publication registries before FRV fanout (#147184) fix(qa): align system-agent delegation with channel contracts (#145905) improve: reduce repeated chat message identity work (#147210) fix(channels): remove stale pre-tool previews from Slack and Telegram (#147106) fix: keep catalog discovery scoped and execution lazy (#147159) fix: serialize reclamation worker shutdown with foreground writes (#147178) test(sessions): cover abrupt committed transcript recovery (#143984) fix: stop transcript storms during context overflow recovery (#147202) fix: reduce CPU overhead for small history and usage reads (#147205) fix: resume tasks after tools finish and the model times out (#147203) refactor(scripts): share SQLite reliability message waits (#146900) feat(exec): configure approval reviewer thinking and fastMode (#147192) test: remove redundant Bonjour module headers (#146981) ...
What Problem This Solves
Importing the worker-turn launcher eagerly loads execution implementations and their workspace-settlement dependencies before a turn passes admission.
Why This Change Was Made
Keep workspace validation, placement authority and turn-claim cleanup in their existing owners. Load only the selected execution implementation on each recovery-loop iteration, inside the existing claim-cleanup boundary. Revalidate admission, placement and the exact claim after loading and before registering the execution owner.
Preserve the worker-specific composed admission callback through asynchronous context preparation, while remote execution retains its existing caller callback. Redispatch retains the composed callback and abort signal. Admission notification, persistence, release-before-reconciliation, pending-result custody and identity-based cleanup remain unchanged.
Move the unchanged reconciliation error constructor and workspace-settlement functions into shared leaves. Redirect the three eager settlement consumers so they do not restore the cold-import dependency path. No configuration, protocol, schema or persistence-contract changes.
User Impact
Less execution code is loaded eagerly. No measured startup, latency or RSS improvement is claimed. Revocation, claim replacement, loader failure, rollback and recovery continue through their existing owners, without a new operator action.
Evidence
Current Integrated Source
9ec456dcfc26775b5a871307ea972b506701668e.6b5db794123fb767af6e80ce2aaf2734b3004881and main integration snapshot2700b9e34e6f79afba980dac67508af4c6eb707e. Both ancestries are preserved; this is not replacement of the published branch.Current Local Qualification
pnpm buildpassed in 273.777 seconds, with all sixteen build phases completed and build metadata bound to the exact head. This is not a whole-environment cold-build or performance claim.Retained History And Limits
008cf5d9b0a4b1dcae5517706ea06d31ec1082ffand signed sourced90d6944c42ef023d964eeee8cec08d11ac1f930supplied four intended baseline cold-import failures. Twenty new cases had passing observations across recorded revisions, not one final-byte twenty-case run: an initial fixture error was corrected using the actual claim return, and the affected cases were rerun. A selector-miss attempt selected zero tests and is not proof.--no-cachediagnostic pair preserved staged-results -> repository -> finalize order and passed 31/31 on both baseline and candidate. The original timeout was not reproduced under those diagnostic conditions. Instrumentation was removed. A later uninstrumented published-head run passed 13 + 15 + 3 = 31, without explaining or erasing the original timeout.6b5db794123fb767af6e80ce2aaf2734b3004881had successful CI run 34424900129 and normal Node 26.1.0 / Ubuntu compatibility run 34429388774, including fullpnpm build. The declaration-restore step was skipped; no broader cold-build claim follows. These runs remain old-head evidence, not current-head CI.