Skip to content

feat: add SameNetTraceMergerSolver to snap nearly-collinear same-net traces#433

Open
kuaaq wants to merge 19 commits into
tscircuit:mainfrom
kuaaq:feat/same-net-trace-merger
Open

feat: add SameNetTraceMergerSolver to snap nearly-collinear same-net traces#433
kuaaq wants to merge 19 commits into
tscircuit:mainfrom
kuaaq:feat/same-net-trace-merger

Conversation

@kuaaq
Copy link
Copy Markdown

@kuaaq kuaaq commented May 25, 2026

feat: SameNetTraceMergerSolver — snap nearly-collinear same-net traces

Closes #34, closes #29

Problem

When multiple traces belong to the same net (e.g. GND), independent routing produces segments with nearly-identical but not exactly-equal coordinates. This creates a visual gap or misalignment on the schematic.

Solution

SameNetTraceMergerSolver groups traces by globalConnNetId, compares every segment pair between same-net traces, and snaps collinear overlapping segments (horizontal within Y threshold, vertical within X threshold) to their average coordinate.

  • Default threshold: 0.15
  • Runs as a new pipeline step after traceCleanupSolver
  • All downstream steps (netLabelPlacementSolver, example28Solver) updated to consume merged output

Files changed

  • lib/solvers/SameNetTraceMergerSolver/SameNetTraceMergerSolver.ts — new solver with _step(), getOutput(), and visualize()
  • lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts — wired into pipeline
  • tests/same-net-trace-merger.test.ts — 4 unit tests + 1 snapshot test
  • tests/assets/SameNetTraceMerger.test.input.json — snapshot fixture (3-chip GND circuit)

Tests

  • Snaps nearly-horizontal same-net segments to same Y ✓
  • Does NOT snap segments from different nets ✓
  • Does NOT snap segments beyond threshold ✓
  • Snaps nearly-vertical same-net segments to same X ✓
  • Snapshot test with 3-chip GND circuit ✓

/claim #34
/claim #29

@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
schematic-trace-solver Ready Ready Preview, Comment May 25, 2026 7:34pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant