Skip to content

fix: native worker turns fail to load WebSocket transport - #140071

Merged
steipete merged 2 commits into
mainfrom
codex/fix-native-worker-websocket-bundle
Sep 6, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/fix-native-worker-websocket-bundle

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where starting a native OpenClaw turn on a cloud or paired worker fails before its first reply because the transferred worker cannot find ws/package.json.

Related: #138724, #138900. Found during the requested post-merge main live validation.

Why This Change Was Made

The installed WebSocket loaders deliberately select the real ws implementation to preserve options and receiver behavior under Bun. The portable worker build must bundle that same transport instead of resolving an installed package at runtime. Its existing dependency transform now covers the Gateway client, Gateway server, and lazy realtime-transcription loaders; ordinary installed runtime paths are unchanged.

The eager failure was introduced by #139919 (56924648b69b97ee0d9eca5dcac9d3aa58fce3f4), after the earlier cloud-session candidate proof. The deferred loaders share the same standalone-bundle requirement. No dependency, configuration, protocol, or SQLite schema changes.

User Impact

Native worker turns can initialize their Gateway connection from the transferred bundle. Realtime transcription also retains its lazy transport without requiring a ws installation beside that bundle.

Evidence

  • Actual main b72a36a77d1b9fe5b7acb4e94042fddf827d7e40: repository-only creation and dispatch succeeded; the native turn failed in 907ms with the exact missing-package error. The session was reclaimed, pairing removed, processes joined, and preexisting state preserved.
  • New executable regression selects the real worker build configuration, relocates its output without a resolvable ws installation, and verifies client headers, echo, normal close, and lazy transcription headers/audio exchange/close. It failed before the fix with the same ws/package.json error and passes afterward. All 10 focused tests pass.
  • Final independent P0–P2 review is clean. All changed-file checks pass after correcting three lint errors in the new test fixture.
  • Full pnpm build passed on exact candidate 01371e3fa0ade67a995b6b93471aeaecd8fa1349 in 3m35.8s. The emitted worker has no remaining ws/package.json lookups.
  • Real paired-Mac native flow on that complete build passed: repository-only creation 51ms; initial dispatch 6.578s; write/read turn 8.088s; editor save; normal Stop and retained readback; new-environment restore 1.428s; exact restored read turn 5.999s; final Stop. Both source environments are destroyed with empty attachments, pairing removed, all owned processes absent, test port closed, and preexisting owners preserved. No Gateway project checkout, publication, or OAuth was requested. This is paired-Mac proof with separate HOME/state/workspace and colocated filesystems, not managed AWS provisioning.
  • An earlier harness attempt observed pairing's transient uncertain record before confirmed delivery and stopped prematurely. The same setup subsequently confirmed; the harness now waits for confirmation with a bounded observation and retains uncertainty for exact cleanup only. Original failure evidence is retained. Gateway shutdown on the passing candidate exited naturally with code 0 in 11.985s.
  • A prewarm-only invocation does not initialize the failing turn graph and is not claimed as regression proof. Exact-head CI remains required; the initial draft-only CI was skipped and supplies no validation.

Tooling/production: +27 lines in the existing build owner. Tests/support: +139 lines. The growth replaces three worker package lookups with bundled transport imports while retaining the installed-runtime contract. npm audit is non-blocking at the maintainer's request.

CI follow-through: the first ready-state run 34030297710 passed 71 jobs but failed 37 declaration cases across four shards because the existing minimal declaration fixture omitted the new build inputs. Commit 707d1e9e4f5221463dab47dedf022f28b3c97c6e adds those three paths to its canonical placeholder list. All four affected suites now pass locally (61 tests, two platform-specific skips), and scoped independent review is clean. This child changes only that test fixture; production and the full-build/live candidate above remain byte-identical. Required CI 34030846467 passed on the new head: 76 jobs passed, 17 skipped, no failures or reruns.

ClawSweeper’s 11:36 UTC review found no actionable correctness/security findings and accepted the real native-flow proof. Its “Add data-model compatibility proof” item is not applicable: this diff changes the build plugin and two test files only; it changes no SQLite DDL, schema version, stored representation, migration, retention, projection, or runtime storage reader/writer. The worker archive remains the existing content-addressed JavaScript artifact with the same manifest and transfer protocol. No migration proof or schema approval is needed for this build-only repair. The intervening commit only corrects declaration fixtures.

