Fix bd-pq5k: merge conflicts now prefer closed>open and deletion>modification
CHANGES: 1. Merge logic (internal/merge/merge.go): - Added mergeStatus() enforcing closed ALWAYS wins over open - Fixed closed_at handling: only set when status='closed' - Changed deletion handling: deletion ALWAYS wins over modification 2. Deletion tracking (cmd/bd/snapshot_manager.go): - Updated ComputeAcceptedDeletions to accept all merge deletions - Removed "unchanged locally" check (deletion wins regardless) 3. FK constraint helper (internal/storage/sqlite/util.go): - Added IsForeignKeyConstraintError() for bd-koab - Detects FK violations for graceful import handling TESTS UPDATED: - TestMergeStatus: comprehensive status merge tests - TestIsForeignKeyConstraintError: FK constraint detection - bd-pq5k test: validates no invalid state (status=open with closed_at) - Deletion tests: reflect new deletion-wins behavior - All tests pass ✓ This ensures issues never get stuck in invalid states and prevents the insane situation where issues never die! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -232,21 +232,19 @@ func (sm *SnapshotManager) Initialize() error {
|
||||
// An issue is an "accepted deletion" if:
|
||||
// - It exists in base (last import)
|
||||
// - It does NOT exist in merged (after 3-way merge)
|
||||
// - It is unchanged in left (pre-pull export) compared to base
|
||||
//
|
||||
// Note (bd-pq5k): Deletion always wins over modification in the merge,
|
||||
// so if an issue is deleted in the merged result, we accept it regardless
|
||||
// of local changes.
|
||||
func (sm *SnapshotManager) ComputeAcceptedDeletions(mergedPath string) ([]string, error) {
|
||||
basePath, leftPath := sm.getSnapshotPaths()
|
||||
basePath, _ := sm.getSnapshotPaths()
|
||||
|
||||
// Build map of ID -> raw line for base and left
|
||||
// Build map of ID -> raw line for base
|
||||
baseIndex, err := sm.buildIDToLineMap(basePath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read base snapshot: %w", err)
|
||||
}
|
||||
|
||||
leftIndex, err := sm.buildIDToLineMap(leftPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read left snapshot: %w", err)
|
||||
}
|
||||
|
||||
// Build set of IDs in merged result
|
||||
mergedIDs, err := sm.buildIDSet(mergedPath)
|
||||
if err != nil {
|
||||
@@ -257,13 +255,13 @@ func (sm *SnapshotManager) ComputeAcceptedDeletions(mergedPath string) ([]string
|
||||
|
||||
// Find accepted deletions
|
||||
var deletions []string
|
||||
for id, baseLine := range baseIndex {
|
||||
for id := range baseIndex {
|
||||
// Issue in base but not in merged
|
||||
if !mergedIDs[id] {
|
||||
// Check if unchanged locally - try raw equality first, then semantic JSON comparison
|
||||
if leftLine, existsInLeft := leftIndex[id]; existsInLeft && (leftLine == baseLine || sm.jsonEquals(leftLine, baseLine)) {
|
||||
deletions = append(deletions, id)
|
||||
}
|
||||
// bd-pq5k: Deletion always wins over modification in 3-way merge
|
||||
// If the merge resulted in deletion, accept it regardless of local changes
|
||||
// The 3-way merge already determined that deletion should win
|
||||
deletions = append(deletions, id)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user