# tombl/distro architecture

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

- Interactive diagram: https://gitdiagram.com/tombl/distro
- Repository: https://github.com/tombl/distro

## Overview

This repository provides a Linux-on-WebAssembly runtime, guest-side syscall access, and distro guest components. A typical workflow boots a machine with kernel plugins and devices, runs guest code, then exposes guest process, filesystem, or network operations through the guest API. The excerpts establish kernel worker/platform relationships and guest client/transport/syscall relationships; several major subsystems are present in the tree but not sampled, so their internal links are omitted or marked unverified.

Main entry points: [`packages/linux-guest/src/syscalls.ts`](https://github.com/tombl/distro/blob/main/packages/linux-guest/src/syscalls.ts) (Syscall table), [`packages/kernel/src/worker.ts`](https://github.com/tombl/distro/blob/main/packages/kernel/src/worker.ts) (Wasm workers), [`packages/linux-guest/src/client.ts`](https://github.com/tombl/distro/blob/main/packages/linux-guest/src/client.ts) (Guest client), [`packages/kernel/src/wasm.ts`](https://github.com/tombl/distro/blob/main/packages/kernel/src/wasm.ts) (Wasm loading)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_kernel["Kernel runtime"]
  node_runner["Machine runner<br/>[run.ts]"]
  node_worker["Wasm workers<br/>[worker.ts]"]
  node_platform["Platform adapter<br/>[platform.ts]"]
  node_wasm["Wasm loading<br/>[wasm.ts]"]
  node_wasmbin["Wasm inspection<br/>[wasm_binary.ts]"]
  node_endpoint["Worker endpoints<br/>[endpoint.ts]"]
end

subgraph group_guestapi["Guest interface"]
  node_abi["Guest ABI<br/>[abi.ts]"]
  node_conn["Guest transport<br/>[conn.ts]"]
  node_syscalls["Syscall table<br/>[syscalls.ts]"]
  node_client["Guest client<br/>[client.ts]"]
  node_file["File handles<br/>[file.ts]"]
  node_process["Child processes<br/>[process.ts]"]
  node_network["Guest networking<br/>[network.ts]"]
  node_http["HTTP framing<br/>[http.ts]"]
  node_fetchhandler["Guest fetch bridge"]
end

subgraph group_devices["Devices and storage"]
  node_virtdevice["Virtio devices<br/>[device.ts]"]
  node_virtfs["Virtio filesystem<br/>[fs.ts]"]
  node_virtqueue["Virtio queues<br/>[queue.ts]"]
  node_block["Block device<br/>[block.ts]"]
  node_net["Virtual networking<br/>[net.ts]"]
  node_vsock["Guest vsock<br/>[vsock.ts]"]
  node_diskworker["Disk worker<br/>[disk-worker.ts]"]
  node_opfs["Browser disk worker"]
end

subgraph group_distro["Linux distro"]
  node_agent["Guest syscall agent<br/>[agent.c]"]
  node_init["Guest init<br/>[init.c]"]
end

node_worker -->|"uses"| node_platform
node_worker -->|"invokes"| node_wasm
node_worker -->|"inspects"| node_wasmbin
node_worker -->|"listens on"| node_endpoint
node_wasm -->|"loads through"| node_platform
node_wasm -->|"reads"| node_wasmbin
node_virtfs -->|"uses"| node_virtdevice
node_virtfs -->|"uses"| node_virtqueue
node_diskworker -->|"configures"| node_block
node_opfs -->|"configures"| node_block
node_client -->|"opens sessions"| node_conn
node_client -->|"invokes"| node_syscalls
node_client -->|"creates"| node_file
node_client -->|"creates"| node_process
node_conn -.->|"connects via"| node_vsock
node_syscalls -->|"exchanges over"| node_conn
node_syscalls -->|"encodes with"| node_abi
node_file -->|"invokes"| node_syscalls
node_process -->|"invokes"| node_syscalls
node_fetchhandler -->|"frames traffic"| node_http
node_fetchhandler -->|"uses"| node_network
node_runner -.->|"boots through"| node_worker
node_agent -.->|"serves protocol"| node_syscalls
node_init -.->|"starts"| node_agent

click node_runner "https://github.com/tombl/distro/blob/main/packages/runner/src/run.ts"
click node_worker "https://github.com/tombl/distro/blob/main/packages/kernel/src/worker.ts"
click node_platform "https://github.com/tombl/distro/blob/main/packages/kernel/src/platform.ts"
click node_wasm "https://github.com/tombl/distro/blob/main/packages/kernel/src/wasm.ts"
click node_wasmbin "https://github.com/tombl/distro/blob/main/packages/kernel/src/wasm_binary.ts"
click node_endpoint "https://github.com/tombl/distro/blob/main/packages/kernel/src/endpoint.ts"
click node_virtdevice "https://github.com/tombl/distro/blob/main/packages/kernel/src/virtio/device.ts"
click node_virtfs "https://github.com/tombl/distro/blob/main/packages/kernel/src/virtio/fs.ts"
click node_virtqueue "https://github.com/tombl/distro/blob/main/packages/kernel/src/virtio/queue.ts"
click node_block "https://github.com/tombl/distro/blob/main/packages/kernel/src/virtio/block.ts"
click node_net "https://github.com/tombl/distro/blob/main/packages/kernel/src/virtio/net.ts"
click node_vsock "https://github.com/tombl/distro/blob/main/packages/kernel/src/virtio/vsock.ts"
click node_diskworker "https://github.com/tombl/distro/blob/main/packages/runner/src/disk-worker.ts"
click node_opfs "https://github.com/tombl/distro/blob/main/apps/site/opfs-disk-worker.js"
click node_abi "https://github.com/tombl/distro/blob/main/packages/linux-guest/src/abi.ts"
click node_conn "https://github.com/tombl/distro/blob/main/packages/linux-guest/src/conn.ts"
click node_syscalls "https://github.com/tombl/distro/blob/main/packages/linux-guest/src/syscalls.ts"
click node_client "https://github.com/tombl/distro/blob/main/packages/linux-guest/src/client.ts"
click node_file "https://github.com/tombl/distro/blob/main/packages/linux-guest/src/file.ts"
click node_process "https://github.com/tombl/distro/blob/main/packages/linux-guest/src/process.ts"
click node_network "https://github.com/tombl/distro/blob/main/packages/linux-guest/src/network.ts"
click node_http "https://github.com/tombl/distro/blob/main/packages/linux-guest/src/http.ts"
click node_fetchhandler "https://github.com/tombl/distro/blob/main/packages/linux-guest/src/guest-fetch-handler.ts"
click node_agent "https://github.com/tombl/distro/blob/main/distro/guest-agent/agent.c"
click node_init "https://github.com/tombl/distro/blob/main/distro/basic-init/init.c"

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_runner,node_worker,node_platform,node_wasm,node_wasmbin,node_endpoint toneBlue
class node_abi,node_conn,node_syscalls,node_client,node_file,node_process,node_network,node_http,node_fetchhandler toneAmber
class node_virtdevice,node_virtfs,node_virtqueue,node_block,node_net,node_vsock,node_diskworker,node_opfs toneMint
class node_agent,node_init toneRose
```

## Components

### Kernel runtime

- [Machine runner](https://github.com/tombl/distro/blob/main/packages/runner/src/run.ts): `packages/runner/src/run.ts`
- [Wasm workers](https://github.com/tombl/distro/blob/main/packages/kernel/src/worker.ts): `packages/kernel/src/worker.ts`
- [Platform adapter](https://github.com/tombl/distro/blob/main/packages/kernel/src/platform.ts): `packages/kernel/src/platform.ts`
- [Wasm loading](https://github.com/tombl/distro/blob/main/packages/kernel/src/wasm.ts): `packages/kernel/src/wasm.ts`
- [Wasm inspection](https://github.com/tombl/distro/blob/main/packages/kernel/src/wasm_binary.ts): `packages/kernel/src/wasm_binary.ts`
- [Worker endpoints](https://github.com/tombl/distro/blob/main/packages/kernel/src/endpoint.ts): `packages/kernel/src/endpoint.ts`

### Guest interface

- [Guest ABI](https://github.com/tombl/distro/blob/main/packages/linux-guest/src/abi.ts): `packages/linux-guest/src/abi.ts`
- [Guest transport](https://github.com/tombl/distro/blob/main/packages/linux-guest/src/conn.ts): `packages/linux-guest/src/conn.ts`
- [Syscall table](https://github.com/tombl/distro/blob/main/packages/linux-guest/src/syscalls.ts): `packages/linux-guest/src/syscalls.ts`
- [Guest client](https://github.com/tombl/distro/blob/main/packages/linux-guest/src/client.ts): `packages/linux-guest/src/client.ts`
- [File handles](https://github.com/tombl/distro/blob/main/packages/linux-guest/src/file.ts): `packages/linux-guest/src/file.ts`
- [Child processes](https://github.com/tombl/distro/blob/main/packages/linux-guest/src/process.ts): `packages/linux-guest/src/process.ts`
- [Guest networking](https://github.com/tombl/distro/blob/main/packages/linux-guest/src/network.ts): `packages/linux-guest/src/network.ts`
- [HTTP framing](https://github.com/tombl/distro/blob/main/packages/linux-guest/src/http.ts): `packages/linux-guest/src/http.ts`
- [Guest fetch bridge](https://github.com/tombl/distro/blob/main/packages/linux-guest/src/guest-fetch-handler.ts): `packages/linux-guest/src/guest-fetch-handler.ts`

### Devices and storage

- [Virtio devices](https://github.com/tombl/distro/blob/main/packages/kernel/src/virtio/device.ts): `packages/kernel/src/virtio/device.ts`
- [Virtio filesystem](https://github.com/tombl/distro/blob/main/packages/kernel/src/virtio/fs.ts): `packages/kernel/src/virtio/fs.ts`
- [Virtio queues](https://github.com/tombl/distro/blob/main/packages/kernel/src/virtio/queue.ts): `packages/kernel/src/virtio/queue.ts`
- [Block device](https://github.com/tombl/distro/blob/main/packages/kernel/src/virtio/block.ts): `packages/kernel/src/virtio/block.ts`
- [Virtual networking](https://github.com/tombl/distro/blob/main/packages/kernel/src/virtio/net.ts): `packages/kernel/src/virtio/net.ts`
- [Guest vsock](https://github.com/tombl/distro/blob/main/packages/kernel/src/virtio/vsock.ts): `packages/kernel/src/virtio/vsock.ts`
- [Disk worker](https://github.com/tombl/distro/blob/main/packages/runner/src/disk-worker.ts): `packages/runner/src/disk-worker.ts`
- [Browser disk worker](https://github.com/tombl/distro/blob/main/apps/site/opfs-disk-worker.js): `apps/site/opfs-disk-worker.js`

### Linux distro

- [Guest syscall agent](https://github.com/tombl/distro/blob/main/distro/guest-agent/agent.c): `distro/guest-agent/agent.c`
- [Guest init](https://github.com/tombl/distro/blob/main/distro/basic-init/init.c): `distro/basic-init/init.c`

## Connections

- Wasm workers → Platform adapter: uses (evidence: `packages/kernel/src/worker.ts`)
- Wasm workers → Wasm loading: invokes (evidence: `packages/kernel/src/worker.ts`)
- Wasm workers → Wasm inspection: inspects (evidence: `packages/kernel/src/worker.ts`)
- Wasm workers → Worker endpoints: listens on (evidence: `packages/kernel/src/worker.ts`)
- Wasm loading → Platform adapter: loads through (evidence: `packages/kernel/src/wasm.ts`)
- Wasm loading → Wasm inspection: reads (evidence: `packages/kernel/src/wasm.ts`)
- Virtio filesystem → Virtio devices: uses (evidence: `packages/kernel/src/virtio/fs.ts`)
- Virtio filesystem → Virtio queues: uses (evidence: `packages/kernel/src/virtio/fs.ts`)
- Disk worker → Block device: configures (evidence: `packages/runner/src/disk-worker.ts`)
- Browser disk worker → Block device: configures (evidence: `apps/site/opfs-disk-worker.js`)
- Guest client → Guest transport: opens sessions (evidence: `packages/linux-guest/src/client.ts`)
- Guest client → Syscall table: invokes (evidence: `packages/linux-guest/src/client.ts`)
- Guest client → File handles: creates (evidence: `packages/linux-guest/src/client.ts`)
- Guest client → Child processes: creates (evidence: `packages/linux-guest/src/client.ts`)
- Guest transport → Guest vsock: connects via
- Syscall table → Guest transport: exchanges over (evidence: `packages/linux-guest/src/syscalls.ts`)
- Syscall table → Guest ABI: encodes with (evidence: `packages/linux-guest/src/syscalls.ts`)
- File handles → Syscall table: invokes (evidence: `packages/linux-guest/src/file.ts`)
- Child processes → Syscall table: invokes (evidence: `packages/linux-guest/src/process.ts`)
- Guest fetch bridge → HTTP framing: frames traffic (evidence: `packages/linux-guest/src/guest-fetch-handler.ts`)
- Guest fetch bridge → Guest networking: uses (evidence: `packages/linux-guest/src/guest-fetch-handler.ts`)
- Machine runner → Wasm workers: boots through
- Guest syscall agent → Syscall table: serves protocol
- Guest init → Guest syscall agent: starts
