(03bdc76) Draw a symmetric relation once, and refuse the mirror, and bump to 0.32.1
`relate` refused a relation the ticket already held but never looked at what the target held, so both ends of a `relates to` could store a line. `show` then drew the same neighbour twice under the same label, since `RelatesTo` maps to itself in `inverse_label`: one row from the stored line and one derived from the far ticket's mirror of it, indistinguishable. Live on this board, where 8556048 and 8c8a520 each stored the other. Both ends of the fix, because they do different jobs. `relation_rows` drops a derived row that reads exactly like a stored one, which repairs the boards that already hold both directions without an edit. `cmd_relate` refuses to store the mirror in the first place, reporting no change since the edge is already recorded at the far end, which stops it recurring. Neither alone closes it. The dedupe keys on the **label** and the target, not the kind and the target. Two tickets each blocking the other is two facts and the block has to say both, `blocked by` from this end and `blocks` from the other; keying on the kind would fold them into one row and lose half of what the ticket says. Only a symmetric kind can collide with its own stored line, and `RelationKind::is_symmetric` derives that from `label() == inverse_label()` rather than naming `RelatesTo`, so a kind added later answers by construction. The same gate is what keeps the refusal off a cycle: a target holding `blocked by <this>` is not a duplicate. The stored row is the survivor, not the derived one, because it is the line `relate --clear` can address. The consequence is worth knowing and is written down: with both ends holding a line, clearing one leaves the other's, which then draws as the derived row. Correct, since the far end still asserts the relation. 4179958 decided that `relates to` is symmetric and "written once, not onto both files". Nothing enforced it until now. The board's own data is left alone. 8556048 and 8c8a520 still both store the line and the block now draws it once, which is what the criterion asked for. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
0f0767ac00
commit
00a64adca8
+40
@@ -7099,6 +7099,46 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// One builder behind both views, so the dedupe 03bdc76 added lands on the board
|
||||
/// without the overlay knowing about it. Criterion 2 names the board as well as
|
||||
/// `show`, and this is the half that says so.
|
||||
#[test]
|
||||
fn a_relates_to_stored_at_both_ends_is_drawn_once_in_the_overlay() {
|
||||
let dir = board_dir();
|
||||
let holder = "11111111-0000-4000-8000-000000000000";
|
||||
let target = "22222222-0000-4000-8000-000000000000";
|
||||
|
||||
// Both lines, which is the state a board recorded before `relate` refused the
|
||||
// mirror. The section goes ahead of the metadata on the holder, where `relate`
|
||||
// writes it and where the overlay has it on screen.
|
||||
std::fs::write(
|
||||
dir.join("backlog").join(format!("{holder}_a-holder.md")),
|
||||
format!(
|
||||
"# A holder\n\n## Description\nA description.\n\n## Relations\n\
|
||||
- relates to {target}\n\n## Metadata\n\n- **ID**: {holder}\n\
|
||||
- **Priority**: 2\n- **Status**: backlog\n"
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
write_ticket(
|
||||
&dir,
|
||||
"reviewing",
|
||||
target,
|
||||
"The target",
|
||||
&format!("\n## Relations\n- relates to {holder}\n"),
|
||||
);
|
||||
|
||||
let mut board = one_board(&dir);
|
||||
board.toggle_detail();
|
||||
let body = board.detail.as_ref().expect("no detail").plain();
|
||||
|
||||
assert_eq!(
|
||||
body.matches("relates to").count(),
|
||||
1,
|
||||
"the same edge is drawn twice in the overlay:\n{body}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The body is no longer one string, so the clamp and the draw could measure two
|
||||
/// different things. They take the same `Text`, and this is what says so: a ticket
|
||||
/// whose relations run past the overlay scrolls to its last row.
|
||||
|
||||
Reference in New Issue
Block a user