How gastownhall/gascity works
Purpose and Entry Points
Gas City is a Go-based orchestration toolkit for multi-agent coding workflows. The primary executable is gc, whose root command wires CLI commands, city discovery, configuration, storage, runtimes, and controller behavior. gc init scaffolds a city; gc start launches its control plane; operational commands manage rigs, work, sessions, formulas, orders, and services.
• cmd/gc/main.go
• cmd/gc/cmd_commands.go
• cmd/gc/cmd_start.go
City Configuration, Packs, and Scoping
A city is declaratively configured through city.toml; configuration composition resolves packs, imports, overlays, provider definitions, storage bindings, agents, named sessions, and rig-specific overrides. Packs are both a distribution boundary and an extensibility mechanism: the embedded core pack supplies default agents, formulas, orders, scripts, skills, and provider overlays.
• internal/config/config.go
• internal/config/compose.go
• internal/bootstrap/packs/core/pack.toml
Storage and Work Model
“Beads” are the durable work/coordination records underlying work tracking, mail, convoys, waits, and workflow graphs. The store abstraction supports multiple backends, notably the default external bd/Dolt path, native Dolt, SQLite, file, and memory implementations. Store binding resolves which backend serves each storage class and protects migrations/lifecycle transitions; this is a major boundary between orchestration logic and persistence.
• internal/beads/beads.go
• internal/beads/factory.go
• internal/storebinding/storebinding.go
Controller Reconciliation and Dispatch
The controller continuously reconciles configured and observed state into desired pools/sessions. It computes demand, creates or wakes capacity, routes ready work, tracks assignments, and repairs drift or failed ownership. Dispatch turns bead/workflow graph state into runnable work and supports retry, drain, fanout, and control-routing semantics. Conditional writes, residency, and store fences protect cross-process and cross-store ownership.
• cmd/gc/controller.go
• cmd/gc/build_desired_state.go
• cmd/gc/session_reconciler.go
• internal/dispatch/runtime.go
Sessions, Workers, and Runtime Providers
Sessions are the lifecycle unit for an agent invocation: identity, persisted state, waits, chat/submission, transcript metadata, and transitions are handled independently of a concrete runtime. Worker handles normalize agent operations and observation. The runtime interface permits the same orchestration layer to launch or control tmux, local subprocess/exec, ACP, Kubernetes, SSH, hybrid, T3 bridge, or herdr providers. tmux remains the default/fallback runtime.
• internal/session/manager.go
• internal/worker/handle.go
• internal/runtime/runtime.go
• internal/runtime/tmux/tmux.go
• internal/runtime/k8s/provider.go
Workflow Compilation and Scheduled Automation
Formulas define reusable multi-step workflows and compile into graph-shaped molecule/work records. The convergence subsystem runs bounded iterative refinement and gates over those workflows. Orders are separately parsed periodic or event-triggered automation definitions; their dispatcher evaluates triggers and launches actions through the same control/runtime boundaries.
• internal/formula/compile.go
• internal/molecule/molecule.go
• internal/convergence/reconcile.go
• internal/orders/triggers.go
Supervisor, API, Observability, and Integrations
A supervisor manages city-level service lifecycle, publishes status, and can host the HTTP control API and embedded dashboard. The API exposes typed resources for cities, sessions, agents, beads, runs, events, mail, rigs, and operational actions; SSE supports live streams. Events provide durable observability, while external-message and webhook modules connect outside systems. Optional infrastructure includes managed Dolt, Git/GitHub, MCP mail, Docker, and Kubernetes manifests.
• internal/supervisor/registry.go
• internal/api/server.go
• internal/api/dashboardspa/embed.go
• internal/events/events.go
• internal/extmsg/services.go
Main entry points: controller.go Controller reconciler · compose.go City configuration · beads.go Beads work records · main.go gc command
Components 21
CLI and bootstrap
- gc command · Root command and operational entry point.
cmd/gc/main.go - Operational commands
cmd/gc/cmd_commands.go - gc start
cmd/gc/cmd_start.go
Configuration
- City configuration · Composes imports, overlays, providers, storage, agents, and rigs.
internal/config/compose.go - Embedded core pack · Supplies default agents, formulas, orders, scripts, and overlays.
internal/bootstrap/packs/core/pack.toml
Control plane
- Store binding · Selects storage backends and protects lifecycle transitions.
internal/storebinding/storebinding.go - Beads work records · Tracks work, coordination, mail, convoys, waits, and workflow graphs.
internal/beads/beads.go - Store backends · Supports bd/Dolt, native Dolt, SQLite, file, and memory stores.
internal/beads/factory.go - Controller reconciler · Reconciles capacity, assignments, routing, and ownership drift.
cmd/gc/controller.go - Work dispatch · Turns ready work into runnable assignments with retry and drain semantics.
internal/dispatch/runtime.go
Execution
- Session manager · Persists invocation state, waits, chat, submissions, and transitions.
internal/session/manager.go - Worker handles · Normalizes agent operations and observation.
internal/worker/handle.go - Runtime providers · Launches or controls tmux, exec, ACP, Kubernetes, SSH, hybrid, T3, and herdr.
internal/runtime/runtime.go - tmux runtime
internal/runtime/tmux/tmux.go
Automation and operations
- Formula compiler · Compiles reusable formulas into graph-shaped work records.
internal/formula/compile.go - Convergence reconciler · Runs bounded refinement and gates workflow progress.
internal/convergence/reconcile.go - Orders dispatcher · Evaluates periodic or event triggers and launches actions.
internal/orders/triggers.go - City supervisor · Manages city services and publishes status.
internal/supervisor/registry.go - HTTP API and dashboard · Provides typed resources, operational actions, SSE, and embedded dashboard.
internal/api/server.go - Durable events
internal/events/events.go - External messaging · Connects webhooks and outside message systems.
internal/extmsg/services.go
Connections 23
- gc command → Operational commands: registers
- gc command → gc start: launch command
- gc command → City configuration: discovers city
- City configuration → Embedded core pack: resolves packs
- gc start → Controller reconciler: starts
- City configuration → Controller reconciler: desired inputs
- City configuration → Store binding: storage bindings
- Store binding → Store backends: selects backend
- Store binding → Beads work records: persists through
- Controller reconciler → Beads work records: reconciles work
- Controller reconciler → Work dispatch: routes ready work
- Work dispatch → Session manager: creates or wakes
- Session manager → Worker handles: manages
- Worker handles → Runtime providers: normalizes provider
- Runtime providers → tmux runtime: default/fallback
- Formula compiler → Beads work records: compiles workflows
- Convergence reconciler → Formula compiler: gates iterations
- Orders dispatcher → Work dispatch: launches actions
- City supervisor → HTTP API and dashboard: hosts
- City supervisor → Controller reconciler: manages service
- Controller reconciler → Durable events: emits lifecycle events
- HTTP API and dashboard → Session manager: operates sessions
- External messaging → Beads work records: integrates coordination