From a86ef6afb809ae3438fbd3027bc5a14493c73877 Mon Sep 17 00:00:00 2001 From: master <> Date: Fri, 3 Apr 2026 07:47:07 +0300 Subject: [PATCH] fix(elksharp): preserve source/target endpoints in corridor reroute clearance push MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the corridor reroute pushes a horizontal segment away from a blocking node, preserve the first point (source connection) and insert a vertical step to reconnect the last point (target connection) at the original Y. Previously, pushing all points uniformly would disconnect the edge from its target node when the push Y exceeded the target node's boundary. Fixes edge/9 (Retry Decision → Set batchGenerateFailed) which was pushed to Y=653 but the target node bottom is at Y=614 — the endpoint now steps back up to Y=592 to reconnect. Co-Authored-By: Claude Opus 4.6 (1M context) --- ...Iterative.BoundaryFirst.CorridorReroute.cs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/__Libraries/StellaOps.ElkSharp/ElkEdgeRouterIterative.BoundaryFirst.CorridorReroute.cs b/src/__Libraries/StellaOps.ElkSharp/ElkEdgeRouterIterative.BoundaryFirst.CorridorReroute.cs index 1afb03343..0e0ac05e2 100644 --- a/src/__Libraries/StellaOps.ElkSharp/ElkEdgeRouterIterative.BoundaryFirst.CorridorReroute.cs +++ b/src/__Libraries/StellaOps.ElkSharp/ElkEdgeRouterIterative.BoundaryFirst.CorridorReroute.cs @@ -209,12 +209,30 @@ internal static partial class ElkEdgeRouterIterative && bestPushY < graphMaxY + 56d && Math.Abs(bestPushY - laneY) > 2d) { - var newPath = new List(path.Count); + var newPath = new List(path.Count + 2); for (var i = 0; i < path.Count; i++) { if (i >= bestSegStart && i <= bestSegStart + 1 && Math.Abs(path[i].Y - laneY) <= 2d) { + // Preserve source connection (first point). + if (i == 0) + { + newPath.Add(path[i]); + continue; + } + + // Preserve target connection (last point) — + // insert a vertical step to reconnect. + if (i == path.Count - 1) + { + var stepX = path[i].X + (path[i - 1].X > path[i].X ? 24d : -24d); + newPath.Add(new ElkPoint { X = stepX, Y = bestPushY }); + newPath.Add(new ElkPoint { X = stepX, Y = path[i].Y }); + newPath.Add(path[i]); + continue; + } + newPath.Add(new ElkPoint { X = path[i].X, Y = bestPushY }); } else