Skip to content

fix(infra): resolve source worker preload off the main thread - #200565

Merged
RomneyDa merged 3 commits into
mainfrom
fix/worker-preload-no-sync
Nov 17, 2026
Merged

RomneyDa merged 3 commits into
mainfrom
fix/worker-preload-no-sync

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Problem

FRV3 reproduces two failures in nested SQLite creation. Source worker startup resolves tsx/esm synchronously on the spawning thread, recording a realpathSync call before the worker starts. The pump-delivery assertion also depends on a ten-frame stack trace that can omit its caller.

Changes

  • Select a source-only ESM preload by URL; resolve tsx inside the worker, not on the spawning thread. Compiled workers and Bun retain their existing loader-free path.
  • Preserve the preload in test-generation assets and the PR wrapper source inventory.
  • Observe preparation during the actual synchronous service call instead of matching stack text.
  • Exercise a real TypeScript Worker from a foreign working directory.

Evidence

  • Exact main 5fb2315: 2 reproduced failures, 25 passes.
  • Fixed Node proof: all 30 tests pass (28 infra + 2 wrapper/source-closure tests).
  • Canonical core typecheck, targeted lint, format, and diff checks pass.
  • No SQLite admission, durability, authorization, or revocation rules changed.

Scope

Main-first repair for 2026.11.10-beta.1. This does not resolve the independently recurring Bun chat authorization failures or the proxy-retention failure. Independent review waived by release owner; required qualification gates remain.

Simplification: no cache, startup warmup, or public option; the two-line source preload moves resolution to its owning worker. Six files, 39 insertions / 6 deletions.

CI correction at 4fa7c31

The source-only preload URL was retained in sealed recovery bundles, causing both staged managed/package runtime closure tests to fail. The existing SEALED_RUNTIME_BUILD contract now omits source-only loader setup from compiled sealed workers. No missing-asset exception or weakened assertion was added.

  • Reproduced both exact CI failures locally on the previous head.
  • Corrected production staging tests: 2/2 pass; worker URL tests: 23/23 pass, including actual source worker execution.
  • Canonical lint, format, 12 GiB core typecheck and diff check pass.
  • The separate CI failure in Bun plugin recovery-source retention was reproduced on unchanged main and fixed in fix(plugins): release retired callers after source recovery #200571, merged at 234be12. That exact fix is now integrated here as 7b9d1d4; all 17 runtime-retention tests, canonical lint/format, and the 12 GiB core typecheck pass. Original xAI authorization remains unresolved; these passes do not constitute release qualification.
  • Existing auto-merge request was not re-armed; CI remains required on the new head.

Reproduce and fix cold worker creation's synchronous loader resolution. Observe pump delivery directly instead of depending on truncated stack traces.

Co-authored-by: RomneyDa <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: XS labels Nov 17, 2026
@RomneyDa
RomneyDa marked this pull request as ready for review November 17, 2026 11:12
@RomneyDa
RomneyDa enabled auto-merge (squash) November 17, 2026 11:18
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 17, 2026
@clawsweeper

clawsweeper Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

Move Node’s source-worker loader resolution into the worker and replace a stack-dependent SQLite test assertion with direct observation.

Example: Node starts a TypeScript worker that creates a nested SQLite database.

  • Before: The spawning thread synchronously resolves tsx/esm before worker startup.
  • After: The spawning thread supplies a preload URL, and the worker resolves tsx/esm itself.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The repair is useful and narrowly scoped, but exact-head CI exposes an introduced recovery-bundle closure defect.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the contributor proof gate; supplied validation exercises real worker startup and SQLite owners through tests, rather than a shipped CLI or Gateway run.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Cold source-worker startup can block the spawning thread on synchronous filesystem resolution.
Reason: The maintainer-authored direction addresses an observed failure without adding configuration, changing admission policy, or expanding the runtime capability surface.

Merge readiness

⛔ Needs changes before merge - 1 item remains

This PR addresses a concrete source-worker startup defect and should remain open, but its new preload URL breaks the sealed recovery bundles’ asset-closure checks.

Priority: P2
Reviewed head: 70e9b8a4ab614fb2fa936c0bb828a50eec5aeb38

