Skip to content

fix: exclude net-label-only nets from MSP pair queue (closes #79)#162

Open
satyamdas03 wants to merge 1 commit intotscircuit:mainfrom
satyamdas03:fix/issue-79-net-label-only-traces
Open

fix: exclude net-label-only nets from MSP pair queue (closes #79)#162
satyamdas03 wants to merge 1 commit intotscircuit:mainfrom
satyamdas03:fix/issue-79-net-label-only-traces

Conversation

@satyamdas03
Copy link
Copy Markdown

Problem

Pins connected only via netConnections (net labels like VCC/GND, with no directConnections) incorrectly produced routed wire traces. Since net labels already represent the electrical connection visually, drawing a wire trace between these pins creates a spurious extra line (the repro61 bug).

Root Cause

getConnectivityMapsFromInputProblem passes directConnMap.netMap by reference to new ConnectivityMap(...). When netConnMap.addConnections adds net-label entries, it mutates the same underlying object — so directConnMap.netMap ends up containing all nets, including purely-netlabel ones.

As a result, Object.keys(netConnMap.netMap) in MspConnectionPairSolver queues every net (including VCC, GND that have zero direct wires), which generates spurious MSP pairs and traces.

Fix

Build a flat Set<string> of pin IDs that appear in at least one directConnections entry. Then filter the queued net IDs to only those where at least one connected pin is in that set:

const directlyWiredPinIds = new Set<string>()
for (const dc of inputProblem.directConnections) {
  for (const pid of dc.pinIds) {
    directlyWiredPinIds.add(pid)
  }
}
this.queuedDcNetIds = Object.keys(netConnMap.netMap).filter((netId) => {
  const connectedIds = netConnMap.getIdsConnectedToNet(netId) as string[]
  return connectedIds.some((id) => directlyWiredPinIds.has(id))
})

Tests

  • MspConnectionPairSolver_repro61 — verifies 0 MSP pairs for net-label-only circuits ✅
  • SchematicTracePipelineSolver_repro61 — full pipeline, 0 traces generated ✅
  • MspConnectionPairSolver_repro1 expectation corrected (4 → 2 pairs; GND was net-label-only) ✅
  • 7 example snapshots updated (cleaner output — no more spurious GND traces) ✅
  • 51 pass, 0 fail — full suite

/claim #79

)

Pins connected only via netConnections (net labels like VCC/GND with no
directConnections) were incorrectly generating routed traces. Net labels
already represent the electrical connection visually, so no wire trace
should be drawn between them.

Root cause: getConnectivityMapsFromInputProblem passed directConnMap.netMap
by reference to new ConnectivityMap(...), so adding net-label entries to
netConnMap mutated directConnMap.netMap as well. This caused
Object.keys(netConnMap.netMap) to include purely-netlabel nets.

Fix: Build a flat Set of pin IDs that appear in at least one
directConnections entry, then filter the queued net IDs to only those
where at least one connected pin is in that set. Net-label-only nets are
excluded and produce no MSP pairs / traces.

Tests:
- MspConnectionPairSolver_repro61: 0 MSP pairs for netlabel-only circuits
- SchematicTracePipelineSolver_repro61: full pipeline, 0 traces generated
- MspConnectionPairSolver_repro1 expectation corrected (4 → 2 pairs)
- 7 example snapshots updated (cleaner output, no spurious GND traces)
- 51 pass, 0 fail

/claim tscircuit#79

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

vercel bot commented Apr 5, 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 Apr 5, 2026 3:19am

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.

1 participant