Skip to content

fix(packaging): restore cloud-session bootstrap for CommonJS bundles - #160583

Merged
steipete merged 1 commit into
mainfrom
codex/bootstrap-cjs-closure
Sep 28, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/bootstrap-cjs-closure

Conversation

@steipete

@steipete steipete commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes all cloud-session dispatch on main failing before provisioning since 2026-09-28 01:44 UTC, when #160015 added undici to the bundled dependencies.

User Impact

Cloud-session dispatch can prepare its node bootstrap artifact again. The fix takes effect on the next Gateway update (or source rebuild and restart). No published version release is affected: the latest published version is v2026.9.6 from September 23, before the trigger; git tag --contains ce73f2c8f2a7 has no version-release tag.

Why This Change Was Made

The shared closure checker required exact paths for CommonJS require() calls even though undici ships the referenced files with .js extensions. It now applies Node's relative CommonJS file and directory resolution, using each file's extension and package metadata for parsing. ESM imports and exports keep exact-path checks.

Bootstrap reads package metadata before scanning JavaScript and preserves canonical manifest hashing. Installed bundles still receive full closure validation. Existing npm tarball, standalone dist, and private bundled-runtime checks share the corrected resolver; the set of release-checked scopes is unchanged. The macOS worker graph retains its existing imported paths.

Evidence

  • Both new regressions fail on the original main-based checkout (e256cbef8ae0): the checker reports present CommonJS targets as missing, and the bootstrap fixture reproduces the undici-style incomplete-closure error.
  • Checker and bootstrap suites, including prebuilt artifacts, plugin selection, and patched MCP: 82 tests passed. The synthetic undici-shaped dependency is packed, extracted, and executed through the transferred launcher.
  • Full branch build: node scripts/worktree-setup.mjs gateway passed.
  • Independent Codex P2 autoreview: clean.
  • Real artifact provider proof against this checkout's built package and installed undici 8.10.2: 45,471,321 bytes, 9,622 entries, 214 undici entries, 24.48 s; SHA-256 664d9363f7157a2316f1cd9066a1177b9bede0a9832cc6e0d0122090011be531. No Gateway was started or stopped; actual cloud dispatch is reserved for the coordinator.
  • pnpm tsgo:core, pnpm tsgo:scripts, targeted core/script/test lint, formatting, and git diff --check passed. All core and root test typecheck graphs also passed.
  • Single-worker cost: checker file 25 tests / 6.90 s Vitest wall, 8.27 s wrapper wall (new cases 8 ms total in the combined run); bootstrap-artifact file 33 tests / 31.01 s Vitest wall, 34.81 s wrapper wall. The new artifact regression took 1.398 s in the combined proof run. Existing archive mutation/lifecycle cases account for the rest; these exercise real packing/extraction rather than a mocked checker. Measurements were on a heavily loaded host; CI cost is pending.
  • Broader consumer run: 92 passed, one existing Homebrew-specific fixture failure in accepts a real pnpm-produced package without booting npm for version diagnostics. Its preload rejects npm --version, but the supported Homebrew npm layout requires that fallback. The dist import graph passed; a standalone probe reproduced the preload failure while normal npm version retrieval succeeded. The fixture and npm inventory/resolution owners are unchanged from main. This is unrelated to the closure repair.
  • Enrollment consumer: all 39 tests passed, including archive custody, transfer authority, cancellation, and teardown.
  • The extra repository-wide check:changed wrapper was interrupted during the unrelated legacy-store scan after the requested gates passed. Its later whole-repository guards were not run; this is not claimed as a complete wrapper pass.

The bundleDependencies change in #160015 exposed exact-path closure checks rejecting valid undici CommonJS requires. Resolve require edges with Node file and directory rules while keeping ESM imports strict, and carry package metadata through bootstrap inspection.

Restore cloud-session dispatch on the next Gateway update. Add checker and transferred-artifact regressions; verify a real undici 8.10.2 bootstrap artifact without starting or stopping a Gateway.
@clawsweeper

clawsweeper Bot commented Sep 28, 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 gateway Gateway runtime scripts Repository scripts size: M labels Sep 28, 2026
@steipete
steipete marked this pull request as ready for review September 28, 2026 17:18
@steipete
steipete enabled auto-merge (squash) September 28, 2026 17:18
@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 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 1:24 PM ET / 17:24 UTC.

ClawSweeper review

What this changes

The branch teaches package closure validation to resolve relative CommonJS requires using Node file and directory rules, and supplies package metadata before the Gateway builds a cloud-node archive.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Current main still rejects valid extensionless CommonJS imports during cloud bootstrap preparation. The PR addresses that failure at the shared package checker, and the reviewed patch has no discrete blocking finding.

Priority: P1
Reviewed head: 60644b25f47c6ca032fad3a0a61d28d01208034e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused owner-level repair has meaningful archive-boundary and reported real-package proof, with live dispatch outside the observed scope.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The changed Gateway archive provider has contributor-reported after-fix evidence from a built package with installed undici 8.10.2, including successful artifact preparation, archive size, inventory, and digest; the added fixture also executes an extracted launcher. A live cloud-session dispatch was not observed, and 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 changed Gateway archive provider has contributor-reported after-fix evidence from a built package with installed undici 8.10.2, including successful artifact preparation, archive size, inventory, and digest; the added fixture also executes an extracted launcher. A live cloud-session dispatch was not observed, and no stored-data contract changes.
Evidence reviewed 7 items Current-main failure path: The shared checker on fetched main requires an exact file path for every collected relative edge; the root package bundles undici 8.10.2, whose extensionless CommonJS requires are the reported trigger.
Introduced repair: The pinned merge-base-to-head patch applies CommonJS file and directory resolution to require edges while retaining exact-path checks for other imports.
Gateway integration: The builder reads package manifests before scanning JavaScript and passes that metadata to the shared checker; Gateway startup calls this artifact provider before node enrollment.
Findings None None.
Security None None.

