Skip to content

fix(workers): resume interrupted bootstrap downloads - #160655

Merged
steipete merged 2 commits into
mainfrom
codex/resumable-bootstrap-download
Sep 28, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/resumable-bootstrap-download

Conversation

@steipete

@steipete steipete commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes cloud worker bootstrap downloads exhausting their retries when a slow connection or buffering proxy repeatedly resets the response body.

Related: #159546.

User Impact

Interrupted bootstrap downloads retain received bytes and request the remainder, allowing preparation to finish within the existing retry window. A server that ignores Range safely replaces the partial file; inconsistent ranges restart cleanly, and complete-file integrity failures still stop installation.

Why This Change Was Made

The shared artifact route now accepts only a single open-ended Range: bytes=N-, returns 206 with the exact remaining length and Content-Range, and rejects unsupported or unsatisfiable ranges with 416. The generated Crabbox setup script retains its partial file across transient failures and verifies the complete archive against its descriptor's SHA-256 before installation. The node-host bundle installer is intentionally unchanged: its one-serve token is revoked after the first authorized attempt and its archive lives in a per-call staging directory, so a ranged retry there could never be authorized.

Security: no new capability, lifetime, or serve budget. Ranges only reduce bytes per serve. Bootstrap tokens retain three serial serves and their 10-minute lifetime; node bundle tokens retain one serve and their existing operation window. Each accepted ranged request consumes a serve. Live authority, revocation, exclusivity, and bootstrap busy-503 handling are unchanged.

Evidence

  • Baseline regressions failed because the route returned 200 instead of 206/416 and downloaders did not resume. Fake-time bootstrap downloader tests cover interruption after 40%, ignored Range, inconsistent ranges, and corrupted resumed bytes; route tests cover exact remaining bytes, budgets, and mid-stream revocation.
  • node scripts/run-vitest.mjs extensions/crabbox --maxWorkers=4: 874 passed, 13 skipped; 133.63s wall.
  • Artifact-transfer, bootstrap, and bundle-transfer suites under src/gateway/worker-environments (10 files, four workers): 149 passed; 84.72s wall.
  • Core and extension production typechecks, extension test types, touched core test graphs (gateway-other, other), targeted core/extension lint, formatting, and git diff --check passed. P2 Codex autoreview is scoped-clean after correcting its finding about terminal full-response length mismatches.
  • Full pnpm tsgo:core:test and node scripts/check-changed.mjs stop at a pre-existing TS2741 in src/gateway/session-row-projection.config-commits.test.ts:76 (missing required scheduler). That test and config-reload.ts are unchanged from the base and observed origin/main; the touched test graphs pass. All changed-file checks before that failure passed.
  • Maintainer follow-up commit drops the unreachable node-bundle range resume (and its tests) and keeps a zero-byte artifact without Range on HTTP 200; affected suites re-run green (artifact-transfer-http 25, bundle-transfer + installer 25, bootstrap download 39) and Codex autoreview is scoped-clean on the final branch.
  • No Gateway was started or stopped. Live tunnel/lease proof remains with the coordinator. An initial test-compiler attempt overlapped SDK declaration generation; serializing preparation resolved that tooling failure.

Single-worker cost, measured with pnpm test <file> --maxWorkers=1 (wall includes wrapper/import preparation):

Changed test file Tests Case time Wall
src/gateway/worker-environments/artifact-transfer-http.test.ts 24 0.27s 31.87s
extensions/crabbox/src/crabbox-worker-bootstrap-download.test.ts 39 0.19s 2.78s

CI timing is pending the initial PR run. No workflow was dispatched or rerun for proof.

@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 docs Improvements or additions to documentation gateway Gateway runtime extensions: crabbox size: L labels Sep 28, 2026
@steipete
steipete marked this pull request as ready for review September 28, 2026 18:41
@steipete
steipete enabled auto-merge (squash) September 28, 2026 18:41
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 28, 2026, 3:11 PM ET / 19:11 UTC (Revision 2).

ClawSweeper review

What this changes

The branch adds bounded byte-range responses to the Gateway artifact route and makes Crabbox bootstrap downloads retain partial archives, resume them, and verify the completed file; it also updates tests and troubleshooting guidance.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: the merged retry fix still downloads from byte zero after an interruption, so this follow-up remains useful. The latest commit resolves the prior one-serve objection, and I found no blocking patch defect.

