Skip to content

perf(cloud workers): download the worker bundle while the node bootstrap installs - #164187

Merged
steipete merged 2 commits into
mainfrom
steipete/cs-enrollment-overlap-20261002
Oct 3, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/cs-enrollment-overlap-20261002

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Cold cloud enrollment without a prepared project downloads the node runtime and worker bundle serially, delaying worker readiness.

User Impact

Ordinary cloud workers now download the worker bundle while the node runtime downloads and installs. A worker-download failure terminates the owned npm process tree promptly, while cleanup still waits for npm to close. npm timeout and setup cancellation use that same termination path.

The expected time-to-active improvement is bounded by the shorter of the worker download and bootstrap work. The broader estimate is min(bundle download, bootstrap install + connect); this implementation reuses the existing preparation join before enrollment, so its actual overlap covers bootstrap download/install, with connection afterward and additional setup and verification overhead. Hetzner/AWS A/B measurements remain pending.

Why This Change Was Made

Core prepares both immutable artifacts before node-backed provisioning. Crabbox reuses the existing prepareNodeRuntime() and runtime setup script for ordinary enrollment, then starts enrollment after preparation settles. Runtime and worker hashes, live owner/epoch checks, combined-byte grant TTLs, grant revocation before enrollment, and the installer's prepared-archive verification remain intact. Both preparation and enrollment retain their own time allowances.

This adds no public SDK surface, protocol field, configuration key, or environment variable. Project capture continues through its existing branch; disabling warm images skips checkout/capture while still preparing runtime bytes.

Evidence

Every changed test file was run with one worker. Wall time includes the repository test harness's worker compilation, transformation, and cleanup.

Command Result Wall time
pnpm test src/gateway/worker-environments/provider-provisioning-node.test.ts --maxWorkers=1 17 passed 294.93 s
pnpm test src/gateway/worker-environments/provider-provisioning.cancellation.test.ts --maxWorkers=1 19 passed 88.51 s
pnpm test src/gateway/worker-environments/provider-crabbox-runtime-preflight.test.ts --maxWorkers=1 15 passed 233.08 s
pnpm test extensions/crabbox/src/crabbox-worker-enrollment-overlap.test.ts --maxWorkers=1 2 passed 173.54 s
pnpm test extensions/crabbox/src/crabbox-worker-node-install.test.ts --maxWorkers=1 6 passed 288.84 s
pnpm test extensions/crabbox/src/crabbox-worker-bootstrap-download.test.ts --maxWorkers=1 28 passed 276.07 s
pnpm test extensions/crabbox/src/crabbox-worker-node-enrollment.test.ts --maxWorkers=1 28 passed 180.16 s
pnpm test extensions/crabbox/src/crabbox-worker-read-budget.test.ts --maxWorkers=1 5 passed 46.54 s
pnpm test extensions/crabbox/src/crabbox-worker-provider-desktop.test.ts --maxWorkers=1 10 passed 32.20 s
pnpm test extensions/crabbox/src/crabbox-worker-project.test.ts --maxWorkers=1 57 passed 190.83 s

The new ordinary enrollment cases take about 0.5 s of test execution and the six process settlement cases about 1.1 s. Existing suites above 30 s exercise real npm/HTTP/process or SQLite/provider lifecycle boundaries: node provisioning, cancellation, preflight/restart, source enrollment, and project capture. The existing real-npm fixture proves the peer-failure fix in about 1.1 s; the new tests of the generated script use fake time and process mocks, without additional process boots or sleeps.

Additional coverage: the node installer passed 27 tests, including prepared archive acquisition without HTTP and integrity rejection; shutdown/replay passed its lease-adoption test. The general provider suite passed 115 tests in 96.92 s. Initial local failures from the moved test's missing database-worker registration, obsolete opt-out expectations, an unused import, and a catch-variable type annotation were corrected.

Negative controls against c7c937abfea22 failed for the intended regressions: four core cases entered enrollment before packaging, two provider cases skipped runtime preparation, and six generated-script cases failed to terminate the npm tree. Candidate production files were restored byte-for-byte afterward.

  • Changed-file gate: node scripts/check-changed.mjs --base c7c937abfea22f17be5cac24bfc906d4d91368f6 passed (2,925.82 s), including format, typechecks, lint, and all selected guards.
  • Fixture follow-up changed-file checks: node scripts/check-changed.mjs --base HEAD passed (HEAD was 03ec82de713ba; 1,313.43 s).
  • Fixture follow-up review: scoped clean; no accepted/actionable P0–P2 findings, with the unchanged production owners supplied as review context.
  • Independent review: scoped clean; no accepted/actionable P0–P2 findings on an isolated, hash-verified copy of the initial candidate (03ec82de713ba). The test-only follow-up was reviewed separately as noted above.
  • git diff --check: clean.
  • No pnpm build was run; the required test/check harnesses prepared their own artifacts.
  • Initial CI run 37110441709 exposed two additional stale fixtures: preflight assertions forbidding early packaging, and a download VM missing timer/process globals. Both fixtures are corrected without production changes; the VM also asserts kill at 1 s and delayed close settlement at 2 s. The failed preflight invocation took 18.52 s in CI; the download suite shared a 12.07 s invocation with its sibling files. Updated-head CI verification is pending. Live cloud A/B and native Windows/macOS cloud enrollment remain unverified. Windows tree termination is covered by generated-script process mocks, and real npm descendant termination was exercised locally.

