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:
@@ -33,7 +33,7 @@ func validateBatchIssues(issues []*types.Issue) error {
|
||||
}
|
||||
|
||||
// generateBatchIDs generates IDs for all issues that need them atomically
|
||||
func generateBatchIDs(ctx context.Context, conn *sql.Conn, issues []*types.Issue, actor string) error {
|
||||
func (s *SQLiteStorage) generateBatchIDs(ctx context.Context, conn *sql.Conn, issues []*types.Issue, actor string) error {
|
||||
// Get prefix from config (needed for both generation and validation)
|
||||
var prefix string
|
||||
err := conn.QueryRowContext(ctx, `SELECT value FROM config WHERE key = ?`, "issue_prefix").Scan(&prefix)
|
||||
@@ -45,7 +45,7 @@ func generateBatchIDs(ctx context.Context, conn *sql.Conn, issues []*types.Issue
|
||||
}
|
||||
|
||||
// Generate or validate IDs for all issues
|
||||
if err := EnsureIDs(ctx, conn, prefix, issues, actor); err != nil {
|
||||
if err := s.EnsureIDs(ctx, conn, prefix, issues, actor); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ func (s *SQLiteStorage) CreateIssues(ctx context.Context, issues []*types.Issue,
|
||||
}()
|
||||
|
||||
// Phase 3: Generate IDs for issues that need them
|
||||
if err := generateBatchIDs(ctx, conn, issues, actor); err != nil {
|
||||
if err := s.generateBatchIDs(ctx, conn, issues, actor); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user