Commit Graph

903 Commits

Author SHA1 Message Date
Steve Yegge
731f40da34 Fix FileWatcher robustness issues (bd-71)
- Fix Debouncer race condition with sequence numbers to prevent double-fire
- Add parent directory watch to catch file creates/renames
- Add .git/HEAD watch for branch change detection
- Implement retry/backoff (50-400ms) for re-establishing JSONL watch
- Handle Create/Chmod events in addition to Write
- Add .git/HEAD polling in polling mode
- All 18 debouncer and watcher tests pass

Amp-Thread-ID: https://ampcode.com/threads/T-4029d643-b4b4-4d3b-bd85-74461f78cd7f
Co-authored-by: Amp <amp@ampcode.com>
2025-10-29 22:55:13 -07:00
Steve Yegge
0f1b597961 chore: Bump version to 0.19.0
Release highlights:
- Fix bd-160: JSONL integrity validation prevents export deduplication data loss
- Add comprehensive integration tests for export/import workflows
- Clear export_hashes on imports to prevent staleness
- Created bd-179 epic for remaining test coverage improvements

This release fixes a critical P0 bug that could cause silent data loss
when JSONL and export_hashes diverged after git operations.
2025-10-29 22:05:18 -07:00
Steve Yegge
9ba77e981f bd sync: 2025-10-29 21:57:23 2025-10-29 21:57:23 -07:00
Steve Yegge
c34b93fa1a Fix bd-160: Implement JSONL integrity validation and prevent export deduplication data loss
## Problem
Export deduplication feature broke when JSONL and export_hashes diverged
(e.g., after git pull/reset). This caused exports to skip issues that
weren't actually in the file, leading to silent data loss.

## Solution
1. JSONL integrity validation before every export
   - Store JSONL file hash after export
   - Validate hash before export, clear export_hashes if mismatch
   - Automatically recovers from git operations changing JSONL

2. Clear export_hashes on all imports
   - Prevents stale hashes from causing future export failures
   - Import operations invalidate export_hashes state

3. Add Storage interface methods:
   - GetJSONLFileHash/SetJSONLFileHash for integrity tracking
   - ClearAllExportHashes for recovery

## Tests Added
- TestJSONLIntegrityValidation: Unit tests for validation logic
- TestImportClearsExportHashes: Verifies imports clear hashes
- TestExportIntegrityAfterJSONLTruncation: Simulates git reset (would have caught bd-160)
- TestExportIntegrityAfterJSONLDeletion: Tests recovery from file deletion
- TestMultipleExportsStayConsistent: Tests repeated export integrity

## Follow-up
Created bd-179 epic for remaining integration test gaps (multi-repo sync,
daemon auto-sync, corruption recovery tests).

Closes bd-160
2025-10-29 21:57:15 -07:00
Steve Yegge
52e6361ad8 Add recovery plan documentation for bd-160 export bug 2025-10-29 21:37:58 -07:00
Steve Yegge
d5400dcdeb bd sync: 2025-10-29 21:37:39 2025-10-29 21:37:39 -07:00
Steve Yegge
c6476fe2da bd sync: 2025-10-29 21:30:19 2025-10-29 21:30:19 -07:00
Steve Yegge
a7f86341a7 bd sync: 2025-10-29 21:21:13 2025-10-29 21:21:15 -07:00
Steve Yegge
bafa8374f9 CRITICAL: Disable export deduplication (bd-160)
The timestamp-only deduplication feature causes data loss when
export_hashes table gets out of sync with JSONL file (after git
operations, imports, etc). This leads to exports skipping issues
that aren't actually in the file.

Symptoms we saw:
- Export reports 'Skipped 128 issues with timestamp-only changes'
- JSONL only has 38 lines but DB has 149 issues
- Two repos on same commit show different issue counts
- Auto-import doesn't trigger (hash matches despite missing data)

Fix: Disable the feature entirely until we can implement proper
JSONL integrity validation (see bd-160 for proposed solutions).
2025-10-29 21:21:04 -07:00
Steve Yegge
c9704f8bd4 Fix export: clear stale export_hashes 2025-10-29 21:19:29 -07:00
Steve Yegge
98b153f2a7 bd sync: apply rename detection from import 2025-10-29 21:16:13 -07:00
Steve Yegge
a001e4ee7b bd sync: 2025-10-29 21:14:31 2025-10-29 21:14:31 -07:00
Steve Yegge
c9e6757f9e bd sync: 2025-10-29 20:48:48 2025-10-29 20:48:48 -07:00
Steve Yegge
4a9ee2f1e7 bd sync: 2025-10-29 20:48:00 2025-10-29 20:48:00 -07:00
Steve Yegge
4d62cb944c bd sync: 2025-10-29 20:45:07 2025-10-29 20:45:07 -07:00
Steve Yegge
1523bd5875 Merge remote changes 2025-10-29 20:44:28 -07:00
Steve Yegge
7001c422de bd sync: 2025-10-29 20:44:15 2025-10-29 20:44:15 -07:00
Steve Yegge
73ee51bb3f Sync bd changes: close bd-59, link bd-65 to bd-102 2025-10-29 20:44:07 -07:00
Steve Yegge
5766bcb496 Import remapped issues after collision 2025-10-29 20:02:51 -07:00
Steve Yegge
5b752903ae bd sync: 2025-10-29 20:02:48 2025-10-29 20:02:48 -07:00
Steve Yegge
08bdac1e14 bd daemon sync: 2025-10-29 19:52:19 2025-10-29 19:52:19 -07:00
Steve Yegge
6e6e7eb1f5 bd daemon sync: 2025-10-29 19:52:15 2025-10-29 19:52:15 -07:00
Steve Yegge
ba18638da2 bd sync: 2025-10-29 19:51:50 2025-10-29 19:51:50 -07:00
Steve Yegge
71cc695a7d Add issue bd-102: --json flag consistency 2025-10-29 19:49:26 -07:00
Steve Yegge
e972295c1e Sync beads database 2025-10-29 19:45:50 -07:00
Steve Yegge
17a20748cb Mark in-progress issues as open 2025-10-29 19:44:54 -07:00
Steve Yegge
6d3888617c Merge remote-tracking branch 'origin/main'
Resolved version conflicts by accepting version 0.18.0 across all files.
2025-10-29 19:41:12 -07:00
Steve Yegge
b2d874cbbf chore: Bump version to 0.18.0
Amp-Thread-ID: https://ampcode.com/threads/T-34d05149-eda4-40e0-b758-28a736a7eba6
Co-authored-by: Amp <amp@ampcode.com>
2025-10-29 19:34:01 -07:00
Steve Yegge
0f3b826010 Resolve merge conflict: use local JSONL 2025-10-29 19:32:03 -07:00
Steve Yegge
98c39c2e6f bd sync: 2025-10-29 19:31:28 2025-10-29 19:31:28 -07:00
Steve Yegge
5513af3b63 Fix CI: Configure git identity for tests 2025-10-29 19:16:43 -07:00
Steve Yegge
3fd3760a28 bd daemon export: 2025-10-29 19:12:54 2025-10-29 19:12:54 -07:00
Steve Yegge
1873764370 bd daemon export: 2025-10-29 19:11:58 2025-10-29 19:11:58 -07:00
Steve Yegge
a9a26275d5 bd daemon export: 2025-10-29 19:11:28 2025-10-29 19:11:28 -07:00
Steve Yegge
6045e87d55 bd daemon export: 2025-10-29 19:08:03 2025-10-29 19:08:03 -07:00
Steve Yegge
cb68ca3781 bd daemon sync: 2025-10-29 19:06:11 2025-10-29 19:06:11 -07:00
Steve Yegge
84fd068e3f Add TestSymmetricCollision unit test for deterministic collision resolution 2025-10-29 17:49:46 -07:00
Steve Yegge
8e85ececd2 bd sync: 2025-10-29 17:49:41 2025-10-29 17:49:41 -07:00
Steve Yegge
5743b48ca2 bd sync: 2025-10-29 16:43:32 2025-10-29 16:43:32 -07:00
Steve Yegge
29326d84c3 bd sync: 2025-10-29 16:15:13 2025-10-29 16:15:13 -07:00
Steve Yegge
86945f2ac4 Add event-driven daemon documentation and platform tests
- Document BEADS_DAEMON_MODE environment variable in AGENTS.md
- Add comprehensive platform tests for FileWatcher (Linux/macOS/Windows)
- Close bd-75, bd-79, bd-83, bd-85 (event-driven daemon epic complete)
2025-10-29 15:53:41 -07:00
Steve Yegge
1238a0a689 bd sync: 2025-10-29 15:53:34 2025-10-29 15:53:34 -07:00
Steve Yegge
8a7c36fe70 Validation and testing improvements (bd-74, bd-77)
- Remove unreachable function DroppedEventsCount from RPC server
- Add TestMutationToExportLatency for event-driven daemon validation
- Test currently skipped pending full bd-85 implementation
- Create test coverage improvement issues (bd-114 through bd-118)
- All validation checks pass: tests, build, linting baseline

