# minoansecurity/sidekernel architecture

> Architecture diagram of the GitHub repository minoansecurity/sidekernel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/minoansecurity/sidekernel
- Repository: https://github.com/minoansecurity/sidekernel

## Overview

SideKernel runs coding agents and other commands inside disposable macOS-hosted Linux microVMs. The main workflow is host CLI → provisioned VM → guest command execution, with host-mediated credentials, networking, and optional file/state features. The graph includes the documented guest tools even where their implementation was not sampled; those links cite the README. Internal guest-agent relationships are limited to calls visible in the excerpts or source index.

Main entry points: [`Host/Sandbox.swift`](https://github.com/minoansecurity/sidekernel/blob/main/Host/Sandbox.swift) (Sandbox orchestration), [`Host/Session.swift`](https://github.com/minoansecurity/sidekernel/blob/main/Host/Session.swift) (Interactive session), [`agent/src/serve.rs`](https://github.com/minoansecurity/sidekernel/blob/main/agent/src/serve.rs) (Control server), [`Host/CLI.swift`](https://github.com/minoansecurity/sidekernel/blob/main/Host/CLI.swift) (CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host runtime"]
  node_cli["CLI<br/>[CLI.swift]"]
  node_sandbox["Sandbox orchestration<br/>[Sandbox.swift]"]
  node_vm["MicroVM lifecycle<br/>[MicroVM.swift]"]
  node_session["Interactive session<br/>[Session.swift]"]
  node_terminal["Terminal I/O<br/>[Terminal.swift]"]
  node_contract["Wire protocol<br/>[Contract.swift]"]
end

subgraph group_guest["Guest runtime"]
  node_guestagent["Guest agent entry<br/>[main.rs]"]
  node_guestinit["Guest boot<br/>[init.rs]"]
  node_guestserve["Control server<br/>[serve.rs]"]
  node_process["Command execution<br/>[process.rs]"]
  node_vsock["VSOCK transport<br/>[vsock.rs]"]
  node_net["Guest networking<br/>[net.rs]"]
end

subgraph group_features["Sandbox features"]
  node_proxy["Credential proxy<br/>[Proxy.swift]"]
  node_approval["Host approvals<br/>[HostApproval.swift]"]
  node_drop["Approved file import<br/>[DropIn.swift]"]
  node_clipboard["Clipboard and drag-drop<br/>[Clipboard.swift]"]
  node_forward["Port forwarding"]
  node_guesttools["Guest convenience tools"]
  node_harness["Agent harness<br/>[harness.py]"]
  node_networktool["Network toggle"]
  node_save["Save command"]
end

subgraph group_state["Provisioning and state"]
  node_provision["VM provisioning<br/>[Provisioning.swift]"]
  node_store[("Persistent personal state")]
end

node_user(("Host user"))

node_user -->|"launches"| node_cli
node_cli -->|"starts"| node_sandbox
node_cli -->|"ensures artifacts"| node_provision
node_sandbox -->|"configures and starts"| node_vm
node_sandbox -->|"runs command"| node_session
node_session -->|"connects control"| node_vm
node_session -->|"uses terminal I/O"| node_terminal
node_session -->|"exchanges frames"| node_contract
node_vm -->|"uses port constants"| node_contract
node_guestagent -->|"boots as PID 1"| node_guestinit
node_guestagent -->|"starts listener"| node_guestserve
node_guestserve -->|"spawns command"| node_process
node_guestserve -->|"updates posture"| node_net
node_guestserve -.->|"accepts connections"| node_vsock
node_sandbox -->|"routes credentials"| node_proxy
node_sandbox -->|"requests approval"| node_approval
node_sandbox -->|"dispatches file import"| node_drop
node_sandbox -->|"sets up clipboard"| node_clipboard
node_sandbox -->|"starts forwarding"| node_forward
node_sandbox -->|"publishes state"| node_store
node_provision -->|"prepares state"| node_store
node_guesttools -.->|"offers sandbox commands"| node_user
node_harness -.->|"invokes guest control"| node_guestagent
node_networktool -.->|"requests network approval"| node_approval
node_save -.->|"persists packages"| node_store

click node_cli "https://github.com/minoansecurity/sidekernel/blob/main/Host/CLI.swift"
click node_sandbox "https://github.com/minoansecurity/sidekernel/blob/main/Host/Sandbox.swift"
click node_vm "https://github.com/minoansecurity/sidekernel/blob/main/Host/MicroVM.swift"
click node_session "https://github.com/minoansecurity/sidekernel/blob/main/Host/Session.swift"
click node_terminal "https://github.com/minoansecurity/sidekernel/blob/main/Host/Terminal.swift"
click node_contract "https://github.com/minoansecurity/sidekernel/blob/main/Host/Contract.swift"
click node_guestagent "https://github.com/minoansecurity/sidekernel/blob/main/agent/src/main.rs"
click node_guestinit "https://github.com/minoansecurity/sidekernel/blob/main/agent/src/init.rs"
click node_guestserve "https://github.com/minoansecurity/sidekernel/blob/main/agent/src/serve.rs"
click node_process "https://github.com/minoansecurity/sidekernel/blob/main/agent/src/process.rs"
click node_vsock "https://github.com/minoansecurity/sidekernel/blob/main/agent/src/vsock.rs"
click node_net "https://github.com/minoansecurity/sidekernel/blob/main/agent/src/net.rs"
click node_proxy "https://github.com/minoansecurity/sidekernel/blob/main/Host/Proxy.swift"
click node_approval "https://github.com/minoansecurity/sidekernel/blob/main/Host/HostApproval.swift"
click node_drop "https://github.com/minoansecurity/sidekernel/blob/main/Host/DropIn.swift"
click node_clipboard "https://github.com/minoansecurity/sidekernel/blob/main/Host/Clipboard.swift"
click node_forward "https://github.com/minoansecurity/sidekernel/blob/main/Host/PortForwarder.swift"
click node_provision "https://github.com/minoansecurity/sidekernel/blob/main/Host/Provisioning.swift"
click node_store "https://github.com/minoansecurity/sidekernel/blob/main/Host/PersonalStore.swift"
click node_guesttools "https://github.com/minoansecurity/sidekernel/tree/main/guest"
click node_harness "https://github.com/minoansecurity/sidekernel/blob/main/guest/internal/harness.py"
click node_networktool "https://github.com/minoansecurity/sidekernel/blob/main/guest/sk-net"
click node_save "https://github.com/minoansecurity/sidekernel/blob/main/guest/save"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_sandbox,node_vm,node_session,node_terminal,node_contract,node_user toneBlue
class node_guestagent,node_guestinit,node_guestserve,node_process,node_vsock,node_net toneAmber
class node_proxy,node_approval,node_drop,node_clipboard,node_forward,node_guesttools,node_harness,node_networktool,node_save toneMint
class node_provision,node_store toneRose
```

## Components

### Host runtime

- [CLI](https://github.com/minoansecurity/sidekernel/blob/main/Host/CLI.swift): `Host/CLI.swift`
- [Sandbox orchestration](https://github.com/minoansecurity/sidekernel/blob/main/Host/Sandbox.swift): `Host/Sandbox.swift`
- [MicroVM lifecycle](https://github.com/minoansecurity/sidekernel/blob/main/Host/MicroVM.swift): `Host/MicroVM.swift`
- [Interactive session](https://github.com/minoansecurity/sidekernel/blob/main/Host/Session.swift): `Host/Session.swift`
- [Terminal I/O](https://github.com/minoansecurity/sidekernel/blob/main/Host/Terminal.swift): `Host/Terminal.swift`
- [Wire protocol](https://github.com/minoansecurity/sidekernel/blob/main/Host/Contract.swift): `Host/Contract.swift`

### Guest runtime

- [Guest agent entry](https://github.com/minoansecurity/sidekernel/blob/main/agent/src/main.rs): `agent/src/main.rs`
- [Guest boot](https://github.com/minoansecurity/sidekernel/blob/main/agent/src/init.rs): `agent/src/init.rs`
- [Control server](https://github.com/minoansecurity/sidekernel/blob/main/agent/src/serve.rs): `agent/src/serve.rs`
- [Command execution](https://github.com/minoansecurity/sidekernel/blob/main/agent/src/process.rs): `agent/src/process.rs`
- [VSOCK transport](https://github.com/minoansecurity/sidekernel/blob/main/agent/src/vsock.rs): `agent/src/vsock.rs`
- [Guest networking](https://github.com/minoansecurity/sidekernel/blob/main/agent/src/net.rs): `agent/src/net.rs`

### Sandbox features

- [Credential proxy](https://github.com/minoansecurity/sidekernel/blob/main/Host/Proxy.swift): `Host/Proxy.swift`
- [Host approvals](https://github.com/minoansecurity/sidekernel/blob/main/Host/HostApproval.swift): `Host/HostApproval.swift`
- [Approved file import](https://github.com/minoansecurity/sidekernel/blob/main/Host/DropIn.swift): `Host/DropIn.swift`
- [Clipboard and drag-drop](https://github.com/minoansecurity/sidekernel/blob/main/Host/Clipboard.swift): `Host/Clipboard.swift`
- [Port forwarding](https://github.com/minoansecurity/sidekernel/blob/main/Host/PortForwarder.swift): `Host/PortForwarder.swift`
- [Guest convenience tools](https://github.com/minoansecurity/sidekernel/tree/main/guest): `guest`
- [Agent harness](https://github.com/minoansecurity/sidekernel/blob/main/guest/internal/harness.py): `guest/internal/harness.py`
- [Network toggle](https://github.com/minoansecurity/sidekernel/blob/main/guest/sk-net): `guest/sk-net`
- [Save command](https://github.com/minoansecurity/sidekernel/blob/main/guest/save): `guest/save`

### Provisioning and state

- [VM provisioning](https://github.com/minoansecurity/sidekernel/blob/main/Host/Provisioning.swift): `Host/Provisioning.swift`
- [Persistent personal state](https://github.com/minoansecurity/sidekernel/blob/main/Host/PersonalStore.swift): `Host/PersonalStore.swift`

### Other components

- **Host user**

## Connections

- Host user → CLI: launches (evidence: `README.md`)
- CLI → Sandbox orchestration: starts (evidence: `Host/CLI.swift`)
- CLI → VM provisioning: ensures artifacts (evidence: `Host/CLI.swift`)
- Sandbox orchestration → MicroVM lifecycle: configures and starts (evidence: `Host/Sandbox.swift`)
- Sandbox orchestration → Interactive session: runs command (evidence: `Host/Sandbox.swift`)
- Interactive session → MicroVM lifecycle: connects control (evidence: `Host/Session.swift`)
- Interactive session → Terminal I/O: uses terminal I/O (evidence: `Host/Session.swift`)
- Interactive session → Wire protocol: exchanges frames (evidence: `Host/Session.swift`)
- MicroVM lifecycle → Wire protocol: uses port constants (evidence: `Host/MicroVM.swift`)
- Guest agent entry → Guest boot: boots as PID 1 (evidence: `agent/src/main.rs`)
- Guest agent entry → Control server: starts listener (evidence: `agent/src/main.rs`)
- Control server → Command execution: spawns command (evidence: `agent/src/serve.rs`)
- Control server → Guest networking: updates posture (evidence: `agent/src/serve.rs`)
- Control server → VSOCK transport: accepts connections (evidence: `agent/src/serve.rs`)
- Sandbox orchestration → Credential proxy: routes credentials (evidence: `Host/Sandbox.swift`)
- Sandbox orchestration → Host approvals: requests approval (evidence: `Host/Sandbox.swift`)
- Sandbox orchestration → Approved file import: dispatches file import (evidence: `Host/Sandbox.swift`)
- Sandbox orchestration → Clipboard and drag-drop: sets up clipboard (evidence: `Host/Sandbox.swift`)
- Sandbox orchestration → Port forwarding: starts forwarding (evidence: `Host/Sandbox.swift`)
- Sandbox orchestration → Persistent personal state: publishes state (evidence: `Host/Sandbox.swift`)
- VM provisioning → Persistent personal state: prepares state (evidence: `Host/Provisioning.swift`)
- Guest convenience tools → Host user: offers sandbox commands (evidence: `README.md`)
- Agent harness → Guest agent entry: invokes guest control
- Network toggle → Host approvals: requests network approval (evidence: `README.md`)
- Save command → Persistent personal state: persists packages (evidence: `README.md`)
