Skip to content

feat: add SameNetTraceMergeSolver to combine close same-net trace segments#339

Open
tungnguyentu wants to merge 1 commit into
tscircuit:mainfrom
tungnguyentu:feat/same-net-trace-merge-29
Open

feat: add SameNetTraceMergeSolver to combine close same-net trace segments#339
tungnguyentu wants to merge 1 commit into
tscircuit:mainfrom
tungnguyentu:feat/same-net-trace-merge-29

Conversation

@tungnguyentu
Copy link
Copy Markdown

@tungnguyentu tungnguyentu commented May 14, 2026

Summary

Adds a new `SameNetTraceMergeSolver` pipeline phase (inserted after `TraceCleanupSolver`) that merges `SolvedTracePath` segments on the same net whose endpoints are within a distance threshold.

  • Groups traces by `globalConnNetId`
  • Iteratively finds the closest endpoint pair between any two same-net traces
  • If within `MERGE_THRESHOLD` (0.4 schematic units), merges them into a single `tracePath`
  • Downstream phases (`NetLabelPlacementSolver`, `Example28Solver`, etc.) receive the merged traces
  • Updated all SVG snapshots for example tests

Tests

6 new unit tests covering:

  • Adjacent endpoints (exact match)
  • Endpoints within threshold
  • Different nets (no merge)
  • Endpoints too far apart (no merge)
  • Chain of 3 traces merging to 1
  • Unrelated isolated traces preserved

All 63 existing tests pass (4 skipped, 0 failed).

Fixes #29
/claim #29

…e-net traces

Adds a new pipeline phase that merges SolvedTracePath segments on the same
net whose endpoints are within a threshold distance (0.4 schematic units).

The solver runs iteratively — each step finds one mergeable pair, combines
their tracePaths into a single continuous path, and repeats until no more
merges are possible. It is inserted after TraceCleanupSolver so downstream
phases (NetLabelPlacementSolver, Example28Solver, …) receive the merged traces.

Closes tscircuit#29
/claim tscircuit#29

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 14, 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 14, 2026 4:24pm

Request Review

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.

New Phase To combine same-net trace segments that are close together

1 participant