Before merge

  • Exclude the source preload from sealed recovery bundles (P2) - The new literal sibling URL survives bundling into both managed-handoff-runtime.mjs and package-update-activation-recovery.mjs, but their production build configuration emits no runtime-worker-loader.mjs. Exact-head CI consequently fails both production-bundle closure cases at managed-handoff-build-config.test.ts:175. Adding the file to the Vitest preserved assets and PR wrapper inventory does not cover these separately sealed builds. Use their existing SEALED_RUNTIME_BUILD specialization to remove the unused source-loader branch, and retain the closure assertions.

Findings

  • [P2] Exclude the source preload from sealed recovery bundles — src/infra/runtime-worker-url.ts:87
Agent review details

How this fits together

The runtime worker helper converts worker URLs and runtime selection into launch arguments consumed by worker pools, SQLite brokers, and background services.

flowchart LR
  A[Worker pool or SQLite broker] --> B[Runtime worker argument owner]
  B --> C[Node source worker]
  C --> D[Source preload]
  D --> E[tsx ESM loader]
  E --> F[TypeScript worker entry]
Loading

Technical review

Best possible solution:

Keep worker-local source loading and use the existing sealed-build mechanism to eliminate the unused source-preload reference from recovery bundles.

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

Current-main source directly shows synchronous loader resolution in worker launch preparation, and the PR reports baseline failures; this read-only review ran no target code.

Is this the best way to solve the issue?

Deferring resolution through a source-relative preload is a focused fix that preserves foreign-working-directory and Bun behavior, but the sealed build must exclude its unused source-only asset reference.

Full review comments:

  • [P2] Exclude the source preload from sealed recovery bundles — src/infra/runtime-worker-url.ts:87
    The new literal sibling URL survives bundling into both managed-handoff-runtime.mjs and package-update-activation-recovery.mjs, but their production build configuration emits no runtime-worker-loader.mjs. Exact-head CI consequently fails both production-bundle closure cases at managed-handoff-build-config.test.ts:175. Adding the file to the Vitest preserved assets and PR wrapper inventory does not cover these separately sealed builds. Use their existing SEALED_RUNTIME_BUILD specialization to remove the unused source-loader branch, and retain the closure assertions.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Node and Bun worker preload selection keeps the original intent (8430fcf: Use tsx/esm for Node source workers while allowing Bun native TypeScript execution and avoiding file preloads for non-file URLs.)
  • Foreign-working-directory loader resolution keeps the original intent (2551878: Anchor loader resolution to OpenClaw rather than the child working directory.)
  • Nested SQLite creation test changes intended behavior with a stated reason (2c4413a: Verify nested creation and synchronous pump delivery perform no main-thread synchronous filesystem calls while preserving actual database results.)
  • Prepared assets and wrapper inventory keeps the original intent (fix: keep cold child compilation outside CI test deadlines #156011: Preserve source-relative assets and complete runtime dependencies in prepared execution layouts.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/infra/runtime-worker-url.test.ts src/infra/sqlite-database-admission.nested-create.test.ts test/scripts/pr-wrapper-source-closure.test.ts test/scripts/managed-handoff-build-config.test.ts --maxWorkers=1
  • node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.test.root.tooling.json --incremental
  • node scripts/run-oxlint.mjs --tsconfig tsconfig.json src/infra/runtime-worker-url.ts
  • git diff --check

What I checked:

Likely related people:

  • gaoanze888: Raw commit 2551878 adds src/infra/runtime-worker-url.ts:31 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 255187830f84; files: src/infra/runtime-worker-url.ts)

PR surface

Source +2, Tests +29, Other +2. Total +33 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 3 1 +2
Tests 2 34 5 +29
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 2 0 +2
Total 6 39 6 +33

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: The source-worker repair has clear value, with a focused packaging defect to resolve before merge.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: The source-worker repair has clear value, with a focused packaging defect to resolve before merge.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 17, 2026, 6:29 AM ET / 11:29 UTC.

Sealed recovery bundles contain compiled workers. Keep the source-only preload out of their dependency closure; staging regressions pass without adding neighboring assets.

Co-authored-by: RomneyDa <[email protected]>
@RomneyDa
RomneyDa merged commit eceb208 into main Nov 17, 2026
150 of 151 checks passed
@RomneyDa
RomneyDa deleted the fix/worker-preload-no-sync branch November 17, 2026 12:11
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Reproduce and fix cold worker creation's synchronous loader resolution. Observe pump delivery directly instead of depending on truncated stack traces.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit eceb208)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 18, 2026
…aw#200565)

Reproduce and fix cold worker creation's synchronous loader resolution. Observe pump delivery directly instead of depending on truncated stack traces.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant