Skip to content

fix(gateway): cloud worker dispatch fails with incomplete built import closure when an external plugin ships hidden dist chunks - #165669

Merged
Patrick-Erichsen merged 2 commits into
openclaw:mainfrom
LiuwqGit:feat/issue-165638-node-bootstrap-dotsetup
Oct 6, 2026
Merged

Patrick-Erichsen merged 2 commits into
openclaw:mainfrom
LiuwqGit:feat/issue-165638-node-bootstrap-dotsetup

Conversation

@LiuwqGit

@LiuwqGit LiuwqGit commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

AI-assisted: yes

Closes #165638

What Problem This Solves

  • Fixes an issue where users with an external plugin such as @openclaw/codex installed (npm plugins whose built chunks live under dist/.setup/) could not dispatch cloud workers: every dispatch failed during node bootstrap preparation with Node distribution openclaw has an incomplete built import closure ... dist/extensions/codex/dist/api.js imports missing dist/extensions/codex/dist/.setup/....

  • No worker VM is ever created while such a plugin is installed, so remote-exec dispatch is fully blocked on affected hosts.

  • Related: [Bug]: Cloud worker dispatch fails with "incomplete built import closure" when @openclaw/codex is installed (node bootstrap skips dist/.setup/ in external plugins) #165638; clawsweeper review confirmed the defect remains on current main and requested (a) narrowing hidden-file retention to required compiled chunks only, and (b) installed-runtime proof with the published plugin. Both are addressed in this update.

Why This Change Was Made

  • Intended outcome: the node bootstrap packager keeps an installed external plugin's published shared runtime chunks — exactly the hidden dist/.setup/ directory that OpenClaw's plugin npm build emits (scripts/lib/plugin-npm-runtime-build.mts chunkFileNames) — so the import-closure validator sees a complete built closure and the worker enrolls.
  • Out of scope: the analogous dot-entry filter in collectInstalledBundledFiles (bundled npm dependencies) is unchanged — it is not implicated in this failure and keeps this fix bounded; no changes to plugin published layouts or to import validation.
  • Highest-risk area: over-inclusion of private hidden files in the packaged archive.
  • How is that risk mitigated? Only the exact dist/.setup/ directory entry itself is exempt from the dot-entry check — hidden children below it (for example dist/.setup/.cache/credentials.json) stay excluded, and the node_modules/src/test/tests exclusions apply unconditionally at every depth, including inside dist/.setup/. The regression test asserts hidden and ignored entries both below dist/ and inside dist/.setup/ stay out of the archive, and the real-plugin run below confirms the same with the published @openclaw/codex package.

User Impact

  • Success criteria: with an external plugin that ships dist/.setup/ chunks installed, cloud worker dispatch proceeds past bootstrap preparation and the worker enrolls; the artifact contains dist/extensions/<id>/dist/.setup/* and no other hidden plugin entries.
  • What should reviewers focus on? src/gateway/worker-environments/node-bootstrap-artifact-build.ts (single visitor condition + the dist/.setup constant) and the regression fixture "retains an external plugin's hidden runtime chunks under its dist directory" in src/gateway/worker-environments/node-bootstrap-artifact.test.ts.

Evidence

  • Real environment tested: git worktree of openclaw main running (1) the focused vitest project suite and (2) the production builder prepareNodeBootstrapArtifact directly against the published @openclaw/[email protected] npm tarball (npm pack @openclaw/[email protected]), which ships 140 files under package/dist/.setup/.
  • Exact steps or commands run after this patch:
    # 1) Focused regression test (RED on unmodified main, GREEN after the patch)
    node scripts/run-vitest.mjs run src/gateway/worker-environments/node-bootstrap-artifact.test.ts -t "hidden runtime chunks"
    # 2) Full directory suite + format + lint + core typecheck
    bash skills/fix-pr/scripts/validate.sh src/gateway/worker-environments/node-bootstrap-artifact-build.ts \
      src/gateway/worker-environments/node-bootstrap-artifact.test.ts \
      src/gateway/worker-environments/node-bootstrap-artifact.test-support.ts
    # 3) Real published-plugin run of the production builder (RED on main code, GREEN after the patch):
    #    packs @openclaw/[email protected], registers it as the installed external plugin, builds
    #    the node bootstrap artifact, extracts it, and inspects the entries.
    node --import ./scripts/tsx.mjs real-plugin-bootstrap-proof.mts
    # 4) Targeted CI-like test-type shard
    node scripts/run-tsgo.mts -b test/tsconfig/tsconfig.core.test.gateway-other.json --builders 1
  • Evidence after fix:
    {
      "prepare": "ok",
      "openclawVersion": "2026.9.8",
      "enabledPluginIds": ["codex"],
      "archiveEntries": 172,
      "archiveSetupChunks": 140,
      "sampleSetupChunk": "package/dist/extensions/codex/dist/.setup/account-usage-runtime-G348lY1q.mjs",
      "sampleChunkMatchesSource": true,
      "hiddenNonSetupEntries": [],
      "injectedCacheExcluded": true,
      "nestedSetupPrivateExcluded": true
    }
    The real-plugin run packs all 140 published dist/.setup/ chunks with byte-identical contents, while injected private entries — dist/.cache/credentials.json, dist/.setup/.cache/credentials.json, and dist/.setup/node_modules/ — all stay excluded. The focused vitest suite additionally executes the packaged openclaw.mjs with a real Node process and prints local-ai:cloud-ready.
  • Observed result after fix: bootstrap preparation with the published @openclaw/[email protected] external plugin now completes (140 hidden shared chunks retained, no other hidden entries transferred); the artifact's built import closure validates. The changed test costs ~150ms (34 tests in the file pass in ~6s).
  • Before evidence (optional, visual changes encouraged): with the same real-plugin setup on unmodified main code, prepareNodeBootstrapArtifact fails with the issue's exact diagnostic before any worker VM is created:
    Error: Node distribution openclaw has an incomplete built import closure; rebuild and restart
    the Gateway: dist/extensions/codex/dist/api.js imports missing
    dist/extensions/codex/dist/.setup/config-parsing-b088LyhT.mjs; ... config-options-CzyWLTJt.mjs;
    ... managed-binary-kiWRhNRE.mjs; ... auth-profile-health-oHizqgye.mjs; ... spawn-error-CL3n6MAa.mjs
    
  • What was not tested: dispatch against a live cloud provider (needs real provider credentials; the issue states the failure occurs before the provider is reached, and the proof above exercises exactly that pre-provider bootstrap-preparation stage); the latent dot-filter in collectInstalledBundledFiles for bundled npm dependencies.
  • Proof tier: L2
  • Proof limitations: none
  • Review state: Awaiting CI + maintainer review; CI lanes pending.

…t closure when an external plugin ships hidden dist chunks

The node bootstrap packager skipped every dot-prefixed entry at every depth when copying an installed external plugin, dropping the dist/.setup/ shared chunks that OpenClaw's npm plugin build publishes. Keep dot entries inside the plugin's own dist/ tree so the built import closure stays complete, while plugin-root dot entries and IGNORED_PLUGIN_DIRECTORIES stay excluded.

Fixes openclaw#165638
@clawsweeper

clawsweeper Bot commented Oct 5, 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.

@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 1:43 PM ET / 17:43 UTC (Revision 3).

ClawSweeper review

What this changes

The cloud-worker bootstrap packager retains external plugins’ compiled dist/.setup chunks while preserving private-file exclusions, with an archive extraction and execution regression.

Merge readiness

✅ Ready for maintainer review

The PR remains necessary because pinned main and v2026.9.8 still omit the required chunks. The revised head resolves the previous private-file exclusion finding, and the published-plugin proof covers the failing preparation boundary. No remaining actionable finding was identified.

Priority: P1
Reviewed head: a5860797595773926706d8ec5efe7879b8c554d4

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant published-plugin proof and a meaningful archive regression; the prior exclusion blocker is resolved.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured published-plugin before/after run exercises prepareNodeBootstrapArtifact against @openclaw/[email protected]: preparation changes from missing-import failure to success, with 140 runtime chunks retained and injected private entries excluded. The extraction-and-execution regression is supplemental; live provider enrollment is not claimed as proven. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured published-plugin before/after run exercises prepareNodeBootstrapArtifact against @openclaw/[email protected]: preparation changes from missing-import failure to success, with 140 runtime chunks retained and injected private entries excluded. The extraction-and-execution regression is supplemental; live provider enrollment is not claimed as proven. No stored-data contract changes.
Evidence reviewed 9 items Pinned introduced change: The merge-base-to-head patch narrowly changes external-plugin file selection and its regression fixture. The verified test merge contains the same three-file change relative to its main parent.
Prior finding resolved: The exemption now matches only dist/.setup itself. Descendant .cache and node_modules entries cannot match that exact path and remain excluded. The regression asserts their absence from the extracted archive and executes the packaged entry. This satisfies the concrete prior finding and rank-up move.
Current main still needs the fix: The pinned current-main builder still skips every dot-prefixed external-plugin entry, including dist/.setup, before collecting files for closure validation.
Findings None None.
Security None None.

How this fits together

Before provisioning a remote-exec cloud worker, the Gateway packages its runtime and required trusted plugins into a bootstrap archive. The archive’s import closure must validate before provisioning can continue.

flowchart TD
  A[Remote-exec worker request] --> B[Select required trusted plugins]
  B --> C[Package Gateway and plugin files]
  C --> D[Retain compiled chunks and exclude private files]
  D --> E[Validate complete import closure]
  E --> F[Bootstrap archive]
  F --> G[Worker provisioning]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +11, Tests +50. Total +61 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 13 2 +11
Tests 2 51 1 +50
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 64 3 +61

Review metrics

None.

Technical review

Best possible solution:

Keep the existing bootstrap builder as the packaging owner, preserving published runtime chunks together with private-file exclusions and complete import validation.

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

Yes, from source: an external plugin entry importing dist/.setup chunks loses those files under the current-main filter and fails closure validation. The contributor supplies matching before/after output; this read-only review did not execute the path.

Is this the best way to solve the issue?

Yes. Exempting the exact published chunk directory repairs the existing packaging owner while preserving descendant exclusions and validation.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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 published-plugin before/after run exercises prepareNodeBootstrapArtifact against @openclaw/[email protected]: preparation changes from missing-import failure to success, with 140 runtime chunks retained and injected private entries excluded. The extraction-and-execution regression is supplemental; live provider enrollment is not claimed as proven. No stored-data contract changes.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 security-boundary: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The existing packaging failure blocks affected remote-exec cloud workers before provisioning on the current release.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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 published-plugin before/after run exercises prepareNodeBootstrapArtifact against @openclaw/[email protected]: preparation changes from missing-import failure to success, with 140 runtime chunks retained and injected private entries excluded. The extraction-and-execution regression is supplemental; live provider enrollment is not claimed as proven. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured published-plugin before/after run exercises prepareNodeBootstrapArtifact against @openclaw/[email protected]: preparation changes from missing-import failure to success, with 140 runtime chunks retained and injected private entries excluded. The extraction-and-execution regression is supplemental; live provider enrollment is not claimed as proven. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduced change: The merge-base-to-head patch narrowly changes external-plugin file selection and its regression fixture. The verified test merge contains the same three-file change relative to its main parent. (src/gateway/worker-environments/node-bootstrap-artifact-build.ts:375, a58607975957)
  • Prior finding resolved: The exemption now matches only dist/.setup itself. Descendant .cache and node_modules entries cannot match that exact path and remain excluded. The regression asserts their absence from the extracted archive and executes the packaged entry. This satisfies the concrete prior finding and rank-up move. (src/gateway/worker-environments/node-bootstrap-artifact.test.ts:118, a58607975957)
  • Current main still needs the fix: The pinned current-main builder still skips every dot-prefixed external-plugin entry, including dist/.setup, before collecting files for closure validation. (src/gateway/worker-environments/node-bootstrap-artifact-build.ts:367, 4c4e42aabbe9)
  • Latest release remains affected: The v2026.9.8 source at the supplied release commit contains the same recursive dot-entry exclusion. REST source inspection succeeded after the local historical blob could not be fetched. (src/gateway/worker-environments/node-bootstrap-artifact.ts:374, fc23bc864e45)
  • Authoritative plugin layout: OpenClaw’s npm plugin builder emits shared runtime chunks under .setup. The changed contract is OpenClaw package layout and archive completeness; it does not depend on the sibling Codex harness or runtime protocol. (scripts/lib/plugin-npm-runtime-build.mts:679, a58607975957)
  • Published-plugin behavior proof: The captured PR body reports a before/after production-builder run using the published @openclaw/[email protected] tarball. Before the fix, preparation failed with missing .setup imports; afterward, preparation completed, all 140 chunks were retained, a sampled chunk matched its source bytes, and injected sibling and nested private entries were excluded. This proves the changed pre-provider packaging boundary, not worker enrollment or live provider dispatch. (a58607975957)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RomneyDa: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-05T16:37:34.412Z sha f69d9cf :: needs real behavior proof before merge. :: [P2] Preserve private hidden-file exclusions inside plugin dist
  • reviewed 2026-10-05T17:13:53.362Z sha 1c4fa4a26618dceb7268d16e6ec984816a627fd3 :: blocked before merge. :: [P2] Preserve exclusions beneath the allowed chunk directory

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 5, 2026
…etup

Only the plugin npm build's published shared-chunk directory dist/.setup is
retained; other hidden entries below dist (for example dist/.cache) stay
excluded so private host metadata cannot reach the worker archive.
@LiuwqGit
LiuwqGit force-pushed the feat/issue-165638-node-bootstrap-dotsetup branch from 1c4fa4a to a586079 Compare October 5, 2026 17:26
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 5, 2026
@Patrick-Erichsen Patrick-Erichsen self-assigned this Oct 6, 2026
@Patrick-Erichsen
Patrick-Erichsen merged commit b1f85ad into openclaw:main Oct 6, 2026
129 of 130 checks passed
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
…t closure when an external plugin ships hidden dist chunks (openclaw#165669)

* fix(gateway): cloud worker dispatch fails with incomplete built import closure when an external plugin ships hidden dist chunks

The node bootstrap packager skipped every dot-prefixed entry at every depth when copying an installed external plugin, dropping the dist/.setup/ shared chunks that OpenClaw's npm plugin build publishes. Keep dot entries inside the plugin's own dist/ tree so the built import closure stays complete, while plugin-root dot entries and IGNORED_PLUGIN_DIRECTORIES stay excluded.

Fixes openclaw#165638

* fix(gateway): narrow node bootstrap hidden-chunk retention to dist/.setup

Only the plugin npm build's published shared-chunk directory dist/.setup is
retained; other hidden entries below dist (for example dist/.cache) stay
excluded so private host metadata cannot reach the worker archive.
RomneyDa pushed a commit that referenced this pull request Oct 6, 2026
…t closure when an external plugin ships hidden dist chunks (#165669)

* fix(gateway): cloud worker dispatch fails with incomplete built import closure when an external plugin ships hidden dist chunks

The node bootstrap packager skipped every dot-prefixed entry at every depth when copying an installed external plugin, dropping the dist/.setup/ shared chunks that OpenClaw's npm plugin build publishes. Keep dot entries inside the plugin's own dist/ tree so the built import closure stays complete, while plugin-root dot entries and IGNORED_PLUGIN_DIRECTORIES stay excluded.

Fixes #165638

* fix(gateway): narrow node bootstrap hidden-chunk retention to dist/.setup

Only the plugin npm build's published shared-chunk directory dist/.setup is
retained; other hidden entries below dist (for example dist/.cache) stay
excluded so private host metadata cannot reach the worker archive.

(cherry picked from commit b1f85ad)
wheakerd pushed a commit to wheakerd/clawdbot that referenced this pull request Oct 22, 2026
Backport openclaw#165669 to the extended-stable bootstrap packager.

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

gateway Gateway runtime 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. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

2 participants