Skip to content

feat(core): prefer an interior corridor over the canvas-edge gutter - #2368

Merged
kompiro merged 1 commit into
feat/routing-composed-chainfrom
feat/routing-shorter-detours
Aug 7, 2026
Merged

kompiro merged 1 commit into
feat/routing-composed-chainfrom
feat/routing-shorter-detours

Conversation

@kompiro

@kompiro kompiro commented Aug 5, 2026 •

Copy link
Copy Markdown
Owner

Purpose

Closes #2365 — slice D of #2330. Stack 2/4, builds on #2367.

Summary

A blocked edge used to run straight out to a gutter at the canvas edge, so reaching a node two rows down meant crossing the whole diagram twice. Offer a vertical lane beside each card first, nearest to the midpoint between the endpoints, and fall through to the gutters when none is clear.

Changes

  • New tryCorridorRoute: unlike a gutter route, each endpoint attaches on the side facing the corridor, which is what makes a lane between the endpoints usable at all.
  • Candidates are offered just outside every card border rather than derived from gaps in the union of card x-ranges. Rows are centred and vary in width, so that union usually spans the whole canvas and yields nothing — offering a lane beside each card and letting the existing whole-polyline verification reject the blocked ones finds the lanes that actually exist over the rows an edge crosses.
  • Scoped to ungrouped canvases. P2c's gutter is penetration-safe by construction (every lane x lies beyond all content) and distributeGutterLanes widens lanes on that assumption. An interior corridor has neither property. Applying it to grouped canvases broke five existing P2c tests and introduced collinear overlaps, so rather than weaken the grouped guarantee it is offered only where no frames exist — which is where the long detours were observed.
  • For the same reason the router claims interior lanes as it goes: distributeGutterLanes only relocates corridors outside the content, so an interior collision cannot be fixed afterwards (TPL-1954).

Measured

Ungrouped, over the bundled examples: total edge length 45,780 → 42,883 (−6.3%), crossings 42 → 39, total width 12,707 → 12,627. Best single case ec-platform/04-annotations at −42% edge length and 5 → 2 crossings. Grouped output is byte-identical.

hr-tool is unchanged — the case that motivated the slice. Its rows overlap in x across every row its detours traverse, so no interior lane is clear and the gutter route correctly stands. Interior corridors help where a lane exists and do nothing where it does not; they are not a general fix for diagram width.

Preview URL

Scope filter (new-feature PRs only)

  • N/A — not a new-feature PR (routing refinement)

Dependency & license impact

  • N/A — no production dependency added or bumped across a major version

Manual Verification Checklist

  • Open examples/en/client-mcp and examples/en/ec-platform/04-annotations.krs and confirm detours read as shorter, not more tangled

TPL impact

Disposition: Fenced against TPL-1954 — a new route shape must take part in the overlap passes, and since interior corridors cannot be lane-separated after the fact, the claim-as-you-route mechanism is asserted directly (an interior lane is never shared). TPL-1927's penetration/overlap assertions from #2367 cover the new shape unchanged. Added a test pinning that grouped canvases keep every corridor outside the content, so the scoping decision cannot be lost silently.

Related Docs

  • ADR-1859 (P2c gutter guarantee, deliberately preserved)

🤖 Generated with Claude Code

A blocked edge went straight out to a side gutter at the canvas edge, so on a
wide diagram reaching a node two rows down meant crossing the whole layout
twice. Offer a vertical lane beside each card first, nearest to the midpoint
between the endpoints, and fall through to the gutters when none is clear.

Unlike a gutter route, an interior corridor lets each endpoint attach on the
side facing it, which is what makes a lane *between* the endpoints usable.

Scoped to ungrouped canvases. P2c's gutter is penetration-safe by construction
-- every lane x lies beyond all content -- and `distributeGutterLanes` widens
lanes on that assumption. An interior corridor has neither property, so rather
than weaken the grouped guarantee it is offered only where no frames exist,
which is where the long detours were observed. For the same reason the router
claims interior lanes as it routes: they cannot be lane-separated afterwards.

Measured over the bundled examples (ungrouped): total edge length 45,780 ->
42,883 (-6.3%), crossings 42 -> 39, total width 12,707 -> 12,627. Best single
case is ec-platform/04-annotations at -42% edge length. Grouped output is
byte-identical. hr-tool is unchanged -- its rows overlap in x across every row
its detours traverse, so no interior lane is clear and the gutter route stands.

Closes #2365

Co-Authored-By: Claude Fable 5 <[email protected]>
@kompiro
kompiro force-pushed the feat/routing-shorter-detours branch from e60ed74 to 888ca37 Compare August 7, 2026 13:31
@kompiro
kompiro merged commit f79a369 into main Aug 7, 2026
13 of 23 checks passed
@kompiro
kompiro deleted the feat/routing-shorter-detours branch August 7, 2026 13:48

This branch was successfully deployed

1 active deployment
preview — 888ca376 Deployed Aug 7, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shorten gutter detours with an intermediate routing candidate (slice D)

1 participant