Skip to content

fix(cloud-workers): size node enrollment deadlines from the bootstrap window - #160904

Merged
steipete merged 2 commits into
mainfrom
codex/crabbox-enrollment-deadline
Sep 29, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/crabbox-enrollment-deadline

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Cold cloud-worker enrollment over a slow Gateway uplink (a home connection, or a Cloudflare quick tunnel as gateway.publicOrigin) could not finish. Live, with #160655 and #160687 in place, a Crabbox Hetzner cold dispatch over a ~160 KB/s tunnel resumed its interrupted download correctly (Range, no 404), but was killed at +1,105 s:

Crabbox node enrollment setup did not exit normally (timeout): ... download-body Cloud worker bootstrap download body failed (ECONNRESET); retrying download attempt 2/3 ... download-http-response ... download-body

The node bootstrap artifact (~45 MB) and the worker bundle (~28 MB) download concurrently. Crabbox capped the whole enrollment command at a fixed CRABBOX_NODE_ENROLLMENT_TIMEOUT_MS = 15 min, which also covers Node/npm install and setup. Core already sizes these same transfers from their byte counts (125 KB/s floor, workerBootstrapOperationTimeoutMs), so the plugin's fixed deadline contradicted core's own transfer policy. Each HTTP attempt also had a hard 10-minute cap, so three attempts could not move 250 MB at the floor rate.

User Impact

Slow-uplink Gateways can enroll cold cloud workers. Stalled download connections are detected within two minutes and resumed from the last byte, and slow-but-progressing transfers are never cut by a per-attempt limit.

Why This Change Was Made

  • One owner for transfer timing. The size-derived policy moves out of the SSH-heavy bootstrap.ts into bootstrap-timeouts.ts, and all consumers are migrated. Node enrollment grants now carry a core-owned bootstrapTimeoutMs, sized from the combined bytes of the artifacts that download concurrently through one uplink. That window also sizes both transfer tokens.
  • Crabbox consumes the fact rather than a constant. The enrollment and runtime-preparation command deadlines use the grant's window, with the existing 15 minutes kept as a floor when no fact is supplied. Provisioning resolves its outer timeout before grants exist, so core passes its policy maximum (MAX_NODE_BOOTSTRAP_TIMEOUT_MS: the largest operation window plus the node connection wait) to resolveProvisionTimeoutMs and provision, and the outer budget can always contain the derived command deadline.
  • Stall detection instead of per-attempt caps. The download script drops the per-attempt AbortSignal.timeout. A two-minute socket inactivity timeout raises a transient ETIMEDOUT, so the existing retry and Range resume continue from the partial file. Attempt count, authority checks, busy-503 handling, integrity verification and cleanup are unchanged.
  • SDK: additive, optional timing facts on existing contracts (WorkerNodeBootstrapAccess.bootstrapTimeoutMs, provision option nodeBootstrapTimeoutMs, and an optional second argument to resolveProvisionTimeoutMs), documented in docs/plugins/sdk-overview/capabilities.md. They add no authority, subpath, protocol or schema.

Not changed: the node pairing credential keeps its 10-minute lifetime. Enrollment closure does not currently revoke it (redemption checks durable environment eligibility, not the live enrollment binding), so extending it would widen that gap. That is tracked separately. Until then, a cold enrollment whose downloads take longer than 10 minutes can still fail at pairing; the docs say so.

Evidence

  • Negative controls fail on main: grant timing facts are missing, a 900,000 ms vs 5,700,000 ms command deadline, an insufficient outer budget, and progressing transfers cut by the old attempt caps (3 of 42 download cases fail).
  • New fake-time regressions: 48/46-minute progressing transfers complete on one attempt each; header and body stalls abort as transient and resume with Range; grant windows are sized from combined bytes; the pre-grant outer budget contains the derived deadline. The download suite runs in 3.9 s wall (42 tests), and the grant-window case takes 13.0 s, including its database fixture.
  • Suites: crabbox provider/read-budget/node-enrollment(-replay/-windows)/bootstrap-download give 273 + 42 passed; worker-environments node-enrollment, provider-provisioning-node, bootstrap, artifact-transfer-http, worker-bootstrap-artifact-transfer, node-worker-bundle-transfer-service/installer and provider-bootstrap give 156 + 77 passed. After rebasing onto current main: 119 + 42 passed.
  • Types: core production types, all 27 core-test graphs, and extension production/test graphs pass. The line-cap and max-lines ratchets are OK, the OPENCLAW_* count is 476/476, and oxfmt/oxlint and git diff --check are clean. Codex autoreview P2 is scoped-clean in branch mode for both commits.
  • The live rerun of the slow-tunnel cold Hetzner cell will be added after merge.

Carry optional core timing facts into provider budgets before allocation and
into artifact-specific Crabbox commands and HTTP requests. Size concurrent
runtime downloads from their combined bytes while retaining separate
connection, scrub, diagnostics, settlement, and cleanup allowances.

Keep the existing pairing credential lifetime: enrollment closure does not
revoke its bearer. Document that remaining limit rather than extending it.
…ttempts

Use a two-minute socket inactivity timeout so stalled bootstrap downloads retry and resume retained bytes, while progressing transfers share only the core-owned command deadline. Remove the unused script timeout argument without changing the grant or command budgets.

Fake-time proof covers 48/46-minute progressing transfers and header/body stalls; the origin/main negative control fails all three cases. The crabbox enrollment/provider suites and downloader suite pass 315 tests total. Extension production/test typechecks, changed-file formatting/lint, and P2 candidate autoreview pass.
@clawsweeper

clawsweeper Bot commented Sep 29, 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.

@steipete
steipete enabled auto-merge (squash) September 29, 2026 02:37
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: crabbox size: M labels Sep 29, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 29, 2026
@clawsweeper

clawsweeper Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 10:43 PM ET / September 29, 2026, 02:43 UTC.

ClawSweeper review

What this changes

This PR gives cloud-worker enrollment a size-derived command window and replaces Crabbox’s fixed HTTP attempt deadline with a two-minute inactivity timeout.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main has the earlier download-resume and transfer-lifetime fixes, but still has the fixed command and per-attempt deadlines this PR addresses. The patch is coherent, and this review found no definite introduced defect.

Priority: P1
Reviewed head: df2beee763d9448f150b63c0cc0eee0a00bc151d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused negative controls and boundary regressions support a coherent fix, with the documented pairing limit outside its scope.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate. A prior real Crabbox cold dispatch shows the failure, while after-fix evidence is fake-time boundary testing; the PR body explicitly leaves a live slow-tunnel rerun for later. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate. A prior real Crabbox cold dispatch shows the failure, while after-fix evidence is fake-time boundary testing; the PR body explicitly leaves a live slow-tunnel rerun for later. No stored-data contract changes.
Evidence reviewed 9 items Current-main gap: The fetched main revision lacks the new timeout-policy module; its Crabbox downloader still uses a ten-minute per-attempt signal.
Core deadline policy: The introduced policy bounds bootstrap work from archive size and reserves a maximum that includes the separate node connection wait.
Grant and command wiring: Runtime preparation sizes both artifact grants from their combined bytes; Crabbox consumes the grant window for its remote setup command.
Findings None None.
Security None None.

How this fits together

The Gateway prepares cloud-worker archives and grants temporary HTTP download access. Crabbox downloads and installs those archives on a remote machine, then waits for the node to pair and become available.

flowchart LR
  A[Cloud worker dispatch] --> B[Core bootstrap window]
  B --> C[Artifact grants]
  B --> D[Crabbox command deadline]
  C --> E[HTTP downloads]
  D --> F[Remote setup]
  E --> F
  F --> G[Node pairing]
  G --> H[Available worker]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +49, Tests +113, Docs +4. Total +166 across 20 files.

