Skip to main content

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 — see docs/ARCHITECTURE.md in the sandbox repository, which is the canonical reference. For the Rust-controller-specific architecture see stateset-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
Responsibilities:
  • 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
Pre-installed Tools:

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 unified Dockerfile 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 (sandbox user)
  • 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_CLASS config

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.
Last modified on August 31, 2026