Repository navigation
perf(cloud workers): download the worker bundle while the node bootstrap installs - #164187
Conversation
…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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 5:41 AM ET / 09:41 UTC (Revision 2). ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherThe 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]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +56, Tests +216, Docs 0. Total +272 across 18 files. View PR surface stats
Review metrics
Technical reviewBest 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. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Model the timer and process APIs used during runtime installation, retain delayed close settlement after SIGKILL, and update preflight expectations for eager bundle preparation.
|
Merged via squash.
|
…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.
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.
pnpm test src/gateway/worker-environments/provider-provisioning-node.test.ts --maxWorkers=1pnpm test src/gateway/worker-environments/provider-provisioning.cancellation.test.ts --maxWorkers=1pnpm test src/gateway/worker-environments/provider-crabbox-runtime-preflight.test.ts --maxWorkers=1pnpm test extensions/crabbox/src/crabbox-worker-enrollment-overlap.test.ts --maxWorkers=1pnpm test extensions/crabbox/src/crabbox-worker-node-install.test.ts --maxWorkers=1pnpm test extensions/crabbox/src/crabbox-worker-bootstrap-download.test.ts --maxWorkers=1pnpm test extensions/crabbox/src/crabbox-worker-node-enrollment.test.ts --maxWorkers=1pnpm test extensions/crabbox/src/crabbox-worker-read-budget.test.ts --maxWorkers=1pnpm test extensions/crabbox/src/crabbox-worker-provider-desktop.test.ts --maxWorkers=1pnpm test extensions/crabbox/src/crabbox-worker-project.test.ts --maxWorkers=1The 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
c7c937abfea22failed 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.node scripts/check-changed.mjs --base c7c937abfea22f17be5cac24bfc906d4d91368f6passed (2,925.82 s), including format, typechecks, lint, and all selected guards.node scripts/check-changed.mjs --base HEADpassed (HEAD was03ec82de713ba; 1,313.43 s).03ec82de713ba). The test-only follow-up was reviewed separately as noted above.git diff --check: clean.pnpm buildwas run; the required test/check harnesses prepared their own artifacts.37110441709exposed 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-downloadmarks overlap. After node connection,Worker bundle already prepared locally: <sha256>fromnode/worker-bundleis 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.