Repository navigation
fix: isolate delegated worker transcript ownership - #168946
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 real behavior proof before merge. What this changesThis PR clears inherited transcript and CLI-history writer context when placement admits an independent turn. Example: A parent calls sessions_send with message "Reply with exactly: ok" into a paired-device worker session.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 3 items remain Keep this PR open: it addresses a documented delegation failure that remains on current main, and source review found no introduced correctness defect. Priority: P1 Before merge
Findings
Tests
Agent review detailsHow this fits togetherPlacement admission receives a prepared agent turn, selects local or worker execution, and returns its settled result; transcript and placement owners guard durable writes. flowchart TD
A[Parent session tool] --> B[Placement admission]
B --> C[Independent context scope]
C --> D[Worker turn owner]
D --> E[Target transcript and result guards]
E --> F[Settled reply]
Technical reviewBest possible solution: Use the existing admission owner to isolate independent turns while preserving exact-continuation fences and target-owned commit guards. Do we have a high-confidence way to reproduce the issue? The release report supplies a repeatable paired-device sequence and control, and current source retains the inherited writer scope; the PR reports a matching baseline harness failure, but this review ran no target code. Is this the best way to solve the issue? The repair addresses context leakage at the shared admission owner, reuses the existing exit helper, and preserves the exact-instance continuation branch rather than weakening target write checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 35b6b308f6cb. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: Source retains target-owned guards, but supplied evidence does not establish their final-effect rejection after the inherited authority scope is cleared. EvidenceSecurity concerns:
What I checked:
Likely related people:
PR surfaceSource +1, Tests +79, Docs +3. Total +83 across 4 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 HistoryReview history (1 earlier review cycle)
Reviewed October 11, 2026, 3:11 AM ET / 07:11 UTC (Revision 2). |
## What Problem This Solves Launcher tests repeatedly stop and restart the same database reader workers between cases, adding seconds to each case despite using independent state roots. ## User Impact Faster node/worker test feedback, with the same behavioral coverage and per-case database isolation. No production behavior changes. ## Why This Change Was Made Sixteen launcher, execution, detached-context, transcript-admission, and run-owner suites now opt into the fixture's existing reader-reuse mode. Each case still drains its work and closes its database resources before removing its state; the existing database cleanup owner stops the retained pool after the suite. Detached-context keeps its unjoined-owner guard in both cleanup phases. The terminal-results suite's extra state root, lazy/module-reset tests, and import-boundary tests retain their existing isolation. No assertions, test cases, timeouts, retries, worker settings, production seams, or dependencies change. Production LOC delta: **0**. Sixteen test files, +93/−33 lines. ## Evidence The same 290-test command runs before and after on one AWS machine, with `--maxWorkers=1` and Vitest JSON reporting. Both revisions use the corrected Node test environment from main; the earlier jsdom-contaminated baseline is excluded from the speed comparison. | Command wall | Before | After | Saved | |---|---:|---:|---:| | 290 tests, one worker | 1,755.032 s | 1,089.346 s | 665.686 s / 37.93% | | Summed Vitest file execution | 1,717.203 s | 1,054.089 s | 663.115 s / 38.62% | Both runs passed all 290 tests on AWS `cbx_77c6df7bbddc`, Node 24.19.0. [Paired run](https://crabbox.openclaw.ai/portal/runs/run_71809623ad760587e2a081422f8a6e5c). Independent review has no actionable P0/P1 findings. The tested candidate matches the committed files after repository import formatting. [Final source/static validation](https://crabbox.openclaw.ai/portal/runs/run_f86a2ec39ad898ca0e5ffe33907a437e) passed check:changed, type-aware lint, Knip exports, and export-name collisions. [Pre-integration CI](https://github.com/openclaw/openclaw/actions/runs/38120713206) passed: 489 s elapsed CI wall and 1,082 summed Node-job seconds. [Current-head CI](https://github.com/openclaw/openclaw/actions/runs/38125109973) also passed after preserving main’s remote-handoff regression from #168946. The timing comparison is pinned to the pre-integration base. Post-integration, both handoff tests passed in 163.877 s; type-aware lint and export-name collisions passed. Full-tree max-lines and Knip checks reproduce two unrelated base failures in `src/web-search/runtime.test.ts` and `src/infra/agent-run-terminal-writes.ts` on exact base `90f04bfb10df` with unchanged source blobs; no baseline was changed. [Base qualification](https://crabbox.openclaw.ai/portal/runs/run_9922dda00b9c648692a436c8091ac52f). <details> <summary>Exact timed command</summary> ```sh pnpm test \ src/gateway/worker-environments/worker-turn-launcher.test.ts \ src/gateway/worker-environments/worker-turn-launcher-computer.test.ts \ src/gateway/worker-environments/worker-turn-launcher-claim-admission.test.ts \ src/gateway/worker-environments/worker-turn-launcher-initial-setup.test.ts \ src/gateway/worker-environments/worker-turn-launcher-failure-recovery.test.ts \ src/gateway/worker-environments/worker-turn-launcher-reconcile-error.test.ts \ src/gateway/worker-environments/worker-turn-launcher-reconciliation-authority.test.ts \ src/gateway/worker-environments/worker-turn-launcher-media.test.ts \ src/gateway/worker-environments/worker-turn-launcher-build-recovery.test.ts \ src/gateway/worker-environments/worker-turn-launcher-reclaimed-placement.test.ts \ src/gateway/worker-environments/worker-turn-launcher-remote-handoff.test.ts \ src/gateway/worker-environments/worker-turn-launcher.claim-recovery.test.ts \ src/gateway/worker-environments/worker-turn-execution.test.ts \ src/gateway/worker-environments/worker-turn-detached-context.test.ts \ src/gateway/worker-environments/cloud-transcript-write-admission.test.ts \ src/gateway/worker-environments/worker-turn-run-owner.test.ts \ --maxWorkers=1 --reporter=verbose --reporter=json --outputFile=/tmp/launcher.json ``` </details>
Closes openclaw#159801 ## Problem An in-process `sessions_send` into a placed worker session carries the caller's async context into the child's placement admission. Worker execution does not enter the local attempt runner that normally replaces the transcript scope. After the remote reply commits, Gateway result handling can therefore reject the child's transcript with `SessionTranscriptWriterClaimReboundError`, reporting failure for completed work. Thanks @alexph-dev for the report. ## Change Clear inherited transcript and CLI-history writer scope alongside the existing tool-caller scope when admitting an independent turn. Exact continuations of the same operational run retain their existing scope and live write guard. The child's placement and transcript owners continue to enforce its own authority. The remote-handoff regression uses real placement admission, a separate parent transcript, and the existing simulated worker transport. It verifies the completed reply and conflict report, released claim, and unchanged parent transcript. The continuation cases verify that an exact continuation can write while admitted and cannot write after closure. Documentation describes the target-session behavior. Production LOC: **+1** in one file; four changed files total. This uses the existing context-exit helper and adds no lifecycle state, durable state, public contract, or limit change. ## Proof - Pinned pre-fix main `f53ba67676d5dc1b182fb695b7b4b86e53409d69`: the delegated-worker regression fails with `SessionTranscriptWriterClaimReboundError` while finalizing the completed worker result (48.90 s command wall). - `pnpm test src/gateway/worker-environments/worker-turn-launcher-remote-handoff.test.ts --maxWorkers=1`: 2 passed, 76.73 s wall. Caller-scope file: 8 passed, 61.73 s wall. - Type-aware lint: zero warnings/errors. Export-name collisions, full `pnpm check:changed --base f53ba67` (2300.16 s), and all three Knip export scans pass. - Independent review: scoped-clean P0/P1. The final test assertion uses the real recorder’s string content representation; the baseline rejection occurs earlier at the transcript owner boundary. Proof uses synthetic sessions on an isolated Linux AWS host with deterministic remote-transport fixtures; it makes no live provider or macOS performance claim. Integrated current main including the landed worker-byte repair; the four reviewed files are byte-identical to the proved change. Post-integration proof also passes: remote-handoff 2 tests/101.71 s, caller-scope 8 tests/59.55 s; type-aware lint, export-name collisions, and all three Knip scans pass. Exact-head CI is green.
## What Problem This Solves Launcher tests repeatedly stop and restart the same database reader workers between cases, adding seconds to each case despite using independent state roots. ## User Impact Faster node/worker test feedback, with the same behavioral coverage and per-case database isolation. No production behavior changes. ## Why This Change Was Made Sixteen launcher, execution, detached-context, transcript-admission, and run-owner suites now opt into the fixture's existing reader-reuse mode. Each case still drains its work and closes its database resources before removing its state; the existing database cleanup owner stops the retained pool after the suite. Detached-context keeps its unjoined-owner guard in both cleanup phases. The terminal-results suite's extra state root, lazy/module-reset tests, and import-boundary tests retain their existing isolation. No assertions, test cases, timeouts, retries, worker settings, production seams, or dependencies change. Production LOC delta: **0**. Sixteen test files, +93/−33 lines. ## Evidence The same 290-test command runs before and after on one AWS machine, with `--maxWorkers=1` and Vitest JSON reporting. Both revisions use the corrected Node test environment from main; the earlier jsdom-contaminated baseline is excluded from the speed comparison. | Command wall | Before | After | Saved | |---|---:|---:|---:| | 290 tests, one worker | 1,755.032 s | 1,089.346 s | 665.686 s / 37.93% | | Summed Vitest file execution | 1,717.203 s | 1,054.089 s | 663.115 s / 38.62% | Both runs passed all 290 tests on AWS `cbx_77c6df7bbddc`, Node 24.19.0. [Paired run](https://crabbox.openclaw.ai/portal/runs/run_71809623ad760587e2a081422f8a6e5c). Independent review has no actionable P0/P1 findings. The tested candidate matches the committed files after repository import formatting. [Final source/static validation](https://crabbox.openclaw.ai/portal/runs/run_f86a2ec39ad898ca0e5ffe33907a437e) passed check:changed, type-aware lint, Knip exports, and export-name collisions. [Pre-integration CI](https://github.com/openclaw/openclaw/actions/runs/38120713206) passed: 489 s elapsed CI wall and 1,082 summed Node-job seconds. [Current-head CI](https://github.com/openclaw/openclaw/actions/runs/38125109973) also passed after preserving main’s remote-handoff regression from openclaw#168946. The timing comparison is pinned to the pre-integration base. Post-integration, both handoff tests passed in 163.877 s; type-aware lint and export-name collisions passed. Full-tree max-lines and Knip checks reproduce two unrelated base failures in `src/web-search/runtime.test.ts` and `src/infra/agent-run-terminal-writes.ts` on exact base `587f0b81b1ce` with unchanged source blobs; no baseline was changed. [Base qualification](https://crabbox.openclaw.ai/portal/runs/run_9922dda00b9c648692a436c8091ac52f). <details> <summary>Exact timed command</summary> ```sh pnpm test \ src/gateway/worker-environments/worker-turn-launcher.test.ts \ src/gateway/worker-environments/worker-turn-launcher-computer.test.ts \ src/gateway/worker-environments/worker-turn-launcher-claim-admission.test.ts \ src/gateway/worker-environments/worker-turn-launcher-initial-setup.test.ts \ src/gateway/worker-environments/worker-turn-launcher-failure-recovery.test.ts \ src/gateway/worker-environments/worker-turn-launcher-reconcile-error.test.ts \ src/gateway/worker-environments/worker-turn-launcher-reconciliation-authority.test.ts \ src/gateway/worker-environments/worker-turn-launcher-media.test.ts \ src/gateway/worker-environments/worker-turn-launcher-build-recovery.test.ts \ src/gateway/worker-environments/worker-turn-launcher-reclaimed-placement.test.ts \ src/gateway/worker-environments/worker-turn-launcher-remote-handoff.test.ts \ src/gateway/worker-environments/worker-turn-launcher.claim-recovery.test.ts \ src/gateway/worker-environments/worker-turn-execution.test.ts \ src/gateway/worker-environments/worker-turn-detached-context.test.ts \ src/gateway/worker-environments/cloud-transcript-write-admission.test.ts \ src/gateway/worker-environments/worker-turn-run-owner.test.ts \ --maxWorkers=1 --reporter=verbose --reporter=json --outputFile=/tmp/launcher.json ``` </details>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
Closes #159801
Problem
An in-process
sessions_sendinto a placed worker session carries the caller's async context into the child's placement admission. Worker execution does not enter the local attempt runner that normally replaces the transcript scope. After the remote reply commits, Gateway result handling can therefore reject the child's transcript withSessionTranscriptWriterClaimReboundError, reporting failure for completed work. Thanks @alexph-dev for the report.Change
Clear inherited transcript and CLI-history writer scope alongside the existing tool-caller scope when admitting an independent turn. Exact continuations of the same operational run retain their existing scope and live write guard. The child's placement and transcript owners continue to enforce its own authority.
The remote-handoff regression uses real placement admission, a separate parent transcript, and the existing simulated worker transport. It verifies the completed reply and conflict report, released claim, and unchanged parent transcript. The continuation cases verify that an exact continuation can write while admitted and cannot write after closure. Documentation describes the target-session behavior.
Production LOC: +1 in one file; four changed files total. This uses the existing context-exit helper and adds no lifecycle state, durable state, public contract, or limit change.
Proof
45630ed81200bfb64f973d73ea10c29425fc0358: the delegated-worker regression fails withSessionTranscriptWriterClaimReboundErrorwhile finalizing the completed worker result (48.90 s command wall).pnpm test src/gateway/worker-environments/worker-turn-launcher-remote-handoff.test.ts --maxWorkers=1: 2 passed, 76.73 s wall. Caller-scope file: 8 passed, 61.73 s wall.pnpm check:changed --base 45630ed81200bfb64f973d73ea10c29425fc0358(2300.16 s), and all three Knip export scans pass.Proof uses synthetic sessions on an isolated Linux AWS host with deterministic remote-transport fixtures; it makes no live provider or macOS performance claim.
Integrated current main including the landed worker-byte repair; the four reviewed files are byte-identical to the proved change. Post-integration proof also passes: remote-handoff 2 tests/101.71 s, caller-scope 8 tests/59.55 s; type-aware lint, export-name collisions, and all three Knip scans pass. Exact-head CI is green.