From 684f69c2ae906a3cbb4cd4781610b37af19c3283 Mon Sep 17 00:00:00 2001 From: master <> Date: Mon, 6 Apr 2026 16:14:58 +0300 Subject: [PATCH] docs(elksharp): document post-routing visual quality pipeline Add AGENTS.md sections for the four late-stage post-processing steps (SpreadOuterCorridors, CollapseOrthogonalBacktracks, ExtendShortApproachSegments, ReduceLineNodeProximity) and the SVG bridge gap detection corner radius rationale. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/__Libraries/StellaOps.ElkSharp/AGENTS.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/__Libraries/StellaOps.ElkSharp/AGENTS.md b/src/__Libraries/StellaOps.ElkSharp/AGENTS.md index 90e07d6a9..640a9c843 100644 --- a/src/__Libraries/StellaOps.ElkSharp/AGENTS.md +++ b/src/__Libraries/StellaOps.ElkSharp/AGENTS.md @@ -48,6 +48,18 @@ - Under-node alongside detection extends the standard gap > 0.5px check to include flush edges (gap >= -4px and <= 0.5px for bottom, same for top). This catches edges "glued" to node boundaries. - Target-join spread pushes convergent approach lanes apart by minClearance - currentGap + 8px (half applied to each edge). The spread runs as a final winner refinement step and uses weighted score comparison (Score.Value) for promotion. +## Post-routing visual quality pipeline +The following steps run at the end of `ElkSharpLayeredLayoutEngine` after `Optimize()` returns, in order: +- `SpreadOuterCorridors`: enforces minimum gap between adjacent above-graph corridors. Splits shared-Y lanes when edges have overlapping X ranges (>40px overlap). Pushes End-bound corridors below all repeat-return corridors into a separate visual tier. +- `CollapseOrthogonalBacktracks`: detects and removes U-turn loops (right-left-right backtracks) in non-corridor edges. Only accepts if the collapsed path introduces no new shared lane violations. +- `ExtendShortApproachSegments`: extends short final approach segments to half the average node width (~101px). Shifts the penultimate vertical bend point, capped at 80% of feasible horizontal space. Skips diagonal gateway approaches. +- `ReduceLineNodeProximity`: pushes edge segments away from non-source/non-target nodes when within minClearance. Validates no new crossings, shared lanes, or target-join violations. + +These steps are additive cosmetic passes — they never regress hard routing defects (node crossings, under-node, shared lane, boundary slot, target join, gateway source exit, backtracking). + +## SVG bridge gap detection +The SVG renderer uses a 12px corner radius for bridge gap (crossing cut) detection via `EnumerateEffectiveSegments`. This is intentionally smaller than the visual 40px corner radius to ensure crossings on shorter segments near bends are still detected and drawn with the visual cut effect. + ## Testing - Run the targeted workflow renderer test project for ElkSharp changes. - Add regression tests for geometry-sensitive behavior before broad refactors.