|
| 1 | +# beads-merge Agent Guidelines |
| 2 | + |
| 3 | +## Purpose |
| 4 | + |
| 5 | +beads-merge is a 3-way merge tool specifically for beads `.jsonl` issue files. It implements intelligent merging based on issue identity and field-specific merge strategies. |
| 6 | + |
| 7 | +## Testing Requirements |
| 8 | + |
| 9 | +- All changes to merge logic must include unit tests |
| 10 | +- Test both successful merge cases and conflict scenarios |
| 11 | +- Integration tests should cover real-world merge patterns from `.beads/issues.jsonl` |
| 12 | + |
| 13 | +## Merge Algorithm Constraints |
| 14 | + |
| 15 | +### DO NOT change these without discussion: |
| 16 | + |
| 17 | +1. Issue identity is based on `.id`, `.created_at`, and `.created_by` only |
| 18 | +2. Timestamps (updated_at, closed_at) always use max value |
| 19 | +3. Dependencies are always merged (deduplicated by issue_id + depends_on_id + type) |
| 20 | +4. String fields use 3-way merge (prefer the side that changed from base) |
| 21 | + |
| 22 | +### Fields that need special handling: |
| 23 | + |
| 24 | +- Priority: integer field, handle like strings but compare as numbers |
| 25 | +- Dependencies: array, must deduplicate based on composite key |
| 26 | + |
| 27 | +## Common Issues |
| 28 | + |
| 29 | +### Issue not merging when expected |
| 30 | +Check that `.id`, `.created_at`, and `.created_by` match exactly in all three files. Even minor differences (timezone, precision) will cause issues to be treated as different. |
| 31 | + |
| 32 | +### Dependencies being duplicated |
| 33 | +Ensure the deduplication key includes all three fields: issue_id, depends_on_id, and type. Two dependencies with same issue_id and depends_on_id but different types are distinct. |
| 34 | + |
| 35 | +### Incorrect conflict markers |
| 36 | +Conflicts should only be generated when both sides changed the same field to different values (not when base == left or base == right). |
0 commit comments