fix: daemon delete creates tombstones, export includes tombstones (bd-rp4o)

Three changes to fix deleted issues resurrecting during bd sync:

1. daemon handleDelete now uses CreateTombstone instead of DeleteIssue
   - internal/rpc/server_issues_epics.go

2. sync.go exportToJSONL now includes IncludeTombstones:true
   - cmd/bd/sync.go

3. server_export_import_auto.go handleExport and auto-export now include
   tombstones in SearchIssues filter
   - internal/rpc/server_export_import_auto.go

Also adds README.md documentation for sync.branch mode (bd-dsdh):
- Explains "always dirty" working tree behavior
- Shell alias tip: gs='git status -- ":!.beads/"'
- When to use bd sync --merge

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-17 01:15:40 -08:00
parent 123e66f625
commit ff0ecb526e
4 changed files with 71 additions and 10 deletions

View File

@@ -49,8 +49,9 @@ func (s *Server) handleExport(req *Request) Response {
manifest = export.NewManifest(cfg.Policy)
}
// Get all issues (core operation, always fail-fast)
issues, err := store.SearchIssues(ctx, "", types.IssueFilter{})
// Get all issues including tombstones for sync propagation (bd-rp4o fix)
// Tombstones must be exported so they propagate to other clones and prevent resurrection
issues, err := store.SearchIssues(ctx, "", types.IssueFilter{IncludeTombstones: true})
if err != nil {
return Response{
Success: false,
@@ -464,8 +465,8 @@ func (s *Server) triggerExport(ctx context.Context, store storage.Storage, dbPat
}
}
// Export to JSONL (this will update the file with remapped IDs)
allIssues, err := sqliteStore.SearchIssues(ctx, "", types.IssueFilter{})
// Export to JSONL including tombstones for sync propagation (bd-rp4o fix)
allIssues, err := sqliteStore.SearchIssues(ctx, "", types.IssueFilter{IncludeTombstones: true})
if err != nil {
return fmt.Errorf("failed to fetch issues for export: %w", err)
}

View File

@@ -1,6 +1,7 @@
package rpc
import (
"context"
"encoding/json"
"fmt"
"os"
@@ -481,10 +482,26 @@ func (s *Server) handleDelete(req *Request) Response {
continue
}
// Delete the issue
if err := store.DeleteIssue(ctx, issueID); err != nil {
errors = append(errors, fmt.Sprintf("%s: %v", issueID, err))
continue
// Create tombstone instead of hard delete (bd-rp4o fix)
// This preserves deletion history and prevents resurrection during sync
type tombstoner interface {
CreateTombstone(ctx context.Context, id string, actor string, reason string) error
}
if t, ok := store.(tombstoner); ok {
reason := deleteArgs.Reason
if reason == "" {
reason = "deleted via daemon"
}
if err := t.CreateTombstone(ctx, issueID, "daemon", reason); err != nil {
errors = append(errors, fmt.Sprintf("%s: %v", issueID, err))
continue
}
} else {
// Fallback to hard delete if CreateTombstone not available
if err := store.DeleteIssue(ctx, issueID); err != nil {
errors = append(errors, fmt.Sprintf("%s: %v", issueID, err))
continue
}
}
// Emit mutation event for event-driven daemon