Skip to content

Fix same-net trace segment merging#430

Open
I-Fog wants to merge 1 commit into
tscircuit:mainfrom
I-Fog:fix/merge-same-net-trace-segments
Open

Fix same-net trace segment merging#430
I-Fog wants to merge 1 commit into
tscircuit:mainfrom
I-Fog:fix/merge-same-net-trace-segments

Conversation

@I-Fog
Copy link
Copy Markdown

@I-Fog I-Fog commented May 25, 2026

Summary

  • Adds a dedicated TraceSegmentMergeSolver pipeline pass to merge nearby parallel segments that belong to the same net.
  • Preserves endpoints by adding terminal jogs when needed and keeps pipeline integration deterministic.
  • Blocks unsafe merges that would collide with other nets, including generated jog collisions.
  • Optimizes large batches with reusable simulation context, grouped merge candidates, cached cluster simulations, and a hybrid collision index.

Coverage

Performance

Median local benchmark for independent parallel same-net pairs:

  • 50 traces: 1.57ms
  • 800 traces: 11.26ms
  • 1600 traces: 25.87ms
  • 3200 traces: 50.43ms
  • 6400 traces: 80.48ms

Validation

  • npx --yes bun x tsc --noEmit
  • npx --yes bun test -> 102 pass, 4 skip, 0 fail
  • npx --yes bun test tests/examples/example29.test.ts tests/examples/example34.test.ts tests/solvers/TraceSegmentMergeSolver/TraceSegmentMergeSolver.basic.test.ts tests/solvers/TraceSegmentMergeSolver/TraceSegmentMergeSolver.collision.test.ts tests/solvers/TraceSegmentMergeSolver/TraceSegmentMergeSolver.edge-cases.test.ts tests/solvers/TraceSegmentMergeSolver/TraceSegmentMergeSolver.pipeline.test.ts tests/solvers/TraceSegmentMergeSolver/TraceSegmentMergeSolver.visual.test.ts -> 45 pass, 0 fail
  • git diff --check

/claim #29
/claim #34

@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 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 25, 2026 12:50am

Request Review

@I-Fog
Copy link
Copy Markdown
Author

I-Fog commented May 25, 2026

Hi @seveibar, I linked this PR to the #29 bounty and added /claim #29 to the PR body.

CI is green, and this version includes focused regression coverage plus collision safeguards for generated jogs and different-net overlaps. Happy to adjust anything you want changed.

@I-Fog
Copy link
Copy Markdown
Author

I-Fog commented May 26, 2026

Traceability clarification: I updated the PR body to claim #34 as well as #29 because the existing implementation covers both close same-net trace cleanup cases.

The architecture here is intentionally a standalone TraceSegmentMergeSolver pipeline phase, not extra logic folded into TraceCleanupSolver. That matches #29's request for a new phase and also covers #34's same-X/same-Y alignment case while preserving terminal endpoints and rejecting different-net collisions.

Fresh focused verification:

  • npx --yes bun test tests/examples/example29.test.ts tests/examples/example34.test.ts tests/solvers/TraceSegmentMergeSolver/TraceSegmentMergeSolver.basic.test.ts tests/solvers/TraceSegmentMergeSolver/TraceSegmentMergeSolver.collision.test.ts tests/solvers/TraceSegmentMergeSolver/TraceSegmentMergeSolver.edge-cases.test.ts tests/solvers/TraceSegmentMergeSolver/TraceSegmentMergeSolver.pipeline.test.ts tests/solvers/TraceSegmentMergeSolver/TraceSegmentMergeSolver.visual.test.ts -> 45 pass, 0 fail
  • npx --yes bun x tsc --noEmit -> pass
  • git diff --check -> pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant