plugins/rebuild-gt/plugin.md
+++ name = "rebuild-gt" description = "Rebuild stale gt binary from gastown source" version = 2
[gate] type = "cooldown" duration = "1h"
[tracking] labels = ["plugin:rebuild-gt", "rig:gastown", "category:maintenance"] digest = true
[execution] timeout = "5m" notify_on_failure = true severity = "medium" +++
Checks if the gt binary is stale (built from older commit than HEAD) and rebuilds.
SAFETY: This plugin MUST only rebuild forward (binary ancestor of HEAD) and only from the main branch. Rebuilding to an older or diverged commit caused a crash loop where every new session's startup hook failed, the witness respawned it, and the loop repeated every 1-2 minutes.
The Deacon evaluates this before dispatch. If gate closed, skip.
Check binary staleness:
gt stale --json
Parse the JSON output and check these fields:
"stale": false → record success wisp and exit early (binary is fresh)"safe_to_rebuild": false → DO NOT REBUILD. Record a skip wisp and exit.
This means the repo is on a non-main branch or HEAD is not a descendant of the
binary commit (would be a downgrade)."safe_to_rebuild": true → proceed to buildIf safe_to_rebuild is false, record a skip wisp:
bd create --wisp-type patrol \
--labels type:plugin-run,plugin:rebuild-gt,rig:gastown,result:skipped \
--description "Skipped: not safe to rebuild (forward=$FORWARD, main=$ON_MAIN)" \
"Plugin: rebuild-gt [skipped]"
Before building, verify the source repo is clean and on main:
cd ~/gt/gastown/mayor/rig
git status --porcelain # Must be clean
git branch --show-current # Must be "main"
If either check fails, skip the rebuild and record a wisp.
Rebuild from source (the mayor/rig directory is the canonical source):
cd ~/gt/gastown/mayor/rig && make build && make safe-install
IMPORTANT: Use make safe-install (not make install) to avoid restarting
the daemon while sessions are active. safe-install replaces the binary but does
NOT restart the daemon — sessions will pick up the new binary on their next cycle.
On success:
bd create --wisp-type patrol \
--labels type:plugin-run,plugin:rebuild-gt,rig:gastown,result:success \
--description "Rebuilt gt: $OLD → $NEW ($N commits)" \
"Plugin: rebuild-gt [success]"
On failure:
bd create --wisp-type patrol \
--labels type:plugin-run,plugin:rebuild-gt,rig:gastown,result:failure \
--description "Build failed: $ERROR" \
"Plugin: rebuild-gt [failure]"
gt escalate --severity=medium \
--subject="Plugin FAILED: rebuild-gt" \
--body="$ERROR" \
--source="plugin:rebuild-gt"