Skip to content

fix: New Phase To combine same-net trace segments that are close together (#29)#343

Open
IbrahimLaeeq wants to merge 2 commits into
tscircuit:mainfrom
IbrahimLaeeq:fix/bounty-issue-29
Open

fix: New Phase To combine same-net trace segments that are close together (#29)#343
IbrahimLaeeq wants to merge 2 commits into
tscircuit:mainfrom
IbrahimLaeeq:fix/bounty-issue-29

Conversation

@IbrahimLaeeq
Copy link
Copy Markdown

Fixes #29.

/claim #29

per-pair traces, a single net can be drawn as multiple parallel SolvedTracePaths with parallel segments running close to one another, looking like redundant duplicate traces.

Changes:

  1. lib/solvers/SameNetTraceCombineSolver/SameNetTraceCombineSolver.ts (new) — A BaseSolver that:

    • Groups traces by globalConnNetId.
    • For each pair of parallel orthogonal segments on the same net whose perpendicular distance is below closeDistanceThreshold (default 0.2) and whose projections overlap, picks the closest pair.
    • Shifts shiftable interior segments (segments not touching a pin and whose neighbors are perpendicular) to a shared axis (midpoint when both are shiftable; otherwise to the fixed segment).
    • Simplifies paths afterwards to drop zero-length / colinear interior points.
    • Pin endpoints stay anchored; pin connectivity is preserved.
  2. lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts — inserted the new phase between longDistancePairSolver and traceOverlapShiftSolver, and updated the latter to consume the combined output.

  3. tests/solvers/SameNetTraceCombineSolver/SameNetTraceCombineSolver.test.ts (new) — three unit tests covering: parallel close same-net segments get merged onto a shared axis with pin endpoints preserved; segments past the threshold are left alone; different-net segments are not merged.

Verified: 3/3 new tests pass, all 34 example snapshot tests still pass, bunx tsc --noEmit is clean.


Verified against the repository's own test suite before submission.

Copilot AI review requested due to automatic review settings May 14, 2026 17:43
@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 6:12pm

Request Review

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new SameNetTraceCombineSolver pipeline phase that snaps closely-spaced parallel same-net trace segments onto a shared axis, reducing the visual appearance of redundant parallel traces. It is inserted between LongDistancePairSolver and TraceOverlapShiftSolver, with the latter updated to consume its output.

Changes:

  • New SameNetTraceCombineSolver that groups traces by globalConnNetId, finds parallel overlapping segments within closeDistanceThreshold, and shifts safely-shiftable interior segments to a shared axis, then simplifies paths.
  • Pipeline integration: new step added; traceOverlapShiftSolver now reads from the combiner's output with fallback to longDistancePairSolver.allTracesMerged.
  • Unit tests covering merge, distance threshold, and different-net cases.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
lib/solvers/SameNetTraceCombineSolver/SameNetTraceCombineSolver.ts New solver implementing same-net close-segment combination.
lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts Registers the new solver as a pipeline step and routes its output into TraceOverlapShiftSolver.
tests/solvers/SameNetTraceCombineSolver/SameNetTraceCombineSolver.test.ts Unit tests for the new solver.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

2 participants