feat(import): implement parent resurrection (bd-cc4f, bd-d76d, bd-02a4)

Phase 2 of fixing import failure on missing parent issues (bd-d19a).

Implemented:
- TryResurrectParent: searches JSONL history for deleted parents
- TryResurrectParentChain: recursively resurrects entire parent chains
- Creates tombstones (status=closed) to preserve hierarchical structure
- Modified EnsureIDs and CreateIssue to call resurrection before validation

When importing a child issue with missing parent:
1. Searches .beads/issues.jsonl for parent in git history
2. If found, creates tombstone with status=closed
3. Preserves original title and metadata
4. Appends original description to tombstone
5. Copies dependencies if targets exist

This allows imports to proceed even when parents were deleted,
enabling multi-repo workflows and normal database hygiene operations.

Part of bd-d19a (fix import failure on missing parents).

Amp-Thread-ID: https://ampcode.com/threads/T-a1c9e824-885e-40ce-a179-148cf39c7e64
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-11-04 13:16:17 -08:00
parent d6e2ff6151
commit 93195e336b
6 changed files with 290 additions and 78 deletions

View File

@@ -270,7 +270,7 @@ func TestGenerateBatchIDs(t *testing.T) {
{Title: "Issue 3", Description: "Third", CreatedAt: time.Now()},
}
err = generateBatchIDs(ctx, conn, issues, "test-actor")
err = s.generateBatchIDs(ctx, conn, issues, "test-actor")
if err != nil {
t.Fatalf("failed to generate IDs: %v", err)
}
@@ -299,7 +299,7 @@ func TestGenerateBatchIDs(t *testing.T) {
{ID: "wrong-prefix-123", Title: "Wrong", CreatedAt: time.Now()},
}
err = generateBatchIDs(ctx, conn, issues, "test-actor")
err = s.generateBatchIDs(ctx, conn, issues, "test-actor")
if err == nil {
t.Fatal("expected error for wrong prefix")
}