Files
lolympus-tournament-support/docs/plans/double-elimination-connector-routing.md

3.9 KiB

Implementation Plan: Double-Elimination Connector Routing

Overview

Replace per-edge winner rail staggering with deterministic, collision-aware winner bundles while retaining the existing target-corridor H-V-H path model and the current loser/reset routing behavior.

Architecture Decisions

  • Keep routing as a pure layout calculation; the React renderer consumes unchanged BracketConnectorLayout paths.
  • Allocate baseline rails first, then choose one rail for each same-target winner bundle while leaving loser/reset coordinates unchanged.
  • Score complete candidate paths by parallel-stroke clearance, strict crossings, and distance from the corridor midpoint.
  • Permit shared verticalX only when the participating vertical intervals do not overlap; otherwise search the same corridor for the nearest deterministic pair of separate rails with focused-stroke clearance.

Task List

Phase 1: Regression Contract

  • Add tests proving quiet winner bundles use the corridor midpoint and all shareable same-target winner paths remain aligned.
  • Replace target-column rail uniqueness with interval-aware segment assertions.
  • Cover reversed A/B input where overlapping vertical spans require the deterministic separate-rail fallback.
  • Confirm the focused test fails with the current allocator.

Checkpoint: RED

  • The new behavioral assertion fails for the expected unequal verticalX.
  • Existing tests remain unchanged except where their invariant is obsolete.

Phase 2: Bundle-Aware Allocator

  • Represent connector routing inputs with precomputed source/target anchors.
  • Retain stable independent rails for loser/reset routes.
  • Group the two winners entering each target and select the nearest safe shared rail without card penetration, forbidden overlap, or avoidable added crossings.
  • Fall back to the nearest deterministic, stroke-clear separate rails only when the pair's own vertical intervals overlap and cannot safely share a rail.

Checkpoint: GREEN

  • Focused layout tests pass for four-team, eight-team, reset-final, and shuffled input fixtures.
  • Strict crossing, collinear-overlap, and 5px parallel-clearance safeguards pass.

Phase 3: Verification and Review

  • Run the full web suite, lint, and production build; document the unrelated pre-existing full-lint failures while verifying changed files separately.
  • Inspect the diff for correctness, simplicity, security, performance, and adherence to the approved spec.
  • Perform an independent review and address all required findings.

Checkpoint: Complete

  • All success criteria in the spec are verified.
  • No unrelated files are modified.

Risks and Mitigations

Risk Impact Mitigation
Blind midpoint alignment adds crossings in busy upper rounds High Score complete candidate paths and move the winner bundle together to the nearest safe rail.
Shared rails create overlapping vertical segments High Check interval overlap before allowing a shared verticalX; search deterministic fallback rails with 5px clearance otherwise.
Visually parallel rails pass exact-coordinate tests but overlap at stroke width High Require 5px clearance across overlapping vertical runs and cover it for 4/8-team fixtures.
Routing changes depend on input array order Medium Sort routes and bundles by graph display order and retain shuffled-fixture equality tests.
A long connector bends through an intermediate card High Restrict every candidate to the target corridor and retain card-penetration assertions.
Reset-final slot carry-over is accidentally treated as a winner pair Medium Bundle only connectors whose computed kind is winner; keep reset paths independent.

Dependencies

Regression contract -> bundle-aware rail allocator -> full verification -> review

Open Questions

None.