Skip to main content

Agent Hierarchy

Gas Town uses a supervisor tree pattern inspired by Erlang/OTP. Each agent level monitors the level below it, providing fault tolerance and automatic recovery.

Supervision Tree

Monitoring Chain

MonitorWatchesDetectsAction
DaemonDeaconUnresponsiveRestart Deacon session
DeaconAll WitnessesStuck/dead WitnessRestart Witness
DeaconBoot dogTriage neededSpawn Boot for assessment
WitnessPolecats in rigStalled/crashedNudge, then nuke zombie
WitnessRefineryMerge failuresEscalate to Mayor

Patrol Cycles

Persistent agents run patrol cycles — periodic health checks:

AgentIntervalActions
Deacon5 minCheck Witnesses, process lifecycle requests, run Boot triage
Witness5 minCheck polecats, detect stalls, clean zombies
Refinery5 minProcess merge queue, rebase and validate
Daemon3 minSend heartbeat to Deacon

Boot Dog: The Triage Agent

The Boot dog is a special agent spawned by the Deacon to assess situations that need triage — new work arriving, health check failures, or ambiguous states. Boot performs a quick assessment and reports back to the Deacon, which then takes action (spawn polecats, escalate, etc.). Boot is short-lived and focused: assess, report, exit.

Escalation Path

When an agent encounters a problem it cannot resolve:

Polecat (stuck)
→ Witness detects stall (patrol cycle)
→ Witness nudges polecat
→ If still stuck: Witness escalates to Deacon
→ Deacon escalates to Mayor
→ Mayor escalates to Human/Overseer

Agents can also self-escalate using gt escalate:

gt escalate "Brief description" -s HIGH -m "Details"

Severity levels control routing:

LevelCodeRoute
CriticalP0Bead → Mail:Mayor → Email:Human → SMS:Human
HighP1Bead → Mail:Mayor → Email:Human
MediumP2Bead → Mail:Mayor
LowP3Bead only