refactor: rename last_import_hash to jsonl_content_hash (bd-39o)

The metadata key 'last_import_hash' was misleading because it's updated on
both import AND export. Renamed to 'jsonl_content_hash' which more accurately
describes its purpose - tracking the content hash of the JSONL file.

Added migration support: read operations try new key first, then fall back
to old key for backwards compatibility with existing databases.

Files modified:
- cmd/bd/integrity.go: Update key name with migration support
- cmd/bd/import.go: Update key name
- cmd/bd/sync.go: Update key name
- cmd/bd/autoflush.go: Update key name with migration support
- cmd/bd/daemon_sync.go: Update key name
- cmd/bd/daemon_event_loop.go: Update key name with migration support
- internal/autoimport/autoimport.go: Update key name with migration support
- Updated all related tests

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-11-28 23:14:06 -08:00
parent bca8022bee
commit f59f8c20d0
9 changed files with 90 additions and 64 deletions

View File

@@ -174,10 +174,13 @@ func checkDaemonHealth(ctx context.Context, store storage.Storage, log daemonLog
// Health check 1: Verify metadata is accessible
// This helps detect if external operations (like bd import --force) have modified metadata
// Without this, daemon may continue operating with stale metadata cache
if _, err := store.GetMetadata(ctx, "last_import_hash"); err != nil {
log.log("Health check: metadata read failed: %v", err)
// Non-fatal: daemon continues but logs the issue
// This helps diagnose stuck states in sandboxed environments
// Try new key first, fall back to old for migration (bd-39o)
if _, err := store.GetMetadata(ctx, "jsonl_content_hash"); err != nil {
if _, err := store.GetMetadata(ctx, "last_import_hash"); err != nil {
log.log("Health check: metadata read failed: %v", err)
// Non-fatal: daemon continues but logs the issue
// This helps diagnose stuck states in sandboxed environments
}
}
// Health check 2: Database integrity check