From 11fe4dddc53f3ac3faa9fa9dddfb1defa8e18a5d Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Sat, 20 Dec 2025 13:23:17 -0800 Subject: [PATCH] fix(handoff): Use actual rig name in lifecycle messages (gt-6vks) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The getManager() function was returning a literal "/witness" string for polecats and refineries instead of substituting the actual rig name. This caused LIFECYCLE messages to be sent to "@/witness" instead of proper addresses like "@gastown/witness". Fix: - Add detectRigFromContext() to extract rig from current directory - Update getManager() to use detected rig name - Fallback to deacon/ if rig detection fails (safety) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/cmd/handoff.go | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/internal/cmd/handoff.go b/internal/cmd/handoff.go index 058afbb7..a07647ff 100644 --- a/internal/cmd/handoff.go +++ b/internal/cmd/handoff.go @@ -222,14 +222,20 @@ func preFlightChecks() error { } // getManager returns the address of our lifecycle manager. +// For polecats and refineries, it detects the rig from context. func getManager(role Role) string { switch role { case RoleMayor, RoleWitness: return "deacon/" case RolePolecat, RoleRefinery: - // Would need rig context to determine witness address - // For now, use a placeholder pattern - return "/witness" + // Detect rig from current directory context + rig := detectRigFromContext() + if rig == "" { + // Fallback if rig detection fails - this shouldn't happen + // in normal operation but is better than a literal placeholder + return "deacon/" + } + return rig + "/witness" case RoleCrew: return "human" // Crew is human-managed default: @@ -237,6 +243,22 @@ func getManager(role Role) string { } } +// detectRigFromContext determines the rig name from the current directory. +func detectRigFromContext() string { + cwd, err := os.Getwd() + if err != nil { + return "" + } + + townRoot, err := workspace.FindFromCwd() + if err != nil || townRoot == "" { + return "" + } + + ctx := detectRole(cwd, townRoot) + return ctx.Rig +} + // sendHandoffMail updates the pinned handoff bead for the successor to read. func sendHandoffMail(role Role, townRoot string) error { // Build handoff content