Architecture
Host support: This fork supports macOS 27+ on Apple Silicon only. Linux guests remain supported; Linux hosts are outside this fork’s scope.
iso is a Swift CLI that orchestrates isolated VM environments for running AI
coding agents (Claude Code, Codex). It manages the full VM lifecycle — setup,
up/start, shell, stop, destroy, status, logs — on one backend: iso-sandbox
VMs on apple/containerization (iso-sandbox). See
backends.md.
This document maps the modules, the backend, the data flow from host to guest,
and the architectural invariants. For the security view of the same system, see
trust-model.md; for Swift conventions, see
code-style.md.
Executables and packages
A distribution holds five executables. The first four are host processes;
iso-macos-helper runs inside macOS guests:
| Executable | Package | Responsibility |
|---|---|---|
iso |
root Package.swift |
CLI, configuration, host state, workspace and agent orchestration |
iso-sandbox |
iso-sandbox/ |
Apple Containerization VM ownership and runtime operations; macOS guests (iso-sandbox macos …) on Virtualization.framework directly |
iso-proxy |
iso-proxy/ |
Confined, credential-bearing provider transport |
iso-egress |
iso-egress/ |
Confined CONNECT companion for filtered egress; no provider credentials |
iso-macos-helper |
iso-sandbox/ |
Guest agent that iso-sandbox macos template build installs in macOS templates; never runs on the host |
Two more executables sit outside that set. iso-cu-mcp
(iso-sandbox/) is an arm64 Linux binary the release ships
as a guest file for computer use; it never runs on the host. iso-ci
(iso-ci/, ci.md) is the separately installed GitHub
Actions companion, which base iso never requires.
The host drives the runtime over its JSON CLI and starts companions through
their startup protocols; it never links those packages. The one shared code
is the iso-policy/ package, never a process of its own. Its
IsoPolicy library (the default-deny policy evaluator, sliding-window
admissions and single-use approvals) is linked by both iso and iso-proxy
(policy.md, design/iso-policy.md); its
IsoGitIndex library, the inert Git index reader, is linked by iso and the
separately installed iso-ci. iso resolves
iso-sandbox, iso-proxy, and iso-egress beside its own executable, and
iso-sandbox finds iso-macos-helper beside itself. A missing iso-egress
blocks only filtered boots.
Layout
iso/
├── Package.swift # host package: IsoCore, IsoConfiguration, IsoSecrets, IsoHost, IsoHostControl, IsoCLI
├── Sources/
│ ├── IsoCore/ # validated values, AtomicFile/FileLock; no subprocess or network side effects
│ ├── IsoConfiguration/ # JSONC scanning, preflight, decoding, config edits
│ ├── IsoSecrets/ # Secure Enclave-bound local secret store
│ ├── IsoHost/ # host orchestration, grouped within one target
│ │ ├── Lifecycle/ # setup/up/start/run/reprovision workflows and requests
│ │ ├── Runtime/ # runtime protocol, isolation checks, readiness and handoff
│ │ ├── Processes/ # spawning, signal propagation, detached child ownership
│ │ ├── Guest/ # SSH, bootstrap, images, agents, proxy startup; Resources/
│ │ ├── Editor/ # compiled-in editor providers; sandboxed editor sessions
│ │ ├── Policy/ # policy state, grant ledger, workspace policy, effective report
│ │ ├── Credentials/ # credential resolution, Keychain, GitHub and proxy config
│ │ ├── Workspace/ # transfer and staged-return workflows
│ │ ├── Devcontainer/ # parsing, translation and verified OCI Features
│ │ ├── State/ # persistence, config writes and boundary audit
│ │ ├── Update/ # verified releases, versioning and uninstall
│ │ └── Support/ # command context, diagnostics and bounded parsing
│ ├── IsoHostControl/ # execution-host protocol, supervisor, run/artifact stores, relays
│ └── IsoCLI/ # Argument Parser executable `iso`
│ ├── Commands/ # argument parsing, prompts, dispatch and presentation
│ └── Support/ # typed CLI response models
├── tests/swift/ # Swift test targets (one per module + fuzz corpus replay)
├── tests/ # integration and command contract scripts; fixtures
├── fuzz/ # libFuzzer harnesses (Targets/, Entrypoints/), corpus, vendored libFuzzer
├── iso-sandbox/ # Swift VM runtime: Linux sandboxes on Apple Containerization;
│ # macOS guests (IsoSandboxCore/MacOS, IsoMacProtocol, iso-macos-helper);
│ # computer use and the live view for both (IsoSandboxCore/ComputerUse);
│ # Linux displays (LinuxDisplay, LinuxDesktop; kernel/ builds the desktop kernel)
├── iso-proxy/ # Swift credential proxy: injection, policy, TLS, Seatbelt
├── iso-egress/ # Swift filtered-egress companion: destination policy, leases, CONNECT
├── iso-policy/ # shared libraries: IsoPolicy (evaluator), IsoGitIndex (inert index reader)
├── iso-ci/ # separately installed GitHub Actions companion; speaks iso.host/v1
├── skills/ # the distributable `iso` agent skill
├── experiments/ # throwaway spikes; not built, tested or shipped
├── www/ # project website
├── scripts/guest/ # guest-image provisioning scripts (embedded at build)
└── docs/ # this tree
Target dependencies: IsoConfiguration, IsoSecrets and IsoHost depend
on IsoCore; IsoSecrets also uses swift-crypto’s CryptoExtras;
IsoHost also depends on IsoConfiguration and IsoSecrets;
IsoHostControl sits above IsoHost, which never depends on it; IsoCLI
assembles them with Swift Argument Parser. Both external dependencies are pinned in
Package.resolved. Internal cross-target APIs use package access; types used
within a target stay internal. The four packages publish executable products.
Folders group related code without creating additional module boundaries.
IsoCore
Smart-constructor value types shared by configuration, state and commands:
Names.swift (instance, image, profile, host and environment-variable names;
the safe-name character class), RuntimeNames.swift (runtime object names and
identifiers persisted in host state), Units.swift (memory/disk quantities,
vCPU counts, the bootable RAM floor), GitRepoURL.swift (clone URL plus its
owner/repo slug), RemoteCommand.swift (injection-safe guest shell commands
and GuestPath), JSONOutput (Foundation encoding of typed output) with
OutputJSON for dynamic configuration/guest documents, and the state-write primitives
AtomicFile.swift and FileLock.swift (with HostError), shared with
modules that must not depend on IsoHost.
IsoConfiguration
The JSONC pipeline: JSONCScanner (the one comment scanner,
shared with devcontainer input under explicit policies) → JSONPreflight
(UTF-8, duplicate keys by decoded name, trailing commas, resource limits,
fraction/exponent literals) → Foundation JSONDecoder into JSONValue →
ConfigDecoding (explicit absent/null/wrong-type handling, per-section
unknown-key policy) → the immutable IsoConfig.
ConfigLoader selects the file (--config, default ~/.iso/config.jsonc,
missing-selected-file refusal); ConfigValidation checks environmental facts at
lifecycle boundaries; ConfigEditor and GitHubConfigEdits make structural
edits that keep unmodeled keys; ConfigTemplate is the template written by
setup --config-only (kept equal to config.example.jsonc
by a test).
IsoSecrets
The local secret store (design), with no
dependency on IsoHost (its SecretName identifier type lives in IsoCore): KDF (bounded scrypt parameters via
swift-crypto’s CryptoExtras, HKDF store key), DeviceFactor (the Secure
Enclave key, the digest-checked device.sekey file, the sealed device unlock
key), StoreFormat (the AES-GCM envelope and its bounds) and EnclaveStore
(init/set/rm/list/resolve, one unlock per call, owner-only files under a
FileLock).
IsoHost
| Area | Files |
|---|---|
| Lifecycle and runtime | AppleBackend (probes, liveness proofs, SSH target), AppleLifecycle (create/boot/stop/destroy/resize/commit/restore with journals), AppleSetup + ImageBuild + ImageRecords (image preparation and records), ProjectLifecycle, UpWorkflow, RunWorkflow and ReprovisionWorkflow (host orchestration accepting typed request values), SandboxRuntime (the narrow runtime-client seam), RuntimeOperations (mutating runtime calls, deadlines, cancellability), RuntimeProtocol (typed parsers for untrusted runtime output) |
| Processes and signals | ProcessRunner (the one subprocess launcher: argv, environment, bounded capture, deadlines, process groups), ChildGroups (forward termination signals to child groups), Shutdown (sticky SIGINT/SIGTERM flag for interruptible operations) |
| SSH and workspace | SSH (pinned-host-key connections), GuestSession (aliased SendEnv forwarding restored by a guest wrapper, minimal guest-bound environment, opaque workload sessions), SSHConfig (managed ~/.ssh/config aliases), Workspace (copy/clone/sync, push/pull), WorkspaceStage / WorkspaceStageApply / WorkspaceStageReview (staged pulls), PortForwards (ssh -L session per VM) |
| Editor providers | SSHConnectionTarget (alias, guest path and egress mode; no key material or workload state), EditorProviderID / EditorProvider (the closed set of compiled-in code and zed launch adapters, not a plugin ABI and not backends), EditorLauncher (strategy loop with a late handoff check and a deadline per spawn; EditorChoice selects exactly one provider or iso editor’s first-available order, and once a provider’s editor fails no other is tried), ProjectEditorWorkflow (iso code / iso zed: UpWorkflow, then SSHConfigFile.update, then one provider). The default sandboxed path is TrustedEditorApp (fixed-path, signature-verified bundle), EditorEnclave (per-session HOME, profile and Ed25519 key), EditorSandboxPolicy (deny-by-default Seatbelt profile) and SandboxedEditorSession (guest key authorization, loopback ssh -L tunnel, sandbox-exec spawn and proof supervision until the editor exits); see Local editors. Claude and Codex are managed workloads and stay on AgentBootstrap / WorkloadSession, never on this path |
| Guest bootstrap and state | Bootstrap, BootstrapClaude, BootstrapCodex, BootstrapStaging, CodexTOML, AgentUpdate, AgentCatalog / AgentLaunchPlan (definition catalog and reviewed adapter dispatch), RunSession (disposable-run ownership), ProxyLifecycle (proxy processes and reverse tunnels), ProxyStartup (startup wire encoding), ProxyUpstreams (provider selection), ProxyState, ModelState, GuestEnvState, Profiles, SeatbeltProfile, EmbeddedResources (generated from scripts/guest/) |
| GitHub and secrets | ProxyProvisioning (Keychain-backed setup), GitHubAPI, GitHubPAT, GitHubTokens, SecretStore (Keychain provisioning only), CredentialResolver (just-in-time cmd: and vault: resolution) |
| Devcontainer | Devcontainer, DevcontainerJSON, DevcontainerModel, DevcontainerResolve, DevcontainerReport, DevcontainerState, DevcontainerGitRepo, DevcontainerOCI (digest-verified Features) |
| Update and uninstall | Update, UpdateRelease, UpdateVersion, UpdateCheck, BuildRevision, Uninstall |
| Audit | BoundaryAudit (<instance>/audit.jsonl: host-recorded boot policy, raw provider forwards, stops, workspace returns; iso audit NAME), AuditEvent (the typed iso.audit/v1 event model), AuditStore (<stateRoot>/audit/v1: JSONL segments, one retention checkpoint, lock-free snapshots), AuditReader (run summaries, VM-context selection, cursors and coverage for every renderer), AuditRecorder (AuditInvocation, fed by RunWorkflow, the agent commands and InteractiveSSH.attach), ComputerUseAudit (<instance>/computer-use-audited.json: a boot’s computer-use counts are recorded once, from iso stop or from the runtime’s endedBoots). See audit.md |
| Persistent state | StateStore (versioned records under <data_dir>/backends/apple-container-v1; writes through IsoCore’s AtomicFile and FileLock), ConfigStore (locked config edits), DataRoot (real-directory guard) |
| Isolation | IsolationGate (effective VM configuration checked before a guest is handed out; its Ready proof carries a GuestRoute: a vmnet address or a brokered connector route), BrokeredTransport (the NIC-less transport: expected channel policy and digest, per-boot BrokeredNetworkPolicy, BrokeredConnector ProxyCommand, BrokeredView status), NetworkPolicy (creation-time egress and transport, per-boot brokered policy record), WorkloadHandoff (filtered and brokered prepared-session and guest-operation identity continuity), HostKeys (ed25519 pins read over the runtime channel) |
| Support | CommandContext (validated config and injected host services), Diagnostics (stderr), Prompt, bounded guest JSON parsing/editing, ParserStack (8 MiB stack for recursive untrusted-input parsers) |
IsoHostControl
The execution-host layer, a separate target so the compiler enforces its
direction: it uses IsoHost only through package API, cannot construct a
liveness proof, and nothing in IsoHost imports it. It holds the iso.host/v1 wire (HostWire, HostProtocol, HostControlError), the per-user HostSupervisor (durable OperationStore ledger with physical cleanup reservations, reconciliation, cancellation, deadline sweep, disposable HostRuns/RunStore with run.retain), HostCapabilities (host.capabilities and the NET-HANDOFF-1 evidence report), the volatile AccessSessions registry, the revocable GuestRelay, ArtifactStore/ArchiveValidator, the NativeHost seam (AppleNativeHost reuses AppleBackend), LocalHostControl (private sockets, client), SSHHostControl (fixed-entrypoint transport, enrollment registry), HostService (daemon, stdio frontends, launchd user service), ClientBindings (host-qualified bindings, session coordinator) and HostMigration. See design/local-and-remote-hosts-spec.md
IsoCLI
IsoCommand.swift defines the root command, global options and exit-status
mapping. Commands/ groups parsing and presentation by command domain; it
converts arguments into host request values and dispatches to the workflows in
IsoHost/Lifecycle/. Prompts and CLI-specific rendering remain here. Shared host
services and validated configuration live in IsoHost/Support/CommandContext.
Support/JSONResponses.swift defines owned Encodable response models; dynamic
JSON is reserved for guest/configuration documents whose keys are not owned by iso.
Shared pieces keep commands consistent without one universal option set:
- Argument groups in
Support/SharedArguments.swiftcover only the commands they apply to:BootArguments(up,code,zed,start),DevcontainerArguments(those plussetup) andEgressOptions.ProjectArgumentsowns project identity and creation-only options, sostartnever accepts--diskor--image. - Two kinds of checks. Malformed values and conflicting flags are refused
while parsing (transforms and
validate()), before configuration, network or VM work, and exit 2. Whether a valid value may change an existing boot is decided when the command runs (for examplehost up --egressagainst a reused VM). - Collect once, render many.
statusbuilds oneStatus.Reportand renders text, legacy--jsonand--output jsonfrom it; a different renderer never probes again. Legacy--jsonshapes are separate adapters, never aliases of--output json. - One launch path.
InteractiveSSH’s wrappers (run,runReporting,runCommand,exec) differ only in rendering, stdin and PTY policy; all go through oneattachthat revalidates theWorkloadSessionimmediately before spawning. A failed workload carries its own status asWorkloadExit. - Host receipts. Accepted, running, succeeded, failed and uncertain are
distinct; only
succeeded(_:)counts as success, and only an id fromOperationOption(--operation-id) is offered for a same-id retry. - Load intent.
CommandContext.load(intent:)says whether a command shows the update notice and attaches the secret store; previews and dry runs do neither, except that a devcontainer dry run keeps the store for a private repository’s PAT. - Compatibility spellings are extra names on the canonical option (or a
hidden default subcommand for the older
modelgrammar), listed in commands.md and the reviewed inventorytests/fixtures/contracts/cli-inventory.json. An old spelling keeps its units and limits and is retired only in an announced release; an ambiguous old form is refused, never retargeted. - Machine commands are found by walking the registered command tree;
capabilities, dispatch anddocs/machine-interface.mdmust agree.
The backend
There is one concrete backend, AppleBackend. There is no backend
trait, no compile-time or runtime backend selection, and no capability matrix.
SandboxRuntime is the only seam: a narrow runtime-client interface so tests
can script iso-sandbox responses. Disk and resource mutations follow the
invariants in design/apple-sandbox-transactions.md:
each takes the per-instance lock, journals runtime calls whose interruption
could leave runtime and host records disagreeing, and verifies the runtime’s
report instead of trusting an exit status.
Liveness proofs
AppleBackend.Running and AppleBackend.Stopped carry the instance, its owned
sidecar and (for Running) the isolation-gate result and SSH target. Their
initializers are internal to IsoHost; commands obtain them only through
asRunning / resolveRunning / asStopped. Operations that need a live or
stopped VM take the proof, so the precondition is checked once and then
witnessed by the type.
Brokered transport
network.transport: "brokered" (design)
changes only how the host reaches a guest. The runtime builds the VM with no
network device and proves it from the live VZVirtualMachine; its owner
process serves a stream socket and opens vsock streams to the guest’s SSH
adapter for admitted requests (IsoSandboxCore/Brokered.swift:
ChannelPolicy, StreamBroker, StreamConnector). On the host, the gate
returns a .brokered(BrokeredRoute) route and SSHTarget gets the runtime
connector as its ProxyCommand; every SSH-based feature (exec, transfer,
tunnels, brokers, editors, the remote relay’s last hop) is unchanged above
that seam.
Command dispatch
IsoCommand.main() installs ChildGroups termination handlers, parses the
command line (usage errors exit 2, as before), and runs the subcommand.
Commands that must work without a loaded configuration — completions,
setup --config-only, update, uninstall, devcontainer check —
handle that themselves. Others build a CommandContext: the data-root
guard, one validated IsoConfig snapshot with explicit CLI overrides applied,
Diagnostics, the background update notice, the AppleBackend, and the SSH
client. Handlers receive immutable values; credentials are resolved separately
and only when an operation needs them. IsoCLI.run maps failures to a
sanitized Error: … line on stderr and exit status 1; a usage error exits 2,
and a guest command that exits non-zero passes its own status through (see
commands.md).
Data flow: host → guest
The lifecycle is setup → up/start → shell → stop → destroy. A first boot
(IsoHost/Lifecycle/ProjectLifecycle.swift, startInstance /
provisionFirstBoot) runs roughly:
- Resolve the repository (
--git-repo, workspace origin, first mount) and optionally prompt for a GitHub PAT. - Ports — merge forward specs and fail on busy host ports before any VM cost.
- Boot —
AppleLifecycle.createAndStart: create and boot the sandbox, read and pin its host key, pass the isolation gate; then wait for SSH. - Forwards and state — refresh an installed SSH alias, persist and spawn
port forwards, persist
guest_env.jsonand devcontainer state. - Bootstrap — GitHub credential helper when a token is forwarded; Claude
and Codex configuration injection; provider proxies and local-model tunnels;
postStartCommand. - Workspace —
--workspacecopies via a tar pipe;--git-repoclones in the guest; mounts are a one-time sync (useiso push/iso pull).
A failed first boot tears down forwards, proxies, the sandbox and the SSH alias.
Config, secrets, and workspace all cross the host→guest boundary here; the
security-relevant details of each crossing are in trust-model.md.
Configuration and state
Configuration is JSONC at ~/.iso/config.jsonc, or strict JSON through an
explicit --config *.json. Explicit paths must exist; only an absent implicit
default configuration selects built-in defaults.
See configuration.md. Value bounds live in IsoCore
constructors, so validation only checks environmental facts. Proxy credentials
are cmd: references resolved just in time; proxy setup provisions them in
the macOS Keychain.
Host-owned state lives under <data_dir>/backends/apple-container-v1
(data_dir defaults to ~/.iso) as versioned JSON records written through
StateStore/AtomicFile: owner and machine records, journals, per-instance
records (instance.json, workspace.json, forwards.json, guest_env.json,
model.json, proxy.json, devcontainer state), host-key pins and image
records. Instance directories are 0700 and records owner-only. The pinned
HostKeyAlias is <machine>.iso.
iso update
Update.swift installs only from the pinned chr33s/iso release channel:
fetch release metadata, download the platform archive, SHA256SUMS and
SHA256SUMS.sig, verify the maintainer signature against the compiled-in
ReleaseSigners (mandatory), the checksum (mandatory) and the Sigstore
attestation, extract into a private
temporary directory with path validation, then replace iso-sandbox,
iso-macos-helper, iso-proxy, iso-egress and finally iso. Any failure before a replacement leaves every
installed binary untouched; each replacement is atomic but the set is not a
single transaction. Only release builds (-D ISO_RELEASE_BUILD, set by
scripts/build-release.py --release) update themselves. A background notifier
checks for new versions on a 24-hour interval (disabled in dev/CI/non-TTY). The
full verification chain is in trust-model.md.
Guest image
iso setup builds a golden image in a disposable sandbox from the embedded
provisioning scripts in scripts/guest/ plus the profile/package installers,
optionally with devcontainer Features, and publishes its record only after
verification. Instances boot from that image. See
images-and-profiles.md.
Architectural invariants
Hold these when changing the code; the review lenses check for their violation:
- The VM is the isolation boundary. The guest is untrusted from the host’s
view; guest-authored data must not escalate into host code execution or
filesystem escape. See
trust-model.md. - One concrete backend. Don’t add a backend protocol, selector, or cross-platform abstraction; unsupported operations fail explicitly.
- Liveness is a type, not a flag. Route VM operations through
Running/Stoppedproofs and the isolation gate, not ad-hocisRunningchecks. - Value invariants live in constructors. Parse into a
IsoCoretype at the boundary; don’t re-validate primitives downstream. - Secrets never touch argv or logs. Environment/
SendEnv/stdin only; diagnostics never print a resolved secret. The one known argv exception is the macOS Keychain store step (security add-generic-password -w,SecretStore.swift), whose CLI has no stdin path (trust-model). - No shell interpolation. Host processes start only through
ProcessRunnerwith an explicit argv; guest commands are built withRemoteCommand.arg(untrusted values) and.literal(iso-authored fragments only). - State is transparent JSON written through
StateStore/AtomicFileunder the resource’sFileLock, without widening permissions. - Host control selects an execution host, not a backend. Remote and
service-owned work goes through
HostSupervisoraround the sameAppleBackend; accepted operations are durable, retried by their originalHostOperationID, and never relabeled stopped or failed on a lost reply. - No fallback transport. A brokered instance never gains a network device: unsupported runtimes, images and guest OSes are refused before a VM is created, and adapter, broker or relay failures leave the session unavailable.
- Policy only narrows. An
IsoPolicyallow never replaces an existing check; the trusted mediator (proxyInboundGate, host staged apply) runs its hard checks first and fails closed on missing or corrupt policy state. A boot’s policy is immutable; quota state is never reset within an enforcing boot, so its proxy is never relaunched.