Skip to content

fix(cloud-workers): make Crabbox provisioning idempotent - #121019

Merged
steipete merged 3 commits into
mainfrom
steipete/crabbox-fixed-lease-id
Aug 9, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/crabbox-fixed-lease-id

Conversation

@steipete

@steipete steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where a cloud-worker provision operation could create a second Crabbox lease after the Gateway restarted or lost the successful warmup response. OpenClaw previously treated a deterministic slug as ownership, but direct AWS may suffix occupied slugs, so slug probing and adoption could not provide atomic idempotency.

This PR is deliberately separate from #120715. It consumes the fixed lease ID contract landed by openclaw/crabbox#1261.

Why This Change Was Made

OpenClaw now derives one domain-separated canonical cbx_ plus 12-lowercase-hex lease ID from the durable provision operation and passes it to exactly one fixed-ID warmup. Provision operations use the versioned provision:v2:<64hex> form; an interrupted legacy provision:<64hex> row fails visibly before allocation because it cannot be reconciled safely. Existing lifecycle rows that already store a lease ID continue normally.

The deterministic slug remains display metadata only. Provisioning no longer probes, owns, adopts, or cleans up by slug, and it no longer parses an arbitrary lease ID from warmup output. Inspect and stop target only the canonical ID. Transient or ambiguous inspect/cleanup failures leave the fixed lease available for durable Gateway replay; permanent unusable results clean up the exact ID before surfacing. The production TypeScript diff is +125/-124 lines.

User Impact

Repeating the same durable Crabbox provision operation across Gateway restarts cannot allocate a replacement lease. A committed lease whose response was lost is reconciled through the same canonical identity, while drift, terminal reuse, unsupported fixed identity, and unsafe legacy replay fail closed and visibly.

Merge blocker: Crabbox 0.41.1 is the documented minimum, but that release does not exist yet. Releasing or publishing Crabbox requires owner authorization. Do not merge this PR until a Crabbox release containing the landed fixed-ID contract is available; this PR does not claim that 0.41.1 has been released.

Evidence

  • Provider tests: 79 passed.
  • Gateway service tests: 71 passed.
  • Worker-environment store tests: 23 passed.
  • CI=1 node scripts/check-changed.mjs -- <all seven changed files> passed.
  • Gateway runtime build passed all 11 node scripts/tsdown-build.mjs invocations.
  • Codex autoreview through P1 reported no accepted/actionable findings.
  • Public model-identifier audit of the exact diff and this PR text: pass; no model-bearing changes.

Live proof on 2026-08-09 used a real managed Crabbox AWS coordinator. The first warmup committed and its response was withheld until OpenClaw timed out; the durable row remained provisioning with one canonical lease, cbx_f9b3e3fff81a. After restarting the Gateway against the same isolated state, startup replay used the same operation and adopted the same single EC2 resource. The environment reached ready, and OpenClaw destroy moved the lease to released with zero active matching inventory.

The live proof used no Tailscale and no instance profile, allowed only the explicit Gateway /32, kept OpenClaw state isolated, and completed cleanup. No EC2 instance identifier is included here.

AI-assisted: yes. The implementation and final review used Codex; the behavior, dependency boundary, focused tests, and live proof were independently inspected before publication.

@clawsweeper

clawsweeper Bot commented Aug 9, 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 9, 2026 09:46
@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 9, 2026
@clawsweeper clawsweeper Bot added 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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 9, 2026
@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 9, 2026, 2:48 PM ET / 18:48 UTC.

ClawSweeper review

What this changes

The PR replaces slug-based Crabbox lease recovery with a deterministic fixed lease ID so Gateway retries reconcile the same worker after a lost response or restart.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this maintainer-authored, protected PR open. The fixed-ID design addresses a real current-main allocation gap, but merging before a released Crabbox CLI supports the contract would break existing cloud-worker setups.

