Skip to content

feat(cloud-workers): worker bundle production, pinned SSH bootstrap, and admission handshake - #104532

Merged
steipete merged 8 commits into
mainfrom
claude/cloud-workers-bundle-bootstrap
Jul 11, 2026
Merged

steipete merged 8 commits into
mainfrom
claude/cloud-workers-bundle-bootstrap

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Part of #104294 (cloud workers, milestone 1, PR 3 of the series). Builds on #104401 and #104465. Design: docs/plan/cloud-workers.md.

What Problem This Solves

A leased worker machine is useless until the gateway's own build is installed on it and provably identical to what the gateway expects. This PR makes a provisioned box bootstrap-able: content-hashed worker bundles produced from the gateway's running dist, an idempotent hardened SSH bootstrap, and the typed admission handshake that milestone 2's worker role will enforce.

Why This Change Was Made

  • Worker bundle production (src/gateway/worker-environments/bundle.ts): deterministic manifest hashing (sorted paths, versioned, per-file mode/size/sha256) over the gateway's packaged dist, with a content-addressed tarball cache. Two install channels per the plan: bundle (canonical, works for dev builds by construction) and opt-in npm (exact released gateway version, public-tarball SRI + manifest-parity verification).
  • SSH bootstrap (bootstrap.ts): idempotent over SSH/SCP with a hardened client config (-F none, BatchMode, no agent/X11 forwarding, IdentitiesOnly, isolated known_hosts, 0600 identities, secret redaction). Remote steps verify archive hashes, validate a supported Node runtime (actionable error otherwise — toolchain install is provider policy), stage under lock, re-walk the installed tree against the manifest, and write a receipt the gateway validates.
  • Mandatory host-key pinning (fail closed). Adversarial review of the first revision flagged the accept-new fallback as a first-connect MITM window, and we accepted it rather than deferring: WorkerSshEndpoint.hostKey is now a required part of the provider contract, StrictHostKeyChecking is always yes, and bootstrap fails before any connection when the pin is missing. The static-ssh dev provider carries the pin in its profile; the crabbox provider fails closed with a clear error until PR 4 adds host-key exposure and dynamic key-path resolution (it could not complete bootstrap before this PR anyway).
  • Admission handshake groundwork (packages/gateway-protocol additive schema + gateway-side verifier): bundle hash, openclaw version, protocol feature set. Wiring into the worker role lands with milestone 2.
  • Lifecycle integration: the state machine's reserved bootstrapping edge now runs bootstrap; receipts persist on the environment row (additive SQLite columns with ensureColumn migration for existing state DBs); reconcile re-runs bootstrap on receipt/hash mismatch; failures tear down the lease with bounded errors.
  • Per-profile install: "bundle" | "npm" config; configuration reference updated, including honest trust-boundary caveats.

User Impact

Opt-in only; unconfigured installs unchanged. Operators with a static-ssh profile (plus its new required hostKey) get end-to-end provision→bootstrap→ready. Crabbox profiles provision but intentionally fail bootstrap closed until PR 4 — documented. Existing state databases migrate additively.

Evidence

  • Blacksmith Testbox: 7 Vitest shards green (bundle hashing determinism, bootstrap fail-closed/pinned/skip-on-match/missing-runtime paths against an injected exec runner, admission schema + verifier, service bootstrapping-edge transitions incl. failure/reconcile, store round-trip with host keys, state-DB legacy migration, both provider suites, import-boundary and lint-suppression guards).
  • Structured review chain: full-branch adversarial review found the accept-new P1 (fixed as mandatory pinning); commit-scoped review of that fix found a missing ssh_host_key additive migration (fixed with legacy-table test coverage); final review of the migration fix clean ("patch is correct", 0.88). Earlier full-branch pass had no other findings.
  • Local: oxlint over changed files, check:test-types, madge/import cycles zero, db:kysely:check, docs/config generation checks, packaged-dist runtime entry verified on a Testbox build.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime extensions: qa-lab extensions: crabbox size: XL maintainer Maintainer-authored PR labels Jul 11, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 07570cc49e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +151 to 152
if (host === null || port === null || user === null || hostKey === null || encoded === null) {
return null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Migrate legacy worker leases before requiring host keys

On upgrade from the previous worker-environment schema, leased rows can already contain ssh_host, ssh_port, ssh_user, and ssh_key_ref_json but no ssh_host_key; the additive migration only creates the new column as NULL. This branch then returns null for those endpoints, and fromRow() rejects any leased state (including ready, destroying, or destroyed) as missing its SSH endpoint, so workerEnvironmentStore.list() during gateway startup can throw before operators can reconcile or destroy the old lease. The migration/read path needs to transition or otherwise handle legacy rows without a pin instead of making the whole store unreadable.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit 03cab29 into main Jul 11, 2026
149 of 153 checks passed
@steipete
steipete deleted the claude/cloud-workers-bundle-bootstrap branch July 11, 2026 15:14
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 12, 2026
…and admission handshake (openclaw#104532)

* feat(gateway-protocol): add worker admission handshake

* feat(cloud-workers): build and bootstrap worker bundles

* feat(cloud-workers): wire bootstrap lifecycle

* fix(cloud-workers): state host-key TOFU fallback without warning-comment suppression

* test(cloud-workers): assemble host-key fixture to satisfy review secret scanner

* test(cloud-workers): assemble redaction fixture to satisfy review secret scanner

* fix(cloud-workers): require pinned SSH host keys

* fix(state): add ssh_host_key to additive worker_environments migration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation extensions: crabbox extensions: qa-lab gateway Gateway runtime maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant