Skip to content

fix(cloud-workers): keep resuming bootstrap downloads that make progress - #162408

Merged
steipete merged 1 commit into
mainfrom
codex/progress-aware-bootstrap-retries
Oct 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/progress-aware-bootstrap-retries

Conversation

@steipete

@steipete steipete commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes cloud worker startup failing behind reset-prone proxies even when each bootstrap download attempt receives more of the archive.

Related: #160655, #160687, #160904.

User Impact

Cloud bootstrap keeps resuming downloads that grow the retained partial file. Three consecutive transient failures without retained byte progress still stop, as do integrity, identity, TLS-pin, and terminal HTTP failures. The core-sized command deadline and two-minute idle timeout remain unchanged; no configuration or migration is required.

Why This Change Was Made

The downloader and bootstrap token each allowed only three attempts/serves. The client now tracks retained byte growth separately from attempts, so progress resets the failure count. Repeated full responses that merely replay the same prefix do not reset it. Busy transfer_in_progress responses retain their existing backoff behavior.

Bootstrap tokens now allow 256 serial serves. This fixed cap gives a 256 MiB artifact room to complete in roughly 1 MiB increments, while still bounding full-artifact replays. Both completed and interrupted full/ranged responses consume a serve. The original size-derived 45–95 minute lifetime, one-active-transfer limit (busy 503), opaque 404 after expiry/revocation/exhaustion, and enrollment current() owner checks remain intact. Node-worker bundle transfer tokens remain at one serve.

Security: the bearer remains short-lived, owner-revocable, and single-active. More serves only affect a leaked token during its existing window, for the Gateway's own build artifact. Retries do not extend the window or acquire new authority.

Evidence

Maintainer-supplied live evidence from an isolated dev Gateway on main, Crabbox 0.69, Cloudflare quick-tunnel ingress, and three concurrent cold dispatches: GCP provisioning succeeded, but node runtime preparation failed at +920 seconds after download body failed (ECONNRESET) exhausted attempts 2/3 and 3/3. Each attempt resumed with Range and made progress. A concurrent Hetzner dispatch survived but took about 35 minutes. This PR does not claim a new live cloud run; no Gateways were started or stopped.

Fake-time regressions failed against the original production code at base 9680e57a9631b6a7060b9d4642bffb9f9fbc3000: four client cases failed because the third failure stopped the transfer, and three HTTP-boundary cases failed because the fourth serve returned 404. The fixed tests prove five progressing resets complete, progress resets the consecutive failure count, three no-progress failures still stop, and serve 257 returns opaque 404 for both full and ranged responses. Existing expiry, revocation, busy, integrity, and enrollment coverage is retained.

Validation: all 133 targeted tests pass across bootstrap-download (46), node-enrollment (28), artifact-transfer-http (42), and worker-bootstrap-artifact-transfer (17). An interim run failed after I incorrectly changed the native enrollment fixture to expect four requests; its immediate reset retains no bytes. That expectation change was removed, and all 28 unchanged enrollment tests passed. The deterministic fake-time tests own the retained-progress assertions.

Measured cost on the loaded Mac with --maxWorkers=1: the bootstrap-download shard took 5.46 seconds wall (under one second in test bodies); the combined Gateway shard took 56.81 seconds wall, including worker compilation. The changed HTTP test file spent 0.764 seconds in test bodies, including both 256-serve exhaustion cases. CI timing is pending.

P2 autoreview is scoped-clean in both pre-commit local mode and the requested branch mode. The committed branch is aecaaed3292466fa836a89fc923be09ec48516bc.

Focused commands (one worker):

node scripts/run-vitest.mjs extensions/crabbox/src/crabbox-worker-bootstrap-download.test.ts extensions/crabbox/src/crabbox-worker-node-enrollment.test.ts src/gateway/worker-environments/artifact-transfer-http.test.ts src/gateway/worker-environments/worker-bootstrap-artifact-transfer.test.ts --maxWorkers=1
node scripts/run-vitest.mjs extensions/crabbox/src/crabbox-worker-bootstrap-download.test.ts extensions/crabbox/src/crabbox-worker-node-enrollment.test.ts --maxWorkers=1
node scripts/check-changed.mjs
git diff --check

The first run passed both Gateway files, then hit the interim enrollment expectation failure described above. The second passed both extension files. The changed-lane runner passed core and extension production types, all 27 core test typecheck shards, extension test types, formatting, six doctor-contract tests, and its completed repository guards. It exceeded the work order's 15-minute host limit and was stopped during the deprecated-API guard (exit 130); the remaining broad guards were not run. Both remaining scoped oxlint commands passed with one thread, and git diff --check origin/main...HEAD passed. This is the authorized scoped fallback, not a claim that the full changed-check pipeline passed.