Priority: P1
Reviewed head: 1448605f3f567b28817781e3fbfffbdd32cb68f6
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The owner-boundary repair and regression coverage are strong, but the unverified released dependency contract remains a material pre-merge uncertainty.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body additionally describes a managed Crabbox lost-response and restart recovery run.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body additionally describes a managed Crabbox lost-response and restart recovery run.
Evidence reviewed 6 items Current-main gap: Current main still creates the legacy provision operation form, so it has not absorbed the fixed-ID replay behavior.
Provider ownership repair: The PR derives a domain-separated lease ID, passes it to warmup, and attests that exact ID rather than adopting a slug or parsing arbitrary output.
Original-order coverage: The service regression covers lost provider response, durable-store restart, adoption of one physical lease, and cleanup; provider tests cover fixed-ID and legacy-client failure paths.
Findings None None.
Security None None.

How this fits together

Gateway persists a cloud-worker provision operation and delegates allocation to the bundled Crabbox provider plugin. The plugin invokes the local Crabbox CLI, then Gateway records and later inspects or destroys that lease.

flowchart LR
  A[Gateway provision request] --> B[Durable worker environment]
  B --> C[Crabbox provider plugin]
  C --> D[Fixed lease ID warmup]
  D --> E[Crabbox coordinator]
  E --> F[Lease inspection and adoption]
  F --> G[Ready worker or visible failure]
Loading

Decision needed

Question Recommendation
Has a public Crabbox release containing the fixed --lease-id warmup contract been published and approved as the minimum dependency for this PR? Wait for the released dependency: Keep this PR pending until a published Crabbox release supports fixed lease IDs and its released CLI is verified against this integration.

Why: The change intentionally raises the runtime CLI requirement; only maintainers can authorize dependency publication or accept an upgrade-breaking requirement.

Before merge

  • Resolve merge risk (P1) - Until a released Crabbox CLI demonstrably supports fixed lease IDs, merging would make installations on the currently documented 0.38.1 minimum fail cloud-worker allocation before a lease is created.
  • Complete next step (P2) - The remaining blocker is maintainer-controlled dependency release inclusion, not a narrow code repair suitable for automation.
Agent review details

Security

None.

PR surface

Source +3, Tests +129, Docs +2. Total +134 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 131 128 +3
Tests 2 581 452 +129
Docs 2 6 4 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 718 584 +134

Review metrics

Metric Value Why it matters
Required CLI version 1 changed prerequisite: Crabbox 0.38.1 to 0.41.1 This dependency-floor change affects existing cloud-worker installations at upgrade time.
Production and test delta production +137/-132; tests +581/-452 The small production increase is justified by the provider identity boundary, while the test expansion covers restart and ambiguous-response lifecycle behavior.

Stored data model

Persistent data-model change detected: durable storage schema: src/gateway/worker-environments/service.test.ts, durable storage schema: src/gateway/worker-environments/service.ts, serialized state: extensions/crabbox/src/crabbox-worker-provider.test.ts, unknown-data-model-change: src/gateway/worker-environments/service.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Verify the published Crabbox contract first (recommended)
    Wait for an installable Crabbox release, prove warmup --lease-id and replay with that released CLI, then require green exact-head checks.
  2. Own the upgrade break explicitly
    Merge only with maintainer acceptance that older Crabbox clients will reject allocations until operators upgrade.

Technical review

Best possible solution:

Publish and verify the Crabbox release that supports fixed lease IDs, then confirm the released CLI’s warmup/replay behavior and exact-head CI before merging.

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

Yes, source establishes the replay path and the PR describes a managed-coordinator lost-response/restart run; this read-only review did not independently execute the released dependency contract.

Is this the best way to solve the issue?

Yes, conditionally: a fixed durable lease identity at the provider boundary is preferable to slug adoption, but it must wait for the released CLI contract.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: A lost provision response can create an extra cloud-worker lease in an active Gateway workflow.
  • merge-risk: 🚨 compatibility: The new mandatory CLI argument is unsupported by the currently documented minimum Crabbox version.
  • merge-risk: 🚨 availability: Older installed Crabbox binaries would reject allocation before a worker becomes ready.
  • 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 maintainer-authored PR is exempt from the external-contributor proof gate; its body additionally describes a managed Crabbox lost-response and restart recovery run.

Evidence

What I checked:

Likely related people:

  • steipete: Authored all three commits in this PR and the prior provider history that introduced the cloud-worker Crabbox path. (role: current provider feature owner; confidence: high; commits: 8fdf7570, 180533cd956d, dc81bd852f5e; files: extensions/crabbox/src/crabbox-worker-provider.ts, extensions/crabbox/src/crabbox-worker-profile.ts, src/gateway/worker-environments/service.ts)

Rank-up moves

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

  • Link a published Crabbox release that includes fixed lease-ID support.
  • Attach or link a redacted released-CLI warmup, restart-replay, and cleanup trace for the exact head.

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 (2 earlier review cycles)
  • reviewed 2026-08-09T09:56:17.696Z sha 180533c :: needs maintainer review before merge. :: none
  • reviewed 2026-08-09T10:49:07.562Z sha 180533c :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 9, 2026
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof

Final reviewed head: 1448605f3f567b28817781e3fbfffbdd32cb68f6.

The external dependency gate is resolved and public:

The published assets are byte-identical to the signed candidate and the protected verifier executed the arm64 and x86_64 artifacts successfully. The release owner explicitly accepts the visible fail-closed upgrade behavior for interrupted legacy unleased provision:<hash> rows; those rows require cleanup and redispatch rather than unsafe slug adoption.

The existing managed-AWS proof remains the behavior proof: the first fixed-ID warmup committed, its response was withheld until OpenClaw timed out, the isolated Gateway restarted against the same SQLite state, and replay adopted the same single lease. It reached ready, then destroy moved it to released with zero active matching inventory.

Final verification:

  • node scripts/run-vitest.mjs extensions/crabbox/src/crabbox-worker-provider.test.ts — 82/82 passed on the final current-main composition.
  • git diff --check origin/main...HEAD — passed.
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --engine codex --model gpt-5.6-sol --thinking high --stream-engine-output — TruffleHog clean and no accepted/actionable findings.
  • node scripts/watch-pr-ci.mjs 121019 1448605f3f567b28817781e3fbfffbdd32cb68f6 — GREEN, attached run https://github.com/openclaw/openclaw/actions/runs/31329576298; the current rollup has 123 completed checks, 81 success, 41 skipped, 1 neutral, and zero failures, including the selected security lanes.
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 121019 — passed with hosted_exact_or_recent_parent, bound to the exact final head.
  • The original candidate also passed CI=1 node scripts/check-changed.mjs -- docs/gateway/cloud-workers.md docs/gateway/configuration-reference.md extensions/crabbox/src/crabbox-worker-profile.ts extensions/crabbox/src/crabbox-worker-provider.test.ts extensions/crabbox/src/crabbox-worker-provider.ts src/gateway/worker-environments/service.test.ts src/gateway/worker-environments/service.ts, its Gateway runtime build completed all 11 node scripts/tsdown-build.mjs invocations, and its 191-check rollup had zero failures.
  • Public model-identifier audit: PASS. The exact diff has no model-bearing change; the only concrete review model identifier recorded here is the stable public gpt-5.6-sol ID.

The current-main sync preserved the Desktop capability in the shared warmup builder and changed no product behavior beyond composing it with the fixed-ID contract. There is no remaining dependency, live-behavior, CI/Testbox, security, or review proof gap.

@steipete
steipete merged commit 05cd389 into main Aug 9, 2026
123 checks passed
@steipete
steipete deleted the steipete/crabbox-fixed-lease-id branch August 9, 2026 18:51
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 10, 2026
…1019)

* fix(cloud-workers): make Crabbox provisioning idempotent

* fix(crabbox): preserve desktop fixed-id warmups
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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. 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