Files
beads/internal
Ryan 2ab064b2eb Doctor sync issues (#231)
* feat: enhance bd doctor sync detection with count and prefix mismatch checks

Improves bd doctor to detect actual database-JSONL sync issues instead of relying only on file modification times:

Key improvements:
1. Count detection: Reports when database issue count differs from JSONL (e.g., "Count mismatch: database has 0 issues, JSONL has 61")
2. Prefix detection: Identifies prefix mismatches when majority of JSONL issues use different prefix than database config
3. Error handling: Returns errors from helper functions instead of silent failures, distinguishing "can't open DB" from "counts differ"
4. Query optimization: Single database connection for all checks (reduced from 3 opens to 1)
5. Better error reporting: Shows actual error details when database or JSONL can't be read

This addresses the core issue where bd doctor would incorrectly report "Database and JSONL are in sync" when the database was empty but JSONL contained issues (as happened in privacy2 project).

Tests:
- Added TestCountJSONLIssuesWithMalformedLines to verify malformed JSON handling
- Existing doctor tests still pass
- countJSONLIssues now returns error to indicate parsing issues

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: correct git hooks installation instructions in bd doctor

The original message referenced './examples/git-hooks/install.sh' which doesn't exist in user projects. This fix changes the message to point to the actual location in the beads GitHub repository:

Before: "Run './examples/git-hooks/install.sh' to install recommended git hooks"
After: "See https://github.com/steveyegge/beads/tree/main/examples/git-hooks for installation instructions"

This works for any project using bd, not just the beads repository itself.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: add recovery suggestions when database fails but JSONL has issues

When bd doctor detects that the database cannot be opened/queried but the JSONL file contains issues, it now suggests the recovery command:

  Fix: Run 'bd import -i issues.jsonl --rename-on-import' to recover issues from JSONL

This addresses the case where:
- Database is corrupted or inaccessible
- JSONL has all the issues backed up
- User needs a clear path to recover

The check now:
1. Reads JSONL first (doesn't depend on database)
2. If database fails but JSONL has issues, suggests recovery command
3. If database can be queried, continues with sync checks as before

Tested on privacy2 project which has 61 issues in JSONL but inaccessible database.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: support hash-based issue IDs in import rename

The import --rename-on-import flag was rejecting valid issue IDs with
hash-based suffixes (e.g., privacy-09ea) because the validation only
accepted numeric suffixes. Beads now generates and accepts base36-encoded
hash IDs, so update the validation to match.

Changes:
- Update isNumeric() to accept base36 characters (0-9, a-z)
- Update tests to reflect hash-based ID support
- Add gosec nolint comment for safe file path construction

Fixes the error: "cannot rename issue privacy-09ea: non-numeric suffix '09ea'"

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-05 14:25:48 -08:00
..
2025-11-05 14:25:48 -08:00