Unified Sandbox Runner¶
Previously, the repository maintained two separate sandbox launcher scripts: standard_sandbox/main.py for lightweight container sandboxes and vm_sandbox/main.py for virtualized VM sandboxes. Although the image definition (shared/image.py) and startup script (shared/startup.sh) were already unified in ADR 0005, the two runners were ~90% duplicate code and suffered from behavioral drift. We decided to unify both sandbox execution models into a single launcher at sandbox/main.py differentiated by an explicit --vm boolean flag, remove the redundant standard_sandbox/ and vm_sandbox/ directories, and strictly constrain --memory to VM mode.
Considered Options¶
- Retain separate launcher scripts per directory (
standard_sandbox/andvm_sandbox/): Keepstandard_sandbox/main.pyandvm_sandbox/main.pyisolated. Rejected because every feature flag addition, bug fix, or port configuration required identical duplicate edits across both files, creating code drift (e.g. OpenCode client attach syntax and log streaming discrepancies). - Merge into repository root
main.py: Consolidate directly at the repository root. Rejected because keeping sandbox runner logic isolated within a dedicatedsandbox/directory maintains clean separation between repository-level metadata and sandbox runtime tooling. - Unified runner in
sandbox/main.pywith--vmdifferentiator and strict--memoryguard: Consolidate all launcher logic intosandbox/main.py. Without--vm, it provisions a Standard Sandbox on the container runtime with burstable RAM(128, 16384)MiB, no swap, and unstarted Docker daemon. With--vm, it provisions a VM Sandbox withexperimental_options={"vm_runtime": True}, setsENABLE_DOCKER=1, sets swapfile allocation, and accepts--memory(default: 1 GB RAM + 2 GB swap). Accepted because it eliminates code duplication, guarantees feature parity across both flavors, prevents invalid memory configurations, and unifies sandbox documentation.
Consequences¶
standard_sandbox/andvm_sandbox/directories are completely removed.sandbox/main.pyis the canonical entry point for all sandbox launches.- Running without
--vmlaunches a Standard Sandbox by default. - Passing
--vmactivates virtual machine virtualization, custom kernel privileges, Docker daemon startup, and swap allocation. - Passing
--memorywithout--vmproduces an explicit CLI validation error; with--vm, it allocatesNGB RAM and2NGB swap. - Standardizes OpenCode client connection command on
opencode --server <url>. - Documentation is consolidated into
sandbox/readme.mdand referenced from the repository rootreadme.md.