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:
42
README.md
42
README.md
@@ -343,6 +343,48 @@ bd --no-auto-flush create "Issue" # Skip auto-export
|
||||
bd --no-auto-import list # Skip auto-import check
|
||||
```
|
||||
|
||||
### Sync Branch Mode (sync.branch)
|
||||
|
||||
For protected branches or to reduce commit noise on main, configure a separate sync branch:
|
||||
|
||||
```bash
|
||||
bd init --branch beads-sync # During init
|
||||
# Or configure later:
|
||||
git config beads.sync.branch beads-sync
|
||||
```
|
||||
|
||||
**How it works:**
|
||||
1. `bd sync` commits issue changes to the sync branch (e.g., `beads-sync`)
|
||||
2. Issue data is copied to your working tree so CLI commands work normally
|
||||
3. The sync branch accumulates commits; main stays clean
|
||||
4. Periodically merge with `bd sync --merge` (releases, milestones, etc.)
|
||||
|
||||
**The "always dirty" working tree:**
|
||||
|
||||
When sync.branch is configured, `.beads/issues.jsonl` in your working tree will **always appear modified**. This is by design:
|
||||
|
||||
- bd copies the latest JSONL to your working tree so commands work
|
||||
- This copy is NOT committed to main (to reduce commit noise)
|
||||
- The file is "dirty" because it's newer than what's on main
|
||||
|
||||
**Be Zen about it.** This is expected behavior, not a bug. Options:
|
||||
|
||||
1. **Accept it** - Use a shell alias to hide beads from git status:
|
||||
```bash
|
||||
alias gs='git status -- ":!.beads/"'
|
||||
```
|
||||
|
||||
2. **Merge periodically** - Run `bd sync --merge` to snapshot issues to main:
|
||||
```bash
|
||||
bd sync --merge # Merge beads-sync → main
|
||||
bd sync --merge --dry-run # Preview what would be merged
|
||||
```
|
||||
|
||||
3. **Disable sync.branch** - If clean working tree matters more:
|
||||
```bash
|
||||
git config --unset beads.sync.branch
|
||||
```
|
||||
|
||||
## Hash-Based Issue IDs
|
||||
|
||||
**Version 0.20.1 introduces collision-resistant hash-based IDs** to enable reliable multi-worker and multi-branch workflows.
|
||||
|
||||
@@ -1277,8 +1277,9 @@ func exportToJSONL(ctx context.Context, jsonlPath string) error {
|
||||
return fmt.Errorf("failed to initialize store: %w", err)
|
||||
}
|
||||
|
||||
// Get all issues
|
||||
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 fmt.Errorf("failed to get issues: %w", err)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -481,11 +482,27 @@ func (s *Server) handleDelete(req *Request) Response {
|
||||
continue
|
||||
}
|
||||
|
||||
// Delete the issue
|
||||
// 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
|
||||
s.emitMutation(MutationDelete, issueID)
|
||||
|
||||
Reference in New Issue
Block a user