Skip to content

Add unified resource backends and local sandbox operations - #34

Merged
scsmithr merged 6 commits into
mainfrom
feat/local-sandbox-shell
Nov 23, 2026
Merged

scsmithr merged 6 commits into
mainfrom
feat/local-sandbox-shell

Conversation

@scsmithr

@scsmithr scsmithr commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Add local sandboxes to the unified adapt CLI through a resource-level Backend trait. Every sandbox command, execution and file command selects a backend; volumes, images and endpoints also have backend entry points so their local implementations can be added independently. Cloud remains the default. Global --local and --cloud flags select the target, including when placed after a subcommand.

The local backend supports persistent sandbox create/list/get/stop/delete/wait, attached execution, and temporary shells. For example, adapt --local sandbox create --wait --env EDITOR=vim creates a VM that later adapt --local exec ID -- COMMAND invocations can use. Creation environment settings persist privately and execution flags override them. Environment names, counts, and sizes are validated before runtime startup and again after merging execution overrides. Completed sessions are released after stream detachment, with bounded retries for detach races; running commands survive a client disconnect. sandbox sh composes the same create/wait/execute/cleanup operations and deletes the VM on completion or handled interruption.

Unsupported capabilities return explicit errors before loading cloud credentials or launching a runtime, with no cloud fallback. Local start/restart, usage, detached or retained execution management, files, and other resource families remain unsupported. Local commands currently require full sandbox UUIDs; inventory is unpaginated with optional ID-prefix filtering. JSON exposes common ID/status/resource fields alongside Goblin diagnostics.

Local management uses the private Unix HTTP/WebSocket transport and discovery protocol from the merged https://github.com/adapt/goblin/pull/154. Discovery validates the socket path, ownership, permissions, and manager UUID, uses a separate token, and serializes concurrent bootstrap. Local configuration never selects a target implicitly. Existing auth logout --local behavior is preserved.

A compatible Goblin bundle is still supplied through ADAPT_LOCAL_RUNTIME or --runtime-dir. Automatic runtime installation, daemon-enforced expiry, mounts, and moves are follow-ups. An uncatchable CLI kill can leave a VM behind; local list/delete commands now provide cleanup directly through Adapt. Local output is not Platform's retained, redacted log service.

Validation:

  • cargo fmt --all -- --check
  • cargo clippy --locked --all-targets -- -D warnings
  • cargo test --locked: 146 tests, covering cloud behavior, all local capability errors, global target conflicts, persistent lifecycle/environment limits, metadata permissions, discovery security, terminal cleanup, and 70 sequential executions with detach-race retries and preserved exit codes.
  • python3 -m unittest discover -s scripts -p '*_test.py'
  • Real Apple Silicon VMs: persistent create/list/get/exec/environment overrides/stop/delete, invalid environment rejection before manager startup, 70 sequential executions with no retained sessions, Ubuntu boot, remote exit codes, 512 KiB stdin, PTY input/resize, SIGINT during provisioning, daemon reuse, and empty inventory after cleanup. Native Linux KVM validation was not run locally.

@the-adaptile the-adaptile Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confidence Score: 4/5

Summary

Adds unified backends and persistent local sandboxes; all three prior findings are resolved. Local validation passed: 146 Rust tests, nine Python tests, formatting, strict Clippy, and release build; native VM behavior remains independently unverified.

Deployed verification not applicable: adapt/platform-cli is outside the preview pilot and has no PR preview deployment workflow. No webhook was sent.

Important Files Changed

File Changes
src/backend/local.rs Validates environment defaults and overrides; releases completed sessions with bounded retries while preserving outcomes.
src/backend/mod.rs Defines resource operations and explicit unsupported-capability defaults without cloud fallback.
src/backend/cloud.rs Preserves Platform operations, execution management, and confirmed temporary-sandbox cleanup.
src/commands.rs Routes local resources before cloud configuration and shares lifecycle workflows.
src/cli.rs Defines global backend selection while preserving credential-only local logout.
src/local_runtime.rs Validates private Unix-socket discovery and serializes manager bootstrap.
src/shell.rs Composes creation, readiness, execution, interruption, and cleanup across backends.
src/stream.rs Preserves responsive terminal escape with bounded buffering and backpressured piped input.
tests/local_shell/sessions.rs Covers 70 sequential executions, detach races, timeouts, failures, exit preservation, and merged environment rejection.
tests/backend/mod.rs Verifies unsupported operations and invalid environments fail before runtime startup or cloud credential loading.
tests/local_shell/backend.rs Checks persistent lifecycle, environment overrides, metadata permissions, inventory, and waits.
README.md Restores the local examples’ closing code fence.
docs/cli-reference.md Documents environment limits, completed-session cleanup, and retained sessions after disconnecting from running commands.

Run info

Field ID
Agent 0d6ccd7e-b62f-4075-a561-199d1a7b1bf0
Automation 1fbe37ac-ca54-4b0b-9fea-80055702da90
Run c076d559-9150-42e9-bfed-3d2bb9447680

Reviewed: 9f5e86c-e0e435a · ↻ Re-run review

Comment thread src/local_runtime.rs Resolved
Comment thread src/stream.rs Resolved
@scsmithr

Copy link
Copy Markdown
Contributor Author

@the-adaptile please review this PR again at the latest head, 353fe64.

Both review findings have been addressed: local HTTP/WebSocket connections now use a validated private Unix socket, and Ctrl-] remains responsive at zero stdin credit with bounded buffering. The bootstrap fixture and Windows lint fixes are included, and all five build/test CI jobs are green. Please publish an updated formal review and check result for the current head.

@scsmithr scsmithr changed the title Add local sandbox shells through a managed Goblin runtime Add unified resource backends and local sandbox operations Nov 23, 2026
@scsmithr

Copy link
Copy Markdown
Contributor Author

@the-adaptile please review again at d98645c.

The shell-only backend enum is now a Backend trait covering every sandbox operation, execution/files, and entry points for images, volumes and endpoints. Global target selection routes commands once; unsupported local operations fail before cloud configuration or Goblin startup. Persistent local create/list/get/exec/stop/delete/wait share the same implementation used by sandbox sh, including private environment metadata across CLI processes. Goblin PR #154 is merged.

Please focus on backend dispatch, explicit unsupported capabilities, lifecycle/cleanup semantics, and isolation of local configuration and credentials. All 136 Rust tests, nine packaging tests, formatting and strict lint checks passed locally. Real Apple Silicon validation passed persistent lifecycle/environment overrides, shell execution, 512 KiB stdin, PTY resize, interruption cleanup and empty final inventory.

Comment thread src/backend/local.rs Resolved
Comment thread src/backend/local.rs Resolved
Comment thread README.md Resolved
@scsmithr

Copy link
Copy Markdown
Contributor Author

@the-adaptile please review again at e0e435a. All three findings are addressed: completed session cleanup with bounded detach-race retries, environment validation before runtime startup and after merging defaults, and the README fence. All 146 Rust tests, strict Clippy, formatting, and native Apple Silicon checks passed, including 70 sequential executions with no retained sessions.

@scsmithr
scsmithr merged commit fab99b3 into main Nov 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant