StateSet Sandbox Architecture
Scope of this document: a component-level overview suitable for new contributors and integrators. For the deep operational architecture — warm-pool internals, GKE-specific infrastructure, data layer, and event flows — seedocs/ARCHITECTURE.mdin the sandbox repository, which is the canonical reference. For the Rust-controller-specific architecture seestateset-sandbox-controller/README.md.
Overview
StateSet Sandbox provides an isolated execution environment for running Claude Code CLI and AI agents. The system uses a controller-based architecture where a central API manages ephemeral sandbox pods on Kubernetes.System Components
1. Sandbox Controller
The controller is a Node.js/Express API that manages the lifecycle of sandbox pods.- Image:
YOUR_REGISTRY/stateset/sandbox-controller:latest - Replicas: 3 (high availability)
- Namespace:
stateset-sandbox - Exposed at:
sandbox.stateset.com
- Authenticate API requests (JWT or API key)
- Create/delete sandbox pods via Kubernetes API
- Execute commands in running sandboxes
- Stream output via SSE or WebSocket
- Manage file uploads/downloads
- Enforce resource limits and quotas
2. Sandbox Image
The sandbox is a multi-language runtime environment with Claude Code pre-installed.- Image:
YOUR_REGISTRY/stateset/sandbox:latest - Not deployed directly - pulled on-demand by the controller
CI/CD Pipeline Flow
Runtime Flow
Creating and Using a Sandbox
Command Execution Flow
API Endpoints
Sandbox Management
File Operations
Command Execution
Kubernetes Resources
Namespace: stateset-sandbox
Docker Build Targets
The unifiedDockerfile supports multiple build targets:
SDK Usage
TypeScript SDK
Security
Sandbox Isolation
- Ephemeral pods: Each sandbox is a separate pod, destroyed after use
- Non-root user: Sandboxes run as UID 1000 (
sandboxuser) - Resource limits: CPU/memory limits enforced per sandbox
- Network policies: Sandboxes have limited network access
- Read-only filesystem: Optional, configurable per deployment
- gVisor runtime: Optional sandboxing via
RUNTIME_CLASSconfig
Authentication
- API Keys:
Authorization: ApiKey sk-... - JWT Tokens:
Authorization: Bearer eyJ... - Org isolation: Sandboxes are scoped to organizations
Configuration
Environment Variables (Controller)
Directory Structure
Next steps
Runtime selection
Which isolation runtime each component actually runs under.
API reference
The controller surface these components expose.
Security guide
How the boundaries drawn here are enforced.
Deployments
Mapping these components onto a managed Kubernetes cluster.