fix: prevent inherited BEADS_DIR from causing prefix mismatch (#321)

- Fix beads.run() to always explicitly set BEADS_DIR based on the working
  directory or explicit override
- This prevents inherited environment variables (e.g., from mayor session
  with BEADS_DIR=/home/erik/gt/.beads) from causing prefix mismatch errors
  when creating agent beads for rigs
- Update polecat manager to use NewWithBeadsDir for explicitness
- Add comprehensive test coverage for BEADS_DIR routing and validation
- Add SessionLister interface for deterministic orphan session testing

Root cause: When BEADS_DIR was set in the parent environment, all bd
commands used the town database (hq- prefix) instead of the rig database
(gt- prefix), causing "prefix mismatch: database uses 'hq' but you
specified 'gt'" errors during polecat spawn.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gastown/crew/joe
2026-01-11 18:33:34 -08:00
committed by Steve Yegge
parent ea84079f8b
commit 598a39e708
7 changed files with 1298 additions and 83 deletions

View File

@@ -80,7 +80,7 @@ func NewManager(r *rig.Rig, g *git.Git) *Manager {
return &Manager{
rig: r,
git: g,
beads: beads.New(beadsPath),
beads: beads.NewWithBeadsDir(beadsPath, resolvedBeads),
namePool: pool,
}
}