How this fits together

When a cloud session starts, the Gateway builds and validates a runtime archive from its installed package and selected plugins. It transfers the verified archive to the node before enrollment and the first turn.

flowchart LR
  A[Cloud session request] --> B[Gateway package and plugins]
  B --> C[Bootstrap archive builder]
  C --> D[Import closure check]
  D --> E[Verified archive]
  E --> F[Cloud node enrollment]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +16, Tests +131, Other +78. Total +225 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 1 17 1 +16
Tests 2 134 3 +131
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 99 21 +78
Total 5 250 25 +225

Review metrics

Metric Value Why it matters
Production and test growth production +94 net lines, tests +131 net lines The production growth implements CommonJS resolution and manifest ordering; the added tests cover the checker and transferred archive.

Technical review

Best possible solution:

Land the shared checker repair through normal exact-head gates so Gateway archive preparation accepts complete CommonJS bundles while ESM validation remains strict.

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

Yes. A bundled CommonJS file requiring an extensionless relative target that exists as a .js file reaches the current-main exact-path rejection; the PR reports pre-fix failures, though this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. The shared package checker owns the closure rule, and passing package metadata through the existing Gateway artifact builder keeps the fix at that boundary.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7e6dd89766ce.

Labels

Label changes:

  • add P1: The reported current-main regression blocks cloud-session provisioning before a worker can start, while the published release predates the trigger.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The changed Gateway archive provider has contributor-reported after-fix evidence from a built package with installed undici 8.10.2, including successful artifact preparation, archive size, inventory, and digest; the added fixture also executes an extracted launcher. A live cloud-session dispatch was not observed, and no stored-data contract changes.
  • 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 changed Gateway archive provider has contributor-reported after-fix evidence from a built package with installed undici 8.10.2, including successful artifact preparation, archive size, inventory, and digest; the added fixture also executes an extracted launcher. A live cloud-session dispatch was not observed, and no stored-data contract changes.

Label justifications:

  • P1: The reported current-main regression blocks cloud-session provisioning before a worker can start, while the published release predates the trigger.
  • 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 changed Gateway archive provider has contributor-reported after-fix evidence from a built package with installed undici 8.10.2, including successful artifact preparation, archive size, inventory, and digest; the added fixture also executes an extracted launcher. A live cloud-session dispatch was not observed, and no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed Gateway archive provider has contributor-reported after-fix evidence from a built package with installed undici 8.10.2, including successful artifact preparation, archive size, inventory, and digest; the added fixture also executes an extracted launcher. A live cloud-session dispatch was not observed, and no stored-data contract changes.

Evidence

What I checked:

  • Current-main failure path: The shared checker on fetched main requires an exact file path for every collected relative edge; the root package bundles undici 8.10.2, whose extensionless CommonJS requires are the reported trigger. (scripts/lib/package-dist-imports.mjs:111, 7e6dd89766ce)
  • Introduced repair: The pinned merge-base-to-head patch applies CommonJS file and directory resolution to require edges while retaining exact-path checks for other imports. (scripts/lib/package-dist-imports.mjs:59, 60644b25f47c)
  • Gateway integration: The builder reads package manifests before scanning JavaScript and passes that metadata to the shared checker; Gateway startup calls this artifact provider before node enrollment. (src/gateway/worker-environments/node-bootstrap-artifact.ts:464, 60644b25f47c)
  • Boundary regression coverage: The added fixture prepares an archive containing a CommonJS bundle, extracts it, runs its transferred launcher, and checks the result. The PR body reports that the new checker and bootstrap regressions failed on the pre-fix checkout. (src/gateway/worker-environments/node-bootstrap-artifact.test.ts:26, 60644b25f47c)
  • Reported real artifact proof: The captured PR body reports successful preparation against a built package with installed undici 8.10.2: a 45,471,321-byte archive with 214 undici entries and a SHA-256 digest. It expressly says a live Gateway dispatch was not run. (60644b25f47c)
  • Still needed on main: Neither affected production file changed between the pinned PR base and fetched main; the release tag does not contain this PR head. The related merged pull request fix: fresh npm updates fail to load Undici #160015 bundled undici but did not repair this closure check. (package.json:2252, 7e6dd89766ce)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Patrick Erichsen: 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.

@steipete
steipete merged commit 63a7b9f into main Sep 28, 2026
303 of 305 checks passed
@steipete
steipete deleted the codex/bootstrap-cjs-closure branch September 28, 2026 17:44
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
…penclaw#160583)

The bundleDependencies change in openclaw#160015 exposed exact-path closure checks rejecting valid undici CommonJS requires. Resolve require edges with Node file and directory rules while keeping ESM imports strict, and carry package metadata through bootstrap inspection.

Restore cloud-session dispatch on the next Gateway update. Add checker and transferred-artifact regressions; verify a real undici 8.10.2 bootstrap artifact without starting or stopping a Gateway.
roboclaw-bot added a commit that referenced this pull request Sep 30, 2026
Resolve the merge conflict by retaining the CommonJS bootstrap repair already landed in #160583. Only the title-metadata bound and its complete-task regression remain above main.

Co-authored-by: steipete <[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. scripts Repository scripts size: M 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