Skip to content

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

Open
voltrace-io wants to merge 2 commits into
tscircuit:mainfrom
voltrace-io:voltrace-io/1779328522-fix-extra-net-label-repro61
Open

fix: don't route traces between net-label-only pins (#79)#395
voltrace-io wants to merge 2 commits into
tscircuit:mainfrom
voltrace-io:voltrace-io/1779328522-fix-extra-net-label-repro61

Conversation

@voltrace-io
Copy link
Copy Markdown

Summary

Fixes the "trace jumping" bug where the solver created routed traces between pins that share a net only via net labels (netConnections), with no directConnections between them. This is the extra net label / spurious trace issue described in #79 (see also tscircuit/core#1503).

Root causes fixed:

  1. Reference mutation in getConnectivityMapsFromInputProblemdirectConnMap.netMap was passed by reference into netConnMap. Subsequent addConnections() calls mutated the "direct-only" map too, so dcConnMap ended up containing net-label-only pins. Fixed by cloning the netMap.

  2. Wrong map in MspConnectionPairSolver._step — Pin lookup used globalConnMap (which unions direct + net connections). Switching to dcConnMap means net-label-only nets produce zero MSP pairs and zero routed traces.

  3. LongDistancePairSolver reinvented traces for label-only nets — It iterated every net in netConnMap including nets that exist only as labels. Now skips any net that has no primary MSP pair: long-distance routing should only complete partially-routed nets, never create traces for label-only nets.

Changes:

  • 3 source files modified (minimal, focused diff)
  • New repro61 test locks in the fix at both MSP and pipeline levels
  • MspConnectionPairSolver_repro1 updated: GND (net-only, 3 pins) correctly produces 0 MSP pairs instead of 2
  • 22 example snapshots regenerated — spurious net-only traces removed

Tests: 60 pass, 4 skip, 0 fail
Typecheck: bunx tsc --noEmit — no errors
Format: biome format — clean

/claim #79

Review & Testing Checklist for Human

  • Verify repro61 test correctly represents the "two capacitors with only net labels" scenario from core#1503
  • Spot-check 2-3 regenerated snapshots to confirm only spurious net-only traces were removed (no valid direct-connection traces lost)
  • Confirm existing examples with both directConnections and netConnections still produce correct traces (e.g., example01, example15)

Notes

  • The visual change across snapshots is consistent: net labels now stand alone where there is no direct connection, matching the expected schematic behavior
  • No changes to the net label placement logic itself — only the trace routing decision was fixed

@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 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 12:41am

Request Review

voltrace-io and others added 2 commits May 22, 2026 00:39
When pins share a net only via net labels (netConnections) with no
directConnections, the solver was creating routed traces between them.

Root causes fixed:

1. getConnectivityMapsFromInputProblem passed directConnMap.netMap by
   reference into netConnMap. Subsequent addConnections() calls mutated
   the direct-only map. Now clones the netMap to keep views independent.

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

3. LongDistancePairSolver iterated every net in netConnMap, including
   label-only nets. It now skips nets with no primary MSP pair.

Tests:
- New repro61 test locks in the fix at MSP and pipeline levels
- MspConnectionPairSolver_repro1 updated (GND net-only: 4 -> 2 pairs)
- 22 example snapshots regenerated (spurious net-only traces removed)

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@voltrace-io voltrace-io force-pushed the voltrace-io/1779328522-fix-extra-net-label-repro61 branch from f614077 to 894622d Compare May 22, 2026 00:41
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