fix: doctor checks follow redirect for Gas Town support (bd-tvus)

Extended bd-tvus fix to all doctor check functions that access .beads/
directory. In Gas Town multi-clone setups, crew/polecat clones use
.beads/redirect files to point to the shared mayor/rig beads directory.

Doctor checks now use resolveBeadsDir() to follow these redirects:
- daemon.go: CheckDaemonStatus
- git.go: CheckSyncBranchConfig, FindOrphanedIssues, CheckOrphanedIssues
- installation.go: CheckMultipleDatabases, CheckPermissions
- integrity.go: CheckIDFormat, CheckDependencyCycles, CheckTombstones,
  CheckDeletionsManifest, CheckRepoFingerprint
- jsonl_integrity.go: CheckJSONLIntegrity
- legacy.go: CheckFreshClone
- maintenance.go: CheckStaleClosedIssues, CheckExpiredTombstones,
  CheckCompactionCandidates
- perf.go: RunPerformanceDiagnostics, CollectPlatformInfo
- validation.go: CheckMergeArtifacts, CheckOrphanedDependencies,
  CheckDuplicateIssues, CheckTestPollution, CheckChildParentDependencies,
  CheckGitConflicts
- version.go: CheckMetadataVersionTracking

Intentionally NOT changed (check local files):
- CheckInstallation: checks local .beads/ exists
- CheckUntrackedBeadsFiles: checks git tracking of local files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-27 20:41:41 -08:00
parent ac837bc22e
commit a737223b3c
10 changed files with 50 additions and 25 deletions

View File

@@ -43,7 +43,8 @@ func CheckDaemonStatus(path string, cliVersion string) DoctorCheck {
} }
// Check for stale socket directly (catches cases where RPC failed so WorkspacePath is empty) // Check for stale socket directly (catches cases where RPC failed so WorkspacePath is empty)
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
socketPath := filepath.Join(beadsDir, "bd.sock") socketPath := filepath.Join(beadsDir, "bd.sock")
if _, err := os.Stat(socketPath); err == nil { if _, err := os.Stat(socketPath); err == nil {
// Socket exists - try to connect // Socket exists - try to connect

View File

@@ -419,7 +419,8 @@ func CheckMergeDriver(path string) DoctorCheck {
// CheckSyncBranchConfig checks if sync-branch is properly configured. // CheckSyncBranchConfig checks if sync-branch is properly configured.
func CheckSyncBranchConfig(path string) DoctorCheck { func CheckSyncBranchConfig(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
// Skip if .beads doesn't exist // Skip if .beads doesn't exist
if _, err := os.Stat(beadsDir); os.IsNotExist(err) { if _, err := os.Stat(beadsDir); os.IsNotExist(err) {
@@ -686,7 +687,8 @@ func FindOrphanedIssues(path string) ([]OrphanIssue, error) {
return []OrphanIssue{}, nil // Not a git repo, return empty list return []OrphanIssue{}, nil // Not a git repo, return empty list
} }
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
// Skip if no .beads directory // Skip if no .beads directory
if _, err := os.Stat(beadsDir); os.IsNotExist(err) { if _, err := os.Stat(beadsDir); os.IsNotExist(err) {
@@ -814,7 +816,8 @@ func CheckOrphanedIssues(path string) DoctorCheck {
} }
} }
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
// Skip if no .beads directory // Skip if no .beads directory
if _, err := os.Stat(beadsDir); os.IsNotExist(err) { if _, err := os.Stat(beadsDir); os.IsNotExist(err) {

View File

@@ -40,7 +40,8 @@ func CheckInstallation(path string) DoctorCheck {
// CheckMultipleDatabases checks for multiple database files in .beads directory // CheckMultipleDatabases checks for multiple database files in .beads directory
func CheckMultipleDatabases(path string) DoctorCheck { func CheckMultipleDatabases(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
// Find all .db files (excluding backups and vc.db) // Find all .db files (excluding backups and vc.db)
files, err := filepath.Glob(filepath.Join(beadsDir, "*.db")) files, err := filepath.Glob(filepath.Join(beadsDir, "*.db"))
@@ -88,7 +89,8 @@ func CheckMultipleDatabases(path string) DoctorCheck {
// CheckPermissions verifies that .beads directory and database are readable/writable // CheckPermissions verifies that .beads directory and database are readable/writable
func CheckPermissions(path string) DoctorCheck { func CheckPermissions(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
// Check if .beads/ is writable // Check if .beads/ is writable
testFile := filepath.Join(beadsDir, ".doctor-test-write") testFile := filepath.Join(beadsDir, ".doctor-test-write")

View File

@@ -20,7 +20,8 @@ import (
// CheckIDFormat checks whether issues use hash-based or sequential IDs // CheckIDFormat checks whether issues use hash-based or sequential IDs
func CheckIDFormat(path string) DoctorCheck { func CheckIDFormat(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
// Check metadata.json first for custom database name // Check metadata.json first for custom database name
var dbPath string var dbPath string
@@ -108,7 +109,8 @@ func CheckIDFormat(path string) DoctorCheck {
// CheckDependencyCycles checks for circular dependencies in the issue graph // CheckDependencyCycles checks for circular dependencies in the issue graph
func CheckDependencyCycles(path string) DoctorCheck { func CheckDependencyCycles(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
dbPath := filepath.Join(beadsDir, beads.CanonicalDatabaseName) dbPath := filepath.Join(beadsDir, beads.CanonicalDatabaseName)
// If no database, skip this check // If no database, skip this check
@@ -204,7 +206,8 @@ func CheckDependencyCycles(path string) DoctorCheck {
// CheckTombstones checks the health of tombstone records // CheckTombstones checks the health of tombstone records
// Reports: total tombstones, expiring soon (within 7 days), already expired // Reports: total tombstones, expiring soon (within 7 days), already expired
func CheckTombstones(path string) DoctorCheck { func CheckTombstones(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
dbPath := filepath.Join(beadsDir, beads.CanonicalDatabaseName) dbPath := filepath.Join(beadsDir, beads.CanonicalDatabaseName)
// Skip if database doesn't exist // Skip if database doesn't exist
@@ -302,7 +305,8 @@ func CheckTombstones(path string) DoctorCheck {
// CheckDeletionsManifest checks the status of deletions.jsonl and suggests migration to tombstones // CheckDeletionsManifest checks the status of deletions.jsonl and suggests migration to tombstones
func CheckDeletionsManifest(path string) DoctorCheck { func CheckDeletionsManifest(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
// Skip if .beads doesn't exist // Skip if .beads doesn't exist
if _, err := os.Stat(beadsDir); os.IsNotExist(err) { if _, err := os.Stat(beadsDir); os.IsNotExist(err) {
@@ -400,7 +404,8 @@ func CheckDeletionsManifest(path string) DoctorCheck {
// This detects when a .beads directory was copied from another repo or when // This detects when a .beads directory was copied from another repo or when
// the git remote URL changed. A mismatch can cause data loss during sync. // the git remote URL changed. A mismatch can cause data loss during sync.
func CheckRepoFingerprint(path string) DoctorCheck { func CheckRepoFingerprint(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
// Get database path // Get database path
var dbPath string var dbPath string

View File

@@ -14,7 +14,8 @@ import (
) )
func CheckJSONLIntegrity(path string) DoctorCheck { func CheckJSONLIntegrity(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
// Resolve JSONL path. // Resolve JSONL path.
jsonlPath := "" jsonlPath := ""

View File

@@ -369,7 +369,8 @@ func CheckDatabaseConfig(repoPath string) DoctorCheck {
// A fresh clone has JSONL with issues but no database file. // A fresh clone has JSONL with issues but no database file.
// bd-4ew: Recommend 'bd init --prefix <detected-prefix>' for fresh clones. // bd-4ew: Recommend 'bd init --prefix <detected-prefix>' for fresh clones.
func CheckFreshClone(repoPath string) DoctorCheck { func CheckFreshClone(repoPath string) DoctorCheck {
beadsDir := filepath.Join(repoPath, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(repoPath, ".beads"))
// Check if .beads/ exists // Check if .beads/ exists
if _, err := os.Stat(beadsDir); os.IsNotExist(err) { if _, err := os.Stat(beadsDir); os.IsNotExist(err) {

View File

@@ -21,7 +21,8 @@ const DefaultCleanupAgeDays = 30
// CheckStaleClosedIssues detects closed issues that could be cleaned up. // CheckStaleClosedIssues detects closed issues that could be cleaned up.
// This consolidates the cleanup command into doctor checks. // This consolidates the cleanup command into doctor checks.
func CheckStaleClosedIssues(path string) DoctorCheck { func CheckStaleClosedIssues(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
// Check metadata.json first for custom database name // Check metadata.json first for custom database name
var dbPath string var dbPath string
@@ -99,7 +100,8 @@ func CheckStaleClosedIssues(path string) DoctorCheck {
// CheckExpiredTombstones detects tombstones that have exceeded their TTL. // CheckExpiredTombstones detects tombstones that have exceeded their TTL.
func CheckExpiredTombstones(path string) DoctorCheck { func CheckExpiredTombstones(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
jsonlPath := filepath.Join(beadsDir, "issues.jsonl") jsonlPath := filepath.Join(beadsDir, "issues.jsonl")
if _, err := os.Stat(jsonlPath); os.IsNotExist(err) { if _, err := os.Stat(jsonlPath); os.IsNotExist(err) {
@@ -241,7 +243,8 @@ func CheckStaleMolecules(path string) DoctorCheck {
// CheckCompactionCandidates detects issues eligible for compaction. // CheckCompactionCandidates detects issues eligible for compaction.
func CheckCompactionCandidates(path string) DoctorCheck { func CheckCompactionCandidates(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
// Check metadata.json first for custom database name // Check metadata.json first for custom database name
var dbPath string var dbPath string

View File

@@ -21,7 +21,8 @@ func RunPerformanceDiagnostics(path string) {
fmt.Println(strings.Repeat("=", 50)) fmt.Println(strings.Repeat("=", 50))
// Check if .beads directory exists // Check if .beads directory exists
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
if _, err := os.Stat(beadsDir); os.IsNotExist(err) { if _, err := os.Stat(beadsDir); os.IsNotExist(err) {
fmt.Fprintf(os.Stderr, "Error: No .beads/ directory found at %s\n", path) fmt.Fprintf(os.Stderr, "Error: No .beads/ directory found at %s\n", path)
fmt.Fprintf(os.Stderr, "Run 'bd init' to initialize beads\n") fmt.Fprintf(os.Stderr, "Run 'bd init' to initialize beads\n")
@@ -107,7 +108,8 @@ func CollectPlatformInfo(path string) map[string]string {
info["go_version"] = runtime.Version() info["go_version"] = runtime.Version()
// SQLite version - try to find database // SQLite version - try to find database
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
dbPath := filepath.Join(beadsDir, beads.CanonicalDatabaseName) dbPath := filepath.Join(beadsDir, beads.CanonicalDatabaseName)
db, err := sql.Open("sqlite3", "file:"+dbPath+"?mode=ro") db, err := sql.Open("sqlite3", "file:"+dbPath+"?mode=ro")
if err == nil { if err == nil {

View File

@@ -17,7 +17,8 @@ import (
// CheckMergeArtifacts detects temporary git merge files in .beads directory. // CheckMergeArtifacts detects temporary git merge files in .beads directory.
// These are created during git merges and should be cleaned up. // These are created during git merges and should be cleaned up.
func CheckMergeArtifacts(path string) DoctorCheck { func CheckMergeArtifacts(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
if _, err := os.Stat(beadsDir); os.IsNotExist(err) { if _, err := os.Stat(beadsDir); os.IsNotExist(err) {
return DoctorCheck{ return DoctorCheck{
@@ -109,7 +110,8 @@ func readMergeArtifactPatterns(beadsDir string) ([]string, error) {
// CheckOrphanedDependencies detects dependencies pointing to non-existent issues. // CheckOrphanedDependencies detects dependencies pointing to non-existent issues.
func CheckOrphanedDependencies(path string) DoctorCheck { func CheckOrphanedDependencies(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
dbPath := filepath.Join(beadsDir, beads.CanonicalDatabaseName) dbPath := filepath.Join(beadsDir, beads.CanonicalDatabaseName)
if _, err := os.Stat(dbPath); os.IsNotExist(err) { if _, err := os.Stat(dbPath); os.IsNotExist(err) {
@@ -180,7 +182,8 @@ func CheckOrphanedDependencies(path string) DoctorCheck {
// CheckDuplicateIssues detects issues with identical content. // CheckDuplicateIssues detects issues with identical content.
func CheckDuplicateIssues(path string) DoctorCheck { func CheckDuplicateIssues(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
dbPath := filepath.Join(beadsDir, beads.CanonicalDatabaseName) dbPath := filepath.Join(beadsDir, beads.CanonicalDatabaseName)
if _, err := os.Stat(dbPath); os.IsNotExist(err) { if _, err := os.Stat(dbPath); os.IsNotExist(err) {
@@ -250,7 +253,8 @@ func CheckDuplicateIssues(path string) DoctorCheck {
// CheckTestPollution detects test issues that may have leaked into the database. // CheckTestPollution detects test issues that may have leaked into the database.
func CheckTestPollution(path string) DoctorCheck { func CheckTestPollution(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
dbPath := filepath.Join(beadsDir, beads.CanonicalDatabaseName) dbPath := filepath.Join(beadsDir, beads.CanonicalDatabaseName)
if _, err := os.Stat(dbPath); os.IsNotExist(err) { if _, err := os.Stat(dbPath); os.IsNotExist(err) {
@@ -312,7 +316,8 @@ func CheckTestPollution(path string) DoctorCheck {
// These often indicate a modeling mistake (deadlock: child waits for parent, parent waits for children). // These often indicate a modeling mistake (deadlock: child waits for parent, parent waits for children).
// However, they may be intentional in some workflows, so removal requires explicit opt-in. // However, they may be intentional in some workflows, so removal requires explicit opt-in.
func CheckChildParentDependencies(path string) DoctorCheck { func CheckChildParentDependencies(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
dbPath := filepath.Join(beadsDir, beads.CanonicalDatabaseName) dbPath := filepath.Join(beadsDir, beads.CanonicalDatabaseName)
if _, err := os.Stat(dbPath); os.IsNotExist(err) { if _, err := os.Stat(dbPath); os.IsNotExist(err) {
@@ -386,7 +391,8 @@ func CheckChildParentDependencies(path string) DoctorCheck {
// CheckGitConflicts detects git conflict markers in JSONL file. // CheckGitConflicts detects git conflict markers in JSONL file.
func CheckGitConflicts(path string) DoctorCheck { func CheckGitConflicts(path string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
jsonlPath := filepath.Join(beadsDir, "issues.jsonl") jsonlPath := filepath.Join(beadsDir, "issues.jsonl")
if _, err := os.Stat(jsonlPath); os.IsNotExist(err) { if _, err := os.Stat(jsonlPath); os.IsNotExist(err) {

View File

@@ -90,7 +90,8 @@ const localVersionFile = ".local_version"
// GH#662: This was updated to check .local_version instead of metadata.json:LastBdVersion, // GH#662: This was updated to check .local_version instead of metadata.json:LastBdVersion,
// which is now deprecated. // which is now deprecated.
func CheckMetadataVersionTracking(path string, currentVersion string) DoctorCheck { func CheckMetadataVersionTracking(path string, currentVersion string) DoctorCheck {
beadsDir := filepath.Join(path, ".beads") // Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
localVersionPath := filepath.Join(beadsDir, localVersionFile) localVersionPath := filepath.Join(beadsDir, localVersionFile)
// Read .local_version file // Read .local_version file