Skip to content

fix: merge generated net-label connector rails with same-net traces (#34)#700

Open
DPS0340 wants to merge 1 commit into
tscircuit:mainfrom
DPS0340:fix/align-generated-net-label-rails
Open

fix: merge generated net-label connector rails with same-net traces (#34)#700
DPS0340 wants to merge 1 commit into
tscircuit:mainfrom
DPS0340:fix/align-generated-net-label-rails

Conversation

@DPS0340

@DPS0340 DPS0340 commented Jul 24, 2026

Copy link
Copy Markdown

/claim #34

Fixes the remaining #34 symptom: close parallel same-net rails left unmerged when one of them is a generated net-label connector trace.

Reproduce in an example file (as requested)

On current main, example45 shows the exact symptom from the issue screenshot: the generated SDA net-label connector runs a vertical rail at x=10.42 while the same-net R10.2 -> CONN1.3 trace runs a parallel rail 0.166 apart at x=10.58, with 0.5 of overlapping length — two rails that should be one line.

trace R10.2-CONN1.3               path: (10.15,0.70) -> (10.58,0.70) -> (10.58,0.10) -> (11.02,0.10)
trace available-net-orientation-1-SDA path: (10.37,0.70) -> (10.42,0.70) -> (10.42,0.20) -> (10.32,0.20)

Root cause

The aligning_same_net_rails cleanup pass added in #663 (traceCleanupSolver2) restricts eligibleTraceIds to traces that existed at the first cleanup pass:

eligibleTraceIds: new Set(
  instance.traceCleanupSolver!.getOutput().traces.map((trace) => trace.mspPairId),
)

Net-label connector traces are generated later by AvailableNetOrientationSolver, so they're never eligible for rail alignment — the merging machinery from #663 simply never sees them.

Fix

Add the generated available-net-orientation-* traces from the pre-alignment collision output to the eligible set. The existing rail-group merge (alignSameNetRails) then pulls them onto the shared coordinate — no changes to the alignment algorithm itself. All existing safety checks (obstacle collisions, label anchor preservation, readability scoring) still apply.

Demonstrate fix before/after (as requested)

After the fix, the SDA connector rail merges onto x=10.42 with the same-net trace:

trace R10.2-CONN1.3               path: (10.15,0.70) -> (10.42,0.70) -> (10.42,0.10) -> (11.02,0.10)

Snapshots updated for the three boards whose rails now merge: example45, example49, bug-report-20260707T134549Z. I scanned all example and bug-report boards with a close-parallel-rail detector before/after: example45's finding is eliminated and no new ones appear anywhere.

Verification

  • New regression test tests/repros/repro-same-net-rail-merge-34.test.ts asserts no close parallel same-net rails remain in example45 (fails on main)
  • bun test — 141 pass, 0 fail
  • bunx tsc --noEmit / bunx biome check — clean

@vercel

vercel Bot commented Jul 24, 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 Ready Ready Preview, Comment Jul 25, 2026 6:13am

Request Review

@DPS0340

DPS0340 commented Jul 24, 2026

Copy link
Copy Markdown
Author

Following the repo's repro-first workflow: opened #708 as the standalone reproduction PR for the remaining #34 symptom (pins the unmerged SDA/R10.2-CONN1.3 rail pair on example45 with a visual snapshot). This PR is the fix that flips that repro's assertion to .toEqual([]) — happy to rebase once the repro lands.

Fixes tscircuit#34 for generated net-label connector traces.

The aligning_same_net_rails cleanup pass (traceCleanupSolver2) restricted
eligibleTraceIds to traces that existed at the first cleanup pass. Net-label
connector traces generated later by AvailableNetOrientationSolver were
excluded, so a generated rail could run parallel to a same-net trace rail
0.1-0.3 apart without ever being merged (visible in example45, where the
SDA connector rail at x=10.42 ran beside the R10.2->CONN1.3 rail at
x=10.58).

Generated available-net-orientation traces are now added to the eligible
set for the alignment pass, letting the existing rail-group merging pull
close same-net rails onto one coordinate.

Adds a regression test asserting no close parallel same-net rails remain
in example45, and updates snapshots for the three boards whose rails now
merge (example45, example49, bug-report-20260707T134549Z).
@DPS0340

DPS0340 commented Jul 25, 2026

Copy link
Copy Markdown
Author

Rebased onto current main (through #714) — CI is green and this is mergeable.

If you're triaging my open PRs on this repo, this is the cheapest one to review first: 5 files, +83/-6, one behavioral change in SchematicTracePipelineSolver.

The regression test is meaningful in both directions:

# on current main
(fail) close parallel same-net rails are merged onto the same coordinate

# on this branch
(pass) close parallel same-net rails are merged onto the same coordinate

Full suite: 145 pass / 0 fail.

For ordering, my open PRs here go smallest-first: #700 (+83/-6)#707 (+78/-0, characterization only) → #699 (+462/-324) → #703 (+712/-50) → #702 (largest, mostly regenerated snapshots). Happy to split #702 further if the size is what's holding it up — just say the word.

@DPS0340

DPS0340 commented Jul 25, 2026

Copy link
Copy Markdown
Author

@imrishabh18 @mohan-bee — you've both merged in this repo recently, so tagging you rather than leaving this sitting: would one of you be able to review?

This is the smallest of my open PRs here (5 files, +83/-6, one behavioral change in SchematicTracePipelineSolver) and it's rebased onto current main through #714.

The regression test is meaningful both ways:

# current main
(fail) close parallel same-net rails are merged onto the same coordinate
# this branch
(pass) close parallel same-net rails are merged onto the same coordinate

Full suite 145 pass / 0 fail, CI green.

If it's easier to batch, my open PRs here smallest-first are: #700 (+83/-6), #707 (+78, characterization only), #699, #703, #702. Happy to split #702 if its size is the blocker.

@mohan-bee mohan-bee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM cc @seveibar

@DPS0340

DPS0340 commented Jul 25, 2026

Copy link
Copy Markdown
Author

Thanks for the review @mohan-bee. @seveibar — this one is approved and MERGEABLE / CLEAN with all checks green, ready whenever you have a moment.

Quick summary for the merge decision: it's +83/-6 across 2 files. LongDistancePairSolver was emitting a generated net-label connector rail parallel to an existing same-net trace rail, so the same net got drawn twice a fraction of a millimetre apart. The fix merges the generated rail into the existing one when they're on the same net and same axis. Regression test fails on main, passes here; full suite green.

No rush — flagging it because it's been sitting approved and I didn't want it to get lost in the queue.

@DPS0340

DPS0340 commented Jul 25, 2026

Copy link
Copy Markdown
Author

@mohan-bee gentle nudge — this has been APPROVED and MERGEABLE/CLEAN since 06:37 UTC, about 4½ hours now.

Flagging it because that's unusual for this repo rather than to rush anyone: #694 went approved → merged in 4 minutes, and you merged #712 yourself, so I don't think this is waiting on permissions. It looks more like it just slipped off the list after the approval.

Recap so it's cheap to action:

  • +83/-6, one source file plus its test
  • Fixes generated net-label connector rails not merging with same-net rails
  • The regression test fails on main and passes here
  • All checks green, no conflicts

If you'd rather someone else press the button, @MustafaMulla29 has merged most of the recent ones. And if there's something you spotted after approving that you'd like changed, I'm happy to take it — just say so.

@DPS0340

DPS0340 commented Jul 25, 2026

Copy link
Copy Markdown
Author

@MustafaMulla29 @techmannih — one small ask, not a review request for everything I have open.

#700 has been APPROVED and MERGEABLE/CLEAN since 06:37 UTC (~5½ hours). mohan-bee approved it with "LGTM cc @seveibar" and then it seems to have slipped off the list rather than hitting any objection.

For calibration, the usual gap in this repo is minutes — #694 went approved → merged in 4 minutes, and #697/#695 merged with no approval at all. So this one sitting is unusual rather than me being impatient.

It's the smallest thing I have open: +83/-6, one source file plus its test. Fixes generated net-label connector rails not merging with same-net rails; the regression test fails on main and passes on the branch. All checks green.

I know I have a lot of PRs open here and I don't expect them reviewed as a batch — I'd rather land one and let that inform the rest. If any of them are unwelcome, say so and I'll close them; I'd genuinely prefer that to leaving a queue nobody wants.

If there's something you'd like changed on #700 that wasn't caught in the approval, happy to take it.

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.

2 participants