Fix bd-hv01: Implement deletion tracking for multi-workspace sync
- Add 3-way merge deletion tracking using snapshot files - Create .beads/beads.base.jsonl and .beads/beads.left.jsonl snapshots - Integrate into both sync.go and daemon_sync.go - Add comprehensive test suite in deletion_tracking_test.go - Update .gitignore to exclude snapshot files This fixes the resurrection bug where deleted issues come back after multi-workspace git sync. Uses the beads-merge 3-way merge logic to detect and apply deletions correctly.
This commit is contained in:
@@ -499,6 +499,11 @@ func createSyncFunc(ctx context.Context, store storage.Storage, autoCommit, auto
|
||||
}
|
||||
log.log("Exported to JSONL")
|
||||
|
||||
// Capture left snapshot (pre-pull state) for 3-way merge
|
||||
if err := captureLeftSnapshot(jsonlPath); err != nil {
|
||||
log.log("Warning: failed to capture snapshot for deletion tracking: %v", err)
|
||||
}
|
||||
|
||||
if autoCommit {
|
||||
// Try sync branch commit first
|
||||
committed, err := syncBranchCommitAndPush(syncCtx, store, autoPush, log)
|
||||
@@ -549,6 +554,12 @@ func createSyncFunc(ctx context.Context, store storage.Storage, autoCommit, auto
|
||||
return
|
||||
}
|
||||
|
||||
// Perform 3-way merge and prune deletions
|
||||
if err := applyDeletionsFromMerge(syncCtx, store, jsonlPath); err != nil {
|
||||
log.log("Error during 3-way merge: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := importToJSONLWithStore(syncCtx, store, jsonlPath); err != nil {
|
||||
log.log("Import failed: %v", err)
|
||||
return
|
||||
@@ -567,6 +578,11 @@ func createSyncFunc(ctx context.Context, store storage.Storage, autoCommit, auto
|
||||
return
|
||||
}
|
||||
|
||||
// Update base snapshot after successful import
|
||||
if err := updateBaseSnapshot(jsonlPath); err != nil {
|
||||
log.log("Warning: failed to update base snapshot: %v", err)
|
||||
}
|
||||
|
||||
if autoPush && autoCommit {
|
||||
if err := gitPush(syncCtx); err != nil {
|
||||
log.log("Push failed: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user