fix(MspConnectionPairSolver): prevent net-label-only pins from producing spurious wire traces#272
Open
chengyixu wants to merge 2 commits intotscircuit:mainfrom
Open
fix(MspConnectionPairSolver): prevent net-label-only pins from producing spurious wire traces#272chengyixu wants to merge 2 commits intotscircuit:mainfrom
chengyixu wants to merge 2 commits intotscircuit:mainfrom
Conversation
…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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…PairSolver_repro79 test
Author
|
Fixed the CI failures: the test was missing the required |
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! |
Author
|
Hi! This PR is CI green and ready for merge when you have a moment. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
getConnectivityMapsFromInputProblempasseddirectConnMap.netMapby reference tonew ConnectivityMap(...). TheConnectivityMapconstructor stores the object directly andaddConnections()mutates arrays in-place. EverynetConnectionsentry (VCC/GND labels) sharing a pin with a direct-wire net pushed additional foreign pins into the direct-wire net array, corruptingdirectConnMap.MspConnectionPairSolverthen generated spurious MSP pairs between components only connected via net labels.How to test
bun test tests/solvers/MspConnectionPairSolver/MspConnectionPairSolver_repro79.test.tsBefore / 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
directConnMap.netMapbefore constructingnetConnMap(getConnectivityMapFromInputProblem.ts)dcConnMapinstead ofglobalConnMap(MspConnectionPairSolver._step())queuedDcNetIdsto enumerate direct-wire and net-label-only net IDs separately/claim #79