node scripts/run-oxlint.mjs --threads=1 --tsconfig config/tsconfig/oxlint.core.json src/gateway/worker-environments/artifact-transfer-http.test.ts src/gateway/worker-environments/artifact-transfer-service.ts src/gateway/worker-environments/worker-bootstrap-artifact-transfer-service.ts
node scripts/run-oxlint.mjs --threads=1 --tsconfig extensions/tsconfig.json extensions/crabbox/src/crabbox-worker-bootstrap-download.test.ts extensions/crabbox/src/crabbox-worker-node-enrollment.ts

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: crabbox size: S labels Oct 1, 2026
@steipete
steipete marked this pull request as ready for review October 1, 2026 04:52
@clawsweeper

clawsweeper Bot commented Oct 1, 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) October 1, 2026 04:53
@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 Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 12:59 AM ET / 04:59 UTC.

ClawSweeper review

What this changes

The PR lets cloud-worker bootstrap downloads continue while retained bytes grow, raises bootstrap tokens to 256 serial serves, and updates regression coverage and troubleshooting guidance.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main still stops progressing bootstrap downloads after three attempts or serves. No actionable introduced defect was found.

Priority: P1
Reviewed head: aecaaed3292466fa836a89fc923be09ec48516bc

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful regression coverage, disclosed validation limits, and no blocking correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: GitHub verifies the author as a repository admin, so ordinary external-contributor proof is exempt. The supplied live Gateway/Crabbox tunnel observations demonstrate the original failure, while after-fix coverage uses mocked downloader transport and synthetic HTTP response fixtures; neither is claimed as a new live recovery run. No unresolved authority violation requires an exception proof gate, and 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: GitHub verifies the author as a repository admin, so ordinary external-contributor proof is exempt. The supplied live Gateway/Crabbox tunnel observations demonstrate the original failure, while after-fix coverage uses mocked downloader transport and synthetic HTTP response fixtures; neither is claimed as a new live recovery run. No unresolved authority violation requires an exception proof gate, and no stored-data contract changes.
Evidence reviewed 6 items Pinned introduced change: Reviewed the merge-base-to-head patch. The verified test merge has the recorded base followed by the exact PR head as parents, and its resulting delta contains the same six intended paths.
Still necessary on main: Fetched main retains maxServes: 3, and comparison of the downloader shows the fixed three-attempt limit remains there. The related merged changes supplied range resume and larger timing windows, not this progress-aware retry policy. GitHub's latest release check returned v2026.9.7; this unmerged fix is not established as shipped.
Progress and terminal failure handling: The downloader compares the settled partial-file size with its prior offset, resets only on growth, excludes busy responses, and stops after three consecutive no-progress failures. Complete archive verification and terminal integrity, HTTP, and TLS-pin failures remain intact.
Findings None None.
Security None None.

How this fits together

The Gateway grants temporary access to its runtime archives during cloud-worker preparation. Crabbox downloads and verifies those archives before installing the runtime and connecting the worker.

flowchart TD
  A[Cloud worker preparation] --> B[Gateway archive grant]
  B --> C[Live owner and expiry checks]
  C --> D[Full or ranged download]
  D --> E{Retained bytes grow?}
  E -->|Yes| D
  E -->|Three failures without progress| F[Preparation fails]
  D --> G[Verify and install archive]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +8, Tests +87, Docs 0. Total +95 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 19 11 +8
Tests 2 113 26 +87
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 133 38 +95

Review metrics

Metric Value Why it matters
Bootstrap serve budget 3 → 256 serial serves; node-worker bundle stays at 1 Frequent resumes become possible within the original authorization window, with a bounded increase in possible artifact replays.

Technical review

Best possible solution:

Keep progress-aware retries in the existing downloader and preserve the Gateway's live authorization, fixed expiry, exclusive streaming, and archive verification.

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

Yes, source establishes the failure path: repeated interrupted downloads can retain additional bytes yet exhaust current main's three attempts or serves. The supplied live failure supports that mechanism; this review did not execute it.

Is this the best way to solve the issue?

Yes, the patch repairs the existing retry owners without adding configuration or competing implementations, and preserves terminal failures and authorization boundaries.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: Reported live cloud-worker preparation fails despite continued download progress, blocking the worker workflow.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool 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: GitHub verifies the author as a repository admin, so ordinary external-contributor proof is exempt. The supplied live Gateway/Crabbox tunnel observations demonstrate the original failure, while after-fix coverage uses mocked downloader transport and synthetic HTTP response fixtures; neither is claimed as a new live recovery run. No unresolved authority violation requires an exception proof gate, and no stored-data contract changes.

