Fix bd-dvd and bd-ymj: Parent resurrection and export metadata

Bug 1 (bd-dvd): GetNextChildID now attempts parent resurrection from JSONL
before failing. Added TryResurrectParent call to match CreateIssue behavior.

Bug 2 (bd-ymj): Export now updates last_import_hash metadata to prevent
'JSONL content has changed' errors on subsequent exports.

Files changed:
- internal/storage/sqlite/hash_ids.go: Add resurrection attempt
- cmd/bd/daemon_sync.go: Add metadata updates after export
- Tests added for both fixes
- Fixed pre-existing bug in integrity_content_test.go

Follow-up work tracked in epic bd-ar2 (9 issues for improvements).

Fixes GH #334
This commit is contained in:
Steve Yegge
2025-11-21 10:29:30 -05:00
parent ff3ccdd26e
commit 4c5f99c5bd
6 changed files with 230 additions and 20 deletions

View File

@@ -27,6 +27,8 @@ func TestContentBasedComparison(t *testing.T) {
dbPath := filepath.Join(beadsDir, "beads.db")
jsonlPath := filepath.Join(beadsDir, "issues.jsonl")
ctx := context.Background()
// Create and populate database
localStore, err := sqlite.New(ctx, dbPath)
if err != nil {
@@ -34,8 +36,6 @@ func TestContentBasedComparison(t *testing.T) {
}
defer localStore.Close()
ctx := context.Background()
// Initialize database with issue_prefix
if err := localStore.SetConfig(ctx, "issue_prefix", "test"); err != nil {
t.Fatalf("Failed to set issue_prefix: %v", err)
@@ -179,6 +179,8 @@ func TestContentHashComputation(t *testing.T) {
dbPath := filepath.Join(beadsDir, "beads.db")
jsonlPath := filepath.Join(beadsDir, "issues.jsonl")
ctx := context.Background()
// Create and populate database
localStore, err := sqlite.New(ctx, dbPath)
if err != nil {
@@ -186,8 +188,6 @@ func TestContentHashComputation(t *testing.T) {
}
defer localStore.Close()
ctx := context.Background()
if err := localStore.SetConfig(ctx, "issue_prefix", "test"); err != nil {
t.Fatalf("Failed to set issue_prefix: %v", err)
}