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

@@ -63,11 +63,12 @@ func TestValidatePreExportSuite(t *testing.T) {
}
// Store hash metadata to indicate JSONL and DB are in sync
// bd-39o: renamed from last_import_hash to jsonl_content_hash
hash, err := computeJSONLHash(jsonlPath)
if err != nil {
t.Fatalf("Failed to compute hash: %v", err)
}
if err := s.SetMetadata(ctx, "last_import_hash", hash); err != nil {
if err := s.SetMetadata(ctx, "jsonl_content_hash", hash); err != nil {
t.Fatalf("Failed to set hash metadata: %v", err)
}
@@ -135,12 +136,12 @@ func TestValidatePreExportSuite(t *testing.T) {
t.Fatalf("Failed to write JSONL: %v", err)
}
// Store hash of original content
// Store hash of original content (bd-39o: renamed to jsonl_content_hash)
hash, err := computeJSONLHash(jsonlPath)
if err != nil {
t.Fatalf("Failed to compute hash: %v", err)
}
if err := s.SetMetadata(ctx, "last_import_hash", hash); err != nil {
if err := s.SetMetadata(ctx, "jsonl_content_hash", hash); err != nil {
t.Fatalf("Failed to set hash: %v", err)
}
@@ -402,7 +403,7 @@ func TestHasJSONLChangedSuite(t *testing.T) {
if err != nil {
t.Fatalf("Failed to compute hash: %v", err)
}
if err := s.SetMetadata(ctx, "last_import_hash:"+keySuffix, hash); err != nil {
if err := s.SetMetadata(ctx, "jsonl_content_hash:"+keySuffix, hash); err != nil {
t.Fatalf("Failed to set metadata: %v", err)
}
@@ -437,7 +438,7 @@ func TestHasJSONLChangedSuite(t *testing.T) {
if err != nil {
t.Fatalf("Failed to compute hash: %v", err)
}
if err := s.SetMetadata(ctx, "last_import_hash:"+keySuffix, hash); err != nil {
if err := s.SetMetadata(ctx, "jsonl_content_hash:"+keySuffix, hash); err != nil {
t.Fatalf("Failed to set metadata: %v", err)
}
@@ -522,7 +523,7 @@ func TestHasJSONLChangedSuite(t *testing.T) {
if err != nil {
t.Fatalf("Failed to compute hash: %v", err)
}
if err := s.SetMetadata(ctx, "last_import_hash:"+keySuffix, hash); err != nil {
if err := s.SetMetadata(ctx, "jsonl_content_hash:"+keySuffix, hash); err != nil {
t.Fatalf("Failed to set hash: %v", err)
}
@@ -560,7 +561,7 @@ func TestHasJSONLChangedSuite(t *testing.T) {
if err != nil {
t.Fatalf("Failed to compute hash: %v", err)
}
if err := s.SetMetadata(ctx, "last_import_hash:"+keySuffix, hash); err != nil {
if err := s.SetMetadata(ctx, "jsonl_content_hash:"+keySuffix, hash); err != nil {
t.Fatalf("Failed to set hash: %v", err)
}