# hedaas-code/pyvdisk architecture

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

- Interactive diagram: https://gitdiagram.com/hedaas-code/pyvdisk
- Repository: https://github.com/hedaas-code/pyvdisk

## Overview

PyVDisk is a single-machine data and execution platform centered on a unified DataDisk image, with VScript as its safe workflow language. The main user path is an application, CLI, or agent using the API to access a DataDisk; scripts can be parsed and run through VScript, while storage, transaction recovery, execution queues, and capability checks provide supporting services. README statements establish the broad product relationships; source-index references and excerpts support the indicated VScript and storage-layer calls. Unsampled subsystem internals are represented at their documented boundaries.

Main entry points: [`pyvdisk/infrastructure/disk.py`](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/infrastructure/disk.py) (DataDisk), [`pyvdisk/vscript/runtime.py`](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vscript/runtime.py) (Interpreter), [`pyvdisk/execution.py`](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/execution.py) (ExecutionService), [`pyvdisk/cli.py`](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/cli.py) (CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["Interfaces and governance"]
  node_cli["CLI<br/>[cli.py]"]
  node_sandbox["AgentSandbox<br/>[sandbox.py]"]
  node_capabilities["Scoped capabilities<br/>[capabilities.py]"]
  node_contracts["Execution contracts<br/>[contracts.py]"]
end

subgraph group_storage["DataDisk storage"]
  node_datadisk["DataDisk<br/>[disk.py]"]
  node_vfs["Path filesystem<br/>[vfs.py]"]
  node_fs["Virtual filesystem<br/>[fs.py]"]
  node_virtualdisk[("Block image<br/>[disk.py]")]
  node_volume[("Volume / mirror<br/>[volume.py]")]
  node_vector[("Vector memory<br/>[vector_disk.py]")]
  node_eventlog[("Event log<br/>[log_disk.py]")]
  node_wal[("Write-ahead log<br/>[wal.py]")]
  node_checkpoint[("Checkpoints<br/>[checkpoint.py]")]
end

subgraph group_execution["Durable execution"]
  node_execution["ExecutionService<br/>[execution.py]"]
  node_queue["Durable queue<br/>[queue.py]"]
  node_operations[("Operation records<br/>[operations.py]")]
  node_runstate[("Run state<br/>[run_state.py]")]
end

subgraph group_vscript["VScript runtime"]
  node_lexer["Lexer<br/>[lexer.py]"]
  node_parser["Parser / AST<br/>[parser.py]"]
  node_runtime["Interpreter<br/>[runtime.py]"]
  node_stdlib["Capability stdlib<br/>[stdlib.py]"]
  node_host["Host access<br/>[host.py]"]
  node_audit[("Audit records<br/>[audit.py]")]
  node_cron["Cron / triggers<br/>[cron.py]"]
end

node_application(("Application / agent"))

node_application -->|"invokes"| node_cli
node_application -->|"uses tools"| node_sandbox
node_sandbox -->|"scopes access"| node_capabilities
node_sandbox -->|"wraps"| node_datadisk
node_cli -->|"opens image"| node_datadisk
node_cli -->|"runs scripts"| node_runtime
node_datadisk -->|"uses"| node_vfs
node_datadisk -->|"uses"| node_vector
node_datadisk -->|"uses"| node_eventlog
node_vfs -->|"delegates"| node_fs
node_fs -->|"reads / writes"| node_virtualdisk
node_vfs -->|"opens volume"| node_volume
node_datadisk -->|"records transactions"| node_wal
node_datadisk -->|"uses checkpoints"| node_checkpoint
node_execution -->|"dispatches work"| node_queue
node_execution -->|"tracks operations"| node_operations
node_execution -->|"updates state"| node_runstate
node_execution -->|"checks access"| node_capabilities
node_lexer -->|"provides tokens"| node_parser
node_runtime -->|"parses source"| node_parser
node_runtime -->|"calls native functions"| node_stdlib
node_stdlib -->|"creates host module"| node_host
node_runtime -->|"emits run record"| node_audit
node_runtime -->|"uses shared WAL"| node_wal
node_cron -.->|"schedules scripts"| node_runtime
node_application -->|"uses Python API"| node_datadisk
node_datadisk -->|"offers scoped access"| node_capabilities

click node_cli "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/cli.py"
click node_sandbox "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/sandbox.py"
click node_capabilities "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/infrastructure/capabilities.py"
click node_contracts "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/contracts.py"
click node_datadisk "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/infrastructure/disk.py"
click node_vfs "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vfs.py"
click node_fs "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/fs.py"
click node_virtualdisk "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/disk.py"
click node_volume "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/volume.py"
click node_vector "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vector_disk.py"
click node_eventlog "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/log_disk.py"
click node_wal "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/infrastructure/wal.py"
click node_checkpoint "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/infrastructure/checkpoint.py"
click node_execution "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/execution.py"
click node_queue "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/infrastructure/queue.py"
click node_operations "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/infrastructure/operations.py"
click node_runstate "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/infrastructure/run_state.py"
click node_lexer "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vscript/lexer.py"
click node_parser "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vscript/parser.py"
click node_runtime "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vscript/runtime.py"
click node_stdlib "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vscript/stdlib.py"
click node_host "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vscript/host.py"
click node_audit "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vscript/audit.py"
click node_cron "https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vscript/cron.py"

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_capabilities,node_contracts toneBlue
class node_datadisk,node_vfs,node_fs,node_virtualdisk,node_volume,node_vector,node_eventlog,node_wal,node_checkpoint toneAmber
class node_execution,node_queue,node_operations,node_runstate toneMint
class node_lexer,node_parser,node_runtime,node_stdlib,node_host,node_audit,node_cron toneRose
class node_application toneIndigo
```

## Components

### Interfaces and governance

- [CLI](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/cli.py): `pyvdisk/cli.py`
- [AgentSandbox](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/sandbox.py): `pyvdisk/sandbox.py`
- [Scoped capabilities](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/infrastructure/capabilities.py): `pyvdisk/infrastructure/capabilities.py`
- [Execution contracts](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/contracts.py): `pyvdisk/contracts.py`

### DataDisk storage

- [DataDisk](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/infrastructure/disk.py): `pyvdisk/infrastructure/disk.py`
- [Path filesystem](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vfs.py): `pyvdisk/vfs.py`
- [Virtual filesystem](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/fs.py): `pyvdisk/fs.py`
- [Block image](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/disk.py): `pyvdisk/disk.py`
- [Volume / mirror](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/volume.py): `pyvdisk/volume.py`
- [Vector memory](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vector_disk.py): `pyvdisk/vector_disk.py`
- [Event log](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/log_disk.py): `pyvdisk/log_disk.py`
- [Write-ahead log](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/infrastructure/wal.py): `pyvdisk/infrastructure/wal.py`
- [Checkpoints](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/infrastructure/checkpoint.py): `pyvdisk/infrastructure/checkpoint.py`

### Durable execution

- [ExecutionService](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/execution.py): `pyvdisk/execution.py`
- [Durable queue](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/infrastructure/queue.py): `pyvdisk/infrastructure/queue.py`
- [Operation records](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/infrastructure/operations.py): `pyvdisk/infrastructure/operations.py`
- [Run state](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/infrastructure/run_state.py): `pyvdisk/infrastructure/run_state.py`

### VScript runtime

- [Lexer](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vscript/lexer.py): `pyvdisk/vscript/lexer.py`
- [Parser / AST](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vscript/parser.py): `pyvdisk/vscript/parser.py`
- [Interpreter](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vscript/runtime.py): `pyvdisk/vscript/runtime.py`
- [Capability stdlib](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vscript/stdlib.py): `pyvdisk/vscript/stdlib.py`
- [Host access](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vscript/host.py): `pyvdisk/vscript/host.py`
- [Audit records](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vscript/audit.py): `pyvdisk/vscript/audit.py`
- [Cron / triggers](https://github.com/hedaas-code/pyvdisk/blob/master/pyvdisk/vscript/cron.py): `pyvdisk/vscript/cron.py`

### Other components

- **Application / agent**

## Connections

- Application / agent → CLI: invokes (evidence: `README.md`)
- Application / agent → AgentSandbox: uses tools (evidence: `README.md`)
- AgentSandbox → Scoped capabilities: scopes access (evidence: `pyvdisk/sandbox.py`)
- AgentSandbox → DataDisk: wraps (evidence: `README.md`)
- CLI → DataDisk: opens image (evidence: `pyvdisk/cli.py`)
- CLI → Interpreter: runs scripts (evidence: `pyvdisk/cli.py`)
- DataDisk → Path filesystem: uses (evidence: `pyvdisk/infrastructure/disk.py`)
- DataDisk → Vector memory: uses (evidence: `pyvdisk/infrastructure/disk.py`)
- DataDisk → Event log: uses (evidence: `pyvdisk/infrastructure/disk.py`)
- Path filesystem → Virtual filesystem: delegates (evidence: `pyvdisk/vfs.py`)
- Virtual filesystem → Block image: reads / writes (evidence: `pyvdisk/fs.py`)
- Path filesystem → Volume / mirror: opens volume (evidence: `pyvdisk/vfs.py`)
- DataDisk → Write-ahead log: records transactions (evidence: `pyvdisk/infrastructure/disk.py`)
- DataDisk → Checkpoints: uses checkpoints (evidence: `pyvdisk/infrastructure/disk.py`)
- ExecutionService → Durable queue: dispatches work (evidence: `README.md`)
- ExecutionService → Operation records: tracks operations (evidence: `README.md`)
- ExecutionService → Run state: updates state (evidence: `README.md`)
- ExecutionService → Scoped capabilities: checks access (evidence: `pyvdisk/execution.py`)
- Lexer → Parser / AST: provides tokens (evidence: `pyvdisk/vscript/parser.py`)
- Interpreter → Parser / AST: parses source (evidence: `pyvdisk/vscript/runtime.py`)
- Interpreter → Capability stdlib: calls native functions (evidence: `pyvdisk/vscript/runtime.py`)
- Capability stdlib → Host access: creates host module (evidence: `pyvdisk/vscript/stdlib.py`)
- Interpreter → Audit records: emits run record (evidence: `pyvdisk/vscript/runtime.py`)
- Interpreter → Write-ahead log: uses shared WAL (evidence: `README.md`)
- Cron / triggers → Interpreter: schedules scripts
- Application / agent → DataDisk: uses Python API (evidence: `README.md`)
- DataDisk → Scoped capabilities: offers scoped access (evidence: `README.md`)
