Skip to content

feat: add SameNetTraceCombiningSolver phase to merge close same-net t…#393

Open
voltrace-io wants to merge 2 commits into
tscircuit:mainfrom
voltrace-io:voltrace-io/1779325293-same-net-trace-combining
Open

feat: add SameNetTraceCombiningSolver phase to merge close same-net t…#393
voltrace-io wants to merge 2 commits into
tscircuit:mainfrom
voltrace-io:voltrace-io/1779325293-same-net-trace-combining

Conversation

@voltrace-io
Copy link
Copy Markdown

@voltrace-io voltrace-io commented May 21, 2026

Summary

Adds a new SameNetTraceCombiningSolver pipeline phase that merges same-net trace segments running close together by snapping parallel segments onto a shared coordinate.

How it works:

  • Groups traces by globalConnNetId
  • For each same-net group, finds parallel segments within a 0.15 snap threshold
  • Snaps close horizontal segments to the average Y, close vertical segments to the average X
  • Preserves terminal pin endpoints (first/last path points are never moved)
  • Iterates until stable (max 20 passes) so multi-segment clusters collapse consistently

Pipeline placement: After TraceOverlapShiftSolver, before NetLabelPlacementSolver. Downstream solvers (TraceLabelOverlapAvoidanceSolver, etc.) now consume the combined output.

Files changed:

  • lib/solvers/SameNetTraceCombiningSolver/SameNetTraceCombiningSolver.ts — new solver (207 lines)
  • lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts — pipeline integration
  • tests/solvers/SameNetTraceCombiningSolver/SameNetTraceCombiningSolver.test.ts — 7 focused tests

Tests:

  • bun test69 pass, 4 skip, 0 fail (including example34)
  • bunx tsc --noEmit — no type errors
  • bun run format:check — passes

/claim #29
/claim #34

Also addresses #34 — the "merge same-net trace lines that are close together (make at the same Y or same X)" behavior. The snapping logic aligns nearby same-net horizontal segments to a shared Y coordinate and nearby vertical segments to a shared X coordinate, which is exactly the visual improvement described in #34. The existing example34 test passes with this solver in the pipeline (69 tests pass total).

Review & Testing Checklist for Human

  • Run bun test — verify all tests pass
  • Run bunx tsc --noEmit — verify no type errors
  • Visually verify trace combining in the playground: check that same-net traces that previously ran close together are now merged onto shared coordinates
  • Confirm existing example snapshots still render correctly

Notes

  • Segments farther apart than the 0.15 threshold are left unchanged
  • Different-net segments are never affected
  • The solver produces stable output — running it twice gives the same result

…race segments

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 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 21, 2026 1:26am

Request Review

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant