fix: use mayor/rig path for beads to prevent prefix mismatch (#38)

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 <rig>/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 <noreply@anthropic.com>
This commit is contained in:
Chris Sloane
2026-01-04 15:58:53 -05:00
committed by GitHub
parent 257bfbcbd8
commit 1733c6dbae
2 changed files with 9 additions and 12 deletions
+3 -2
View File
@@ -56,8 +56,9 @@ func runCrewAdd(cmd *cobra.Command, args []string) error {
crewGit := git.NewGit(r.Path) crewGit := git.NewGit(r.Path)
crewMgr := crew.NewManager(r, crewGit) crewMgr := crew.NewManager(r, crewGit)
// Beads for agent bead creation (use rig root where .beads/ lives) // Beads for agent bead creation (use mayor/rig where beads.db lives)
bd := beads.New(r.Path) // The rig root .beads/ only has config.yaml, no database.
bd := beads.New(filepath.Join(r.Path, "mayor", "rig"))
// Track results // Track results
var created []string var created []string
+6 -10
View File
@@ -47,16 +47,12 @@ type Manager struct {
// NewManager creates a new polecat manager. // NewManager creates a new polecat manager.
func NewManager(r *rig.Rig, g *git.Git) *Manager { func NewManager(r *rig.Rig, g *git.Git) *Manager {
// Determine the canonical beads location: // Always use mayor/rig as the beads path.
// - If mayor/rig/.beads exists (source repo has beads tracked), use that // This matches routes.jsonl which maps prefixes to <rig>/mayor/rig.
// - Otherwise use rig root .beads/ (created by initBeads during gt rig add) // The rig root .beads/ only contains config.yaml (no database),
// This matches the conditional logic in setupSharedBeads and route registration. // so running bd from there causes it to walk up and find town beads
// For repos that have .beads/ tracked in git, the canonical database lives in mayor/rig/. // with the wrong prefix (e.g., 'gm' instead of the rig's prefix).
mayorRigBeads := filepath.Join(r.Path, "mayor", "rig", ".beads") beadsPath := filepath.Join(r.Path, "mayor", "rig")
beadsPath := r.Path
if _, err := os.Stat(mayorRigBeads); err == nil {
beadsPath = filepath.Join(r.Path, "mayor", "rig")
}
// Try to load rig settings for namepool config // Try to load rig settings for namepool config
settingsPath := filepath.Join(r.Path, "settings", "config.json") settingsPath := filepath.Join(r.Path, "settings", "config.json")