Skip to content

feat(cloud-workers): warm project seeds and automatic image refresh - #131744

Merged
steipete merged 2 commits into
mainfrom
claude/cloud-session-snapshots-4dbff9
Aug 28, 2026
Merged

steipete merged 2 commits into
mainfrom
claude/cloud-session-snapshots-4dbff9

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Creating a cloud session on a project you have used before still pays the full cold
path every time: a fresh machine, profile setup, node enrollment, a bundle push, and
a complete repository checkout. On team.openclaw.ai a new session on
openclaw/openclaw sits in "Provisioning environment…" for minutes. Warm machine
images (phase 1 of docs/plan/worker-hibernation.md) exist but silently degrade to
cold on the machine0 provider (its native checkpoints require --strategy image),
are captured once and never refreshed, and deliberately exclude the workspace — so
even a warm fork re-clones the whole repository from GitHub per session.

Why This Change Was Made

Three coordinated repairs, each at its owning boundary:

  1. Per-repository git seeds (core, node workspace sync). After a successful
    published-origin sync — while the workspace is a pristine clone, before any agent
    activity — the worker stores a copy at
    ~/.openclaw-worker/git-seeds/<gatewayNamespace>/<sha256(origin)>, the same
    machine-level cache boundary as content-addressed bundle installs (outside the
    per-lease scrub root). The next session for the same repository applies the seed
    and runs git fetch (delta) + git checkout instead of a full blobless clone.
    Seed operations are first-class protocol ops (seed: {action, key}) — the
    workspace exec transport's argv path-containment guard stays intact and no host
    paths cross the wire. Old node hosts reject the unknown field with
    INVALID_REQUEST; the gateway memoizes that per placement and degrades to
    today's clone path. Seed mtime is deliberately the store-freshness clock:
    apply never bumps it, so an actively used seed still re-stores every 6h and
    stale content cannot pin itself "fresh".
  2. Warm-image auto-management (crabbox plugin). checkpoint create passes
    --strategy image on machine0 with a 10-minute capture budget (machine0 image
    save stops the source and waits for availability even with --wait=false,
    verified against crabbox main); images older than 24h are re-captured at the
    next eligible teardown and the superseded checkpoint is deleted best-effort;
    the reservation-staleness window now covers the slowest provider capture budget
    so a live capture cannot be stolen and orphan a checkpoint; the existing
    14-day unused GC and 128-entry cap stay.
  3. Scrub gap (capture boundary). The pre-capture scrub now also removes
    ~/.openclaw-worker/workspaces — SSH-transport (remote-exec) session
    workspaces previously survived into shared provider images.

Seeds contain only origin-published repository content (taken from a fresh clone
before the turn starts, never at teardown), so no session work, agent state, or
credentials can enter a shared image through this path. settings.warmImage
remains opt-in per the accepted phase-1 review.

User Impact

A new cloud session on an already-used project skips machine boot + toolchain
install (warm image fork) and transfers only the repository delta since the image
was captured, instead of a full clone. Automatic refresh keeps the captured seed,
npm cache, and toolchain current without operator action; superseded and unused
checkpoints are cleaned up automatically. machine0 — the team.openclaw.ai
provider — now actually captures and forks warm images instead of silently cold
provisioning.

Evidence

Live A/B, isolated qa gateway child + real crabbox (built from crabbox main
58323474, which carries the fixed-ID fork + JSON contract) + Docker
local-container backend + real GitHub repo (openclaw/crabbox) + mock model:

Leg Cold session Warm session (same profile+repo)
dispatch → placement active 81.3s 23.2s (3.5x)
provisioning (machine + setup + enrollment) 69.1s 16.1s (checkpoint fork)
workspace sync origin attempt 9.2s (published-origin, full blobless clone) 4.2s (published-origin-seeded, copy + delta fetch + checkout)
reclaim (teardown) 54.2s incl. scrub + docker-commit capture 15.3s (capture skipped: image fresh)
  • Gateway log lines: worker workspace sync path selected with
    reason: "published-origin" (cold) and reason: "published-origin-seeded"
    (warm); no seed-store or seeded-sync failure warnings.
  • Fork ancestry: checkpoint chk_3c084f4a99a075d4 (kind docker-commit) created
    during the cold teardown, lastUsedAt bumped at the warm fork.
  • Crabbox primitive contract, proven live out-of-band: checkpoint create --mode native --wait=false --json → fixed-ID checkpoint fork --lease-id … --json returns the exact {checkpointId, leaseId, provider, slug, workdir}
    identity the plugin validates, and content under ~/.openclaw-worker/git-seeds/
    survives capture → fork.
  • machine0 (the team.openclaw.ai provider), CLI-level proof of the plugin's exact
    command sequence with crabbox built from main: checkpoint create --strategy image --wait=false --json captured a machine0-image in 254s — validating
    the new 10-minute machine0 budget (the previous 180s cap would have starved
    every capture); fixed-ID checkpoint fork --lease-id booted a ready VM in
    132s; ~/.openclaw-worker/git-seeds content survived capture -> fork; and
    pre-seeded ~/.openclaw-worker/workspaces content also survived, demonstrating
    the exact leak the scrub extension closes. Both proof VMs, the checkpoint, and
    the machine0 image were deleted afterwards. Honest bound: on machine0 the
    ~2-minute VM create/boot dominates machine acquisition in both modes; warm
    forks remove the setup, enrollment-install, and repository-clone legs that
    follow it (the standby-lease follow-up targets the boot floor itself).
  • Tests: node scripts/run-vitest.mjs src/worker/node-workspace-protocol.test.ts src/node-host/node-worker-workspace.test.ts src/gateway/worker-environments/node-worker-workspace-fallback.test.ts extensions/crabbox/src/crabbox-worker-warm-image.test.ts — all green (76+
    tests, incl. seed round-trip on a real git repo, containment/symlink rejection,
    prune, freshness, fallback ordering, INVALID_REQUEST memoization, refresh races,
    restore-on-failed-refresh, machine0 strategy args).
  • node scripts/check-changed.mjs green; pnpm build green (no
    INEFFECTIVE_DYNAMIC_IMPORT).
  • The seeded-sync gain scales with repository size: the proof repo is small
    (~9s cold clone); openclaw-sized repositories pay tens of seconds to minutes on
    the clone leg that the seed removes.

Production LOC: +~330 (new capability: seed store + protocol op + plugin
auto-refresh); tests +~620.

Follow-ups (named, not in this PR): seeding for the SSH/rsync sync path
(remote-exec parity); relocating the node-path bundle cache outside the per-lease
state dir so warm forks also skip the bundle push + prewarm; standby forked leases
(machine0 supports pause/resume) for single-digit-seconds session starts;
per-phase provisioning timing telemetry.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 28, 2026 11:09
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: crabbox size: XL maintainer Maintainer-authored PR labels Aug 28, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 7:15 AM ET / 11:15 UTC.

ClawSweeper review

What this changes

The branch adds per-repository Git seed reuse for node-worker workspace sync, refreshes stale Crabbox warm images, and scrubs SSH workspaces before image capture.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open. This maintainer-authored PR adds a coherent, tested cloud-worker performance and isolation feature; no introduced correctness defect was established. Its machine0 behavior relies on the external Crabbox CLI contract, which could not be independently inspected from the unavailable sibling checkout, so that contract should be confirmed before landing.

Priority: P2
Reviewed head: b3012e08517effe4811f50791471d8602ffd8b53
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has strong owner-boundary coverage and reported live behavior, but independent verification of its external Crabbox machine0 contract remains unavailable.
Proof confidence 🌊 off-meta tidepool Not applicable: This is maintainer-authored work, so the external-contributor proof gate does not apply; the PR body nevertheless documents a real Crabbox-backed A/B run.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is maintainer-authored work, so the external-contributor proof gate does not apply; the PR body nevertheless documents a real Crabbox-backed A/B run.
Evidence reviewed 6 items Seed owner boundary: The Gateway only selects the seed path after verifying a clean repository root and credential-free HTTP(S) origin; it applies the seed, verifies its origin, fetches, checks out the requested commit, validates the manifest, and falls back to clone on any seed failure.
Node-host isolation: Seed requests are protocol-validated, keyed by a SHA-256 digest, constrained to the node-owned cache root, serialized per seed, and an apply removes the session workspace before copying the seed.
Warm-image lifecycle: The plugin retains existing warm-image cleanup, uses image strategy only for machine0, preserves a prior image if refresh fails, and scrubs SSH transport workspaces while retaining the intentional machine cache roots.
Findings None None.
Security None None.

How this fits together

Cloud-worker sessions provision a remote machine, enroll it with the Gateway, then synchronize a project workspace. This change lets eligible clean Git repositories reuse a machine-local seed while the Crabbox provider refreshes reusable worker images and removes session-owned files before capture.

flowchart LR
  A[Clean local repository] --> B[Gateway workspace sync]
  B --> C[Node worker seed cache]
  C --> D[Fetch delta and checkout]
  D --> E[Remote worker workspace]
  E --> F[Crabbox worker teardown]
  F --> G[Scrub session workspaces]
  G --> H[Refresh reusable image]
Loading

Decision needed

Question Recommendation
Is the supplied machine0 Crabbox live evidence sufficient to accept the new ten-minute image-capture contract, or should a redacted reproducible CLI trace/upstream source reference be added before merge? Add contract evidence: Attach or link a redacted machine0 checkpoint-create/fork trace or exact upstream source reference confirming --strategy image and the capture wait behavior.

Why: The changed behavior depends on Crabbox CLI semantics not available in the required sibling checkout, so source review alone cannot confirm the external command contract.

Before merge

  • Resolve merge risk (P1) - On machine0, an opted-in worker teardown may now wait up to ten minutes for image capture; the exact Crabbox --strategy image and availability semantics need maintainer-visible confirmation because the upstream checkout was unavailable for direct inspection.
  • Complete next step (P2) - Confirm the externally owned machine0 CLI contract before normal maintainer merge review; no mechanical repair is indicated.
Agent review details

Security

None.

PR surface

Source +336, Tests +622, Docs +20. Total +978 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 7 440 104 +336
Tests 4 659 37 +622
Docs 3 27 7 +20
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 1126 148 +978

Review metrics

Metric Value Why it matters
Production versus test delta production +336 net, tests +621 net, docs +20 net The production growth implements a new cache/protocol capability and plugin lifecycle behavior; the larger focused test delta covers its safety and fallback boundaries.

Stored data model

Persistent data-model change detected: durable storage schema: src/gateway/worker-environments/node-worker-tunnel.ts, durable storage schema: src/gateway/worker-environments/node-worker-workspace-fallback.ts, durable storage schema: src/gateway/worker-environments/tunnel-contract.ts, durable storage schema: src/worker/node-workspace-protocol.ts, unknown-data-model-change: src/gateway/worker-environments/node-worker-workspace-fallback.ts, unknown-data-model-change: src/worker/node-workspace-protocol.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Confirm machine0 capture contract (recommended)
    Add a redacted reproducible Crabbox trace or upstream reference showing that image capture can legitimately require the ten-minute budget before landing.
  2. Accept the provider timing risk
    Maintain the ten-minute opt-in teardown budget based on the existing live evidence and accept that provider behavior is externally owned.

Technical review

Best possible solution:

Retain the single validated seed path and the plugin-owned image lifecycle, with a redacted Crabbox contract trace or upstream-source confirmation for the machine0 command before merge.

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

Not applicable as an issue reproduction: this PR adds a new acceleration path, and its body reports a real cold-versus-warm worker run plus focused regression coverage.

Is this the best way to solve the issue?

Yes, subject to external-contract confirmation: seed state is owned by node workspace sync and provider image behavior remains in the Crabbox plugin, avoiding a competing core policy path.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is an opt-in cloud-worker improvement with bounded impact rather than an emergency regression.
  • add merge-risk: 🚨 availability: For enabled machine0 profiles, teardown can wait up to ten minutes on external image-capture availability.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is maintainer-authored work, so the external-contributor proof gate does not apply; the PR body nevertheless documents a real Crabbox-backed A/B run.

Label justifications:

  • P2: This is an opt-in cloud-worker improvement with bounded impact rather than an emergency regression.
  • merge-risk: 🚨 availability: For enabled machine0 profiles, teardown can wait up to ten minutes on external image-capture availability.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is maintainer-authored work, so the external-contributor proof gate does not apply; the PR body nevertheless documents a real Crabbox-backed A/B run.

Evidence

What I checked:

Likely related people:

  • steipete: Authored both branch commits implementing the cloud-worker seed and warm-image lifecycle. (role: current feature owner; confidence: high; commits: 308215f9d170, b3012e08517e; files: src/gateway/worker-environments/node-worker-workspace-fallback.ts, src/node-host/node-worker-workspace-seeds.ts, extensions/crabbox/src/crabbox-worker-warm-image.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add a redacted reproducible machine0 capture/fork trace or exact upstream source reference for the --strategy image contract.

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

Copy link
Copy Markdown
Contributor Author

machine0 Crabbox contract evidence (ClawSweeper decision item)

Upstream source (openclaw/crabbox @ 58323474, current main — inspected directly via git show origin/main:... from the sibling checkout's fetched refs):

  • internal/providers/machine0/images.go NativeCheckpointCapability: the disk-snapshot strategy is rejected with CreateUnsupported = "Machine0 reusable images use --strategy image; suspend is available separately through crabbox pause" — this is why the plugin now passes --strategy image for machine0 (and why every machine0 capture silently degraded to cold before this PR).
  • internal/providers/machine0/images.go createNativeCheckpoint: for a RUNNING source it calls prepareNativeImageSource → api.Stop → waitForStopped → api.SaveImage → waitForImageVersion(..., snapshotTimeout) — i.e. the source is stopped and the call waits for image-version availability even with --wait=false, which is the basis for the 10-minute machine0 capture budget (WARM_IMAGE_MACHINE0_CAPTURE_TIMEOUT_MS).
  • Fixed-ID forks: internal/cli/machine0_fixed_create_intent.go (landed in feat: replay-safe fixed checkpoint forks and JSON output crabbox#1526 together with checkpoint fork --lease-id and --json).

Redacted live CLI trace (crabbox built from that exact main SHA; all resources destroyed afterwards):

$ crabbox warmup --provider machine0 --machine0-key <managed-key> --lease-id cbx_ac0feed00003 --slug m0-proof --keep
ready ssh=ubuntu@<vm1-ip>:22 network=public workroot=/home/ubuntu/crabbox
warmup complete total=2m7.835s

$ crabbox checkpoint create --provider machine0 --id cbx_ac0feed00003 --mode native --strategy image --wait=false --json
{"id":"chk_917c2e7de20e835e","kind":"machine0-image","provider":"machine0","leaseId":"cbx_ac0feed00003",
 "native":{"kind":"machine0-image","state":"ACTIVE","strategy":"image","imageId":"<image-id>@v1", ...}}
CREATE_SECONDS=254   # returns only once the image version is ACTIVE, despite --wait=false

$ crabbox checkpoint fork chk_917c2e7de20e835e --provider machine0 --machine0-key <managed-key> --lease-id cbx_ac0feed00004 --slug m0-fork --json
{"checkpointId":"chk_917c2e7de20e835e","leaseId":"cbx_ac0feed00004","slug":"m0-fork","provider":"machine0",
 "workdir":"/home/ubuntu/crabbox/cbx_ac0feed00004/repo"}
FORK_SECONDS=132

$ crabbox run --id cbx_ac0feed00004 --no-sync --shell -- 'cat ~/.openclaw-worker/git-seeds/proofns/deadbeef/marker.txt'
m0-seed-marker      # machine-cache content survives capture -> fork

# cleanup
released lease=cbx_ac0feed00004 action=destroy
released lease=cbx_ac0feed00003 action=destroy
checkpoint deleted id=chk_917c2e7de20e835e   # deletes the machine0 image as well

On the teardown-latency note: the capture wait happens inside the reclaim path after the session has already left the machine, capture failure never blocks teardown (warn + cold-only), and the 10-minute budget applies only to provider === "machine0"; all other backends keep the live-measured 180s budget.

@steipete
steipete merged commit 117078f into main Aug 28, 2026
317 of 318 checks passed
@steipete
steipete deleted the claude/cloud-session-snapshots-4dbff9 branch August 28, 2026 15:19
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL 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