fix: support delete in --no-db mode (GH#822)

Add CreateTombstone() to MemoryStorage and deleteBatchFallback() to
handle deletion when SQLite is not available. This fixes the error
"tombstone operation not supported by this storage backend" when
using bd delete with --no-db flag.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
beads/crew/emma
2025-12-31 11:45:37 -08:00
committed by Steve Yegge
parent ee51298fd5
commit b161e22144
4 changed files with 217 additions and 5 deletions

View File

@@ -474,6 +474,41 @@ func (m *MemoryStorage) CloseIssue(ctx context.Context, id string, reason string
}, actor)
}
// CreateTombstone converts an existing issue to a tombstone record.
// This is a soft-delete that preserves the issue with status="tombstone".
func (m *MemoryStorage) CreateTombstone(ctx context.Context, id string, actor string, reason string) error {
m.mu.Lock()
defer m.mu.Unlock()
issue, ok := m.issues[id]
if !ok {
return fmt.Errorf("issue not found: %s", id)
}
now := time.Now()
issue.OriginalType = string(issue.IssueType)
issue.Status = types.StatusTombstone
issue.DeletedAt = &now
issue.DeletedBy = actor
issue.DeleteReason = reason
issue.UpdatedAt = now
// Mark as dirty for export
m.dirty[id] = true
// Record tombstone creation event
event := &types.Event{
IssueID: id,
EventType: "deleted",
Actor: actor,
Comment: &reason,
CreatedAt: now,
}
m.events[id] = append(m.events[id], event)
return nil
}
// DeleteIssue permanently deletes an issue and all associated data
func (m *MemoryStorage) DeleteIssue(ctx context.Context, id string) error {
m.mu.Lock()