When git merge replaces the .beads/beads.db file, the daemon's SQLite connection becomes stale (still reading deleted inode). This adds FreshnessChecker that detects file replacement via inode/mtime comparison and triggers automatic reconnection. Implementation: - freshness.go: monitors db file for replacement - store.go: adds EnableFreshnessChecking() and reconnect() - queries.go: calls checkFreshness() on GetIssue/SearchIssues - daemon.go: enables freshness checking at startup - freshness_test.go: comprehensive tests including merge scenario Code quality (per review): - Extract configureConnectionPool() helper to reduce duplication - Handle Close() error in reconnect() (log but continue) - Use t.Cleanup() pattern in tests per project conventions - Rename setupFreshnessTest() per naming conventions Overhead: ~2.6μs per read op (~0.8% of total query time) Signed-off-by: Alessandro De Blasis <alex@deblasis.net> 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
15 KiB
15 KiB