For the live A/B, CRABBOX_PHASE:openclaw-bootstrap-installation-and-worker-download marks overlap. After node connection, Worker bundle already prepared locally: <sha256> from node/worker-bundle is emitted only after the installer copies and verifies the prepared archive, immediately before returning without its worker-bundle HTTP GET. Capture that line on a fresh worker alongside time-to-active.

…rap installs

Prepare both artifacts before node provisioning and reuse runtime preparation
for ordinary Crabbox enrollment. Preserve grant ownership and archive validation,
reserve both phase budgets, and terminate the owned npm tree on peer failure,
timeout, or cancellation before settling staging cleanup.
@clawsweeper

clawsweeper Bot commented Oct 3, 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 docs Improvements or additions to documentation gateway Gateway runtime extensions: crabbox size: L labels Oct 3, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 5:41 AM ET / 09:41 UTC (Revision 2).

ClawSweeper review

What this changes

The PR downloads cloud-worker artifacts alongside runtime installation and terminates the owned npm process tree on failure, timeout, or cancellation.

Merge readiness

✅ Ready for maintainer review

Keep open: the optimization remains absent from current main and the latest release, and review found no blocking correctness defect. The fixture follow-up preserves the production implementation and addresses the reported CI failures.

Priority: P2
Reviewed head: fc2f61c06a7c670d1867cb732031f88db7c10260

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with meaningful lifecycle coverage, explicit measurement limits, and no blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a MEMBER author, so ordinary external-contributor proof is exempt. The inspected generated-script and real-npm fixtures support termination and settlement; cloud speedup and native enrollment remain unmeasured. No stored-data contract changes were introduced.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a MEMBER author, so ordinary external-contributor proof is exempt. The inspected generated-script and real-npm fixtures support termination and settlement; cloud speedup and native enrollment remain unmeasured. No stored-data contract changes were introduced.
Evidence reviewed 9 items Introduced production change: The pinned merge-base-to-head diff prepares the worker bundle unconditionally before node provisioning and adds ordinary Crabbox runtime preparation through the existing operation.
Current main still needs the optimization: Fetched main still prepares the bundle at this stage only for project-backed requests; ordinary Crabbox provisioning proceeds directly to enrollment.
Latest release check: The v2026.9.8 source also retains the project-only preparation condition, so the central optimization is not already shipped.
Findings None None.
Security None None.

How this fits together

The Gateway prepares immutable runtime and worker archives, and the Crabbox plugin installs them on a leased cloud machine. After preparation, authenticated node enrollment connects the machine and the node installer verifies the retained worker archive.

flowchart TD
  A[Worker provisioning request] --> B[Gateway prepares both archives]
  B --> C[Live artifact grants]
  C --> D[Concurrent downloads and runtime installation]
  D --> E{Preparation succeeds}
  E -->|Yes| F[Revoke preparation grants and enroll node]
  F --> G[Verify retained worker archive]
  E -->|No| H[Terminate npm tree and settle cleanup]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +56, Tests +216, Docs 0. Total +272 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 5 65 9 +56
Tests 11 389 173 +216
Docs 2 5 5 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 459 187 +272

Review metrics

Metric Value Why it matters
Production versus regression coverage production net +56 lines; tests net +215; test routing +1 Production growth implements overlap and process-tree settlement, with coverage for ordering, cancellation, failure cleanup, and separate phase budgets.

Technical review

Best possible solution:

Reuse the existing preparation owner, preserve grant revocation and archive verification, and report performance gains only once measured.

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

Not applicable to the performance request; source confirms the serial ordinary-enrollment path. Cancellation regression scenarios are present in the inspected fixtures, but were not executed during this review.

Is this the best way to solve the issue?

Yes: the patch extends the existing preparation path instead of adding a competing installer or SDK contract, and preserves authenticated fallback when a retained archive is absent.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded cloud-worker startup improvement with associated cancellation hardening and no demonstrated urgent regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies a MEMBER author, so ordinary external-contributor proof is exempt. The inspected generated-script and real-npm fixtures support termination and settlement; cloud speedup and native enrollment remain unmeasured. No stored-data contract changes were introduced.

Evidence

What I checked:

Likely related people:

  • steipete: 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 (1 earlier review cycle)
  • reviewed 2026-10-03T08:44:05.978Z sha 03ec82d :: needs maintainer review before merge. :: none

Model the timer and process APIs used during runtime installation, retain
delayed close settlement after SIGKILL, and update preflight expectations
for eager bundle preparation.
@steipete
steipete merged commit a6748f0 into main Oct 3, 2026
137 checks passed
@steipete
steipete deleted the steipete/cs-enrollment-overlap-20261002 branch October 3, 2026 10:12
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…rap installs (openclaw#164187)

* perf(cloud workers): download the worker bundle while the node bootstrap installs

Prepare both artifacts before node provisioning and reuse runtime preparation
for ordinary Crabbox enrollment. Preserve grant ownership and archive validation,
reserve both phase budgets, and terminate the owned npm tree on peer failure,
timeout, or cancellation before settling staging cleanup.

* test(cloud workers): align preflight and download fixtures

Model the timer and process APIs used during runtime installation, retain
delayed close settlement after SIGKILL, and update preflight expectations
for eager bundle preparation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: crabbox gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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