# gu1p/tak architecture

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

- Interactive diagram: https://gitdiagram.com/gu1p/tak
- Repository: https://github.com/gu1p/tak

## Overview

Tak is a workspace task orchestrator with a separate local daemon that owns run scheduling and execution. The principal workflow loads and resolves workspace tasks, submits a run to the daemon, executes local or remotely placed work, and exposes persisted status and outputs. The README documents additional Makefile, graph-viewing, remote-management, and update capabilities. Source excerpts are limited, so edges reflect documented workflow or directly visible behavior; uncertain internal wiring is omitted.

Main entry points: [`crates/tak/src/main.rs`](https://github.com/gu1p/tak/blob/main/crates/tak/src/main.rs) (Tak CLI), [`crates/takd/src/daemon/attempt_coordinator.rs`](https://github.com/gu1p/tak/blob/main/crates/takd/src/daemon/attempt_coordinator.rs) (Attempt coordinator), [`crates/tak-proto/src/local_daemon.rs`](https://github.com/gu1p/tak/blob/main/crates/tak-proto/src/local_daemon.rs) (Daemon protocol client), [`crates/tak/src/cli/daemon_run/resolve.rs`](https://github.com/gu1p/tak/blob/main/crates/tak/src/cli/daemon_run/resolve.rs) (Run resolution)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_author["Authoring and planning"]
  node_loader["Workspace loader<br/>[mod.rs]"]
  node_make["Make integration<br/>[run_make.rs]"]
  node_planner["Task model and planner<br/>[planner.rs]"]
end

subgraph group_client["CLI and client"]
  node_cli["Tak CLI<br/>[main.rs]"]
  node_resolve["Run resolution<br/>[resolve.rs]"]
  node_submit["Run submission<br/>[submission.rs]"]
  node_clientproto["Daemon protocol client<br/>[local_daemon.rs]"]
  node_runs["Run history and outputs<br/>[runs_cli.rs]"]
  node_dashboard["Run dashboard<br/>[run_dashboard.rs]"]
end

subgraph group_daemon["Daemon coordination"]
  node_daemon["Local takd<br/>[agent.rs]"]
  node_coordinator["Attempt coordinator"]
  node_leases["Resource leases"]
  node_peers["Peer placement<br/>[peer_manager.rs]"]
  node_runstate[("Persisted run state<br/>[durable_state.rs]")]
end

subgraph group_execution["Execution"]
  node_worker["Worker runtime<br/>[worker_runtime.rs]"]
  node_steps["Step execution<br/>[step_execution.rs]"]
  node_container["Container runtime<br/>[mod.rs]"]
  node_remote["Remote worker<br/>[remote_worker.rs]"]
  node_docker["Container engine"]
end

subgraph group_operations["Operations"]
  node_remotecli["Remote commands<br/>[mod.rs]"]
  node_graph["Graph viewer<br/>[server.rs]"]
  node_update["Self-update<br/>[lib.rs]"]
end

node_user(("Engineer"))
node_workspace["TASKS.py / Makefile"]
node_remoteagents(("Remote agents"))
node_containerengine(("Docker / Podman"))

node_user -->|"invokes"| node_cli
node_workspace -->|"loads definitions"| node_loader
node_workspace -->|"provides Makefile"| node_make
node_cli -->|"loads workspace"| node_loader
node_cli -->|"submits goal"| node_make
node_loader -->|"produces task model"| node_planner
node_cli -->|"resolves targets"| node_resolve
node_resolve -->|"validates graph"| node_planner
node_resolve -->|"passes resolved run"| node_submit
node_submit -->|"encodes request"| node_clientproto
node_clientproto -->|"sends run request"| node_daemon
node_daemon -->|"coordinates attempts"| node_coordinator
node_coordinator -->|"acquires resources"| node_leases
node_coordinator -->|"selects placement"| node_peers
node_coordinator -->|"persists run state"| node_runstate
node_coordinator -->|"dispatches local work"| node_worker
node_worker -->|"runs steps"| node_steps
node_steps -.->|"uses container runtime"| node_container
node_container -->|"selects engine"| node_docker
node_docker -->|"probes engine"| node_containerengine
node_coordinator -.->|"dispatches remote work"| node_remote
node_remote -.->|"executes remotely"| node_remoteagents
node_clientproto -->|"retrieves run data"| node_runs
node_runs -->|"reads persisted state"| node_runstate
node_runs -->|"attaches events"| node_dashboard
node_user -->|"manages remotes"| node_remotecli
node_remotecli -->|"queries daemon"| node_clientproto
node_user -->|"opens graph UI"| node_graph
node_cli -->|"serves task graph"| node_graph
node_user -->|"requests update"| node_update
node_cli -->|"runs update flow"| node_update

click node_cli "https://github.com/gu1p/tak/blob/main/crates/tak/src/main.rs"
click node_loader "https://github.com/gu1p/tak/blob/main/crates/tak-loader/src/loader/mod.rs"
click node_make "https://github.com/gu1p/tak/blob/main/crates/tak-make/src/application/run_make.rs"
click node_planner "https://github.com/gu1p/tak/blob/main/crates/tak-core/src/planner.rs"
click node_resolve "https://github.com/gu1p/tak/blob/main/crates/tak/src/cli/daemon_run/resolve.rs"
click node_submit "https://github.com/gu1p/tak/blob/main/crates/tak/src/cli/daemon_run/submission.rs"
click node_clientproto "https://github.com/gu1p/tak/blob/main/crates/tak-proto/src/local_daemon.rs"
click node_daemon "https://github.com/gu1p/tak/blob/main/crates/takd/src/agent.rs"
click node_coordinator "https://github.com/gu1p/tak/blob/main/crates/takd/src/daemon/attempt_coordinator.rs"
click node_leases "https://github.com/gu1p/tak/blob/main/crates/takd/src/daemon/lease/manager_public_methods.rs"
click node_peers "https://github.com/gu1p/tak/blob/main/crates/takd/src/daemon/peer_manager.rs"
click node_worker "https://github.com/gu1p/tak/blob/main/crates/tak-exec/src/worker_runtime.rs"
click node_steps "https://github.com/gu1p/tak/blob/main/crates/tak-exec/src/step_execution.rs"
click node_container "https://github.com/gu1p/tak/blob/main/crates/tak-exec/src/container_runtime/mod.rs"
click node_remote "https://github.com/gu1p/tak/blob/main/crates/tak-exec/src/remote_worker.rs"
click node_docker "https://github.com/gu1p/tak/blob/main/crates/takd/src/daemon/transport/container_engine_selection.rs"
click node_runstate "https://github.com/gu1p/tak/blob/main/crates/takd/src/daemon/local_attempt_transport/durable_state.rs"
click node_runs "https://github.com/gu1p/tak/blob/main/crates/tak/src/cli/runs_cli.rs"
click node_dashboard "https://github.com/gu1p/tak/blob/main/crates/tak/src/cli/run_dashboard.rs"
click node_remotecli "https://github.com/gu1p/tak/blob/main/crates/tak/src/cli/remote_status/mod.rs"
click node_graph "https://github.com/gu1p/tak/blob/main/crates/tak/src/web/server.rs"
click node_update "https://github.com/gu1p/tak/blob/main/crates/tak-update/src/lib.rs"

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_loader,node_make,node_planner toneBlue
class node_cli,node_resolve,node_submit,node_clientproto,node_runs,node_dashboard toneAmber
class node_daemon,node_coordinator,node_leases,node_peers,node_runstate toneMint
class node_worker,node_steps,node_container,node_remote,node_docker,node_workspace toneRose
class node_remotecli,node_graph,node_update,node_user,node_remoteagents,node_containerengine toneIndigo
```

## Components

### Authoring and planning

- [Workspace loader](https://github.com/gu1p/tak/blob/main/crates/tak-loader/src/loader/mod.rs): `crates/tak-loader/src/loader/mod.rs`
- [Make integration](https://github.com/gu1p/tak/blob/main/crates/tak-make/src/application/run_make.rs): `crates/tak-make/src/application/run_make.rs`
- [Task model and planner](https://github.com/gu1p/tak/blob/main/crates/tak-core/src/planner.rs): `crates/tak-core/src/planner.rs`

### CLI and client

- [Tak CLI](https://github.com/gu1p/tak/blob/main/crates/tak/src/main.rs): `crates/tak/src/main.rs`
- [Run resolution](https://github.com/gu1p/tak/blob/main/crates/tak/src/cli/daemon_run/resolve.rs): `crates/tak/src/cli/daemon_run/resolve.rs`
- [Run submission](https://github.com/gu1p/tak/blob/main/crates/tak/src/cli/daemon_run/submission.rs): `crates/tak/src/cli/daemon_run/submission.rs`
- [Daemon protocol client](https://github.com/gu1p/tak/blob/main/crates/tak-proto/src/local_daemon.rs): `crates/tak-proto/src/local_daemon.rs`
- [Run history and outputs](https://github.com/gu1p/tak/blob/main/crates/tak/src/cli/runs_cli.rs): `crates/tak/src/cli/runs_cli.rs`
- [Run dashboard](https://github.com/gu1p/tak/blob/main/crates/tak/src/cli/run_dashboard.rs): `crates/tak/src/cli/run_dashboard.rs`

### Daemon coordination

- [Local takd](https://github.com/gu1p/tak/blob/main/crates/takd/src/agent.rs): `crates/takd/src/agent.rs`
- [Attempt coordinator](https://github.com/gu1p/tak/blob/main/crates/takd/src/daemon/attempt_coordinator.rs): `crates/takd/src/daemon/attempt_coordinator.rs`
- [Resource leases](https://github.com/gu1p/tak/blob/main/crates/takd/src/daemon/lease/manager_public_methods.rs): `crates/takd/src/daemon/lease/manager_public_methods.rs`
- [Peer placement](https://github.com/gu1p/tak/blob/main/crates/takd/src/daemon/peer_manager.rs): `crates/takd/src/daemon/peer_manager.rs`
- [Persisted run state](https://github.com/gu1p/tak/blob/main/crates/takd/src/daemon/local_attempt_transport/durable_state.rs): `crates/takd/src/daemon/local_attempt_transport/durable_state.rs`

### Execution

- [Worker runtime](https://github.com/gu1p/tak/blob/main/crates/tak-exec/src/worker_runtime.rs): `crates/tak-exec/src/worker_runtime.rs`
- [Step execution](https://github.com/gu1p/tak/blob/main/crates/tak-exec/src/step_execution.rs): `crates/tak-exec/src/step_execution.rs`
- [Container runtime](https://github.com/gu1p/tak/blob/main/crates/tak-exec/src/container_runtime/mod.rs): `crates/tak-exec/src/container_runtime/mod.rs`
- [Remote worker](https://github.com/gu1p/tak/blob/main/crates/tak-exec/src/remote_worker.rs): `crates/tak-exec/src/remote_worker.rs`
- [Container engine](https://github.com/gu1p/tak/blob/main/crates/takd/src/daemon/transport/container_engine_selection.rs): `crates/takd/src/daemon/transport/container_engine_selection.rs`

### Operations

- [Remote commands](https://github.com/gu1p/tak/blob/main/crates/tak/src/cli/remote_status/mod.rs): `crates/tak/src/cli/remote_status/mod.rs`
- [Graph viewer](https://github.com/gu1p/tak/blob/main/crates/tak/src/web/server.rs): `crates/tak/src/web/server.rs`
- [Self-update](https://github.com/gu1p/tak/blob/main/crates/tak-update/src/lib.rs): `crates/tak-update/src/lib.rs`

### Other components

- **Engineer**
- **TASKS.py / Makefile**
- **Remote agents**
- **Docker / Podman**

## Connections

- Engineer → Tak CLI: invokes
- TASKS.py / Makefile → Workspace loader: loads definitions
- TASKS.py / Makefile → Make integration: provides Makefile
- Tak CLI → Workspace loader: loads workspace
- Tak CLI → Make integration: submits goal
- Workspace loader → Task model and planner: produces task model
- Tak CLI → Run resolution: resolves targets
- Run resolution → Task model and planner: validates graph
- Run resolution → Run submission: passes resolved run
- Run submission → Daemon protocol client: encodes request
- Daemon protocol client → Local takd: sends run request
- Local takd → Attempt coordinator: coordinates attempts
- Attempt coordinator → Resource leases: acquires resources
- Attempt coordinator → Peer placement: selects placement
- Attempt coordinator → Persisted run state: persists run state
- Attempt coordinator → Worker runtime: dispatches local work
- Worker runtime → Step execution: runs steps
- Step execution → Container runtime: uses container runtime
- Container runtime → Container engine: selects engine
- Container engine → Docker / Podman: probes engine
- Attempt coordinator → Remote worker: dispatches remote work
- Remote worker → Remote agents: executes remotely
- Daemon protocol client → Run history and outputs: retrieves run data
- Run history and outputs → Persisted run state: reads persisted state
- Run history and outputs → Run dashboard: attaches events
- Engineer → Remote commands: manages remotes
- Remote commands → Daemon protocol client: queries daemon
- Engineer → Graph viewer: opens graph UI
- Tak CLI → Graph viewer: serves task graph
- Engineer → Self-update: requests update
- Tak CLI → Self-update: runs update flow