Priority: P1
Reviewed head: 32417ed03c6c3094bf3c7ffe4baee245f6c9e74f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused boundary coverage and the corrected grant-limit design support a normal good patch.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The member-authored PR is exempt from contributor proof. Focused tests exercise the production Gateway route with a real file and synthetic socket and the generated downloader with a substituted transport; no live worker round trip is shown. 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 member-authored PR is exempt from contributor proof. Focused tests exercise the production Gateway route with a real file and synthetic socket and the generated downloader with a substituted transport; no live worker round trip is shown. No stored-data contract changes.
Evidence reviewed 9 items Current-main gap: The fetched main revision always responds with HTTP 200 and streams from byte zero; its downloader uses a new attempt file and removes it after each attempt.
Current-main downloader: The current-main setup script removes each partial archive at the end of an attempt, which prevents retaining received bytes for the next request.
Introduced range response: The proposed route validates a single open-ended range, sends 206 with the remaining length, and streams from the requested offset after checking current authorization.
Findings None None.
Security None None.

How this fits together

The Gateway grants short-lived access to worker runtime archives and streams them over HTTP. Crabbox's setup script downloads those archives, verifies their contents, and installs the worker runtime.

flowchart LR
A[Bootstrap artifact grant] --> B[Gateway artifact route]
B --> C[Full or ranged bytes]
C --> D[Crabbox downloader]
D --> E{Transfer interrupted?}
E -->|Yes| F[Retained partial file]
F --> B
E -->|No| G[Size and hash verification]
G --> H[Runtime installation]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +40, Tests +135, Docs 0. Total +175 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 54 14 +40
Tests 2 163 28 +135
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 218 43 +175

Review metrics

Metric Value Why it matters
Production and test growth production +40 net lines; tests +135 net lines The production growth implements bounded resume and integrity handling; the test growth covers the new transfer outcomes.

Stored data model

Persistent data-model change detected: serialized state: extensions/crabbox/src/crabbox-worker-node-enrollment.ts, unknown-data-model-change: extensions/crabbox/src/crabbox-worker-node-enrollment.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: canonical
Canonical: #160655
Summary: The merged precursor handles transient retry and grant budgeting; this PR owns the remaining byte-resume behavior.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep byte-range resume within the existing bootstrap grants, with full-response fallback, complete-file verification, and the node-bundle one-serve rule preserved.

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

Yes, from source: interrupt a current-main download after partial delivery and its next attempt starts a full GET because the partial file is removed. This read-only review did not execute that replay.

Is this the best way to solve the issue?

Yes. The change stays with the existing Gateway transfer and Crabbox setup owners, preserves grant limits, and leaves the one-serve node-bundle installer alone.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Repeated body resets can exhaust retries and fail a real cloud-worker provision after substantial setup time.
  • 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 member-authored PR is exempt from contributor proof. Focused tests exercise the production Gateway route with a real file and synthetic socket and the generated downloader with a substituted transport; no live worker round trip is shown. 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-28T18:43:58.789Z sha ffb6ed3 :: blocked before merge. :: [P2] Match node-bundle resume tests to its one-serve grant

@steipete
steipete disabled auto-merge September 28, 2026 18:49
Node worker bundle tokens allow one serve and the archive lives in a per-call staging directory, so a retry with bytes on disk can never be authorized. Keep ranged resume on the three-serve bootstrap path only, and let a zero-byte artifact without Range still serve 200.
@steipete
steipete enabled auto-merge (squash) September 28, 2026 18:57
@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 28, 2026
@steipete
steipete merged commit 97c68f2 into main Sep 28, 2026
254 of 257 checks passed
@steipete
steipete deleted the codex/resumable-bootstrap-download branch September 28, 2026 20:05
steipete added a commit that referenced this pull request Sep 28, 2026
artifact-transfer-http.test.ts vs #160655: progress test adapted to the options-object serve helper.

Adapt the refresh-wait launcher fixture to the shared tunnel and reconciliation helpers after main fixture consolidation removed its direct imports.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
* fix(workers): resume interrupted bootstrap downloads

* refactor(node-host): drop unreachable bundle range resume

Node worker bundle tokens allow one serve and the archive lives in a per-call staging directory, so a retry with bytes on disk can never be authorized. Keep ranged resume on the three-serve bootstrap path only, and let a zero-byte artifact without Range still serve 200.
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