Summary
Add smolvm as an optional sandbox backend for command execution, providing hypervisor-level isolation as an alternative to the existing macOS seatbelt approach.
Motivation
The current sandbox implementation uses macOS seatbelt (syscall-level filtering within the same kernel). While effective and low-overhead, it:
- Only works on macOS
- Can potentially be circumvented by kernel-level exploits
- Does not provide a reproducible execution environment
smolvm offers hardware-isolated microVMs with:
- Sub-second cold boot (<200ms) — acceptable for tool call latency
- Cross-platform: macOS (Hypervisor.framework) + Linux (KVM)
- Built-in network control: opt-in networking with host allowlists
- Volume mounts: expose project directories into the guest
- OCI images: pre-bake reproducible dev environments
- Rust-native: same language as code-assistant
Proposed Design
New executor: SmolVmCommandExecutor
Implements the existing CommandExecutor trait in crates/command_executor/:
pub struct SmolVmCommandExecutor {
machine_name: String,
policy: SandboxPolicy,
workspace_mount: PathBuf,
}
Lifecycle
- Session start: Create/start a persistent VM per session
smolvm machine create --name <session-id> -v /project:/workspace [--net] [--allow-host ...]
- Tool calls: Execute commands inside the running VM
smolvm machine exec --name <session-id> -- sh -c "<command>"
- Pipe stdout/stderr to
StreamingCallback
- Session end: Stop (or optionally destroy) the VM
smolvm machine stop --name <session-id>
Policy mapping
| SandboxPolicy |
smolvm behavior |
DangerFullAccess |
bypass — use DefaultCommandExecutor |
ReadOnly |
VM with read-only volume mount, no network |
WorkspaceWrite |
VM with read-write volume on project root, network per policy |
Configuration
New sandbox mode selectable via CLI flag or session config:
--sandbox-mode smolvm
--sandbox-image alpine # or a custom OCI image with dev tools
Trade-offs vs. Seatbelt
|
Seatbelt |
smolvm |
| Isolation |
Syscall filtering (same kernel) |
Hypervisor boundary (separate kernel) |
| Overhead |
~0ms |
~200ms boot (persistent VM amortizes this) |
| Platform |
macOS only |
macOS + Linux |
| Environment |
Host tools available |
Guest tools only (OCI image) |
| Dependency |
Built-in (/usr/bin/sandbox-exec) |
Requires smolvm installed + signed |
Implementation Steps
- Add
SmolVmCommandExecutor to crates/command_executor/
- Add VM lifecycle management (create/start/stop) tied to session lifecycle
- Map
SandboxPolicy to smolvm flags (network, volumes, allow-hosts)
- Wire up streaming output from
smolvm machine exec
- Add
smolvm as a --sandbox-mode option alongside seatbelt and full-access
- Documentation and tests (integration tests gated on smolvm availability)
References
- smolvm: https://github.com/smol-machines/smolvm
- Current sandbox plan:
docs/sandbox-plan.md (Phase 4 mentions Linux backend placeholders)
- Command executor trait:
crates/command_executor/src/lib.rs
- Sandboxed executor:
crates/command_executor/src/sandboxed_executor.rs
Summary
Add smolvm as an optional sandbox backend for command execution, providing hypervisor-level isolation as an alternative to the existing macOS seatbelt approach.
Motivation
The current sandbox implementation uses macOS seatbelt (syscall-level filtering within the same kernel). While effective and low-overhead, it:
smolvm offers hardware-isolated microVMs with:
Proposed Design
New executor:
SmolVmCommandExecutorImplements the existing
CommandExecutortrait incrates/command_executor/:Lifecycle
smolvm machine create --name <session-id> -v /project:/workspace [--net] [--allow-host ...]smolvm machine exec --name <session-id> -- sh -c "<command>"StreamingCallbacksmolvm machine stop --name <session-id>Policy mapping
DangerFullAccessDefaultCommandExecutorReadOnlyWorkspaceWriteConfiguration
New sandbox mode selectable via CLI flag or session config:
Trade-offs vs. Seatbelt
/usr/bin/sandbox-exec)Implementation Steps
SmolVmCommandExecutortocrates/command_executor/SandboxPolicyto smolvm flags (network, volumes, allow-hosts)smolvm machine execsmolvmas a--sandbox-modeoption alongsideseatbeltandfull-accessReferences
docs/sandbox-plan.md(Phase 4 mentions Linux backend placeholders)crates/command_executor/src/lib.rscrates/command_executor/src/sandboxed_executor.rs