View PR surface stats
Area Files Added Removed Net
Source 12 102 53 +49
Tests 5 164 51 +113
Docs 3 6 2 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 20 272 106 +166

Review metrics

Metric Value Why it matters
Code growth production +49 lines, tests +113 lines Production growth centralizes timing policy and carries optional timing facts through the existing provider contract.

Technical review

Best possible solution:

Keep timeout policy in the Gateway and let Crabbox consume its bounded timing facts; address pairing beyond ten minutes through a separate owner-bound credential design.

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

Yes. Current-main source shows the fixed command and request deadlines, and the supplied slow-tunnel trace reports the command timing out. I did not execute that path in this read-only review.

Is this the best way to solve the issue?

Yes for the deadline mismatch: the existing core policy computes the window and Crabbox consumes it with an optional fallback. The separate pairing-credential limit remains documented.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: The fixed deadlines interrupt a real cloud-worker enrollment workflow on slow Gateway uplinks.
  • 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. Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate. A prior real Crabbox cold dispatch shows the failure, while after-fix evidence is fake-time boundary testing; the PR body explicitly leaves a live slow-tunnel rerun for later. No stored-data contract changes.

Label justifications:

  • P1: The fixed deadlines interrupt a real cloud-worker enrollment workflow on slow Gateway uplinks.
  • 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. Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate. A prior real Crabbox cold dispatch shows the failure, while after-fix evidence is fake-time boundary testing; the PR body explicitly leaves a live slow-tunnel rerun for later. No stored-data contract changes.

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.

@steipete
steipete merged commit 483d3b9 into main Sep 29, 2026
205 of 207 checks passed
@steipete
steipete deleted the codex/crabbox-enrollment-deadline branch September 29, 2026 02:55
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
… window (openclaw#160904)

* fix(cloud-workers): derive enrollment deadlines from bootstrap windows

Carry optional core timing facts into provider budgets before allocation and
into artifact-specific Crabbox commands and HTTP requests. Size concurrent
runtime downloads from their combined bytes while retaining separate
connection, scrub, diagnostics, settlement, and cleanup allowances.

Keep the existing pairing credential lifetime: enrollment closure does not
revoke its bearer. Document that remaining limit rather than extending it.

* fix(crabbox): detect stalled bootstrap downloads instead of capping attempts

Use a two-minute socket inactivity timeout so stalled bootstrap downloads retry and resume retained bytes, while progressing transfers share only the core-owned command deadline. Remove the unused script timeout argument without changing the grant or command budgets.

Fake-time proof covers 48/46-minute progressing transfers and header/body stalls; the origin/main negative control fails all three cases. The crabbox enrollment/provider suites and downloader suite pass 315 tests total. Extension production/test typechecks, changed-file formatting/lint, and P2 candidate autoreview pass.
@steipete

Copy link
Copy Markdown
Contributor Author

Live follow-up on main 483d3b9 or later, which includes this PR plus #160655, #160687 and #160730. Setup: an isolated dev Gateway, Crabbox 0.67, a Hetzner cold profile (warmImage: false), and Cloudflare quick-tunnel ingress measured at about 310 KB/s from the Gateway host during the run.

  • Dispatch: provisioning → active in 970 s, with bootstrap downloads, node enrollment and first sync complete.
  • Two OpenClaw worker turns completed (32 s and 20 s). The first turn launched from the freshly installed worker bundle, which is the fix(cloud-workers): retain bundles through provisioning #160730 path.
  • Reclaim completed in 64 s, with verdict pass.

Before this series, the same cell failed with ECONNRESET followed by 404 (fixed-lifetime token), then with a first-turn bundle ENOENT, then with the 15-minute enrollment timeout on a ~160 KB/s tunnel. Caveat: this run's tunnel was about twice as fast as the timed-out one, so it proves the complete cold path end to end rather than isolating the deadline change. The deadline itself is covered by the fake-time regressions in this PR.

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 P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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