Skip to content

fix: skip MSP pair generation for net-label-only nets (issue #79)#170

Open
cccignore wants to merge 2 commits intotscircuit:mainfrom
cccignore:fix/issue-79-net-label-only-traces
Open

fix: skip MSP pair generation for net-label-only nets (issue #79)#170
cccignore wants to merge 2 commits intotscircuit:mainfrom
cccignore:fix/issue-79-net-label-only-traces

Conversation

@cccignore
Copy link
Copy Markdown

/claim #79

Problem

Nets connected only via netConnections that have availableNetLabelOrientations configured were incorrectly queued for wire-trace generation. This produced spurious trace lines alongside (or instead of) the net labels that should represent the connection — the repro61 bug.

Root Cause

MspConnectionPairSolver built queuedDcNetIds from Object.keys(netConnMap.netMap), which includes every net — including purely label-only ones like GND/VCC.

Fix

Filter queuedDcNetIds to keep only nets that actually need wire traces:

  • Keep — nets with at least one pin in directConnections (explicit wire always wins)
  • Keep — nets in netConnections with no label orientation configured (no other way to show the connection)
  • Skip — nets in netConnections whose user-facing net ID appears in availableNetLabelOrientationsNetLabelPlacementSolver handles these
this.queuedDcNetIds = Object.keys(netConnMap.netMap).filter((netId) => {
  const connectedIds = netConnMap.getIdsConnectedToNet(netId) as string[]
  const hasDirect = connectedIds.some((id) => directlyWiredPinIds.has(id))
  if (hasDirect) return true
  const hasLabelOrientation = connectedIds.some((id) => netLabelOrientedNets.has(id))
  return !hasLabelOrientation
})

Why connectedIds contains the net label string: ConnectivityMap treats the user-provided netId (e.g. "GND") as just another member of the connectivity group, so getIdsConnectedToNet returns it alongside the pin IDs.

Why this is better than PR #162

PR #162 filters on directlyWiredPinIds alone, which removes all netConnections nets when directConnections is empty — leaving MspConnectionPairSolver_repro2-style circuits with no connections at all. This fix only removes nets that have an explicit label orientation configured.

Tests

  • MspConnectionPairSolver_issue79.test.ts — 3 unit tests:
    1. Net-label-only net (GND in netConnections + orientation) → 0 MSP pairs
    2. Net in netConnections without orientation → still gets MSP pair
    3. Net in both directConnections and netConnections → keeps pair
  • SchematicTracePipelineSolver_repro_issue79.test.ts — full pipeline: VCC/GND produce no spurious traces, net labels are placed
  • MspConnectionPairSolver_repro1 — expected pair count updated 4 → 2 (GND was net-label-only)
  • 7 SVG snapshots updated — spurious GND/VCC traces removed from example01, 12, 13, 15, 16, 21, 22
  • Demo page: SchematicTracePipelineSolver_issue79.page.tsx

All 53 tests pass, 0 fail.

…t#79)

Nets that exist only in netConnections and have availableNetLabelOrientations
were incorrectly being queued for wire-trace generation, producing spurious
traces alongside the net labels that represent them.

Root cause: MspConnectionPairSolver used Object.keys(netConnMap.netMap) to
build queuedDcNetIds, which includes all nets — including ones that should
only be shown as net labels.

Fix: filter queuedDcNetIds to only include nets that need wire traces:
  - nets with at least one pin in directConnections (always need a trace), OR
  - nets with no configured label orientation (no label → trace is the only
    representation of the connection)

Nets that are purely in netConnections AND have availableNetLabelOrientations
are skipped — NetLabelPlacementSolver handles them instead.

This is stricter than filtering on directlyWiredPinIds alone (as done in
PR tscircuit#162): that approach incorrectly removes traces for netConnections nets
that have no label orientation configured, leaving the connection invisible.

Changes:
  - MspConnectionPairSolver.ts: add directlyWiredPinIds + netLabelOrientedNets
    filter for queuedDcNetIds
  - MspConnectionPairSolver_repro1.test.ts: update expected pair count 4 → 2
    (GND is net-label-only in that fixture)
  - Add MspConnectionPairSolver_issue79.test.ts: 3 targeted unit tests
  - Add SchematicTracePipelineSolver_repro_issue79.test.ts: full pipeline repro
  - Add SchematicTracePipelineSolver_issue79.page.tsx: demo page
  - Update 7 SVG snapshots (spurious GND/VCC traces removed)

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

vercel bot commented Apr 10, 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 10, 2026 8:56am

Request Review

LongDistancePairSolver independently iterates all nets in netConnMap to
build long-distance candidate pairs, bypassing the filter added to
MspConnectionPairSolver.  Nets that are purely label-only (in
netConnections + availableNetLabelOrientations, no directConnections)
were therefore still producing spurious traces via this second path.

Apply the same hasDirect / hasLabel guard so both solvers agree on which
nets require wire traces.

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

Hi! Could you take a look at this PR when you have a chance? It fixes issue #79 by filtering out net-label-only nets from the MSP pair and long-distance pair generation pipelines. All 53 tests pass and CI is green. 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.

1 participant