Site architecture

From google/capsem · View interactive version

Site architecture is an AI agent skill from the GitHub repository google/capsem. Capsem system architecture: service, per-VM processes, CLI, guest agent, vsock, network proxy. Use when you need the design to write, review, or debug across components.

How to use this skill

Skill file

Capsem Architecture

System overview

Capsem sandboxes AI agents in air-gapped Linux VMs on macOS using Apple's Virtualization.framework (with a KVM backend for Linux). It runs as a daemon service (like Docker). The system has these layers:

Host-side:

(vm-N unless the user supplies a name) and sized by create flags with

fixed defaults.

capsem shell opens the TUI/session picker, creates or attaches through the

authenticated gateway, using the Rust SDK and shared API types. Direct UDS

HTTP is restricted to local status/asset administration and service startup.

Failed gateway authentication never falls back to UDS. User-facing copy says

sessions; implementation/debug output may say VM when describing the

virtualization layer.

Guest-side:

Reference routing

service/process topology, CLI or MCP execution paths, gateway/service routes,

host IPC, vsock framing or ports, or any guest agent binary.

or forks, network interception, security or logger ownership, ephemeral

sessions, installation, service registration, companion launch, or updates.

between crates, changing capsem-process permissions or environment, changing

session/socket/share boundaries, or changing MITM CA-key handling.

an architectural change; it is the full annotated source map.

configuration and IPC. The app remains a thin webview shell; VM operations

and update checks route through the gateway.

Core invariants

session. No other host binary boots a VM or talks to guest vsock directly.

404; do not add compatibility aliases or generic forwarding. Every public

method/path pair is approval-locked in config/public-surface.toml.

distinct vsock responsibilities. Preserve the port and framing contract in

references/service-and-guest-protocols.md.

reaches the host only through the guest net proxy and the MITM/security path.

(capsem-router --network); plug()/unplug() connect a VM's cable to it.

Plugged VMs talk over any protocol. The switch forwards on MAC only and is a

network, not a security boundary: never add per-flow relays, admission,

or IP/TCP parsing to it. See references/storage-network-and-lifecycle.md.

settings.toml and built-in defaults supply the rest of the policy; the

one VM runtime and OCI images own what a guest runs; settings own UI

preferences. All enforcement and detection compiles

into one SecurityRuleSet over SecurityEvent.

ledger storage belongs to capsem-logger; routes, MCP helpers, UI handlers,

benchmarks, and network formatters must not open SQLite or own projection

caches. Missing tables or columns are schema failures, never empty data.

a hidden image-authoring rail; package changes go through the runtime

package set (/build-images) or an OCI image under images/.

0700 session directory, attaches read-only assets and guest binaries, and

shares only session_dir/guest/ with the VM. These controls do not confine

a compromised same-UID host worker by themselves. The VM owner, proxy, ledger

and native MCP workers enforce OS confinement before readiness. The service

retains native MCP child handles and generation-bound cleanup authority.

are service-owned companions and must self-exit with their parent.

Key source files

Read references/key-files.md for the full annotated source map.

Tauri v2 reference

Read references/tauri-v2.md for Tauri v2 patterns and the registered handler in

crates/capsem-app/src/lib.rs for shell commands. All VM operations and update

checks route through the gateway.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.