Skip to content

feat(core): route every mode through one shared candidate chain - #2367

Merged
kompiro merged 2 commits into
mainfrom
feat/routing-composed-chain
Aug 7, 2026
Merged

kompiro merged 2 commits into
mainfrom
feat/routing-composed-chain

Conversation

@kompiro

@kompiro kompiro commented Aug 5, 2026 •

Copy link
Copy Markdown
Owner

Purpose

Closes #2362 — slice A of #2330. Stack 1/4.

Summary

Replaces the if (groupBands) routing fork with one priority chain that runs in grouped and ungrouped mode alike, and — the substance of this slice — gives ungrouped routing a measured fence for the first time.

Changes

  • Compose, don't fork. straight → interior channel-L → side gutter / mixed channel. Each pass skips edges a previous one routed or that need no routing, so the cheapest clear candidate wins. Both router modules stay: the grouping axis and routing capability are independent axes, so composing them lets an ungrouped canvas gain gutter routing without a second implementation.
  • routeOrthogonalEdges takes an external obstacle provider, so group frames block the interior L with the same per-endpoint exemption the gutter router uses.
  • Gutter lanes and 4-side port fan-out run in both modes (TPL-1954). groupBackward dashing stays band-gated; trunk aggregation stays grouped-only (evaluated in Evaluate aggregation trunks for the ungrouped canvas (slice C) #2364).
  • New routing-parity.test.ts. Asserts the TPL-1927 dual metric over the bundled examples — penetration 0, collinear overlap 0, every crossing hop-marked — plus a probe that the router actually fired on the models that used to leak, and pinned grouped crossing counts so an ungrouped win cannot mask a grouped regression.

Measured

12 examples / 18 layouts: ungrouped penetrations 10 → 0; grouped metrics identical on all four grouped layouts; ungrouped crossings 17 → 30, all hop-marked; collinear overlap 0 → 0.

Notably no existing test failed when the gate came out. ADR-1859's AC-5 was a structural guarantee, not a measured one — which is exactly why this slice's real deliverable is the fence, not the churn absorption. Only three committed guide SVGs changed.

Preview URL

Scope filter (new-feature PRs only)

  • N/A — not a new-feature PR (rendering behaviour change, no new modelling vocabulary)

Dependency & license impact

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

Manual Verification Checklist

  • Open a system view with Group by: none and confirm edges no longer cross node cards
  • Toggle Group by: team / boundary and confirm the grouped view looks unchanged

TPL impact

Disposition: Designed against TPL-1927 — its dual metric is extended from grouped fixtures to the real ungrouped examples in routing-parity.test.ts, which is this slice's core deliverable. Also fenced against TPL-1954 (lane/fan-out passes run in both modes so every route shape joins them), TPL-1761 (external side placement asserted intact) and TPL-1983 (the chain behaves the same on every surface). No new TPL — the applicable perspectives existed; what was missing were assertions on the default view.

Related Docs

🤖 Generated with Claude Code

kompiro and others added 2 commits August 7, 2026 13:30
Replace the `if (groupBands)` routing fork with a priority chain that runs in
grouped and ungrouped mode alike: straight (left alone when clear) -> interior
channel-L -> side gutter / mixed channel. Both router modules stay; the grouping
axis and routing capability are independent axes, so composing them lets an
ungrouped canvas gain gutter routing without a second implementation.

`routeOrthogonalEdges` now takes an external obstacle provider so group frames
block the interior L with the same per-endpoint exemption the gutter router
uses. Gutter lanes and 4-side port fan-out run in both modes so every route
shape the chain can produce takes part in the overlap passes (TPL-1954).
`groupBackward` dashing stays band-gated and trunk aggregation stays
grouped-only.

Add `routing-parity.test.ts`: the ungrouped view had no measured fence at all,
which is why removing the gate changed real diagrams without a single test
failing. It asserts the TPL-1927 dual metric over the bundled examples --
penetration 0, collinear overlap 0, every crossing hop-marked -- and pins the
grouped numbers so an ungrouped win cannot mask a grouped regression.

Measured over 12 examples / 18 layouts: ungrouped penetrations 10 -> 0, grouped
metrics identical, ungrouped crossings 17 -> 30 (all hop-marked).

Supersedes the AC-5 byte-identity decision in ADR-1859; the ADR lands with the
last slice of #2330.

Closes #2362

Co-Authored-By: Claude Fable 5 <[email protected]>
Routing an ungrouped edge turns it from a <line> into a <polyline>, and
at-0006 read the painted stroke with querySelectorAll("line, path"). The
polyline matched neither, so the query returned nothing and the empty string
read as "not dashed" -- while the product was emitting the correct
stroke-dasharray="8 4" all along.

at-0058 enumerates shapes the same way for a *negative* assertion (no diff
colour anywhere), where omitting a shape passes for the wrong reason instead of
failing. Both now list line, polyline and path.

Record the instance on TPL-1954: its lesson -- a new route shape must not fall
outside what consumes it -- applies to assertions as much as to the router's
downstream passes, and negative assertions deserve priority because they go
quiet rather than red.

Refs #2362

Co-Authored-By: Claude Fable 5 <[email protected]>
@kompiro
kompiro force-pushed the feat/routing-composed-chain branch from 8de2bd1 to 9a9173a Compare August 7, 2026 13:31
@kompiro
kompiro merged commit bf5fac5 into main Aug 7, 2026
13 checks passed
@kompiro
kompiro deleted the feat/routing-composed-chain branch August 7, 2026 13:48
kompiro added a commit that referenced this pull request Aug 16, 2026
…lution (#2517)

* refactor(core): extract the shared routing chain into runRoutingChain

The 7-step routing candidate chain (ports -> channel-L -> gutter/mixed ->
trunks -> gutter lanes -> fan-out -> channel lanes -> outline seating) was
duplicated between layoutInner and layoutMultipleSystems — the surface where
TPL-219 parity drift already bit twice (#2363 gave the root view no routing
at all; #2367 unified the chain order). The argument mapping between the two
sites is a complete injection: the multi path is the same chain with
expandedFrames and ports undefined, so the shared function reproduces both
byte-identically by construction.

Also folds the single path's duplicate portResolver(options) call into one
resolution — the resolver is a stateless closure over options, so building
it once is behaviorally identical.

Refs #2512

* refactor(core): extract canvasMembershipFor and resolveCanvasAxis

The membership resolution (scoped boundary axis -> diff cut, #2036/#2176)
and the placement-axis/group-index derivation were mirrored between
layoutInner (ancestors+container scope path) and layoutMultipleSystems
(per-system [systemId] scope path). Extract both into shared helpers; the
scope path stays a parameter and the 'is grouping on?' gates stay at the
call sites — the single path gates on a truthy index while the multi path
also requires size > 0, and that truthiness difference is live behavior.

Refs #2512

* test(core): fence the single-pipeline dual metric on the multi-root sample

TPL-219 cross-family fence for #2512: the Shop system from
multi-system-root.krs, rendered through the single-system pipeline, must
clear the same penetration/overlap contract the #2363 describe pins for the
multi-system surface. The two pipelines place the same content differently
(#2514), so router firing is pinned only where the placement provably
pierces (the multi surface); the chain contract is fenced on both.

Refs #2512

* style(core): apply oxfmt to the runRoutingChain call site

Refs #2512

* refactor(core): review fixes — unify axis gates, harden runRoutingChain opts

Code-review findings on this PR's diff:

- resolveCanvasAxis: normalize an empty axis to undefined and return the
  bandOrder (with its declaredGroupOrder fallback) so both pipelines gate
  identically on 'groupBy && groupIndex' and cannot drift on the fallback.
  The multi path's extra size > 0 gate encoded no live behavior: entering
  the collapse machinery with an empty index folds nothing and the band
  assignment's own size guard blocks, so outputs were already equal.
- runRoutingChain: every capability is now a required field (explicit
  undefined at the call site that lacks it), and the helper takes the
  band stack itself (Map | null) and derives 'grouped' internally — adding
  a capability now produces a compile error at every caller, and the
  meaning of grouped lives in one place.
- Reattach portResolver's JSDoc, which the runRoutingChain insertion had
  stranded ~100 lines above its function.
- Inline the single-use membershipForSystem alias and move the
  scopePath/canvasMembership computation below the multi-system dispatch,
  which discarded it.
- Drop the new cross-pipeline describe from routing-parity.test.ts: probing
  showed the Shop-alone rendition never fires the router (0 waypoints), so
  its zero assertions could not observe any call-site drift. The single
  path's chain arguments are already fenced by the UNGROUPED_MODELS suite
  (12 models, firing pinned on PREVIOUSLY_PIERCED) and the multi path by
  the #2363 describe.

All 3691 core tests green; 168/168 example SVGs byte-identical vs main.

Refs #2512

This branch was successfully deployed

1 active deployment
preview — 9a9173aa 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.

Route ungrouped single-system edges through the shared candidate chain (slice A)

1 participant