Landed and verified on main: merged as 8319778f3eb5601bbde4486c645051be0e5c4d7a. A fresh full build of that main commit passed in 3m7.9s. The real paired-native lifecycle then passed again: creation 52ms, initial dispatch 7.867s, write/read turn 9.203s, accepted editor save, Stop and stopped readback, new-environment restore 1.402s, exact read 8.470s, and final Stop. Root independently read both canonical destroyed environment rows with empty attachments, matched the stopped editor bytes, and verified all owned processes absent and the test port closed. The Gateway exited naturally with code 0 in 14.406s. No additional Gateway checkout was created.

@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S maintainer Maintainer-authored PR labels Sep 6, 2026
@steipete
steipete marked this pull request as ready for review September 6, 2026 11:27
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 6, 2026, 7:36 AM ET / 11:36 UTC.

ClawSweeper review

What this changes

Bundle WebSocket transports into portable workers so native turns and lazy transcription can connect without an adjacent ws installation.

Regression provenance

Regression provenance — verified: source commit 56924648b69b by Peter Steinberger; canonical PR #139919 (blame-to-merge-commit).

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains a useful, focused repair: current main lacks the worker transport transforms, and no introduced correctness defect was found. The captured paired-Mac verification supports the fix; the protected maintainer PR remains open for normal landing.

Priority: P1
Reviewed head: 01371e3fa0ade67a995b6b93471aeaecd8fa1349

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with relevant real-flow observations and meaningful packaging regression coverage; no blocking code finding was identified.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured exact-head paired-Mac observations exercise the native worker turn that previously failed during Gateway-client loading, then show successful write/read, Stop, restore, and readback; the relocated-bundle regression additionally covers lazy transcription.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured exact-head paired-Mac observations exercise the native worker turn that previously failed during Gateway-client loading, then show successful write/read, Stop, restore, and readback; the relocated-bundle regression additionally covers lazy transcription.
Evidence reviewed 7 items Introduced changes: The verified merge-base-to-head delta contains only the build-owner transforms and their relocated-bundle regression. Endpoint drift and the stale test merge were not treated as PR-introduced changes.
Still necessary on current main: Fetched main has the existing Playwright and Undici transforms but no WebSocket transform. The three transport loaders and worker build configuration are identical between fetched main and the reviewed head.
Build and runtime boundary: The portable worker configuration bundles non-builtin dependencies and disables code splitting. The patch makes the existing package lookups statically resolvable within that configuration; ordinary installed loaders retain their Bun-specific transport selection. This repair depends on OpenClaw's worker build, not the Codex harness.
Findings None None.
Security None None.

How this fits together

OpenClaw transfers a portable worker bundle to cloud or paired machines to run native agent turns. Its build must include the WebSocket code used to connect to the Gateway and transcription providers.

flowchart TD
  A[Installed transport loaders] --> B[Worker build transforms]
  B --> C[Portable worker bundle]
  C --> D[Gateway client]
  C --> E[Lazy transcription client]
  D --> F[Gateway connection]
  E --> G[Transcription provider]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Tests +136, Other +27. Total +163 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 136 0 +136
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 27 0 +27
Total 2 163 0 +163

Review metrics

Metric Value Why it matters
Production versus regression coverage production/tooling +27 lines; tests +136 lines Production growth extends the existing build owner across three loaders; the test growth exercises relocated output through real WebSocket connections.

Stored data model

Persistent data-model change detected: unknown-data-model-change: scripts/lib/worker-deploy-build-plugin.mts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep standalone dependency resolution in the worker build owner while preserving installed-runtime transport options and lazy transcription initialization.

Do we have a high-confidence way to reproduce the issue?

Yes: importing the Gateway client from a relocated worker without ws installed reaches the unresolved package lookup on current main; the supplied regression and native-run observations corroborate it. This review did not execute that path.

Is this the best way to solve the issue?

Yes: extending the existing worker-only dependency transform addresses the packaging owner without changing installed runtime behavior or adding another transport implementation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against eea0b64eff16.

Labels

Label changes:

  • add P1: The captured main validation shows native remote turns failing before their first reply because the portable worker cannot load its transport.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured exact-head paired-Mac observations exercise the native worker turn that previously failed during Gateway-client loading, then show successful write/read, Stop, restore, and readback; the relocated-bundle regression additionally covers lazy transcription.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured exact-head paired-Mac observations exercise the native worker turn that previously failed during Gateway-client loading, then show successful write/read, Stop, restore, and readback; the relocated-bundle regression additionally covers lazy transcription.

