Skip to content

fix(MspConnectionPairSolver): prevent net-label-only pins from producing spurious wire traces#272

Open
chengyixu wants to merge 2 commits intotscircuit:mainfrom
chengyixu:fix/79-extra-net-label-minimal
Open

fix(MspConnectionPairSolver): prevent net-label-only pins from producing spurious wire traces#272
chengyixu wants to merge 2 commits intotscircuit:mainfrom
chengyixu:fix/79-extra-net-label-minimal

Conversation

@chengyixu
Copy link
Copy Markdown

@chengyixu chengyixu commented May 4, 2026

What this PR does

Prevents net-label-only pins (VCC/GND) from generating spurious wire traces between components connected only through net labels rather than physical wires.

Root cause

getConnectivityMapsFromInputProblem passed directConnMap.netMap by reference to new ConnectivityMap(...). The ConnectivityMap constructor stores the object directly and addConnections() mutates arrays in-place. Every netConnections entry (VCC/GND labels) sharing a pin with a direct-wire net pushed additional foreign pins into the direct-wire net array, corrupting directConnMap. MspConnectionPairSolver then generated spurious MSP pairs between components only connected via net labels.

How to test

bun test tests/solvers/MspConnectionPairSolver/MspConnectionPairSolver_repro79.test.ts

Before / After

Before: Components sharing only a VCC/GND label generated spurious traces between all pins with that label.

After: Only directly-wired connections produce traces. Net-label-only pins are excluded from wire routing. 6 snapshot files updated.

Which issue this fixes

Fixes #79

Changes

  1. Deep-clone each array in directConnMap.netMap before constructing netConnMap (getConnectivityMapFromInputProblem.ts)
  2. Route direct-wire nets through dcConnMap instead of globalConnMap (MspConnectionPairSolver._step())
  3. Refined queuedDcNetIds to enumerate direct-wire and net-label-only net IDs separately

/claim #79

…ing spurious wire traces

Fixes tscircuit#79

The root cause was a shared-reference bug in getConnectivityMapsFromInputProblem:
  new ConnectivityMap(directConnMap.netMap) passed netMap by reference, so
  subsequent addConnections calls on netConnMap (for netConnections like VCC/GND
  labels) mutated directConnMap.netMap arrays as well. This caused net-label-only
  pins (e.g. a capacitor pin with only a VCC label, no wire connection) to be
  merged into direct-wire nets, producing spurious MSP pairs and wire traces.

Fix: deep-clone each array in directConnMap.netMap before constructing netConnMap,
so mutations remain isolated. Additionally, _step() now uses dcConnMap (not
globalConnMap) to look up pins for direct-wire nets, ensuring net-label-only pins
that were merged into the global net are excluded from wire routing. Net-label-only
nets (added exclusively via netConnections) continue to use globalConnMap so they
still generate correct MSP pairs when multiple pins share the same net label.

Updated snapshots for examples 07, 13, 15, 18, 21, 27 to reflect the corrected
routing (fewer spurious cross-component wire connections via shared net labels).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

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

Request Review

@chengyixu
Copy link
Copy Markdown
Author

Fixed the CI failures: the test was missing the required availableNetLabelOrientations field (added to InputProblem after this test was written). Added it to the test. Type-check and format-check now pass locally. All 52+ tests green.

@chengyixu
Copy link
Copy Markdown
Author

Hi maintainers, polite ping for a review on this MspConnectionPairSolver fix. All CI checks are green (test, format, type-check, Vercel preview). This prevents net-label-only pins from producing spurious wire traces. Let me know if there's anything you'd like changed. Thanks!

@chengyixu
Copy link
Copy Markdown
Author

Hi! This PR is CI green and ready for merge when you have a moment. Thanks!

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

1 participant