From 47168adc1e512ae752a0f564531671e1a7b2832a Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Thu, 25 Dec 2025 22:59:42 -0800 Subject: [PATCH] Add mol-town-shutdown formula for clean town reboot (gt-ioij) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps: clear inboxes, kill polecats, stop daemon, rotate logs, sync state, send handoff, restart daemon. Usage: gt sling mol-town-shutdown mayor 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../formulas/mol-town-shutdown.formula.toml | 158 ++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 .beads/formulas/mol-town-shutdown.formula.toml diff --git a/.beads/formulas/mol-town-shutdown.formula.toml b/.beads/formulas/mol-town-shutdown.formula.toml new file mode 100644 index 00000000..b6912fcb --- /dev/null +++ b/.beads/formulas/mol-town-shutdown.formula.toml @@ -0,0 +1,158 @@ +description = """ +Full Gas Town shutdown and restart. + +This is the "nuclear" option for clean reboot. 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 = 1 + +[[steps]] +id = "clear-inboxes" +title = "Clear all agent inboxes" +description = """ +Archive and clear all agent inboxes across all rigs. + +```bash +# For each rig +for rig in $(gt rigs --names); do + # Clear witness inbox + gt mail clear $rig/witness --archive + + # Clear refinery inbox + gt mail clear $rig/refinery --archive + + # Clear crew inboxes + for crew in $(gt crew list $rig --names); do + gt mail clear $rig/crew/$crew --archive + done +done + +# Clear Mayor inbox +gt mail clear mayor/ --archive +``` + +Messages are archived to `.beads/mail-archive/` before deletion. +""" + +[[steps]] +id = "kill-polecats" +title = "Kill all active polecats" +needs = ["clear-inboxes"] +description = """ +Terminate all polecat sessions across all rigs. + +```bash +gt stop --all --force +``` + +This kills all gt-* tmux sessions. Polecats are ephemeral workers +that will be respawned fresh after restart. + +Note: Crew workers are NOT killed (they're persistent). +""" + +[[steps]] +id = "stop-daemon" +title = "Stop the daemon" +needs = ["kill-polecats"] +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 + +# Archive old session captures +gt doctor --fix # Includes session cleanup +``` + +Old logs are moved to `~/gt/logs/archive/` with timestamps. +""" + +[[steps]] +id = "sync-state" +title = "Sync beads and push" +needs = ["rotate-logs"] +description = """ +Ensure all state is persisted before restart. + +```bash +# Sync beads changes +bd sync + +# Push any uncommitted work +git add -A +git commit -m "Town shutdown: state checkpoint" || true +git push +``` + +This ensures no work is lost during the restart. +""" + +[[steps]] +id = "handoff-mayor" +title = "Send Mayor handoff" +needs = ["sync-state"] +description = """ +Record what comes next for the fresh Mayor session. + +```bash +gt mail send mayor/ -s "🤝 HANDOFF: Town restart complete" -m " +Town shutdown completed. Fresh state ready. + +Next steps: +- Run gt prime to restore context +- Check gt status for town health +- Resume normal operations or start maintenance + +Shutdown reason: {{shutdown_reason}} +" +``` + +The handoff mail ensures continuity across the restart. +""" + +[[steps]] +id = "restart-daemon" +title = "Restart daemon fresh" +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 + +Town is now ready for normal operations. +"""