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

View File

@@ -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

View File

@@ -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 <rig>/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")