Skip to content

Fix extra net label in repro61, or remove trace#360

Open
js360000 wants to merge 1 commit into
tscircuit:mainfrom
js360000:bountybox/issue-79
Open

Fix extra net label in repro61, or remove trace#360
js360000 wants to merge 1 commit into
tscircuit:mainfrom
js360000:bountybox/issue-79

Conversation

@js360000
Copy link
Copy Markdown

Summary

fix: don't route traces between net-label-only pins (#79)

When pins share a net only via net labels (no directConnections), the
solver was still creating routed traces between them. This is the
"trace jumping" bug shown in repro61 from tscircuit/core#1503: two
capacitors with GND/VCC net labels on each pin end up with horizontal
traces drawn between same-net pins, on top of the four expected labels.

Root causes:

  1. getConnectivityMapFromInputProblem passed directConnMap.netMap
    into the new netConnMap by reference. Subsequent
    netConnMap.addConnections(...) calls then mutated the "direct
    only" map too, so dcConnMap ended up containing net-only pins.
    Clone the netMap to keep the two views independent.

  2. MspConnectionPairSolver._step looked up pins via globalConnMap,
    which by design unions direct + net connections. Switching to
    dcConnMap means net-only nets produce zero MSP pairs (and so
    zero routed traces).

  3. LongDistancePairSolver iterated every net in netConnMap to fill
    in unconnected pins, including nets that exist only as labels —
    re-creating the bug at the pipeline level. It now skips any net
    that has no primary MSP pair: long-distance routing should only
    complete partially-routed nets, never invent traces for label-only
    nets.

Tests:

  • New tests/repros/repro61-net-label-only-no-trace.test.ts locks in
    the fix at both the MSP and final-pipeline levels.
  • MspConnectionPairSolver_repro1.test.ts updated: GND (net-only,
    3 pins) no longer produces 2 MSP pairs, so the expected count for
    the 2 directConnections + 1 net-only-GND input is 2, not 4.
  • 22 example snapshots regenerated to drop the spurious net-only
    traces. The visual change is consistent across them: net labels
    stand alone where there is no direct connection.

Closes #79

Diff

 tests/examples/__snapshots__/example13.snap.svg    | 243 ++++----
 tests/examples/__snapshots__/example14.snap.svg    | 166 +++--
 tests/examples/__snapshots__/example15.snap.svg    | 680 ++++++++++++---------
 tests/examples/__snapshots__/example16.snap.svg    |  80 +--
 tests/examples/__snapshots__/example18.snap.svg    | 128 ++--
 tests/examples/__snapshots__/example20.snap.svg    |  66 +-
 tests/examples/__snapshots__/example21.snap.svg    | 173 +++---
 tests/examples/__snapshots__/example22.snap.svg    |  72 +--
 tests/examples/__snapshots__/example24.snap.svg    |  70 ++-
 tests/examples/__snapshots__/example25.snap.svg    | 172 +++---
 tests/examples/__snapshots__/example26.snap.svg    |  70 ++-
 tests/examples/__snapshots__/example27.snap.svg    |   5 +-
 tests/examples/__snapshots__/example28.snap.svg    |  43 +-
 tests/examples/__snapshots__/example30.snap.svg    | 168 +++--
 tests/examples/__snapshots__/example31.snap.svg    |  36 +-
 tests/examples/__snapshots__/example32.snap.svg    | 250 ++++----
 tests/examples/__snapshots__/example33.snap.svg    |  80 +--
 .../repros/repro61-net-label-only-no-trace.test.ts |  60 ++
 .../MspConnectionPairSolver_repro1.test.ts         |   6 +-
 27 files changed, 1638 insertions(+), 1360 deletions(-)

Claim

/claim #79

When pins share a net only via net labels (no directConnections), the
solver was still creating routed traces between them. This is the
"trace jumping" bug shown in repro61 from tscircuit/core#1503: two
capacitors with GND/VCC net labels on each pin end up with horizontal
traces drawn between same-net pins, on top of the four expected labels.

Root causes:

1. `getConnectivityMapFromInputProblem` passed `directConnMap.netMap`
   into the new `netConnMap` by reference. Subsequent
   `netConnMap.addConnections(...)` calls then mutated the "direct
   only" map too, so `dcConnMap` ended up containing net-only pins.
   Clone the netMap to keep the two views independent.

2. `MspConnectionPairSolver._step` looked up pins via `globalConnMap`,
   which by design unions direct + net connections. Switching to
   `dcConnMap` means net-only nets produce zero MSP pairs (and so
   zero routed traces).

3. `LongDistancePairSolver` iterated every net in `netConnMap` to fill
   in unconnected pins, including nets that exist only as labels —
   re-creating the bug at the pipeline level. It now skips any net
   that has no primary MSP pair: long-distance routing should only
   complete partially-routed nets, never invent traces for label-only
   nets.

Tests:

- New `tests/repros/repro61-net-label-only-no-trace.test.ts` locks in
  the fix at both the MSP and final-pipeline levels.
- `MspConnectionPairSolver_repro1.test.ts` updated: GND (net-only,
  3 pins) no longer produces 2 MSP pairs, so the expected count for
  the 2 directConnections + 1 net-only-GND input is 2, not 4.
- 22 example snapshots regenerated to drop the spurious net-only
  traces. The visual change is consistent across them: net labels
  stand alone where there is no direct connection.

Closes tscircuit#79
@vercel
Copy link
Copy Markdown

vercel Bot commented May 16, 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 16, 2026 4:41pm

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.

Fix extra net label in repro61, or remove trace

2 participants