From 1733c6dbaea81f22e7717c7bd7f0a99d6ba9ae61 Mon Sep 17 00:00:00 2001 From: Chris Sloane Date: Sun, 4 Jan 2026 15:58:53 -0500 Subject: [PATCH] fix: use mayor/rig path for beads to prevent prefix mismatch (#38) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When creating agent beads for polecats or crew workers, the code was using the rig root path (e.g., ~/gt/infra-dashboard/) instead of the mayor/rig path where the actual beads database lives. The rig root .beads/ directory only contains config.yaml with no database. When bd runs from there, it walks up the directory tree and finds the town-level beads database (with 'gm' prefix) instead of the rig's database (with the rig's prefix like 'id'). This causes prefix mismatch errors: Error: prefix mismatch: database uses 'gm' but you specified 'id' The routes.jsonl file maps rig prefixes to /mayor/rig, so the code should always use that path for beads operations. Changes: - polecat/manager.go: Always use mayor/rig path, remove fallback logic - cmd/crew_add.go: Use mayor/rig path instead of rig root 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 --- internal/cmd/crew_add.go | 5 +++-- internal/polecat/manager.go | 16 ++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/internal/cmd/crew_add.go b/internal/cmd/crew_add.go index 7b197f17..20ec355e 100644 --- a/internal/cmd/crew_add.go +++ b/internal/cmd/crew_add.go @@ -56,8 +56,9 @@ func runCrewAdd(cmd *cobra.Command, args []string) error { crewGit := git.NewGit(r.Path) crewMgr := crew.NewManager(r, crewGit) - // Beads for agent bead creation (use rig root where .beads/ lives) - bd := beads.New(r.Path) + // Beads for agent bead creation (use mayor/rig where beads.db lives) + // The rig root .beads/ only has config.yaml, no database. + bd := beads.New(filepath.Join(r.Path, "mayor", "rig")) // Track results var created []string diff --git a/internal/polecat/manager.go b/internal/polecat/manager.go index 783c88cc..2b80c5f1 100644 --- a/internal/polecat/manager.go +++ b/internal/polecat/manager.go @@ -47,16 +47,12 @@ type Manager struct { // NewManager creates a new polecat manager. func NewManager(r *rig.Rig, g *git.Git) *Manager { - // Determine the canonical beads location: - // - If mayor/rig/.beads exists (source repo has beads tracked), use that - // - Otherwise use rig root .beads/ (created by initBeads during gt rig add) - // This matches the conditional logic in setupSharedBeads and route registration. - // For repos that have .beads/ tracked in git, the canonical database lives in mayor/rig/. - mayorRigBeads := filepath.Join(r.Path, "mayor", "rig", ".beads") - beadsPath := r.Path - if _, err := os.Stat(mayorRigBeads); err == nil { - beadsPath = filepath.Join(r.Path, "mayor", "rig") - } + // Always use mayor/rig as the beads path. + // This matches routes.jsonl which maps prefixes to /mayor/rig. + // The rig root .beads/ only contains config.yaml (no database), + // so running bd from there causes it to walk up and find town beads + // with the wrong prefix (e.g., 'gm' instead of the rig's prefix). + beadsPath := filepath.Join(r.Path, "mayor", "rig") // Try to load rig settings for namepool config settingsPath := filepath.Join(r.Path, "settings", "config.json")