Repository navigation
fix(crabbox): keep active cloud worker leases alive - #124615
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 16, 2026, 10:50 AM ET / 14:50 UTC. ClawSweeper reviewWhat this changesThis PR adds provider-owned Crabbox lease heartbeats for active cloud workers, fences them during teardown, and documents the required CLI capability. Merge readinessKeep open. The revised patch fixes the prior one-second cadence blocker, but still accepts sub-millisecond Go durations that the Node timer cannot renew before expiry. Priority: P1 Review scores
Verification
How this fits togetherGateway worker lifecycle reconciliation calls the bundled Crabbox provider to provision, inspect, and destroy cloud-worker leases. The provider’s new scheduler calls the Crabbox CLI while a lease is active and stops before teardown. flowchart LR
A[Gateway worker lifecycle] --> B[Crabbox provider]
B --> C[Provision or inspect lease]
C --> D[Heartbeat scheduler]
D --> E[Crabbox heartbeat command]
E --> F[Coordinator lease liveness]
B --> G[Destroy request]
G --> H[Stop scheduler]
H --> I[Release lease]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +214, Tests +170, Docs 0. Total +384 across 7 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep the provider-owned scheduler, reject idle timeouts below a scheduler-safe minimum, add a real-timer boundary regression, and retain the explicit warning path for older Crabbox binaries. Do we have a high-confidence way to reproduce the issue? Yes, from source: Is this the best way to solve the issue? No. A provider-owned heartbeat is the right layer, but the implementation must not accept durations it cannot renew safely and still needs direct upstream CLI-contract confirmation. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e38a645a7517. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
eb6c163 to
a132661
Compare
|
The original short-timeout P2 is addressed at head Skipping the fresh suggestion to reject sub-millisecond profile strings. That would violate the intentional no-config-contract-change boundary, and its premise is not an effective Crabbox lease state:
So the shortest effective coordinator-idle deadline produced by a positive profile is one second, and that boundary is now explicitly covered at a 500ms heartbeat. No previously accepted profile value is rejected. |
|
Live acceptance test on real Hetzner cloud workers (dev gateway built from this branch at Old Crabbox binary (0.41.6, no Dispatch succeeded normally (active in 5m05s) and the Gateway logged exactly one warning, then stopped retrying that lease: No dispatch failure, no turn failure — existing operators keep today's behavior plus an actionable warning. Heartbeat-capable binary (built from crabbox main Dispatch active in 4m00s, zero unavailability warnings, and the coordinator idle timer was refreshed automatically with no manual intervention: Ten minutes past the window that destroyed three boxes while I was reproducing #124546, and the session was fully usable. Note on scope: this run used the branch at |
|
Merged via squash.
|
* fix(crabbox): heartbeat active worker leases * fix(crabbox): clarify heartbeat upgrade guidance * fix(crabbox): bound heartbeat before idle expiry
Closes #124546
What Problem This Solves
Fixes an issue where active cloud-worker sessions could lose their Crabbox machine when the configured
idleTimeoutelapsed, even while turns, disk probes, workspace reconciliation, and SSH reconnects were still active. The live Hetzner reproduction measured a frozenlast_touchedtimestamp until the lease flippedactivetoexpiredat 15m31s for a 15m timeout.Why This Change Was Made
The bundled Crabbox plugin now owns a per-lease heartbeat for every successfully provisioned or re-adopted live worker. It matches Crabbox's own
idleTimeout / 3cadence with a 5–60 second clamp, aborts the heartbeat before provider teardown, and stops on terminal or missing leases. This remains entirely inside the provider boundary; no Gateway lifecycle or configuration surface changes.The implementation uses the new
crabbox heartbeatcontract from openclaw/crabbox#1356 (ab0bca1c54e). Binaries without that command keep dispatch and normal operation working: OpenClaw logs one bounded warning per environment, explains that the machine may still be reaped afteridleTimeout, and disables further heartbeat attempts for that lease. Other heartbeat failures warn once per failure streak and retry without failing dispatch, turns, or reconciliation.User Impact
Cloud-worker machines now stay leased for as long as their OpenClaw session remains placed, then return to normal idle expiry as soon as teardown begins. Operators on Crabbox 0.43.0 or older keep existing behavior without a hard version gate, with one actionable upgrade warning instead of a broken dispatch.
Evidence
last_touchedremained frozen whileidle_forreached 15m31s and the lease expired during an active session (Cloud worker machines are reaped mid-session: Crabbox idle timer is never refreshed #124546).origin/mainwith zero heartbeat calls.node scripts/run-vitest.mjs extensions/crabbox— 106 tests passed, including 1s, 2s, and 5s interval boundaries.node scripts/check-changed.mjs— passed on Blacksmith Testboxtbx_01m05dzdgv6yb3e7tqhssypsts(run 31951448693), including Crabbox production/test typecheck and lint.node scripts/check-changed.mjswas blocked before PR lanes by a current-main shrink-only assertion baseline mismatch (server.auth.control-ui.pairing.suite.ts: actual 6, baseline 11); no unrelated baseline was edited..claude/skills/autoreview/scripts/autoreview --mode branch --base origin/main— clean, no accepted/actionable findings.node scripts/watch-pr-ci.mjs 124615 a1326618a4bed446020f32bae5d82e27f1b7e8fd—GREENon exact-head CI run 31953222986, including production/test typecheck and lint.unexpected argument heartbeat; a locally built upstream binary accepts the new flags and reaches lease lookup.+361/-147(net+214, including the command-boundary extraction needed to bring the touched provider below 700 lines); tests+173/-3; docs net zero.AI-assisted implementation; the code, upstream CLI contract, lifecycle boundary, and proof were reviewed directly.