fix(merge): sort output by issue id (#859)

Ensure deterministic output when merging issues. Go map iteration order
is non-deterministic, causing inconsistent merge results across runs.

Sort result slice by ID before returning, matching bd export behavior.

Fixes #853
This commit is contained in:
Peter Chanthamynavong
2026-01-02 12:39:09 -08:00
committed by GitHub
parent f37fe949e8
commit ad44b32835
2 changed files with 76 additions and 0 deletions
+7
View File
@@ -29,9 +29,11 @@ package merge
import (
"bufio"
"cmp"
"encoding/json"
"fmt"
"os"
"slices"
"time"
"github.com/steveyegge/beads/internal/types"
@@ -523,6 +525,11 @@ func Merge3WayWithTTL(base, left, right []Issue, ttl time.Duration, debug bool)
}
}
// Sort by ID for deterministic output (matches bd export behavior)
slices.SortFunc(result, func(a, b Issue) int {
return cmp.Compare(a.ID, b.ID)
})
return result, conflicts
}