feat: compound-FK bus routing + complete V1 relationship visualization (ADR-0044)

Completes requirement V1. A compound (multi-column) FK now routes a
bus connector — each paired endpoint's stub merges into a shared
vertical channel that splits to the other side — plus an explicit
"(a, b) ▶ P.(x, y)" pairing line; the bus generalises the single-column
jog (reproducing it exactly, so prior snapshots are unchanged).
Self-referential FKs render as two same-named boxes.

- output_render.rs: gutter_seg routes all endpoint pairs via a
  junction() bus; pairing line for compound FKs; compound, self-ref,
  and compound-from-data (build_diagram_table glue) tests + snapshots
- compound_fk.rs: worker test that show_relationship carries both
  paired column lists into the diagram payload
- db.rs: document do_show_one's now-app-superseded relationship prose
  branch (retained as a worker-API/text fallback; could back a future
  non-visual display option, cf. ADR-0044 OOS-7)

Second /runda pass over the implementation: confirmed ADR-compliance,
UTF-8/byte-range safety, and edge-case routing. The ADR §3 last-resort
helper line was considered and rejected (vertical fallback + ratatui
truncation cover all realistic cases). ADR-0044 marked implemented;
requirements.md V1 -> [x].

Full suite 2207 pass / 0 fail / 1 ignored; clippy nursery clean.
This commit is contained in:
claude@clouddev1
2026-06-10 10:17:09 +00:00
parent a0ee32393f
commit 0a343036d8
8 changed files with 325 additions and 57 deletions
+42
View File
@@ -547,3 +547,45 @@ fn compound_fk_partial_pk_reference_is_refused() {
assert!(err.is_err(), "a partial-PK reference must be refused (F-A)");
});
}
#[test]
fn show_relationship_carries_compound_columns_into_diagram_data() {
// ADR-0044 §2.4: the `show relationship` diagram payload carries
// both paired columns on each side so the renderer can route the
// bus + pairing line.
let (_p, db, _dir) = open_project_db();
let rt = rt();
rt.block_on(async {
seed_compound(&db).await;
db.add_relationship(
Some("city_region".to_string()),
"Region".to_string(),
vec!["country".to_string(), "code".to_string()],
"City".to_string(),
vec!["country".to_string(), "region_code".to_string()],
ReferentialAction::NoAction,
ReferentialAction::NoAction,
false,
None,
)
.await
.expect("add compound relationship");
let data = db
.show_relationship("city_region".to_string())
.await
.expect("ok")
.expect("found");
// child = FK holder (City), parent = referenced (Region).
assert_eq!(data.child.name, "City");
assert_eq!(data.parent.name, "Region");
assert_eq!(
data.rel.child_columns,
vec!["country".to_string(), "region_code".to_string()],
);
assert_eq!(
data.rel.parent_columns,
vec!["country".to_string(), "code".to_string()],
);
});
}