Files
gastown/internal/formula/formulas/mol-town-shutdown.formula.toml
mayor b316239d12 chore(gastown): scorched-earth SQLite removal from codebase
Remove all bd sync references and SQLite-specific code from gastown:

**Formulas (agent priming):**
- mol-polecat-work: Remove bd sync step from prepare-for-review
- mol-sync-workspace: Replace sync-beads step with verify-beads (Dolt check)
- mol-polecat-conflict-resolve: Remove bd sync from close-beads
- mol-polecat-code-review: Remove bd sync from summarize-review and complete-and-exit
- mol-polecat-review-pr: Remove bd sync from complete-and-exit
- mol-convoy-cleanup: Remove bd sync from archive-convoy
- mol-digest-generate: Remove bd sync from send-digest
- mol-town-shutdown: Replace sync-state step with verify-state
- beads-release: Replace restart-daemons with verify-install (no daemons with Dolt)

**Templates (role priming):**
- mayor.md.tmpl: Update session end checklist to remove bd sync steps
- crew.md.tmpl: Remove bd sync references from workflow and checklist
- polecat.md.tmpl: Update self-cleaning model and session close docs
- spawn.md.tmpl: Remove bd sync from completion steps
- nudge.md.tmpl: Remove bd sync from completion steps

**Go code:**
- session_manager.go: Remove syncBeads function and call
- rig_dock.go: Remove bd sync calls from dock/undock
- crew/manager.go: Remove runBdSync, update Pristine function
- crew_maintenance.go: Remove bd sync status output
- crew.go: Update pristine command help text
- polecat.go: Make sync command a no-op with deprecation message
- daemon/lifecycle.go: Remove bd sync from startup sequence
- doctor/beads_check.go: Update fix hints and Fix to use bd import not bd sync
- doctor/rig_check.go: Remove sync status check, simplify BeadsConfigValidCheck
- beads/beads.go: Update primeContent to remove bd sync references

With Dolt backend, beads changes are persisted immediately to the sql-server.
There is no separate sync step needed.

Part of epic: hq-e4eefc (SQLite removal)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 14:08:53 -08:00

203 lines
4.5 KiB
TOML

description = """
Full Gas Town shutdown and restart.
This is an idempotent shutdown - it stops Claude sessions but preserves
polecat sandboxes and hooks. Polecats can resume their work after restart.
Use when you need to:
- Reset all state for a fresh start
- Recover from corrupted agent state
- Prepare for maintenance or upgrades
Sling to Mayor when ready to reboot:
gt sling mol-town-shutdown mayor
"""
formula = "mol-town-shutdown"
type = "workflow"
version = 2
[[steps]]
id = "preflight-check"
title = "Preflight safety check"
description = """
Scan for conditions that might make shutdown inadvisable.
```bash
gt shutdown preflight
```
This checks for:
- **Uncommitted changes**: Polecats with dirty git status
- **Unpushed commits**: Work that hasn't reached remote
- **Active merges**: Refinery mid-merge (could corrupt state)
- **Pending CI**: PRs waiting on GitHub Actions
Output is a report with warnings/blockers:
| Severity | Condition | Action |
|----------|-----------|--------|
| BLOCKER | Active merge in progress | Abort shutdown |
| WARNING | Uncommitted polecat changes | List affected polecats |
| WARNING | Unpushed commits | List repos needing push |
| INFO | Pending CI runs | Note for awareness |
If blockers exist, STOP and resolve them first.
If only warnings, decide whether to proceed (work will be preserved).
"""
[[steps]]
id = "stop-sessions"
title = "Stop Claude sessions (preserve sandboxes)"
needs = ["preflight-check"]
description = """
Kill Claude processes but leave polecat sandboxes intact.
```bash
# Stop all polecat Claude sessions
gt stop --all --preserve-sandbox
# Verify sandboxes still exist
gt polecats --all --status
```
What this does:
- Kills tmux sessions running Claude
- Leaves git clones untouched
- Leaves hook files (pinned molecules) intact
- Leaves uncommitted work in place
What this does NOT do:
- Delete polecat directories
- Remove hook attachments
- Lose any git state
After restart, polecats can be respawned and will resume from their hooks.
Note: Crew workers are NOT stopped (they're user-managed).
"""
[[steps]]
id = "clear-inboxes"
title = "Archive and clear inboxes"
needs = ["stop-sessions"]
description = """
Archive and clear all agent inboxes across all rigs.
```bash
# For each rig
for rig in $(gt rigs --names); do
gt mail clear $rig/witness --archive
gt mail clear $rig/refinery --archive
done
# Clear Mayor inbox
gt mail clear mayor --archive
```
Messages are archived to `.beads/mail-archive/` before deletion.
Crew inboxes are NOT cleared (user manages those).
"""
[[steps]]
id = "stop-daemon"
title = "Stop the daemon"
needs = ["clear-inboxes"]
description = """
Stop the Gas Town daemon gracefully.
```bash
gt daemon stop
```
The daemon handles:
- Heartbeat monitoring
- Pending spawn triggers
- Background coordination
It will be restarted in the final step.
"""
[[steps]]
id = "rotate-logs"
title = "Rotate and archive logs"
needs = ["stop-daemon"]
description = """
Rotate logs to prevent unbounded growth.
```bash
# Rotate daemon logs
gt daemon rotate-logs
# Clean up old session captures (but not current sandboxes)
gt doctor --fix
```
Old logs are moved to `$GT_ROOT/logs/archive/` with timestamps.
"""
[[steps]]
id = "verify-state"
title = "Verify beads state"
needs = ["rotate-logs"]
description = """
Verify beads database is accessible.
```bash
bd doctor
bd list --limit 5 # Quick connectivity check
```
Note: With Dolt backend, changes are persisted immediately to the sql-server.
There is no separate sync step needed.
Note: We do NOT force-commit polecat work here. Their sandboxes
are preserved with whatever state they had. They'll commit their
own work when they resume.
"""
[[steps]]
id = "handoff-mayor"
title = "Send Mayor handoff"
needs = ["verify-state"]
description = """
Record shutdown context for the fresh Mayor session.
```bash
gt mail send mayor -s "🤝 HANDOFF: Town shutdown complete" -m "
Town shutdown completed. State preserved.
Polecat sandboxes: PRESERVED (will resume from hooks)
Inboxes: ARCHIVED and cleared
Daemon: STOPPED
Next steps:
1. gt daemon start
2. gt prime
3. gt status (verify health)
4. Resume operations or respawn polecats
Shutdown reason: {{shutdown_reason}}
"
```
"""
[[steps]]
id = "restart-daemon"
title = "Restart daemon"
needs = ["handoff-mayor"]
description = """
Start the daemon with fresh state.
```bash
gt daemon start
```
The daemon will:
- Begin heartbeat monitoring
- Watch for pending spawns
- Resume background coordination
Polecats are NOT auto-respawned. Use `gt sling` or let Witness
restart them based on their preserved hooks.
"""