# andrewboldi/dibs architecture

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

- Interactive diagram: https://gitdiagram.com/andrewboldi/dibs
- Repository: https://github.com/andrewboldi/dibs

## Overview

dibs is a per-user Linux job scheduler that lets coding agents share one machine, especially its GPUs. An agent submits a command and CPU, RAM, GPU-memory, and time requirements through the CLI; the client contacts or starts the daemon, which plans against machine capacity, persists queue state, and launches eligible jobs in isolated scopes. The daemon also monitors resource use and enforces GPU reservations, while CLI views report queue status and historical sizing. The README documents agent setup, snapshots, and sleep/wake checkpointing; edges for those capabilities are shown only where the supplied index or documentation supports them.

Main entry points: [`src/dibs/daemon.py`](https://github.com/andrewboldi/dibs/blob/main/src/dibs/daemon.py) (Scheduler daemon), [`src/dibs/cli.py`](https://github.com/andrewboldi/dibs/blob/main/src/dibs/cli.py) (CLI commands), [`src/dibs/client.py`](https://github.com/andrewboldi/dibs/blob/main/src/dibs/client.py) (Daemon client), [`src/dibs/guard.py`](https://github.com/andrewboldi/dibs/blob/main/src/dibs/guard.py) (Resource guard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Agent entry"]
  node_cli["CLI commands<br/>[cli.py]"]
  node_client["Daemon client<br/>[client.py]"]
end

subgraph group_scheduler["Scheduling core"]
  node_daemon["Scheduler daemon<br/>[daemon.py]"]
  node_model["Job model<br/>[model.py]"]
  node_planner["Queue planner<br/>[planner.py]"]
  node_store[("SQLite state<br/>[store.py]")]
  node_paths["State paths<br/>[paths.py]"]
end

subgraph group_execution["Job execution"]
  node_launcher["Job launcher<br/>[launcher.py]"]
  node_snapshot["Code snapshots<br/>[snapshot.py]"]
  node_suspend["Sleep checkpointing<br/>[suspend.py]"]
  node_cudapause["CUDA checkpoint API<br/>[cudapause.py]"]
end

subgraph group_monitoring["Resource monitoring"]
  node_machine["Machine capacity<br/>[machine.py]"]
  node_gpu["GPU inventory<br/>[gpu.py]"]
  node_guard["Resource guard<br/>[guard.py]"]
  node_procs["Process inspection<br/>[procs.py]"]
end

subgraph group_experience["Agent experience"]
  node_render["Queue and usage views<br/>[render.py]"]
  node_agents["Agent setup<br/>[agents.py]"]
  node_instructions["Agent instructions<br/>[instructions.py]"]
end

node_agent(("Coding agent"))
node_systemd["systemd scopes"]
node_gpu_drivers["NVIDIA / AMD drivers"]

node_agent -->|"submits jobs"| node_cli
node_cli -->|"sends requests"| node_client
node_client -->|"contacts or starts"| node_daemon
node_daemon -->|"persists queue"| node_store
node_daemon -->|"resolves jobs"| node_model
node_daemon -->|"plans queue"| node_planner
node_daemon -->|"reads capacity"| node_machine
node_daemon -->|"samples GPUs"| node_gpu
node_daemon -->|"starts jobs"| node_launcher
node_launcher -->|"creates scopes"| node_systemd
node_daemon -->|"coordinates enforcement"| node_guard
node_guard -->|"inspects processes"| node_procs
node_guard -->|"checks GPU use"| node_gpu
node_daemon -->|"prepares snapshots"| node_snapshot
node_daemon -->|"handles sleep"| node_suspend
node_suspend -->|"checkpoints memory"| node_cudapause
node_gpu -->|"queries devices"| node_gpu_drivers
node_cli -->|"renders output"| node_render
node_cli -->|"configures agents"| node_agents
node_agents -->|"writes guidance"| node_instructions
node_daemon -->|"uses state locations"| node_paths
node_client -->|"locates socket"| node_paths

click node_cli "https://github.com/andrewboldi/dibs/blob/main/src/dibs/cli.py"
click node_client "https://github.com/andrewboldi/dibs/blob/main/src/dibs/client.py"
click node_daemon "https://github.com/andrewboldi/dibs/blob/main/src/dibs/daemon.py"
click node_model "https://github.com/andrewboldi/dibs/blob/main/src/dibs/model.py"
click node_planner "https://github.com/andrewboldi/dibs/blob/main/src/dibs/planner.py"
click node_store "https://github.com/andrewboldi/dibs/blob/main/src/dibs/store.py"
click node_machine "https://github.com/andrewboldi/dibs/blob/main/src/dibs/machine.py"
click node_gpu "https://github.com/andrewboldi/dibs/blob/main/src/dibs/gpu.py"
click node_guard "https://github.com/andrewboldi/dibs/blob/main/src/dibs/guard.py"
click node_procs "https://github.com/andrewboldi/dibs/blob/main/src/dibs/procs.py"
click node_launcher "https://github.com/andrewboldi/dibs/blob/main/src/dibs/launcher.py"
click node_snapshot "https://github.com/andrewboldi/dibs/blob/main/src/dibs/snapshot.py"
click node_suspend "https://github.com/andrewboldi/dibs/blob/main/src/dibs/suspend.py"
click node_cudapause "https://github.com/andrewboldi/dibs/blob/main/src/dibs/cudapause.py"
click node_render "https://github.com/andrewboldi/dibs/blob/main/src/dibs/render.py"
click node_agents "https://github.com/andrewboldi/dibs/blob/main/src/dibs/agents.py"
click node_instructions "https://github.com/andrewboldi/dibs/blob/main/src/dibs/instructions.py"
click node_paths "https://github.com/andrewboldi/dibs/blob/main/src/dibs/paths.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_client toneBlue
class node_daemon,node_model,node_planner,node_store,node_paths toneAmber
class node_launcher,node_snapshot,node_suspend,node_cudapause toneMint
class node_machine,node_gpu,node_guard,node_procs toneRose
class node_render,node_agents,node_instructions,node_agent,node_systemd,node_gpu_drivers toneIndigo
```

## Components

### Agent entry

- [CLI commands](https://github.com/andrewboldi/dibs/blob/main/src/dibs/cli.py): `src/dibs/cli.py`
- [Daemon client](https://github.com/andrewboldi/dibs/blob/main/src/dibs/client.py): `src/dibs/client.py`

### Scheduling core

- [Scheduler daemon](https://github.com/andrewboldi/dibs/blob/main/src/dibs/daemon.py): `src/dibs/daemon.py`
- [Job model](https://github.com/andrewboldi/dibs/blob/main/src/dibs/model.py): `src/dibs/model.py`
- [Queue planner](https://github.com/andrewboldi/dibs/blob/main/src/dibs/planner.py): `src/dibs/planner.py`
- [SQLite state](https://github.com/andrewboldi/dibs/blob/main/src/dibs/store.py): `src/dibs/store.py`
- [State paths](https://github.com/andrewboldi/dibs/blob/main/src/dibs/paths.py): `src/dibs/paths.py`

### Job execution

- [Job launcher](https://github.com/andrewboldi/dibs/blob/main/src/dibs/launcher.py): `src/dibs/launcher.py`
- [Code snapshots](https://github.com/andrewboldi/dibs/blob/main/src/dibs/snapshot.py): `src/dibs/snapshot.py`
- [Sleep checkpointing](https://github.com/andrewboldi/dibs/blob/main/src/dibs/suspend.py): `src/dibs/suspend.py`
- [CUDA checkpoint API](https://github.com/andrewboldi/dibs/blob/main/src/dibs/cudapause.py): `src/dibs/cudapause.py`

### Resource monitoring

- [Machine capacity](https://github.com/andrewboldi/dibs/blob/main/src/dibs/machine.py): `src/dibs/machine.py`
- [GPU inventory](https://github.com/andrewboldi/dibs/blob/main/src/dibs/gpu.py): `src/dibs/gpu.py`
- [Resource guard](https://github.com/andrewboldi/dibs/blob/main/src/dibs/guard.py): `src/dibs/guard.py`
- [Process inspection](https://github.com/andrewboldi/dibs/blob/main/src/dibs/procs.py): `src/dibs/procs.py`

### Agent experience

- [Queue and usage views](https://github.com/andrewboldi/dibs/blob/main/src/dibs/render.py): `src/dibs/render.py`
- [Agent setup](https://github.com/andrewboldi/dibs/blob/main/src/dibs/agents.py): `src/dibs/agents.py`
- [Agent instructions](https://github.com/andrewboldi/dibs/blob/main/src/dibs/instructions.py): `src/dibs/instructions.py`

### Other components

- **Coding agent**
- **systemd scopes**
- **NVIDIA / AMD drivers**

## Connections

- Coding agent → CLI commands: submits jobs (evidence: `README.md`)
- CLI commands → Daemon client: sends requests (evidence: `src/dibs/cli.py`)
- Daemon client → Scheduler daemon: contacts or starts (evidence: `README.md`)
- Scheduler daemon → SQLite state: persists queue (evidence: `src/dibs/daemon.py`)
- Scheduler daemon → Job model: resolves jobs (evidence: `src/dibs/daemon.py`)
- Scheduler daemon → Queue planner: plans queue (evidence: `src/dibs/daemon.py`)
- Scheduler daemon → Machine capacity: reads capacity (evidence: `src/dibs/daemon.py`)
- Scheduler daemon → GPU inventory: samples GPUs (evidence: `src/dibs/daemon.py`)
- Scheduler daemon → Job launcher: starts jobs (evidence: `src/dibs/daemon.py`)
- Job launcher → systemd scopes: creates scopes (evidence: `README.md`)
- Scheduler daemon → Resource guard: coordinates enforcement (evidence: `src/dibs/daemon.py`)
- Resource guard → Process inspection: inspects processes (evidence: `src/dibs/guard.py`)
- Resource guard → GPU inventory: checks GPU use (evidence: `src/dibs/guard.py`)
- Scheduler daemon → Code snapshots: prepares snapshots (evidence: `src/dibs/daemon.py`)
- Scheduler daemon → Sleep checkpointing: handles sleep (evidence: `src/dibs/daemon.py`)
- Sleep checkpointing → CUDA checkpoint API: checkpoints memory (evidence: `src/dibs/suspend.py`)
- GPU inventory → NVIDIA / AMD drivers: queries devices (evidence: `README.md`)
- CLI commands → Queue and usage views: renders output (evidence: `src/dibs/cli.py`)
- CLI commands → Agent setup: configures agents (evidence: `src/dibs/cli.py`)
- Agent setup → Agent instructions: writes guidance (evidence: `src/dibs/agents.py`)
- Scheduler daemon → State paths: uses state locations (evidence: `src/dibs/daemon.py`)
- Daemon client → State paths: locates socket (evidence: `src/dibs/client.py`)
