Skip to content

Add same-net trace segment merge solver#408

Open
anytimeatvibe wants to merge 2 commits into
tscircuit:mainfrom
anytimeatvibe:codex/same-net-trace-merge
Open

Add same-net trace segment merge solver#408
anytimeatvibe wants to merge 2 commits into
tscircuit:mainfrom
anytimeatvibe:codex/same-net-trace-merge

Conversation

@anytimeatvibe
Copy link
Copy Markdown

@anytimeatvibe anytimeatvibe commented May 22, 2026

/claim #29

Summary

  • Adds a new SameNetTraceSegmentMergeSolver pipeline phase after long-distance trace generation and before cross-net overlap shifting.
  • Aligns nearby horizontal or vertical trace segments that belong to the same net, so close same-net lines share the same Y or X coordinate before later layout cleanup.
  • Keeps different nets isolated, so the existing TraceOverlapShiftSolver still owns cross-net overlap avoidance.
  • Exports the new solver/helpers from lib/index.ts, adds focused coverage for same-net alignment and non-alignment across different nets, and updates affected example SVG snapshots.

Implementation Notes

  • Segments are grouped by userNetId ?? globalConnNetId ?? dcConnNetId.
  • Only orthogonal segments with safe perpendicular neighbors are moved, which avoids introducing diagonal path segments.
  • Close segments are unioned by orientation, fixed-axis distance, and 1D range overlap/gap, then aligned to a length-weighted coordinate.
  • The helper clones traces before modifying coordinates and simplifies duplicate/collinear points afterward.

Validation

npm install --legacy-peer-deps
npm install typescript@5.9.3 --legacy-peer-deps --save-dev --no-package-lock
npm run build
npx tsc --noEmit
npx biome format --write lib/index.ts lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts lib/solvers/SameNetTraceSegmentMergeSolver/SameNetTraceSegmentMergeSolver.ts tests/solvers/SameNetTraceSegmentMergeSolver/SameNetTraceSegmentMergeSolver.test.ts
git diff --cached --check

Additional local Node verification against the compiled dist/index.js confirmed two same-net horizontal segments align to the same weighted coordinate.

GitHub Actions are passing on the latest commit: Bun Test, Type Check, Format Check, and Vercel.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 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 22, 2026 10:10am

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.

1 participant