Repository navigation
fix(exec): avoid gateway stalls during background task writes - #157177
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: blocked before merge. Reviewed September 24, 2026, 10:44 AM ET / 14:44 UTC (Revision 4). ClawSweeper reviewWhat this changesThe branch routes background command registration and terminal task-ledger writes through OpenClaw's task worker while retaining process cleanup ownership until settlement finishes. Merge readiness⛔ Blocked before merge - 1 item remains Current main still performs synchronous background-task writes, so this PR addresses a remaining Gateway stall. The reported real-command contention proof supports the repair, and the prior upgrade concern does not apply to the unchanged stored-data contract. Priority: P1 Review scores
Verification
How this fits togetherThe agent exec tool starts commands and records promoted background processes in a SQLite task ledger. That ledger supplies task status, while process-scope cleanup waits for terminal writes and notifications. flowchart LR
A[Agent exec request] --> B[Process supervisor]
B --> C{Background promotion}
C -->|Yes| D[Task worker]
D --> E[SQLite task ledger]
B --> F[Process exit]
E --> G[Completion notification]
F --> G
G --> H[Scope cleanup]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +233, Tests +408, Docs +8. Total +649 across 18 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep background exec writes with the existing task worker and exact receipt, preserving synchronous V1 adapters and holding process ownership through terminal settlement and cleanup. Do we have a high-confidence way to reproduce the issue? Yes. Current main retains the synchronous write path, and the supplied Testbox negative controls report three original-path failures under task database contention; this read-only review did not execute them. Is this the best way to solve the issue? Yes. Reusing the task worker and its exact creation receipt addresses the blocking write at its owner while preserving the existing synchronous V1 runtime contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1b32a8b3c7fc. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Keep the background process handle after promotion even when the command exits during task registration. Preserve joined terminal cleanup and the synchronous registered runtime contract, and strengthen the fast-exit race regression.
Provide the required stdin end method while preserving the destroy-failure ordering and scope-cleanup assertions.
|
Merged via squash auto-merge.
|
* commit '9ccfc7d1bea21e34da48edbd54afd2e1be57db40': (89 commits) fix(exec): avoid gateway stalls during background task writes (#157177) test(cli): isolate preaction title setter state fix(test): synchronize Git backoff cancellation readiness (#157315) fix: validate Codex model references in Docker (#157175) fix(state): tolerate brief WAL coordinator contention (#157121) fix: unblock conversations after recovery preparation fails (#157214) test(telegram): avoid wall-clock pacing in HTTP conformance (#157281) fix: keep independent database work responsive under load (#157230) refactor(sqlite): centralize WAL checkpoint execution (#157263) improve(android): show tool outcomes in collapsed work (#156950) fix: remove tracked release scratch blocking source capture (#157308) test(update): remove legacy probe stream ordering race fix: preserve steering across reconnects and show queued input (#157135) fix(ui): keep typing focus when the GitHub reader opens (#157202) fix(ios): keep screenshot logs outside capture evidence test(codex): await startup teardown in lifecycle fixtures chore(ui): refresh control ui locales (#157311) refactor(memory): deslop memory plugins (#156867) refactor(test): share CLI diagnostics fixture setup (#157201) fix(release): retry notarization submit/wait on transport failures and name the resume command (#157116) ...
* commit '02ad6b76b1a2ee2b414b170072e6e3e606fda3d4': (134 commits) fix(build): scope normalization declarations to package sources (#157174) fix: exit after validating Codex model references (#157323) fix(gateway): guard workspace adoption during active work (#157259) fix(update): rebuild stale Git runtimes when source is already current (#156996) fix: require a click before diagnosing failed updates (#157359) test(release): provide sealed artifact inputs to writer fixtures fix(ios): preserve chat state and adapt layout when iPad windows resize (#156683) fix(test): prepare native UI fixtures before compilation fix(test): await outbound delivery readiness before assertions fix: clarify deferred Codex catalog refresh warnings (#157352) fix(skills): refresh skills after watched directories are replaced (#156324) ci: reduce Node fixture overhead and defer seven release matrices (#157341) chore(test): stop Codex Computer Use and Signal batching tests flaking under load (#157334) fix(gateway): retain owned suspension status during restart (#157258) fix(ci): scope desktop status assertions to the selected worker chore(i18n): refresh native locales (#157337) test(daemon): use the native PowerShell probe budget (#157289) fix(exec): avoid gateway stalls during background task writes (#157177) test(cli): isolate preaction title setter state fix(test): synchronize Git backoff cancellation readiness (#157315) ...
* commit 'c4333da677cbdfe1bbaf783ed01c363ff39e93b8': (100 commits) fix(test): stop preflight mocks leaking into shared workers (#157207) fix(build): scope normalization declarations to package sources (#157174) fix: exit after validating Codex model references (#157323) fix(gateway): guard workspace adoption during active work (#157259) fix(update): rebuild stale Git runtimes when source is already current (#156996) fix: require a click before diagnosing failed updates (#157359) test(release): provide sealed artifact inputs to writer fixtures fix(ios): preserve chat state and adapt layout when iPad windows resize (#156683) fix(test): prepare native UI fixtures before compilation fix(test): await outbound delivery readiness before assertions fix: clarify deferred Codex catalog refresh warnings (#157352) fix(skills): refresh skills after watched directories are replaced (#156324) ci: reduce Node fixture overhead and defer seven release matrices (#157341) chore(test): stop Codex Computer Use and Signal batching tests flaking under load (#157334) fix(gateway): retain owned suspension status during restart (#157258) fix(ci): scope desktop status assertions to the selected worker chore(i18n): refresh native locales (#157337) test(daemon): use the native PowerShell probe budget (#157289) fix(exec): avoid gateway stalls during background task writes (#157177) test(cli): isolate preaction title setter state ...
* commit '02ad6b76b1a2ee2b414b170072e6e3e606fda3d4': (122 commits) fix(build): scope normalization declarations to package sources (#157174) fix: exit after validating Codex model references (#157323) fix(gateway): guard workspace adoption during active work (#157259) fix(update): rebuild stale Git runtimes when source is already current (#156996) fix: require a click before diagnosing failed updates (#157359) test(release): provide sealed artifact inputs to writer fixtures fix(ios): preserve chat state and adapt layout when iPad windows resize (#156683) fix(test): prepare native UI fixtures before compilation fix(test): await outbound delivery readiness before assertions fix: clarify deferred Codex catalog refresh warnings (#157352) fix(skills): refresh skills after watched directories are replaced (#156324) ci: reduce Node fixture overhead and defer seven release matrices (#157341) chore(test): stop Codex Computer Use and Signal batching tests flaking under load (#157334) fix(gateway): retain owned suspension status during restart (#157258) fix(ci): scope desktop status assertions to the selected worker chore(i18n): refresh native locales (#157337) test(daemon): use the native PowerShell probe budget (#157289) fix(exec): avoid gateway stalls during background task writes (#157177) test(cli): isolate preaction title setter state fix(test): synchronize Git backoff cancellation readiness (#157315) ...
* test(ui): cover stack-free tooltip disconnect cleanup * fix(build): scope normalization declarations to package sources Give normalization-core its own TypeScript project so declaration generation does not load the repository-wide source set. Preserve the existing DTS build command and compiler policy. * Merge normalization declaration scope for tooltip proof * commit '81aeccb3db80136a118d6d2f98b67d836ec25e51': fix(build): scope normalization declarations to package sources * fix(ui): avoid retaining tooltip anchors in abort reasons * Merge main to include native wrapper source inventory repair * commit '02ad6b76b1a2ee2b414b170072e6e3e606fda3d4': (134 commits) fix(build): scope normalization declarations to package sources (#157174) fix: exit after validating Codex model references (#157323) fix(gateway): guard workspace adoption during active work (#157259) fix(update): rebuild stale Git runtimes when source is already current (#156996) fix: require a click before diagnosing failed updates (#157359) test(release): provide sealed artifact inputs to writer fixtures fix(ios): preserve chat state and adapt layout when iPad windows resize (#156683) fix(test): prepare native UI fixtures before compilation fix(test): await outbound delivery readiness before assertions fix: clarify deferred Codex catalog refresh warnings (#157352) fix(skills): refresh skills after watched directories are replaced (#156324) ci: reduce Node fixture overhead and defer seven release matrices (#157341) chore(test): stop Codex Computer Use and Signal batching tests flaking under load (#157334) fix(gateway): retain owned suspension status during restart (#157258) fix(ci): scope desktop status assertions to the selected worker chore(i18n): refresh native locales (#157337) test(daemon): use the native PowerShell probe budget (#157289) fix(exec): avoid gateway stalls during background task writes (#157177) test(cli): isolate preaction title setter state fix(test): synchronize Git backoff cancellation readiness (#157315) ... Co-authored-by: Vincent Koc <[email protected]>
…aw#157177) * perf(exec): move background task writes off the main thread * fix(exec): preserve promoted process handles during registration Keep the background process handle after promotion even when the command exits during task registration. Preserve joined terminal cleanup and the synchronous registered runtime contract, and strengthen the fast-exit race regression. * test(exec): complete stdin settlement failure fixture Provide the required stdin end method while preserving the destroy-failure ordering and scope-cleanup assertions.
* test(ui): cover stack-free tooltip disconnect cleanup * fix(build): scope normalization declarations to package sources Give normalization-core its own TypeScript project so declaration generation does not load the repository-wide source set. Preserve the existing DTS build command and compiler policy. * Merge normalization declaration scope for tooltip proof * commit '81aeccb3db80136a118d6d2f98b67d836ec25e51': fix(build): scope normalization declarations to package sources * fix(ui): avoid retaining tooltip anchors in abort reasons * Merge main to include native wrapper source inventory repair * commit 'f11e16cd65951f284264bd202b49984e21091cf5': (134 commits) fix(build): scope normalization declarations to package sources (openclaw#157174) fix: exit after validating Codex model references (openclaw#157323) fix(gateway): guard workspace adoption during active work (openclaw#157259) fix(update): rebuild stale Git runtimes when source is already current (openclaw#156996) fix: require a click before diagnosing failed updates (openclaw#157359) test(release): provide sealed artifact inputs to writer fixtures fix(ios): preserve chat state and adapt layout when iPad windows resize (openclaw#156683) fix(test): prepare native UI fixtures before compilation fix(test): await outbound delivery readiness before assertions fix: clarify deferred Codex catalog refresh warnings (openclaw#157352) fix(skills): refresh skills after watched directories are replaced (openclaw#156324) ci: reduce Node fixture overhead and defer seven release matrices (openclaw#157341) chore(test): stop Codex Computer Use and Signal batching tests flaking under load (openclaw#157334) fix(gateway): retain owned suspension status during restart (openclaw#157258) fix(ci): scope desktop status assertions to the selected worker chore(i18n): refresh native locales (openclaw#157337) test(daemon): use the native PowerShell probe budget (openclaw#157289) fix(exec): avoid gateway stalls during background task writes (openclaw#157177) test(cli): isolate preaction title setter state fix(test): synchronize Git backoff cancellation readiness (openclaw#157315) ... Co-authored-by: Vincent Koc <[email protected]>
What Problem This Solves
Fixes Gateway pauses when a background command starts or finishes while another writer holds the task database lock.
User Impact
Background task bookkeeping waits through the existing worker without blocking other Gateway work. A promoted background command keeps its process handle even if it exits during registration. Task writes settle before completion notifications and process-scope cleanup.
Why This Change Was Made
Registration and completion reuse the existing task worker and its creation receipt. The process retains ownership through pending registration, terminal writes, and notification-error recovery. Raw process exit metadata remains intact when task callbacks fail, and registered V1 runtimes keep their synchronous contract. Terminal metadata cannot overwrite child, session, or owner authority fields.
Registration stays with the existing settlement owner; terminal exit settlement moves into a focused sibling module. Related lifecycle tests move into their existing cleanup owners. No configuration, schema, durability, migration, or retention change is required.
Evidence
Source-bound Blacksmith Testbox proof passed 122 selected runtime checks, including real command creation and exit under database contention, fast exit during registration, same-run session isolation, repeated callback failures, notification ordering, per-agent result retention, and joined worker-environment cleanup. The affected 24-case cleanup group was rerun successfully after completing its stdin mock. The unchanged 75 receipt-owner checks are retained.
Negative controls reproduce premature task/result settlement on the original implementation and the lost-process-handle regression on the earlier revision. The repaired path passes those same contracts. Assertions and deadlines remain intact.
Single-worker test-cost comparison for the same three contention/fast-exit cases:
The broader 120-case command group took 46.20 s with 2.84 GiB peak RSS; the two worker-environment cases took 22.80 s with 2.89 GiB peak RSS. These are whole-process test costs, including compilation/setup and cache effects, not production latency or per-message transfer measurements.
Production types, all 25 core-test type graphs, targeted lint, formatting/size ratchets, export and import-cycle checks, and the remaining selected guards passed. Independent review has no remaining actionable findings. Required exact-head CI is tracked by this PR's
openclaw/ci-gate.Warm writes use scoped task results through the existing worker transport. Cold registry restoration and large-result deserialization retain their existing behavior; large cold ledgers and deployed latency gains remain unmeasured.