Skip to main content

Architecture Documentation

Current-state documentation for Gas City’s subsystems. Each document describes how the subsystem works today, not how we wish it worked. For proposed changes, write a design doc in docs/design/.

Reading Order

Start with the overview, then dive into the subsystem you need.

Foundation

  1. Glossary — authoritative definitions of all terms
  2. Nine Concepts Overview — the 5 primitives + 4 derived mechanisms that compose Gas City

Layer 0-1: Primitives

These are irreducible. Removing any makes it impossible to build a multi-agent orchestration system.
  1. Bead Store — universal persistence substrate for all work units (tasks, mail, molecules, convoys)
  2. Event Bus — append-only pub/sub log of all system activity
  3. Config System — TOML loading, progressive activation, multi-layer override resolution
  4. Agent Protocol — agent lifecycle backed by session providers (tmux, subprocess, k8s)
  5. Prompt Templates — Go text/template in Markdown defining role behavior

Layer 2-4: Derived Mechanisms

Each is provably composable from the primitives.
  1. Messaging — inter-agent mail via beads + nudge via agent protocol
  2. Formulas & Molecules — work definitions (TOML) and their runtime instances (bead trees)
  3. Dispatch — sling: agent selection + formula instantiation + convoy creation
  4. Health Patrol — supervision model, reconciliation, crash tracking, idle detection

Infrastructure

  1. Controller — the main loop: config watch, reconciliation tick, order dispatch
  2. Orders — gate-conditioned formula/exec dispatch, rig-scoped labels

End-to-End Traces

These trace a concrete operation through all layers. The most effective way to understand how the system fits together.
  1. Life of a Bead — create → hook → claim → execute → close
  2. Life of a Molecule — formula parse → dispatch → molecule create → step execution → completion

Document Types

Gas City uses four document types (following CockroachDB’s tech-note / RFC distinction):
TypeDirectoryPurposeLifecycle
Architecture docdocs/architecture/How it works nowLiving; update when code changes
Design docdocs/design/How we want it to workProposal → accepted → implemented → obsolete
Reference docdocs/reference/Exhaustive lookup (CLI, config, API)Must stay in sync; partially generated
Tutorialdocs/tutorials/Learning path with exercisesOrdered progression

Conventions

  • Code references use repo-relative paths: internal/beads/store.go
  • Cross-references use descriptive link text explaining why you’d follow the link
  • No role names in examples — Gas City has zero hardcoded roles
  • Invariants are stated as testable assertions
  • Update date at the top of each doc tracks when it was last verified against code
Last modified on March 20, 2026