Skip to content

feat(cloud-workers): authenticated worker protocol with closed ingress and minted credentials - #104688

Merged
steipete merged 7 commits into
mainfrom
claude/cloud-workers-worker-role
Jul 11, 2026
Merged

steipete merged 7 commits into
mainfrom
claude/cloud-workers-worker-role

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Part of #104294 (cloud workers, milestone 2, PR 5). Builds on the merged milestone-1 stack (#104401, #104465, #104532, #104553). Design: docs/plan/cloud-workers.md ("Worker protocol (dedicated; not the node protocol)").

What Problem This Solves

Milestone 1 can provision, bootstrap, and tunnel to a worker box, but there is no authenticated way for that box to talk to the gateway. The design deliberately does NOT reuse the node protocol: a connected node can emit node.event: agent.request and start a gateway-side run, so node-role ingress is not a security boundary for untrusted workers. This PR adds a dedicated, authenticated worker connection with a closed dispatch surface and hashed-at-rest minted credentials — the identity layer the milestone-2 loop (transcript ingestion, inference proxy) will plug into.

Why This Change Was Made

  • Closed worker ingress (src/gateway/server/ws-connection/worker-connection.ts): a dedicated loopback worker WS path with a closed dispatcher. Worker connections can invoke only worker-protocol methods (admission verification + heartbeat/status); anything else is rejected fail-closed with a bounded reason and never reaches node/operator/plugin handlers. Enforced at the connection-dispatch boundary, not scattered checks.
  • Minted credentials (worker-environments credential primitives): high-entropy, stored only as hashes (never plaintext at rest) in a dedicated credential table with binding/lifecycle fields kept separate from environment state. Bound to environment id, worker bundle hash, allowed session (SQL NULL until attach), RPC-set version, owner epoch, and expiry. owner_epoch added via additive ensureColumn migration. Plaintext exists only in an in-memory delivery seam (takeMintedCredential) the milestone-2 loop consumes.
  • Admission wiring: on connect, the minted credential plus the PR-3 admission handshake (exact bundle hash, protocol features) are validated before the connection is admitted, including current owner-epoch — a stale (pre-replacement) worker cannot admit. One live socket per environment; a newly validated worker fences and replaces the prior connection. Authenticated frames participate in gateway suspension admission.
  • Session attach rotates the credential and advances the owner epoch. Provider-loss and proven-destruction tunnel cleanup remain durably retryable while credentials are immediately fenced.
  • Additive worker-protocol schema (connect/admission request+response, heartbeat, closed error/close-reason unions) with independent feature negotiation; no protocol version bump.

User Impact

Opt-in only; no worker loop, inference, or transcript RPCs yet (PRs 6-8). Establishes the authenticated connection identity and closed surface those build on. No config, changelog, or version-bump changes.

Evidence

  • Tests green (credential mint/validate incl. expiry/hash-at-rest/wrong-environment/bundle/epoch rejection; closed-allowlist rejection of node/operator methods; each admission rejection reason; heartbeat; suspension admission; connection fencing). Codex pre-commit: 639 changed-suite tests + lint-suppressions guard, oxlint, check-test-types, tsgo, madge zero, db:kysely:check, protocol/docs checks.
  • Testbox validation was blocked by a Blacksmith hydration outage (multiple fresh leases died at the checkout step; pre-warmed leases were direct-blacksmith and not Crabbox-syncable). Per the repo outage protocol, the worker-protocol/state/gateway suite was run through the local scripts/run-vitest.mjs fallback and passed; these are gateway/state/protocol tests with no jsdom dependency, so local execution is representative. Hosted PR CI provides the authoritative Testbox-parity run.
  • Codex fresh autoreview on the exact branch content: clean, "patch is correct" (0.91). The standalone autoreview helper could not re-bundle the diff because origin/main currently carries a fake secret-shaped test literal (service.test.ts, a sk-...-style fixture added by feat(cloud-workers): pinned SSH tunnel runtime and provider-owned key resolution #104553) that this PR cleans up; the helper's secret scanner refuses any diff that deletes a secret-shaped line. Tracked separately; resolved by this PR's own fixture cleanup.

@steipete
steipete requested a review from a team as a code owner July 11, 2026 20:28
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime size: XL maintainer Maintainer-authored PR labels Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 81557b2c0f9a01821c0470a3ac308e938b6f90ec, but the PR head is now a5649951f399c93b8f8660cea79e370ec5a8f744. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

@steipete
steipete merged commit b80ab61 into main Jul 11, 2026
100 checks passed
@steipete
steipete deleted the claude/cloud-workers-worker-role branch July 11, 2026 20:45
@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
…s and minted credentials (openclaw#104688)

* feat(cloud-workers): add authenticated worker protocol

* feat(cloud-workers): add worker credential primitives

* docs(gateway): document closed worker protocol

* test(cloud-workers): keep protocol fixtures lean

* fix(cloud-workers): bound live worker connections

* fix(cloud-workers): close admission and cleanup gaps

* docs: regenerate docs map for worker protocol page
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 gateway Gateway runtime maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant