Skip to content

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

Draft
qlufiq-collab wants to merge 1 commit into
tscircuit:mainfrom
qlufiq-collab:bounty/tscircuit/schematic-trace-solver-29
Draft

New Phase To combine same-net trace segments that are close together#522
qlufiq-collab wants to merge 1 commit into
tscircuit:mainfrom
qlufiq-collab:bounty/tscircuit/schematic-trace-solver-29

Conversation

@qlufiq-collab

@qlufiq-collab qlufiq-collab commented Jun 11, 2026

Copy link
Copy Markdown

Summary

Add a new pipeline phase SameNetTraceSegmentMergeSolver that detects trace segments belonging to the same global net running parallel and close together, then snaps them to a shared perpendicular coordinate. This visually collapses redundant near-parallel routing into a single clean line, improving schematic readability. The phase runs after TraceOverlapShiftSolver (which handles different-net overlaps) and before NetLabelPlacementSolver.

Changes

  • lib/solvers/SameNetTraceSegmentMergeSolver/SameNetTraceSegmentMergeSolver.ts — New solver that iterates over same-net trace pairs, finds parallel segments within a configurable mergeDistance, and aligns them to a common coordinate. Endpoint segments (anchored to pins) are never moved.
  • lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts — Import and register the new solver in the pipeline between traceOverlapShiftSolver and netLabelPlacementSolver. Downstream phases (netLabelPlacementSolver, traceLabelOverlapAvoidanceSolver) now read from the merge solver's output when available.
  • tests/solvers/SameNetTraceSegmentMergeSolver/SameNetTraceSegmentMergeSolver.test.ts — Unit tests covering: horizontal merge, vertical merge, different-net no-merge, endpoint protection.
  • site/SameNetTraceSegmentMergeSolver/SameNetTraceSegmentMergeSolver01.page.tsx — Cosmos fixture for visual debugging of the new phase.

Test Plan

  • bun test tests/solvers/SameNetTraceSegmentMergeSolver → 4 pass, 0 fail
  • bun test → 70 pass, 4 skip, 0 fail (full suite, no regressions)
  • bun tsc --noEmit → clean
  • bun run format:check → 307 files checked, no fixes needed

Notes

  • The default mergeDistance is 0.2 units, matching the typical trace shift offset used elsewhere in the pipeline. This value is configurable via the solver constructor params if future tuning is needed.
  • Only interior segments are merged; first and last segments of each trace path are protected to preserve pin anchoring.
  • The solver is idempotent — it iterates until no further merges are found, then marks itself solved.

Closes #29

@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
schematic-trace-solver Error Error Jun 12, 2026 3:17pm

Request Review

@qlufiq-collab

Copy link
Copy Markdown
Author

🤖 Auto-generated WIP — converting to draft

This PR was opened by an autonomous bounty agent (lufiaq) before its CI
verification gate was strict enough. The CI checks above show failures
that were not caught locally.

Marking this as draft while we improve the agent's pre-submit test
verification. Do not feel obligated to review until I push a clean commit
or close the PR.

Sorry for the noise.

@qlufiq-collab qlufiq-collab marked this pull request as draft June 11, 2026 07:17
@qlufiq-collab qlufiq-collab force-pushed the bounty/tscircuit/schematic-trace-solver-29 branch from fbf8c8d to 6a9856d Compare June 11, 2026 21:55
@qlufiq-collab qlufiq-collab force-pushed the bounty/tscircuit/schematic-trace-solver-29 branch from 6a9856d to 6725e5c Compare June 11, 2026 22:31
@qlufiq-collab qlufiq-collab force-pushed the bounty/tscircuit/schematic-trace-solver-29 branch from 6725e5c to 2328c99 Compare June 12, 2026 13:17
@qlufiq-collab qlufiq-collab force-pushed the bounty/tscircuit/schematic-trace-solver-29 branch from 2328c99 to 02be8ab Compare June 12, 2026 14:38
@qlufiq-collab qlufiq-collab force-pushed the bounty/tscircuit/schematic-trace-solver-29 branch from 02be8ab to 5fbae2b Compare June 12, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

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