Label justifications:

  • P1: The captured main validation shows native remote turns failing before their first reply because the portable worker cannot load its transport.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured exact-head paired-Mac observations exercise the native worker turn that previously failed during Gateway-client loading, then show successful write/read, Stop, restore, and readback; the relocated-bundle regression additionally covers lazy transcription.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured exact-head paired-Mac observations exercise the native worker turn that previously failed during Gateway-client loading, then show successful write/read, Stop, restore, and readback; the relocated-bundle regression additionally covers lazy transcription.

Evidence

What I checked:

  • Introduced changes: The verified merge-base-to-head delta contains only the build-owner transforms and their relocated-bundle regression. Endpoint drift and the stale test merge were not treated as PR-introduced changes. (scripts/lib/worker-deploy-build-plugin.mts:94, 01371e3fa0ad)
  • Still necessary on current main: Fetched main has the existing Playwright and Undici transforms but no WebSocket transform. The three transport loaders and worker build configuration are identical between fetched main and the reviewed head. (scripts/lib/worker-deploy-build-plugin.mts:81, eea0b64eff16)
  • Build and runtime boundary: The portable worker configuration bundles non-builtin dependencies and disables code splitting. The patch makes the existing package lookups statically resolvable within that configuration; ordinary installed loaders retain their Bun-specific transport selection. This repair depends on OpenClaw's worker build, not the Codex harness. (tsdown.config.ts:182, 01371e3fa0ad)
  • Regression coverage: The new test selects the production worker build configuration, relocates output, verifies ws/package.json cannot resolve, and exercises real client headers, echo, normal close, and transcription audio exchange. It uses existing production exports without adding a test-only production seam. Tests were inspected, not executed during this read-only review. (test/scripts/worker-deploy-build-plugin.test.ts:22, 01371e3fa0ad)
  • Captured real behavior evidence: The supplied PR body, captured under sourceRevision 9c5e1aa8d957197a272b13ce63c34ac88324a894ff5036632131737e1ab90291, reports the missing-package failure on b72a36a and successful paired-Mac native dispatch, write/read, Stop, restore, and restored read on the complete exact-head build. It explicitly distinguishes this from managed AWS provisioning and from an unrelated prewarm invocation. (01371e3fa0ad)
  • Relevant merged history: The exact raw parent is 9f089d6; comparison against it shows the installed-package loader was added in this commit. Supplied GitHub metadata identifies the matching merged PR as fix(gateway-client): preserve WebSocket options under Bun #139919. Recent build-transform and transcription history also points to Peter Steinberger. (packages/gateway-client/src/websocket.ts:7, 56924648b69b)

Likely related people:

  • Peter Steinberger: Raw commit 5692464 adds packages/gateway-client/src/websocket.ts:7 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 56924648b69b; files: packages/gateway-client/src/websocket.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 8319778 into main Sep 6, 2026
144 checks passed
@steipete
steipete deleted the codex/fix-native-worker-websocket-bundle branch September 6, 2026 11:50
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc pushed a commit to gaoanze888/openclaw that referenced this pull request Sep 6, 2026
* commit '3ed964c8ca6206d26ecc0b6567ccd1389d9948fc': (36 commits)
  refactor(plugins): unify install config snapshot preparation (openclaw#140081)
  fix: cloud provisioning stays failed after temporary storage recovers (openclaw#140021)
  fix(ci): preflight job outputs exceed 1 MiB on full-plan pull requests (openclaw#140018)
  refactor: consolidate command and provider helpers (openclaw#140072)
  fix(doctor): replace unavailable TUI cleanup advice (openclaw#140074)
  fix(plugins): avoid scoped pack failures and missing runtime entries (openclaw#140016)
  fix: clarify background command timeouts (openclaw#140022)
  fix(workboard): refresh board navigation while retaining drafts (openclaw#139952)
  fix: preserve newer chat drafts when rewind completes (openclaw#140066)
  feat(transcripts): browse and export saved meeting archives (openclaw#139875)
  fix(cron): complete timeout test observation phase (openclaw#140076)
  fix(macos): show the full automation count (openclaw#139692)
  fix: native worker turns fail to load WebSocket transport (openclaw#140071)
  fix(cli): complete quoted Bash option values (openclaw#140034)
  fix(chat): show command instructions while pending (openclaw#140041)
  refactor(cli): use canonical resume result schema (openclaw#140056)
  fix: restore package acceptance across install runtimes (openclaw#140062)
  refactor(auto-reply): keep model-selection fixtures in tests (openclaw#140069)
  fix(plugins): remove owned aliases before uninstalling files (openclaw#140065)
  fix: completed replies hang when context-engine cleanup stalls (openclaw#140023)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…40071)

* fix: bundle WebSocket transports in portable workers

* test: include worker transports in declaration fixtures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant