Add --gastown flag to bd doctor for gastown-specific checks (#1162)

When running in gastown multi-workspace mode, two checks produce false
positives that are expected behavior:

1. routes.jsonl is a valid configuration file (maps issue prefixes to
   rig directories), not a duplicate JSONL file
2. Duplicate issues are expected (ephemeral wisps from patrol cycles)
   and normal up to ~1000, with GC cleaning them up automatically

This commit adds flags to bd doctor for gastown-specific checks:
- --gastown: Skip routes.jsonl warning and enable duplicate threshold
- --gastown-duplicates-threshold=N: Set duplicate tolerance (default 1000)

Fixes false positive warnings:
  Multiple JSONL files found: issues.jsonl, routes.jsonl
  70 duplicate issue(s) in 30 group(s)

Changes:
- Add --gastown flag to bd doctor command
- Add --gastown-duplicates-threshold flag (default: 1000)
- Update CheckLegacyJSONLFilename to skip routes.jsonl when gastown mode active
- Update CheckDuplicateIssues to use configurable threshold when gastown mode active
- Add test cases for gastown mode behavior with various thresholds

Co-authored-by: Roland Tritsch <roland@ailtir.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Roland Tritsch
2026-01-20 22:06:53 +00:00
committed by GitHub
parent f336e669e9
commit 09355eee8c
5 changed files with 277 additions and 18 deletions

View File

@@ -181,7 +181,9 @@ func CheckOrphanedDependencies(path string) DoctorCheck {
}
// CheckDuplicateIssues detects issues with identical content.
func CheckDuplicateIssues(path string) DoctorCheck {
// When gastownMode is true, the threshold parameter defines how many duplicates
// are acceptable before warning (default 1000 for gastown's ephemeral wisps).
func CheckDuplicateIssues(path string, gastownMode bool, gastownThreshold int) DoctorCheck {
// Follow redirect to resolve actual beads directory (bd-tvus fix)
beadsDir := resolveBeadsDir(filepath.Join(path, ".beads"))
dbPath := filepath.Join(beadsDir, beads.CanonicalDatabaseName)
@@ -236,7 +238,13 @@ func CheckDuplicateIssues(path string) DoctorCheck {
}
}
if duplicateGroups == 0 {
// Apply threshold based on mode
threshold := 0 // Default: any duplicates are warnings
if gastownMode {
threshold = gastownThreshold // Gastown: configurable threshold (default 1000)
}
if totalDuplicates == 0 {
return DoctorCheck{
Name: "Duplicate Issues",
Status: "ok",
@@ -244,12 +252,26 @@ func CheckDuplicateIssues(path string) DoctorCheck {
}
}
// Only warn if duplicate count exceeds threshold
if totalDuplicates > threshold {
return DoctorCheck{
Name: "Duplicate Issues",
Status: "warning",
Message: fmt.Sprintf("%d duplicate issue(s) in %d group(s)", totalDuplicates, duplicateGroups),
Detail: "Duplicates cannot be auto-fixed",
Fix: "Run 'bd duplicates' to review and merge duplicates",
}
}
// Under threshold - OK
message := "No duplicate issues"
if gastownMode && totalDuplicates > 0 {
message = fmt.Sprintf("%d duplicate(s) detected (within gastown threshold of %d)", totalDuplicates, threshold)
}
return DoctorCheck{
Name: "Duplicate Issues",
Status: "warning",
Message: fmt.Sprintf("%d duplicate issue(s) in %d group(s)", totalDuplicates, duplicateGroups),
Detail: "Duplicates cannot be auto-fixed",
Fix: "Run 'bd duplicates' to review and merge duplicates",
Status: "ok",
Message: message,
}
}