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:
committed by
Steve Yegge
parent
ea84079f8b
commit
598a39e708
@@ -17,9 +17,23 @@ import (
|
||||
// the expected Gas Town session naming patterns.
|
||||
type OrphanSessionCheck struct {
|
||||
FixableCheck
|
||||
sessionLister SessionLister
|
||||
orphanSessions []string // Cached during Run for use in Fix
|
||||
}
|
||||
|
||||
// SessionLister abstracts tmux session listing for testing.
|
||||
type SessionLister interface {
|
||||
ListSessions() ([]string, error)
|
||||
}
|
||||
|
||||
type realSessionLister struct {
|
||||
t *tmux.Tmux
|
||||
}
|
||||
|
||||
func (r *realSessionLister) ListSessions() ([]string, error) {
|
||||
return r.t.ListSessions()
|
||||
}
|
||||
|
||||
// NewOrphanSessionCheck creates a new orphan session check.
|
||||
func NewOrphanSessionCheck() *OrphanSessionCheck {
|
||||
return &OrphanSessionCheck{
|
||||
@@ -33,11 +47,21 @@ func NewOrphanSessionCheck() *OrphanSessionCheck {
|
||||
}
|
||||
}
|
||||
|
||||
// NewOrphanSessionCheckWithSessionLister creates a check with a custom session lister (for testing).
|
||||
func NewOrphanSessionCheckWithSessionLister(lister SessionLister) *OrphanSessionCheck {
|
||||
check := NewOrphanSessionCheck()
|
||||
check.sessionLister = lister
|
||||
return check
|
||||
}
|
||||
|
||||
// Run checks for orphaned Gas Town tmux sessions.
|
||||
func (c *OrphanSessionCheck) Run(ctx *CheckContext) *CheckResult {
|
||||
t := tmux.NewTmux()
|
||||
lister := c.sessionLister
|
||||
if lister == nil {
|
||||
lister = &realSessionLister{t: tmux.NewTmux()}
|
||||
}
|
||||
|
||||
sessions, err := t.ListSessions()
|
||||
sessions, err := lister.ListSessions()
|
||||
if err != nil {
|
||||
return &CheckResult{
|
||||
Name: c.Name(),
|
||||
|
||||
Reference in New Issue
Block a user