fix(rig): return rig root from BeadsPath() to respect redirect system

BeadsPath() was incorrectly returning <rig>/mayor/rig when HasMayor was
true, bypassing the redirect system at <rig>/.beads/redirect. This caused
beads operations to fail when the user's repo doesn't have tracked beads.

The redirect architecture is:
- <rig>/.beads/redirect -> mayor/rig/.beads (when repo tracks .beads/)
- <rig>/.beads/ contains local database (when repo doesn't track .beads/)

By always returning the rig root, all callers now go through the redirect
system which is set up by initBeads() during rig creation.

Affected callers (all now work correctly):
- internal/refinery/manager.go - Queue() for merge requests
- internal/swarm/manager.go - swarm operations
- internal/cmd/swarm.go - swarm CLI commands
- internal/cmd/status.go - rig status display
- internal/cmd/mq_next.go - merge queue operations
- internal/cmd/mq_list.go - merge queue listing
- internal/cmd/rig_dock.go - dock/undock operations

Fixes #317

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
julianknutsen
2026-01-11 06:35:20 +00:00
parent 982ce6c5d1
commit e7d7a1bd6b
3 changed files with 238 additions and 6 deletions

View File

@@ -70,13 +70,16 @@ func (r *Rig) Summary() RigSummary {
}
// BeadsPath returns the path to use for beads operations.
// Returns the mayor/rig clone path if available (has proper sync-branch config),
// otherwise falls back to the rig root path.
// This ensures beads commands read from a location with git-synced beads data.
// Always returns the rig root path where .beads/ contains either:
// - A local beads database (when repo doesn't track .beads/)
// - A redirect file pointing to mayor/rig/.beads (when repo tracks .beads/)
//
// The redirect is set up by initBeads() during rig creation and followed
// automatically by the bd CLI and beads.ResolveBeadsDir().
//
// This ensures we never write to the user's repo clone (mayor/rig/) and
// all beads operations go through the redirect system.
func (r *Rig) BeadsPath() string {
if r.HasMayor {
return r.Path + "/mayor/rig"
}
return r.Path
}