From baec5b6147eed8c63a0b4cef3529b4ebb520e910 Mon Sep 17 00:00:00 2001 From: mayor Date: Sun, 25 Jan 2026 20:33:23 -0800 Subject: [PATCH] fix(daemon): respect rig bead docked status in isRigOperational The daemon's isRigOperational() was only checking wisp config layer for docked/parked status. However, 'gt rig dock' sets the status:docked label on the rig identity bead (global/synced), not wisp config. This caused the daemon to auto-restart agents on docked rigs because it couldn't see the bead-level docked status. Fix: - Check rig bead labels for status:docked and status:parked - Also updated mol-deacon-patrol formula to explicitly skip DOCKED/PARKED rigs in health-scan step Co-Authored-By: Claude Opus 4.5 --- .../formulas/mol-deacon-patrol.formula.toml | 13 ++++++++++++ internal/daemon/daemon.go | 21 ++++++++++++++++++- .../formulas/mol-deacon-patrol.formula.toml | 13 ++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/.beads/formulas/mol-deacon-patrol.formula.toml b/.beads/formulas/mol-deacon-patrol.formula.toml index f293c2b3..f49f7f5c 100644 --- a/.beads/formulas/mol-deacon-patrol.formula.toml +++ b/.beads/formulas/mol-deacon-patrol.formula.toml @@ -341,6 +341,19 @@ needs = ["trigger-pending-spawns", "dispatch-gated-molecules", "fire-notificatio description = """ Check Witness and Refinery health for each rig. +**IMPORTANT: Skip DOCKED/PARKED rigs** +Before checking any rig, verify its operational state: +```bash +gt rig status +# Check the Status: line - if DOCKED or PARKED, skip entirely +``` + +DOCKED rigs are globally shut down - do NOT: +- Check their witness/refinery status +- Send health pings +- Attempt restarts +Simply skip them and move to the next rig. + **IMPORTANT: Idle Town Protocol** Before sending health check nudges, check if the town is idle: ```bash diff --git a/internal/daemon/daemon.go b/internal/daemon/daemon.go index 0ca1d69e..a1f4c99f 100755 --- a/internal/daemon/daemon.go +++ b/internal/daemon/daemon.go @@ -596,7 +596,7 @@ func (d *Daemon) isRigOperational(rigName string) (bool, string) { d.logger.Printf("Warning: no wisp config for %s - parked state may have been lost", rigName) } - // Check rig status - parked and docked rigs should not have agents auto-started + // Check wisp layer first (local/ephemeral overrides) status := cfg.GetString("status") switch status { case "parked": @@ -605,6 +605,25 @@ func (d *Daemon) isRigOperational(rigName string) (bool, string) { return false, "rig is docked" } + // Check rig bead labels (global/synced docked status) + // This is the persistent docked state set by 'gt rig dock' + rigPath := filepath.Join(d.config.TownRoot, rigName) + if rigCfg, err := rig.LoadRigConfig(rigPath); err == nil && rigCfg.Beads != nil { + rigBeadID := fmt.Sprintf("%s-rig-%s", rigCfg.Beads.Prefix, rigName) + rigBeadsDir := beads.ResolveBeadsDir(rigPath) + bd := beads.NewWithBeadsDir(rigPath, rigBeadsDir) + if issue, err := bd.Show(rigBeadID); err == nil { + for _, label := range issue.Labels { + if label == "status:docked" { + return false, "rig is docked (global)" + } + if label == "status:parked" { + return false, "rig is parked (global)" + } + } + } + } + // Check auto_restart config // If explicitly blocked (nil), auto-restart is disabled if cfg.IsBlocked("auto_restart") { diff --git a/internal/formula/formulas/mol-deacon-patrol.formula.toml b/internal/formula/formulas/mol-deacon-patrol.formula.toml index f293c2b3..f49f7f5c 100644 --- a/internal/formula/formulas/mol-deacon-patrol.formula.toml +++ b/internal/formula/formulas/mol-deacon-patrol.formula.toml @@ -341,6 +341,19 @@ needs = ["trigger-pending-spawns", "dispatch-gated-molecules", "fire-notificatio description = """ Check Witness and Refinery health for each rig. +**IMPORTANT: Skip DOCKED/PARKED rigs** +Before checking any rig, verify its operational state: +```bash +gt rig status +# Check the Status: line - if DOCKED or PARKED, skip entirely +``` + +DOCKED rigs are globally shut down - do NOT: +- Check their witness/refinery status +- Send health pings +- Attempt restarts +Simply skip them and move to the next rig. + **IMPORTANT: Idle Town Protocol** Before sending health check nudges, check if the town is idle: ```bash