feat(doctor): add sync divergence check for JSONL/SQLite/git (GH#885)

Add CheckSyncDivergence doctor check that detects:
- JSONL on disk differs from git HEAD version
- SQLite last_import_time does not match JSONL mtime
- Uncommitted .beads/ changes exist

Each issue includes auto-fix suggestions (bd sync, bd export, git commit).
Multiple divergence issues result in error status.

Part of GH#885 recovery mechanism.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
beads/crew/wolf
2026-01-04 15:13:37 -08:00
committed by Steve Yegge
parent 44a5c3a0ec
commit 68f5bb24f8
3 changed files with 664 additions and 0 deletions

View File

@@ -368,6 +368,14 @@ func runDiagnostics(path string) doctorResult {
result.OverallOK = false
}
// Check 9a: Sync divergence (JSONL/SQLite/git) - GH#885
syncDivergenceCheck := convertWithCategory(doctor.CheckSyncDivergence(path), doctor.CategoryData)
result.Checks = append(result.Checks, syncDivergenceCheck)
if syncDivergenceCheck.Status == statusError {
result.OverallOK = false
}
// Warning-level divergence is informational, doesn't fail overall
// Check 9: Permissions
permCheck := convertWithCategory(doctor.CheckPermissions(path), doctor.CategoryCore)
result.Checks = append(result.Checks, permCheck)