Repository navigation
feat(crabbox): add a lease-backed sandbox backend for tool-call isolation - #144454
Conversation
…tion Register `agents.defaults.sandbox.backend: "crabbox"` from the existing Crabbox plugin when `plugins.entries.crabbox.config.sandbox` is present. The Gateway, agent loop, channels, and model credentials stay on the host; exec, file tools, and media reads run on a box that Crabbox leases for the sandbox scope under a fixed, scope-derived lease ID, so restarts and sibling sessions adopt the same lease instead of allocating another. The endpoint comes from `crabbox ssh --show-secret`; token-based providers such as Daytona rotate the SSH user, so the inner SSH backend handle is rebuilt once the endpoint is older than ten minutes. Everything below the endpoint reuses the built-in SSH backend and the shared remote-shell filesystem bridge. Recreate and prune stop the lease. Crabbox remains the only provider owner: no per-provider plugin, no new dependency. Not supported: the sandboxed browser and sandbox.docker.binds.
…keys Fixed Crabbox lease IDs are single-use: a stopped lease leaves a terminal tombstone, so deriving the ID from the sandbox scope broke `openclaw sandbox recreate`. Each runtime generation now mints its own ID and the sandbox registry carries it, so restarts adopt the live lease and recreate provisions under a fresh one. Crabbox connects with its own SSH client, so its per-lease known_hosts may not hold the OpenSSH entry yet. Record the host key on first contact and run the SSH backend with strict checking against that file instead of disabling verification, so a later impostor cannot receive the token carried in the SSH user.
Crabbox reports a stopped fixed lease as "has no active create attempt; it cannot allocate a replacement". Recognize that wording so recreate mints a fresh lease instead of failing; unknown inspection outcomes still propagate.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 11, 2026, 6:04 PM ET / 22:04 UTC (Revision 7). ClawSweeper reviewWhat this changesAdds Crabbox-hosted tool sandboxes with durable lease recovery and shares remote workspace initialization, execution, and file operations with the SSH backend. Merge readiness⛔ Blocked before merge - 4 items remain This remains useful, maintainer-sponsored work absent from current main. The earlier lifecycle and ownership findings are resolved, and the required Crabbox dependency is now merged; no new blocking code defect was established. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s sandbox layer sends agent commands and file operations to isolated environments while the Gateway and agent loop remain local. The registry owns runtime generations; the Crabbox plugin delegates provider access and repository authorization to the Crabbox CLI. flowchart TD
A[Agent commands and file operations] --> B[Sandbox registry]
B --> C[Reserve or reuse runtime]
C --> D[Shared remote workspace layer]
D --> E[Crabbox repository authorization]
E --> F[Daytona sandbox]
F --> G[Command output and file results]
B --> H[Recreate and recover cleanup]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +994, Tests +1635, Docs +176, Generated 0, Other -2. Total +2803 across 47 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the shared registry and remote-shell owners, with verified published-version upgrade and disable/reconcile-before-rollback behavior that preserves existing runtimes and uncertain leases. Do we have a high-confidence way to reproduce the issue? Not applicable to the feature request. Earlier lifecycle defects have targeted regression coverage and reported Daytona verification; this read-only review did not execute them. Is this the best way to solve the issue? Yes: the existing plugin, registry, and shared remote-shell boundaries are appropriate, and the recorded maintainer rewrite establishes the intended SSH tradeoff. Upgrade and rollback validation remains necessary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f3f3d6b1ed68. LabelsLabel changes:
Label 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 (6 earlier review cycles)
|
|
Reviewed head
The retained SSH handle also bypasses renewed repository admission during its cache window. Inspection reports native readiness, not current repository authorization. Preserve Crabbox's admission at remote I/O; the existing positive live proof does not establish this boundary. No live revocation or cross-repository probe was performed for this review. Dependency evidence was inspected at the merged Crabbox change #1700, commit The exact-head Accepted storage decisionExtend the existing sandbox registry owner to reserve one runtime generation for a backend/scope before provider provisioning, retain that ID through uncertain failures and restart, and publish readiness only for the still-current generation. Crabbox remains the sole provider/claim owner; the plugin consumes the generic registry lifecycle rather than adding a separate state store. Use the existing SQLite table and synchronous transaction owner; do not hold a transaction across provider calls. Coordinate create, retry, recreate, and prune so deletion cannot race a pending generation into publication. The retained reservation is canonical recovery state, not a cache. Keep it visible to recovery and cleanup until the matching provider release is confirmed. The maintainer accepted this design on 2026-09-11 and explicitly directed implementation, improvement, live testing, and landing in the review task. This records acceptance for the material persistence/publication change under the storage review checkpoint. A process-local map would not survive a Gateway restart. Deterministic single-use IDs alone cannot handle repeated recreation without retaining generation state or walking accumulated tombstones. The registry already owns runtime identity and cleanup, making it the appropriate place for this invariant. Keep the change bounded to reservation/recovery for this backend and its generic host contract, with no new configuration, dedicated database, retention policy, or data migration. Preserve existing registered runtimes during adoption. Before rollback, disable the new backend and reconcile its recorded pending leases; do not erase uncertain recovery records. Validation must cover concurrent first use, failure after provider creation followed by restart, resume with remote edits preserved, recreation/pruning during provisioning, and successful use with a shortened credential lifetime. Normal review and exact-head CI remain required before merge. Maintainer rewrite status — 2026-09-11The findings above are resolved in pushed head Crabbox now owns every remote command and cleanup admission through All 190 selected tests pass, together with the chosen types, lint, SDK/import-boundary, documentation and dead-code checks. The complete candidate passed fresh independent P0–P2 review. The final registered-backend Daytona run passed in 143.256 seconds, including pending recovery, shared reuse from another workspace, real exec/file operations, reopen, recreate, prepared execution denied after repository transfer, old-owner cleanup denial, current-owner execution/release, and terminal registry cleanup. All test leases were released. Earlier proof also exercised access beyond the configured SSH token lifetime. Seven exact-product filesystem edge cases passed on non-root macOS (UID 501) and real Daytona Linux (UID 1001). The upstream API-key cleanup/native-expiry repair is merged in openclaw/crabbox#2111 ( OpenClaw exact-head CI and the native maintainer landing gates remain pending. This update records completed implementation/review/live proof, not a merge or a Crabbox release. |
Reserve runtime generations before provisioning, preserve one SSH workspace owner across credential refreshes, and retain runtime authority through deferred execution and upload admission. Keep failed provisioning and cleanup recoverable under the original lease identity and workspace.
Preserve current main changes and regenerate configuration documentation metadata from the combined schema. Sandbox lifecycle, SSH, and exec behavior remains as reviewed; focused integration checks and real Daytona proof pass.
Route Crabbox execution and cleanup through its current repository claim instead of retained SSH credentials. Replay shared reservations from their original provider workspace while preserving each caller's workspace context. Share remote workspace, skills, filesystem, and execution staging between static SSH and provider command transports. Publish initial workspaces with native no-replace rename and clean read-only staging directories safely. Validation: 190 focused tests; selected types, lint, SDK and docs checks; registered Daytona live flow including ownership transfer and cleanup; non-root Linux/macOS bootstrap edge proof; independent P2 review clean. Requires the Crabbox command-ownership contract in openclaw/crabbox#2119, following the cleanup and TTL repair in openclaw/crabbox#2111.
|
Maintainer assessment for head I am accepting the documented compatibility tradeoffs for this requested landing:
The completed proof is proportional to this opt-in backend and its shared owner changes: 190 focused tests, 95 tests for the final cleanup-owner correction, selected type/lint/SDK/docs/dead-code gates, independent P0–P2 reviews, exact-head CI, and the final registered-backend Daytona run (136.474 seconds). Proceeding through the repository's native prepare/merge gates under the requested maintainer scope. |
|
Merged via squash.
|
…tion (openclaw#144454) * feat(crabbox): add a lease-backed sandbox backend for tool-call isolation Register `agents.defaults.sandbox.backend: "crabbox"` from the existing Crabbox plugin when `plugins.entries.crabbox.config.sandbox` is present. The Gateway, agent loop, channels, and model credentials stay on the host; exec, file tools, and media reads run on a box that Crabbox leases for the sandbox scope under a fixed, scope-derived lease ID, so restarts and sibling sessions adopt the same lease instead of allocating another. The endpoint comes from `crabbox ssh --show-secret`; token-based providers such as Daytona rotate the SSH user, so the inner SSH backend handle is rebuilt once the endpoint is older than ten minutes. Everything below the endpoint reuses the built-in SSH backend and the shared remote-shell filesystem bridge. Recreate and prune stop the lease. Crabbox remains the only provider owner: no per-provider plugin, no new dependency. Not supported: the sandboxed browser and sandbox.docker.binds. * fix(crabbox): rotate sandbox lease identity and verify recorded host keys Fixed Crabbox lease IDs are single-use: a stopped lease leaves a terminal tombstone, so deriving the ID from the sandbox scope broke `openclaw sandbox recreate`. Each runtime generation now mints its own ID and the sandbox registry carries it, so restarts adopt the live lease and recreate provisions under a fresh one. Crabbox connects with its own SSH client, so its per-lease known_hosts may not hold the OpenSSH entry yet. Record the host key on first contact and run the SSH backend with strict checking against that file instead of disabling verification, so a later impostor cannot receive the token carried in the SSH user. * fix(crabbox): treat terminal fixed leases as replaceable during adoption Crabbox reports a stopped fixed lease as "has no active create attempt; it cannot allocate a replacement". Recognize that wording so recreate mints a fresh lease instead of failing; unknown inspection outcomes still propagate. * fix(crabbox): make sandbox lease lifecycle durable Reserve runtime generations before provisioning, preserve one SSH workspace owner across credential refreshes, and retain runtime authority through deferred execution and upload admission. Keep failed provisioning and cleanup recoverable under the original lease identity and workspace. * fix(ci): clean sandbox exports and update merge fixtures * fix(sandbox): retain provider ownership through remote operations Route Crabbox execution and cleanup through its current repository claim instead of retained SSH credentials. Replay shared reservations from their original provider workspace while preserving each caller's workspace context. Share remote workspace, skills, filesystem, and execution staging between static SSH and provider command transports. Publish initial workspaces with native no-replace rename and clean read-only staging directories safely. Validation: 190 focused tests; selected types, lint, SDK and docs checks; registered Daytona live flow including ownership transfer and cleanup; non-root Linux/macOS bootstrap edge proof; independent P2 review clean. Requires the Crabbox command-ownership contract in openclaw/crabbox#2119, following the cleanup and TTL repair in openclaw/crabbox#2111. * fix(sandbox): retain ownership of prepared execution cleanup
What Problem This Solves
OpenClaw users can select Crabbox for cloud-hosted tool-call sandboxes. A sandbox must keep the same remote workspace across concurrent creation and session reuse, survive interrupted provisioning, and remain manageable after a restart. Provider execution and cleanup must also respect repository ownership when an operator transfers a lease.
Why This Change Was Made
The Crabbox plugin implements the existing sandbox backend contract. Core reserves a durable runtime ID before provider allocation, serializes lifecycle changes, and retains uncertain or failed operations for recovery. Shared reservations always replay from the original provider workspace while each caller keeps its own workspace context.
Static SSH and Crabbox now share one remote-shell workspace, skills, execution-staging, and filesystem implementation. Initial uploads publish the complete primary/agent workspace atomically; partial transfers cannot be mistaken for completed workspaces, and concurrent publishers preserve the winning workspace and its later edits. Crabbox supplies a local
execcommand for each operation, retaining provider claim authority through execution and transport cleanup. OpenClaw never caches or executes raw provider SSH credentials. Management uses repository-scoped stop. Core independently fences retired runtime generations through actual process admission.User Impact
Set
agents.defaults.sandbox.backendtocrabboxand enable/configure the bundled Crabbox plugin. Remote edits survive lease reuse and registry/plugin reopen; recreate releases the old generation and creates a new one. Unsupported command/provider capabilities fail before allocation.The initial supported route is direct Daytona. This requires a Crabbox build containing claim-owned
exec, offlineexec --check, andstop --current-repo; the released 0.56.0 binary does not provide the complete contract. The prerequisite cleanup/TTL fix landed in openclaw/crabbox#2111. The command-ownership follow-up is merged in openclaw/crabbox#2119 (5c3aec438fa8368263b3465d0376003ff00402b4).Evidence
The final bootstrap uses the existing native no-replace rename helper, preserving even an emptied winner. Its exact-stage cleanup restores owner directory permissions without following symlinks. The seven-case product Python proof passed on real non-root Daytona Linux (UID 1001) and macOS (UID 501), covering empty winners, readonly cleanup, symlink preservation, unsupported primitives, and uploaded modes. New SSH workspaces require native atomic directory publication; existing workspaces remain adopted without reseeding.
Live coverage is Daytona on Linux from macOS. The test reopens the real registry and plugin lifecycle; it does not claim a full Gateway process restart. This PR does not publish Crabbox or change a live operator Gateway.