description = """
Mayor bootstraps Gas Town via a verification-gated lifecycle molecule.

## Purpose
When Mayor executes \"boot up gas town\", this proto provides the workflow.
Each step has action + verification - steps stay open until outcome is confirmed.

## Key Principles
1. **Verification-gated steps** - Not \"command ran\" but \"outcome confirmed\"
2. **gt peek for verification** - Capture session output to detect stalls
3. **gt nudge for recovery** - Reliable message delivery to unstick agents
4. **Parallel where possible** - Witnesses and refineries can start in parallel
5. **Ephemeral execution** - Boot is a wisp, squashed to digest after completion

## Execution
```bash
bd mol wisp mol-gastown-boot  # Create wisp
```"""
formula = "mol-gastown-boot"
version = 1

[[steps]]
description = """
Verify the Gas Town daemon is running.

## Action
```bash
gt daemon status || gt daemon start
```

## Verify
1. Daemon PID file exists: `~/.gt/daemon.pid`
2. Process is alive: `kill -0 $(cat ~/.gt/daemon.pid)`
3. Daemon responds: `gt daemon status` returns success

## OnFail
Cannot start daemon. Log error and continue - some commands work without daemon."""
id = "ensure-daemon"
title = "Ensure daemon"

[[steps]]
description = """
Start the Deacon and verify patrol mode is active.

## Action
```bash
gt deacon start
```

## Verify
1. Session exists: `tmux has-session -t gt-deacon 2>/dev/null`
2. Not stalled: `gt peek deacon/` does NOT show \"> Try\" prompt
3. Heartbeat fresh: `deacon/heartbeat.json` modified < 2 min ago

## OnStall
```bash
gt nudge deacon/ \"Start patrol.\"
sleep 30
# Re-verify
```"""
id = "ensure-deacon"
needs = ["ensure-daemon"]
title = "Ensure deacon"

[[steps]]
description = """
Parallel container: Start all rig witnesses.

Children execute in parallel. Container completes when all children complete."""
id = "ensure-witnesses"
needs = ["ensure-deacon"]
title = "Ensure witnesses"
type = "parallel"

[[steps.children]]
description = """
Start the gastown rig Witness.

## Action
```bash
gt witness start gastown
```

## Verify
1. Session exists: `tmux has-session -t gastown-witness 2>/dev/null`
2. Not stalled: `gt peek gastown/witness` does NOT show \"> Try\" prompt
3. Heartbeat fresh: Last patrol cycle < 5 min ago"""
id = "ensure-gastown-witness"
title = "Ensure gastown witness"

[[steps.children]]
description = """
Start the beads rig Witness.

## Action
```bash
gt witness start beads
```

## Verify
1. Session exists: `tmux has-session -t beads-witness 2>/dev/null`
2. Not stalled: `gt peek beads/witness` does NOT show \"> Try\" prompt
3. Heartbeat fresh: Last patrol cycle < 5 min ago"""
id = "ensure-beads-witness"
title = "Ensure beads witness"

[[steps]]
description = """
Parallel container: Start all rig refineries.

Children execute in parallel. Container completes when all children complete."""
id = "ensure-refineries"
needs = ["ensure-deacon"]
title = "Ensure refineries"
type = "parallel"

[[steps.children]]
description = """
Start the gastown rig Refinery.

## Action
```bash
gt refinery start gastown
```

## Verify
1. Session exists: `tmux has-session -t gastown-refinery 2>/dev/null`
2. Not stalled: `gt peek gastown/refinery` does NOT show \"> Try\" prompt
3. Queue processing: Refinery can receive merge requests"""
id = "ensure-gastown-refinery"
title = "Ensure gastown refinery"

[[steps.children]]
description = """
Start the beads rig Refinery.

## Action
```bash
gt refinery start beads
```

## Verify
1. Session exists: `tmux has-session -t beads-refinery 2>/dev/null`
2. Not stalled: `gt peek beads/refinery` does NOT show \"> Try\" prompt
3. Queue processing: Refinery can receive merge requests"""
id = "ensure-beads-refinery"
title = "Ensure beads refinery"

[[steps]]
description = """
Final verification that Gas Town is healthy.

## Action
```bash
gt status
```

## Verify
1. Daemon running: Shows daemon status OK
2. Deacon active: Shows deacon in patrol mode
3. All witnesses: Each rig witness shows active
4. All refineries: Each rig refinery shows active

## OnFail
Log degraded state but consider boot complete. Some agents may need manual recovery.
Run `gt doctor` for detailed diagnostics."""
id = "verify-town-health"
needs = ["ensure-witnesses", "ensure-refineries"]
title = "Verify town health"