Label justifications:

  • P1: Reported live cloud-worker preparation fails despite continued download progress, blocking the worker workflow.
  • 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: GitHub verifies the author as a repository admin, so ordinary external-contributor proof is exempt. The supplied live Gateway/Crabbox tunnel observations demonstrate the original failure, while after-fix coverage uses mocked downloader transport and synthetic HTTP response fixtures; neither is claimed as a new live recovery run. No unresolved authority violation requires an exception proof gate, and no stored-data contract changes.

Evidence

What I checked:

  • Pinned introduced change: Reviewed the merge-base-to-head patch. The verified test merge has the recorded base followed by the exact PR head as parents, and its resulting delta contains the same six intended paths. (aecaaed32924)
  • Still necessary on main: Fetched main retains maxServes: 3, and comparison of the downloader shows the fixed three-attempt limit remains there. The related merged changes supplied range resume and larger timing windows, not this progress-aware retry policy. GitHub's latest release check returned v2026.9.7; this unmerged fix is not established as shipped. (src/gateway/worker-environments/worker-bootstrap-artifact-transfer-service.ts:28, c6ea95238634)
  • Progress and terminal failure handling: The downloader compares the settled partial-file size with its prior offset, resets only on growth, excludes busy responses, and stops after three consecutive no-progress failures. Complete archive verification and terminal integrity, HTTP, and TLS-pin failures remain intact. (extensions/crabbox/src/crabbox-worker-node-enrollment.ts:270, aecaaed32924)
  • Authority-chain assessment: Increasing the serve budget permits more artifact replays, but does not extend expiry or change the authorized owner. Enrollment binds grants to the active provisioning operation and setup/device identity; the transfer owner rechecks authority after file opening and the HTTP streaming transform checks it before forwarding chunks. Revocation removes the capability and aborts active I/O. Node-worker bundle tokens still allow one serve. No concrete unauthorized or stale-authority path was found. (src/gateway/worker-environments/artifact-transfer-service.ts:71, aecaaed32924)
  • Regression coverage and supplied validation: Inspected generated-script tests covering five progressing resets, mixed failures, repeated prefixes, and terminal failures, plus HTTP-boundary tests for interrupted resumes, exclusive settlement, 256-serve exhaustion, expiry, and owner revocation. The captured PR body reports 133 targeted passing tests and measured test costs, while explicitly disclosing the stopped broad guard run and absence of a new live cloud run. These are supplied results; no tests were executed during this review. (src/gateway/worker-environments/artifact-transfer-http.test.ts:208, aecaaed32924)
  • Verified author authority and historical routing: GitHub verifies steipete has repository admin permission, resolving the association discrepancy in the supplied context. Prior merged history connects this person to resume, lifetime, and enrollment-deadline work. The API commit patch independently confirms the lifetime change. Local follow-history and blame encountered unavailable object retrieval errors, so no source-line introduction attribution is claimed. (src/gateway/worker-environments/worker-bootstrap-artifact-transfer-service.ts, 43ca10703b6d)

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 2dd1091 into main Oct 1, 2026
315 of 317 checks passed
@steipete
steipete deleted the codex/progress-aware-bootstrap-retries branch October 1, 2026 05:06
@vincentkoc

Copy link
Copy Markdown
Member

@steipete: a downstream fixture mismatch after this change blocks #120232. The original failure is https://github.com/openclaw/openclaw/actions/runs/36860624890/job/110364125000: crabbox-worker-node-enrollment.test.ts expects three authenticated requests for the truncated-body case and observed four.

The fixture writes one body byte before destroying the response. If that byte is retained, the new no-progress counter correctly permits one progressing attempt followed by three stalled attempts. The producer/test blobs remain unchanged at main d5e94ecc0939907f18e5980ac6d7613c140387dd. This supports a fixture-contract mismatch, not an established production defect or an observed historical byte-retention trace.

Proposed owner repair, not yet executed: make this diagnostic fixture deliberately zero-progress by retaining the positive Content-Length and response.flushHeaders(), then ending request.socket without writing body bytes. Node's socket end contract sends FIN; its premature HTTP-response closure contract documents the response-side aborted error. The exact existing diagnosis still needs confirmation under the failed Linux/Node runtime.

Keep every current assertion: exactly three authenticated requests for this zero-progress case, failure classification, credential redaction, no node start and complete fixture cleanup. Existing crabbox-worker-bootstrap-download.test.ts cases separately protect advancing partial downloads, budget reset, replayed prefixes and exhaustion. Do not change the expected count to four or accept a range to hide the fixture race.

Routing this to the upstream owner under the repository's known-main-CI policy; no standalone test-only PR, production edit, retry campaign or competing executor has been started. Preserve the original failure and qualify only the proposed fixture/affected owner shard through the accepted remote route.

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: S 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.

2 participants