Completed: bd-74, bd-77
Amp-Thread-ID: https://ampcode.com/threads/T-24404401-6c5b-466d-9045-0da3a70cff9a
Co-authored-by: Amp <amp@ampcode.com>
2025-10-29 15:30:47 -07:00
Steve Yegge
da9773c31b Add bd repair-deps command (bd-58)
- Scans all issues for dependencies pointing to non-existent issues
- Reports orphaned dependencies with issue ID, depends_on ID, and type
- --fix flag automatically removes all orphaned dependencies
- --interactive mode prompts for each orphan before removal
- Uses direct SQL deletion to avoid foreign key errors on missing issues
- JSON output support with --json flag
- 4 comprehensive tests covering scan, fix, and multiple dependency types

Amp-Thread-ID: https://ampcode.com/threads/T-942a3e75-f90b-45b4-9f88-c7f1b8298cef
Co-authored-by: Amp <amp@ampcode.com>
2025-10-29 12:56:51 -07:00
Steve Yegge
0c06900956 Add comprehensive unit tests for Debouncer (bd-82)
- Test batching of multiple triggers into single action
- Test timer reset on subsequent triggers
- Test cancellation during wait and immediately after trigger
- Test thread safety with deterministic concurrent trigger batching
- All tests use t.Cleanup to prevent goroutine leaks
- Tests pass with -race detector
2025-10-29 12:32:27 -07:00
Steve Yegge
2f11eaa54b bd sync: 2025-10-29 11:50:20 2025-10-29 11:50:20 -07:00
Steve Yegge
7d0cccdccb Add comprehensive unit tests for FileWatcher (bd-78)
- Test JSONL change detection with fsnotify
- Test multiple changes debounced into single action
- Test git ref change detection (platform-aware, skips if unsupported)
- Test file removal/recreation handling (platform-aware)
- Test polling fallback mode
- Test polling detects file disappearance
- Test proper cleanup with Close()

All 7 tests pass. Two tests skip gracefully on platforms where
fsnotify doesn't support git ref watching or file removal/recreation
events. No linter warnings for new test file.

Closes bd-78

Amp-Thread-ID: https://ampcode.com/threads/T-76e7b2ba-150c-461f-83e2-4a6d509d6b53
Co-authored-by: Amp <amp@ampcode.com>
2025-10-29 11:47:40 -07:00
Steve Yegge
df71bca0a1 bd sync: 2025-10-29 11:26:50 2025-10-29 11:26:50 -07:00
Steve Yegge
fea86f9b31 Implement event-driven daemon improvements for bd-85
- Add mutation events for label/dep/comment operations
- Create separate export-only and import-only functions
- Add dropped events counter with safety net export
- Complete bd-80 mutation channel implementation

Event-driven mode now:
- Emits mutation events for ALL write operations (not just create/update/close)
- Uses createExportFunc() for mutations (export+commit/push only, no pull)
- Uses createAutoImportFunc() for file changes (pull+import only, no export)
- Tracks dropped events and triggers safety export every 60s if any dropped
- Achieves <500ms latency target by avoiding full sync on each trigger

Behind BEADS_DAEMON_MODE=events flag (poll is still default)
2025-10-29 11:22:29 -07:00
Steve Yegge
55f803a7c9 Fix multi-round convergence for N-way collisions (bd-108)
- Add AllocateNextID() public method to SQLiteStorage for cross-package ID allocation
- Enhance handleRename() to handle collision during rename with retry logic
- Fix stale ID map issue by removing deleted IDs from dbByID after rename
- Update edge case tests to use convergence rounds consistently
- All N-way collision tests now pass (TestFiveCloneCollision, TestEdgeCases)
2025-10-29 11:08:28 -07:00