Repository navigation
fix: allow retrying refused native worker cleanup - #198240
Conversation
Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
Worked on by: - @vincentkoc Co-authored-by: vincentkoc <[email protected]> OpenClaw-Publication: 016c5c6c-b745-4cda-808a-f47a77f8fd72
|
🦞👀 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. |
Store and restore the Worker prototype descriptor, then join through the restored receiver. Fixes the PR-caused lint suppression inventory failure without changing production behavior or growing the test allocation. Co-authored-by: vincentkoc <[email protected]> Co-authored-by: RomneyDa <[email protected]>
Worked on by: - @vincentkoc Co-authored-by: vincentkoc <[email protected]> OpenClaw-Publication: afb073dc-1eba-487b-9810-c4ed84ba3365
|
Codex review: needs maintainer review before merge. What this changesThis PR allows explicit cleanup retries after pre-teardown refusal while preserving terminal native teardown failures. Example: Cleanup is requested while an echo worker is active, then the caller finishes and retries.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR fixes a concrete cleanup retry defect still present on current main, with no introduced correctness findings. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe native-worker lifecycle owner connects execution owners to retained worker supervisors and spawn brokers, admitting work and joining native resources during cleanup. flowchart TD
A[Execution owners] --> B[Native source]
B --> C[Worker supervisor]
C --> D[Native workers]
B --> E[Spawn broker]
A --> F[Explicit cleanup]
F --> B
Technical reviewBest possible solution: Keep the existing source as the sole cleanup owner, allowing explicit retries only before native teardown begins. Do we have a high-confidence way to reproduce the issue? Current-main control flow deterministically retains the refused close and can seal a still-active source; the PR reports matching base failures, but this read-only review ran no target code. Is this the best way to solve the issue? The patch repairs the owning lifecycle boundary with existing state, preserves native failure custody and successful-close coalescing, and avoids restoring the retired shutdown graph. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a71fd0b73262. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +4, Tests +126, Other +2. Total +132 across 4 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 13, 2026, 6:52 AM ET / 11:52 UTC. |
Native cleanup proof: base fails, this head passesReplayed both complete source snapshots with Node v26.12.1 on Linux, in separate processes with isolated temporary homes:
These exercise the production native-source owner, supervisor, and actual Worker transport, not mocked admission/settlement. The existing committed process-isolated fixture was copied with observation-only event recording; production files were unchanged. The terminal control injects an error at the real supervisor’s Worker.terminate, and the owner-refusal control intentionally fails its first cleanup. This is native-boundary proof, not live Gateway/model execution. Reproduce the committed assertions at this PR head: node scripts/run-vitest.mjs run src/infra/worker-native-lifecycle.test.ts --maxWorkers=1 -t 'close-live-worker|close-owner-retry|close-teardown-failure'Actual observed PR subprocess output (all exit 0, empty stderr)close-live-worker (1.081s) [
{
"ending": "close-live-worker",
"trace": [
{
"event": "worker-reply",
"value": 42
},
{
"event": "close-refused",
"message": "Native worker execution owners have not joined",
"activeWorkers": true
},
{
"event": "continued-request",
"value": 8
},
{
"event": "worker-reply",
"value": 9
},
{
"event": "explicit-retry",
"activeWorkers": false
},
{
"event": "retry-and-concurrent-close-resolved",
"activeWorkers": false,
"ownerAttempts": 0
},
{
"event": "work-rejected-after-teardown",
"message": "Native worker source is closing"
},
{
"event": "fresh-source",
"sameSource": false
}
],
"refusedSourceUsable": true,
"retryJoined": true,
"freshSourceUsable": true
}
]close-owner-retry (1.112s) [
{
"ending": "close-owner-retry",
"trace": [
{
"event": "worker-reply",
"value": 42
},
{
"event": "owner-close",
"attempt": 1
},
{
"event": "close-refused",
"message": "Native worker execution owner cleanup failed",
"activeWorkers": true
},
{
"event": "continued-request",
"value": 8
},
{
"event": "worker-reply",
"value": 9
},
{
"event": "explicit-retry",
"activeWorkers": true
},
{
"event": "owner-close",
"attempt": 2
},
{
"event": "retry-and-concurrent-close-resolved",
"activeWorkers": false,
"ownerAttempts": 2
},
{
"event": "work-rejected-after-teardown",
"message": "Native worker source is closing"
},
{
"event": "fresh-source",
"sameSource": false
}
],
"refusedSourceUsable": true,
"retryJoined": true,
"freshSourceUsable": true
}
]close-teardown-failure (1.149s) [
{
"ending": "close-teardown-failure",
"trace": [
{
"event": "terminal-close-rejected",
"message": "synthetic native teardown failure",
"sameFailure": true,
"ownerAttempts": 1
},
{
"event": "work-rejected-after-teardown",
"message": "Native worker source is closing"
},
{
"event": "terminal-close-rejected",
"message": "synthetic native teardown failure",
"sameFailure": true,
"ownerAttempts": 1
},
{
"event": "work-rejected-after-teardown",
"message": "Native worker source is closing"
}
],
"failedSourceRetained": true,
"overlapRefused": true
},
{
"event": "supervisor-cleanup",
"exitCode": 1
}
]The final supervisor-cleanup exitCode 1 is the terminated supervisor’s exit, not the containing fixture’s successful exit 0. CI is tracked separately: the existing Home UI timeout is still red; this proof does not make that run green or waive its gate. Its failure path is being investigated rather than rerun blindly. |
Backport canonical real-Gateway inventory and ownership assertions so bundled CI does not cold-start the Home Gateway test. Preserve timeouts and real-Gateway coverage. Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
Worked on by: - @vincentkoc Co-authored-by: vincentkoc <[email protected]> OpenClaw-Publication: baa6eae6-0dad-479c-ac65-941704454554
* fix: allow retrying refused native worker cleanup Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> * fix: allow retrying refused native worker cleanup Worked on by: - @vincentkoc Co-authored-by: vincentkoc <[email protected]> OpenClaw-Publication: 016c5c6c-b745-4cda-808a-f47a77f8fd72 * test: restore native teardown fixture without suppression Store and restore the Worker prototype descriptor, then join through the restored receiver. Fixes the PR-caused lint suppression inventory failure without changing production behavior or growing the test allocation. Co-authored-by: vincentkoc <[email protected]> Co-authored-by: RomneyDa <[email protected]> * Publish openclaw/native-close-reviewed-20261113 Worked on by: - @vincentkoc Co-authored-by: vincentkoc <[email protected]> OpenClaw-Publication: afb073dc-1eba-487b-9810-c4ed84ba3365 * fix(ci): place readonly Home proof in real Gateway lane Backport canonical real-Gateway inventory and ownership assertions so bundled CI does not cold-start the Home Gateway test. Preserve timeouts and real-Gateway coverage. Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> * Publish openclaw/native-close-reviewed-20261113 Worked on by: - @vincentkoc Co-authored-by: vincentkoc <[email protected]> OpenClaw-Publication: baa6eae6-0dad-479c-ac65-941704454554 --------- Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
* fix(workers): preserve missing-module startup errors Render non-Error diagnostic causes before forwarding native worker failures so loader host objects cannot replace the original error with DataCloneError. Keep primitive causes and structured Error metadata, and verify the real supervisor error and join path on stock Bun, the pinned fork, and Node. Removes the native error-forwarding dependency on oven-sh/bun#46711. * fix(workers): narrow serialized diagnostic scalars explicitly * test(workers): consolidate native failure regressions Reuse one shared and cyclic error graph, extend the downlevel value table, and cover missing worker entries inside the existing supervisor recovery flow before its healthy sibling control. Preserve the original cases while reducing test lines by two against the PR base; remove the now-unneeded allocation. (cherry picked from commit 058133d) Release adaptation: Only cloneable diagnostic normalization and encoder/lifecycle regressions. Later inherited-code fix 416b357 is independent, not prerequisite; supervisor timing and plugin startup rewrites excluded. Follow-up dispositions: d82e097 test(process): wait for broker failure before retained replacement (openclaw#202539); 416b357 fix: preserve the real reason a worker failed; 907e17b fix(plugins): avoid Gateway stalls during source preparation (openclaw#200320); adb660f fix: allow retrying refused native worker cleanup (openclaw#198240) Validation: Direct exported encoder/decoder: baseline fails 3 non-Error diagnostic cases; fixed passes 3; primitive and Error graph regression retained. Normal wrapper lifecycle proof pending compiled-worker setup. diff --check passes. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit cb68af332a1182ed21b39c10b53b1f6e3036461c) (cherry picked from commit 7a4af04d616ab677c58fa1f369b947bef45c382a)
What Problem This Solves
Fixes native-worker cleanup becoming permanently unusable after an early close is refused because work is still active or an execution owner rejects cleanup (RRI-509).
User Impact
A caller can finish its existing work and explicitly retry cleanup without restarting the process. Actual native teardown failures remain terminal, preventing a replacement source from overlapping retained native resources. No automatic work replay, schema, configuration, or public API change.
Why This Change Was Made
Check for unjoined workers after execution owners settle but before entering the closing state. Clear only a rejected pre-teardown close attempt; retain the existing successful-close coalescing and terminal native-failure state. The existing source remains the sole lifecycle owner; no new state or retry mechanism is introduced.
The follow-up CI repair registers the existing read-only Home real-Gateway test in the canonical real-Gateway inventory. This keeps it out of bundled/ordinary test lanes when real-Gateway tests are skipped and assigns it to its dedicated shard. It backports the relevant main-branch inventory repair without changing test timeouts or native behavior.
Evidence
dff958dae159ef494a81bbac95b2fee8075612c8, the two new retry scenarios fail at the intended boundary: new work is rejected after a refused live-worker close, and an owner-close retry returns the cached first failure. The terminal teardown control passes on the base.git diff --checkpass. Staged test-line ratchet passes against the reproduction base: 6,672,265 lines, 6,672,316 ceiling, 51 lines slack. Fresh independent review completed with no P0–P2 findings; publication was approved after direct review. No live Gateway was modified.typescript/unbound-methodsuppression without changing production behavior or growing the test allocation.249be48e5861b4f30a8c2862fb3b810a3b6030b0..56e122382d58711d7dd28b08356563b4f12f46cafound no P0–P2 issues. Published head6ced26f3e013312115846123227093bd46fc2bfchas an identical tree to that reviewed repair.ui/src/e2e/home-readonly.real-gateway.e2e.test.ts:45:3, with stack locationui/src/e2e/control-ui-e2e-suite.test-support.ts:694:9. Earlier scheduled main run 43409014923, job 131830982650, at headf4e9c2731b1b8361eca92edfaf9e030012444d32, had the identical test path, timeout, and stack annotation. The inherited failure was subsequently traced to the Home test missing from the canonical real-Gateway inventory, allowing execution in the bundled lane despite the real-Gateway skip setting.58c15494/2110db5a) while preserving timeouts. Repair-owner validation demonstrated red/green discovery and ownership behavior; 8 sharding tests and targeted types/lint/format passed, and fresh independent review found no actionable issues. Published head9011102268e6820f8f912b5fcc257d4a73232412is tree-identical to reviewed commita302cc1850efb68a4401317db93f197ee6d66c6c.checks-ui-e2eshards andopenclaw/ci-gatepassed. The dedicated real-Gateway lane was skipped in this run; the local inventory/ownership proof above verifies correct placement. The prior erroneous bundled-lane Home failure did not recur. This result applies to head9011102268e6820f8f912b5fcc257d4a73232412, not the older failed runs.6ced26f3e013reported no findings. November 14 observation-only replay on that unchanged head, Node v26.12.1, captured the requested real-process native-boundary trace. All three subprocesses exited 0 with empty stderr:close-live-worker(1.769s),close-owner-retry(1.044s), andclose-teardown-failure(0.948s). Observed sequences:42→ close refused (Native worker execution owners have not joined) → continued request8returned9→ explicit retry and concurrent close resolved with no active workers → old source rejected new work → distinct fresh source usable.Native worker execution owner cleanup failed) → continued request8returned9→ explicit retry made cleanup attempt 2 → concurrent closes resolved with no active workers → distinct fresh source usable.Worker.terminatefailure → two closes retained the identical failure, with owner cleanup attempted only once → new work rejected and failed source retained. Final supervisor cleanup reported exit 1; this is the terminated supervisor's exit, not the containing fixture's successful exit 0. Only this terminal control injects native termination failure; lifecycle admission and settlement use production code. No live Gateway was modified.6ced26f3e013; the terminal failure control passes on both. Native production and fixture code are unchanged by the inventory-only CI repair, so this proof remains applicable. It is native-boundary proof, not live Gateway/model execution.Test-audit: each new scenario protects a distinct lifecycle contract at the real source boundary. Native failure is injected only at Worker termination inside its isolated child process; no production test hook is added. The existing fixture and case table are reused. CI ownership regressions separately enforce complete real-Gateway inventory, correct skip behavior, and dedicated-shard placement.
Simplification: moved rather than duplicated the joined-worker guard, reused the existing closing flag, and added no new production state. Native production delta +4 lines; native regression delta +126 lines, covered by the dedicated RRI-509 test-line allocation. The CI follow-up adds 14 lines across the existing inventory and ownership test helper.
Worked on by