ACP's internal layers and how they fit within the broader three-tier system.
ACP is the middle tier of three:
┌─────────────────────────────────────┐
│ Orchestrator (external) │ ← Talks to user, plans tasks
│ LangGraph / CrewAI / custom LLM │ Writes tasks into ACP
└─────────────────┬───────────────────┘
│ acp task create
▼
┌─────────────────────────────────────┐
│ ACP (this project) │
│ │
│ ┌─────────────────────────────┐ │
│ │ CLI (L0) │ │ ← Human interface for testing/ops
│ └──────────────┬──────────────┘ │
│ │ │
│ ┌──────────────▼──────────────┐ │
│ │ Control Plane (L1) │ │ ← Reconciliation loops (Go daemon)
│ │ RecoveryController │ │
│ │ VaultController │ │
│ │ AgentObserver │ │
│ └──────────────┬──────────────┘ │
│ │ │
│ ┌──────────────▼──────────────┐ │
│ │ The Vault (L2) │ │ ← Filesystem state (single truth)
│ │ tasks/{pending,doing,...} │ │
│ │ agents/ logs/ results/ │ │
│ └──────────────┬──────────────┘ │
└──────────────────┼───────────────────┘
│ vault mounted as volume
▼
┌─────────────────────────────────────┐
│ Worker Agents (external) │ ← Docker containers
│ coder-agent / designer-agent / … │ Poll vault, claim tasks, execute
└─────────────────────────────────────┘
The orchestrator and worker agents are external to this repository. ACP's codebase contains only: CLI, Control Plane, and the Vault schema/access layer.
The acp binary is the human interface. In normal operation, the orchestrator calls it programmatically. In development and debugging, you use it directly.
Commands: init, task create, task list, task show, task retry, status, serve, agent
Tech: Go, compiled to a single static binary. No server required — the CLI reads/writes the vault directly.
Connects to: The vault filesystem (L2). There is no API server in V1.
The Go daemon that runs alongside the vault. Contains three independent loops:
Runs every 5 minutes (configurable). Scans vault/tasks/doing/ for expired leases:
for each task in doing/:
if task.lease_expiry < now:
if task.retry_count < max_retries:
increment retry_count
clear agent fields
move → pending/ ← re-queue
else:
move → failed/ ← permanent failure
This is what makes ACP self-healing. Crashed workers never permanently block tasks.
Runs every 15 minutes (configurable). Scans all task files for integrity violations: malformed JSON, missing required fields, doing/ tasks without agent assignment. Corrupted files are moved to failed/ with descriptive errors.
Reads vault/agents/*.json heartbeat files. Logs warnings when agents haven't updated last_seen_at within the stale threshold. Does not manage container lifecycle — it only observes.
The control plane is also where ACP's "agentic properties" live — autonomous, rule-based behaviors that go beyond basic recovery.
Implemented in V1: lease-expiry re-queue with retry budget, poison-pill failure via release_count, stale-pending warnings, corruption quarantine, stale-agent warnings.
Planned (post-V1): escalating high-priority tasks that have been pending too long, and emitting structured events to vault/events/ for the orchestrator to react to. Do not expect these from the current binary.
These are deterministic policies, not LLM calls. Note the constraint the pull model imposes: policies act on task state only. ACP cannot steer work toward or away from a particular worker (e.g. "deprioritize a flaky agent") because it never assigns tasks in the first place.
The shared filesystem directory. Everything in the system ultimately reads from and writes to the Vault. See Vault Schema for the complete structure.
The Vault is accessed via the StateStore interface:
type StateStore interface {
Read(path string) ([]byte, error)
Write(path string, data []byte) error
Append(path string, data []byte) error
List(path string) ([]string, error)
Exists(path string) bool
Delete(path string) error
Move(src, dest string) error // atomic via os.Rename
}In V1, the only implementation is FileSystemStore. Be honest about what this interface does and doesn't buy: the method signatures could be implemented over Redis or Postgres, but the layers above depend on the semantics of Move (same-filesystem atomic rename, exactly-one-winner) and Write (atomic replace), and the whole directory-per-state layout is filesystem-shaped. Swapping the backend is a real porting effort of the concurrency model, not a drop-in replacement.
Orchestrator calls: acp task create --role coder "Implement binary search"
│
▼
CLI writes: vault/tasks/pending/task_1234.json
│
│ (worker polls every 5 seconds)
▼
coder-agent: os.Rename(pending/task_1234.json → tasks/.wip/task_1234.json) ← atomic acquire
coder-agent: sets assigned_agent, lease_expiry, heartbeat_at; atomic write
coder-agent: os.Rename(tasks/.wip/task_1234.json → doing/task_1234.json)
│
│ (agent works on task, renews lease every 10 min
│ via the same acquire → mutate → settle protocol)
▼
coder-agent: writes vault/results/task_1234.md
coder-agent: acquire doing/ → .wip/, set result, settle into done/
coder-agent: updates vault/agents/coder-1.json (heartbeat)
│
▼
Orchestrator reads: acp task list --status done
acp task show task_1234 (result field → results/…md)
cat vault/results/task_1234.*.md
CLI
└── reads/writes → Vault (FileSystemStore)
Control Plane
└── RecoveryController → reads/writes → Vault
└── VaultController → reads/writes → Vault
└── AgentObserver → reads → Vault (agents/)
Worker Container
└── Agent polling loop → reads/writes → Vault
└── Agent polling loop → calls → AI Tool (Claude Code, Codex, etc.)
No component calls another component directly. All communication is through the Vault. This is the fundamental property that makes the system fault-tolerant and debuggable.
acp/
├── cmd/
│ └── acp/ # CLI entry point (main.go)
│
├── internal/
│ ├── store/
│ │ ├── store.go # StateStore interface
│ │ └── filesystem.go # FileSystemStore implementation
│ │
│ ├── task/
│ │ ├── task.go # Task struct + Status/Priority types + ID generation
│ │ └── queue.go # Queue: lifecycle + the .wip mutation protocol
│ │
│ ├── controller/
│ │ ├── recovery.go # RecoveryController loop + .wip janitor
│ │ ├── vault.go # VaultController loop
│ │ └── observer.go # AgentObserver loop
│ │
│ └── agent/
│ └── agent.go # Standard worker loop + agent records
│
├── vault/ # Runtime state directory (not committed except schema)
└── go.mod
| Interface | Responsibility | V1 Implementation |
|---|---|---|
StateStore |
Read/write/list/move filesystem paths atomically | FileSystemStore |
TaskQueue |
Task lifecycle: create/claim/complete/fail/list | task.Queue (wraps StateStore) |
See Core Interfaces for full Go interface definitions.