80 Key Points · 24 Glossary Entities

Kagex Engineering Key Points, Benchmarks & Glossary

Every verified technical specification behind Kagex's disposable microVMs, Ghost Secrets Vault, allowlist firewall, one-way workspace sync, and multi-OS hypervisor architecture.

80 key points

Architecture & Security Key Points

HypervisorFull guide →

MicroVM Kernel & Compute Isolation

  1. 1Every Kagex sandbox boots a dedicated single-tenant Ubuntu 24.04 Linux kernel rather than sharing the host OS kernel.
  2. 2macOS 14+ (Apple Silicon) runs natively via Apple Virtualization.framework (Code-Hex/vz/v3) with rootless ad-hoc entitlements in infra/vz.entitlements.
  3. 3Linux amd64 and arm64 hosts run Firecracker v1.12.1 over /dev/kvm with per-VM Linux network namespaces and nftables packet filters.
  4. 4Windows 10 (19041+) and Windows 11 (x64/arm64, Home/Pro/Enterprise) supervise Firecracker KVM inside WSL2 without requiring Hyper-V Pro or Admin privileges.
  5. 5Guest base kernels are sha256-verified via infra/scripts/fetch-kernel.sh before registration into _out/images/vmlinux-<arch>.
  6. 6Every microVM boots from an immutable Ubuntu 24.04 ext4 rootfs built reproducibly with Docker or native debootstrap.
  7. 7Nested dockerd and Compose workloads execute inside the isolated guest kernel with zero exposure of host /var/run/docker.sock.
  8. 8internal/scheduler arbitrates vCPU and RAM via a lock-free single-goroutine actor ledger with priority queuing and automatic pressure eviction.
  9. 9Default host memory reserve locks ~50% RAM on macOS/Linux (and safe WSL2 VHDX headroom on Windows), overridable via budgets.max_mem_mb.
  10. 10Active sandboxes pause gracefully to disk on Ctrl-C during foreground sandboxd serve runs and recover safely after crashes via internal/service/recover.go.

Warm Pools, Copy-on-Write Snapshots & Forks

  1. 1Warm pool standby microVMs attach fresh workspaces and run initial commands in 20–50 ms on Apple M4 hardware.
  2. 2Golden snapshot restores complete in 0.5–0.6 seconds including incremental workspace delta synchronization.
  3. 3Pausing and resuming an active sandbox to/from disk finishes in 0.5–0.7 seconds while retaining guest memory state.
  4. 4Parallel CoW forks clone a running sandbox N times concurrently in ~0.8 seconds per child for best-of-N AI evaluation.
  5. 5Cold Linux kernel boot from initramfs to PID 1 sandbox-agent ready completes in ~1.2 seconds.
  6. 6Trivial exec RPC round trips complete in under 5 milliseconds over multiplexed gRPC on AF_VSOCK port 52.
  7. 7macOS clones multi-gigabyte disk images instantaneously via APFS clonefile CoW blocks without duplicating storage.
  8. 8Linux & WSL2 leverage FICLONE reflinks on XFS/Btrfs or sparse SEEK_DATA + CopyFileRange cloning on ext4.
  9. 9Template auto-detection (template='auto') caches repo bootstrap toolchains established during --setup runs.
  10. 10sandboxctl trace <sbx_id|exe_id> renders exact millisecond waterfalls across scheduler.reserve, vm.restore, guest.configure, workspace.sync, and exec.
Repo SafetyFull guide →

One-Way Workspace Sync, 3-Way Apply & Undo

  1. 1Host folders are never shared or mounted into guest microVMs — virtio-fs and 9p mounts are intentionally disabled.
  2. 2Workspace synchronization moves strictly one way (host -> VM) over explicit AF_VSOCK tar streams checked by guest/files.
  3. 3Running rm -rf /workspace inside a sandbox has zero effect on the developer's repository on disk.
  4. 4Before every sandbox_exec, incremental host file changes delta-sync automatically into guest /workspace.
  5. 5Diff previews compare VM edits cleanly against repository git HEAD without mutating host git refs, index, or checked-out branches.
  6. 6Applying approved patches uses temporary git merge-file 3-way merges rather than blind file overwrites.
  7. 7Every host write via sandboxctl apply or pull archives all affected original host files first into a restorable artifact bundle.
  8. 8Instant rollback restores pre-apply host state in one command: sandboxctl undo <artifact_id>.
  9. 9sandboxctl pull refuses to overwrite files modified concurrently on the host since last sync unless explicitly forced.
  10. 10Path validation inside guest/files, apply, and pull rejects absolute paths, '..' segments, escaping symlinks, and .git/ internal writes.

Ghost Secrets Vault & Zero-Leak Proxy

  1. 1Real API tokens and credentials stay encrypted/stored solely on the host with 0600 permissions under daemon data roots.
  2. 2Sandboxes receive only synthetic harmless placeholder tokens formatted as sbxph_<name>_<hex>.
  3. 3Outbound HTTPS requests targeting approved secret hosts terminate TLS cleanly at a per-daemon ECDSA P-256 local CA proxy.
  4. 4Host egress proxy swaps real credentials in transit strictly when both host allowlist and secret destination rules match.
  5. 5Echoed secrets inside upstream HTTP response bodies or debug headers are redacted automatically back into placeholders via scrubReader.
  6. 6Cleartext HTTP requests attempting to carry secret placeholders are dropped immediately before touching the wire.
  7. 7Daemon rejects CLI commands, environment variables, stdin payloads, and synced files containing raw stored secret values.
  8. 8Workspace delta sync automatically skips .env*, *.pem, *.key, id_*, .npmrc, .aws, and .ssh credential paths.
  9. 9Synced .git/config files have credential helpers, HTTP Authorization extraheaders, include paths, and embedded URL tokens stripped.
  10. 10Git smart-HTTP tokens created via sandboxctl secret set-git enforce allowed owner/repo patterns and push branch globs like sbx/*.

Allowlist Egress Firewall & DNS Defense

  1. 1Default outbound network mode is allowlist-only, granting access solely to approved package registries, GitHub, and Ubuntu mirrors.
  2. 2Loopback (127.0.0.0/8), RFC1918 private LAN subnets, link-local/cloud metadata (169.254.0.0/16), and CGNAT (100.64.0.0/10) are always blocked.
  3. 3internal/network/dns inspects all resolved A/AAAA answers and drops records pointing to loopback, LAN, IMDS, or CGNAT ranges to neutralize DNS rebinding.
  4. 4SNI and Host headers are cross-verified at the egress proxy to prevent HTTP Host-header domain fronting bypasses.
  5. 5Harnesses support separate setup bootstrap rules (--setup) that permit temporary package installation before engaging strict runtime lockdown.
  6. 6When a coding agent hits a blocked registry (403 Denied), it calls sandbox_network to prompt explicit human approval rather than bypassing firewall rules.
  7. 7Host-forwarded preview listeners mapped via sandboxctl port bind strictly to 127.0.0.1 and never expose 0.0.0.0 on local Wi-Fi.
  8. 8Unix API middleware validates caller identity via kernel OS peer credentials (SO_PEERCRED on Linux / LOCAL_PEERCRED on macOS).
  9. 9Loopback TCP listeners enforce cryptographic Bearer authentication (sandboxd token) and drop browser Origin CSRF attempts.
  10. 10On Linux KVM, per-VM network namespaces combine with nftables enforcement at kernel level.
Agents & MCPFull guide →

11-Tool MCP Server & One-Command IDE Wiring

  1. 1sandbox-mcp implements JSON-RPC 2.0 over stdio and bridges seamlessly into sandboxd over Unix domain sockets or loopback TCP.
  2. 2sandboxctl mcp install antigravity creates .agents/plugins/kagex/ (or ~/.gemini/config/plugins/kagex/ with --global) containing plugin.json, mcp_config.json, rules/AGENTS.md, and skills/sandbox/SKILL.md.
  3. 3sandboxctl mcp install cursor configures .cursor/mcp.json (or ~/.cursor/mcp.json) alongside always-applied .cursor/rules/sandbox.mdc.
  4. 4sandboxctl mcp install claude writes .claude/skills/sandbox/SKILL.md and registers the MCP server via claude mcp add with --scope project or --scope user.
  5. 5sandboxctl mcp install codex backs up ~/.codex/config.toml to config.toml.bak, appends [mcp_servers.sandbox] (30s startup, 900s tool timeout), and updates AGENTS.md.
  6. 6Eleven specialized tools cover full dev workflows: sandbox_exec, sandbox_read_file, sandbox_write_file, sandbox_diff, sandbox_apply, sandbox_pull, sandbox_snapshot, sandbox_network, sandbox_port, sandbox_status, and sandbox_destroy.
  7. 7Shared policy flags (--auto-pull, --setup, --secrets) are locked by the user at install time so models cannot weaken isolation parameters.
  8. 8On Windows, sandbox-mcp automatically translates Windows paths like D:\repo into corresponding WSL2 paths cleanly.
  9. 9Operators monitor every agent tool invocation, file sync, diff, and firewall block live via sandboxctl events.
  10. 10Custom Go, Python, and REST harnesses receive identical isolation primitives using pkg/client or docs/openapi.yaml.

Guest Agent (PID 1) & AF_VSOCK Protocol

  1. 1sandbox-agent is compiled with CGO_ENABLED=0 as a static Linux binary for both linux/amd64 and linux/arm64.
  2. 2Delivered via a compact initramfs, guest/initd initializes virtual mounts, brings up networking via netlink, arms a deadman timer, and performs switch_root.
  3. 3As PID 1 inside every microVM, guest/proc runs a singleton SIGCHLD zombie-process reaper preventing PID exhaustion during heavy builds.
  4. 4guest/execd executes commands inside isolated process groups with PTY or pipe streams and reads /proc/vmstat to flag memory/OOM kills accurately.
  5. 5guest/spool persists execution output frames on disk so detached or reconnecting clients recover every log byte reliably.
  6. 6Host-guest RPC communication uses strongly typed protobuf schemas defined in internal/proto/guest/v1/guest.proto over AF_VSOCK port 52.
  7. 7guest/files performs traversal-verified tar extraction and file read/write operations inside guest filesystems.
  8. 8Zero SSH daemons, authorized_keys files, or open guest TCP control ports are ever needed inside sandboxes.
  9. 9Linux guest process unit tests run reproducibly inside Docker containers via make test-linux.
  10. 10Artifact versioning embeds build metadata into both sandboxd and sandbox-agent cleanly.
SDKs & APIFull guide →

OpenAPI, Go/Python SDKs & WAL Storage

  1. 1sandboxd serves a versioned REST/JSON + SSE API contracted cleanly in docs/openapi.yaml and live at GET /v1/openapi.yaml.
  2. 2Public Go SDK in pkg/client requires zero cgo and handles automatic platform discovery across macOS, Linux, and Windows.
  3. 3Python integration requires zero third-party pip packages — stdlib http.client + socket AF_UNIX / TCP streams SSE cleanly (docs/examples/python-harness/harness.py).
  4. 4Asynchronous executions via wait=false stream chunked stdout, stderr, and final exit payloads over GET /v1/executions/{exec_id}/stream.
  5. 5Oversized command logs stay searchable directly via GET /v1/executions/{exec_id}/grep without overflowing LLM token windows.
  6. 6Persistence uses pure-Go SQLite (modernc.org/sqlite) in WAL mode with 1 writer and an 8-reader connection pool.
  7. 7Type-safe database queries are generated via sqlc in internal/store/db with embedded SQL migrations in internal/store/migrations.
  8. 8All daemon state, SQLite DBs, rootfs clones, and backup artifacts live cleanly outside git repos (~/Library/Application Support/sandboxd/, /var/lib/sandboxd/, %LOCALAPPDATA%\sandboxd\).
  9. 9Uninstall preserves existing templates and snapshots unless the user explicitly runs sandboxd uninstall --purge --yes.
  10. 10Prometheus /metrics and OTLP --otlp-endpoint http://127.0.0.1:4318 work out of the box with infra/observability/docker-compose.yml.

Kagex vs Docker vs Cloud Sandboxes vs Raw Host

Ten engineering trade-offs comparing isolation boundaries, latency, cost, and credential safety.

DimensionKagex MicroVMDocker ContainersCloud VMs (E2B / Modal)Raw Host Shell
Isolation boundaryDedicated Ubuntu 24.04 Linux kernelShared host Linux kernelRemote microVMNone (full user/host access)
Warm spawn latency20–50 ms (local warm pool)150–600 ms300–1500 ms + WAN upload0 ms (unsafe)
Code stays on laptop100% local & offline-capableLocalUploaded to remote vendorLocal
Monthly & usage cost$0 (MIT open source)$0 / Desktop licensePer-minute vCPU/RAM billing$0
API keys in VM RAMNever (sbxph_ placeholders)Exposed if passed via envOften inside remote VM envFull host ~/.ssh & .env exposed
Host folder mutation riskZero (1-way sync + diff/apply/undo)High with -v bind mountsSync lag / manual downloadUnprotected rm -rf / git reset
Default egress firewallAllowlist-only + DNS rebind guardUnrestricted bridge by defaultVaries by providerFull LAN & internet access
macOS, Linux & Windows parityNative vz + KVM + Win WSL2 KVMLinux VM wrapper on Mac/WinCloud-hosted LinuxOS-dependent
Parallel branching / fork~0.8 s CoW fork (sandboxctl fork)No memory state forkVendor API dependentRequires manual git clones
IDE MCP integration1-cmd Antigravity, Cursor, Claude, CodexManual scripting requiredCustom pluginsHost shell directly

Technical Architecture Glossary (24 Entities)

Exact kernel mechanisms, network guards, storage primitives, and CLI concepts used inside Kagex.

Machine JSON Feed (/ai-data.json) ↗
MicroVM
Compute
A lightweight hardware-virtualized VM running its own Linux kernel and memory space per task.
Explore guide →
Apple Virtualization.framework
Hypervisor
Native macOS 14+ hypervisor API used rootlessly by Kagex on Apple Silicon via Code-Hex/vz.
Explore guide →
Firecracker v1.12.1
Hypervisor
Open-source KVM microVM monitor powering Linux and Windows WSL2 sandboxes inside Kagex.
Explore guide →
AF_VSOCK (Port 52)
Transport
Direct host-to-guest socket address family carrying gRPC control & tar file streams without guest IPs.
Explore guide →
gVisor tap-vsock
Network
Userspace virtual network stack inspecting every packet leaving macOS microVMs before egress.
Explore guide →
APFS clonefile
Storage
Instantaneous copy-on-write file cloning on macOS disks without duplicating unchanged rootfs gigabytes.
Explore guide →
FICLONE & SEEK_DATA
Storage
Linux reflink and sparse-hole copying primitives keeping Firecracker CoW snapshots lightweight.
Explore guide →
Ghost Secrets Vault
Security
Host-side 0600 credential store that keeps real secrets out of VM RAM using placeholder substitution.
Explore guide →
sbxph_<name>_<hex>
Security
Synthetic placeholder token injected into guest sandboxes instead of raw API credentials.
Explore guide →
ECDSA P-256 Local CA
Security
Per-daemon TLS certificate authority enabling host-side secret substitution only on allowed domains.
Explore guide →
scrubReader
Security
Streaming HTTP response sanitizer that scrubs echoed raw secrets back into placeholders before returning to guest VMs.
Explore guide →
DNS Rebinding Guard
Network
Resolver filter rejecting DNS records pointing toward loopback, RFC1918 LAN, IMDS, or CGNAT.
Explore guide →
IMDS (169.254.169.254)
Network
Link-local cloud instance metadata IP range permanently blocked across all Kagex sandboxes.
Explore guide →
No virtio-fs
Isolation
Deliberate ban on shared host folder mounts so untrusted VM syscalls cannot traverse host files.
Explore guide →
safefs.RemoveUnder
Isolation
Symlink-resolving confinement helper gating every deletion targeting paths under daemon directories.
Explore guide →
3-Way Apply (git merge-file)
Workflow
Non-destructive patch merge running on temp files after archiving backups for instant rollback.
Explore guide →
sandboxctl undo
Workflow
One-command rollback restoring host files from pre-apply tar backup artifacts (art_...).
Explore guide →
Warm Pool
Performance
Background pool of booted standby Ubuntu 24.04 microVMs enabling 20–50 ms task attaches.
Explore guide →
Golden Snapshot
Performance
Pre-provisioned disk/memory snapshot capturing base OS or repo setup layers for ~0.5 s restores.
Explore guide →
Parallel Fork (c.Fork)
Performance
CoW cloning of an active running sandbox into multiple independent workers (~0.8 s each).
Explore guide →
SO_PEERCRED / LOCAL_PEERCRED
Auth
Kernel OS peer credential verification authenticating same-user Unix domain socket clients.
Explore guide →
MCP (Model Context Protocol)
Agents
Open JSON-RPC stdio protocol used by sandbox-mcp to expose 11 tools to IDE coding agents.
Explore guide →
SQLite WAL + sqlc
Storage
Write-Ahead Log database persistence powering sandboxes, artifacts, and execution history.
Explore guide →
OTLP / Prometheus /metrics
Observability
OpenTelemetry tracing (port 4318) and Prometheus gauges paired with a prebuilt Grafana dashboard.
Explore guide →

Operational Diagnostics & Runbook Q&A

How do I verify my host, hypervisor, and base images are healthy before debugging anything else?

Run both doctor commands: sandboxd doctor inspects OS hypervisor capability (Virtualization.framework entitlement, /dev/kvm, or WSL2 KVM), APFS/sparse disk space, kernel/rootfs checksums, and sockets; sandboxctl doctor checks the live daemon and warm pool budget.

./_out/bin/sandboxd doctor && ./_out/bin/sandboxctl doctor

Why did an agent get 403 Denied when running curl or pip/npm install inside a microVM?

Kagex blocks unlisted outbound domains by default. Either install dependencies during --setup, approve the agent's sandbox_network prompt, or explicitly allow the host via sandboxctl net allow <id> <host>.

sandboxctl net allow <sbx_id> pypi.org files.pythonhosted.org

How do I recover if a bug caused an unwanted change after running sandboxctl apply?

Every apply/pull creates a backup tar artifact and prints an undo token. Run sandboxctl artifacts to list recent backups and sandboxctl undo <art_id> to restore exact pre-apply host files cleanly.

sandboxctl artifacts && sandboxctl undo <art_id>

Can Windows 10 or Windows 11 Home users run Kagex without Hyper-V Pro?

Yes. Kagex's scripts/setup-windows.ps1 provisions Firecracker and nftables cleanly inside WSL2 (/dev/kvm) with non-Admin HKCU login auto-start and authenticated loopback TCP on 127.0.0.1:17070.

powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\setup-windows.ps1

How can custom scripts or CI pipelines get the Bearer token for TCP daemon access?

Use sandboxd token to print the active cryptographic Bearer token, or read metadata inside %LOCALAPPDATA%\sandboxd\ on Windows.

sandboxd token

How do I reclaim disk space from stopped sandboxes or old golden snapshots safely?

Preview unused resources first with --dry-run using sandboxctl gc --dry-run, then run sandboxctl gc when ready.

sandboxctl gc --dry-run