Skip to content

fix: prevent net-label-only nets from being routed as trace pairs#340

Open
tungnguyentu wants to merge 1 commit into
tscircuit:mainfrom
tungnguyentu:fix/net-label-only-79
Open

fix: prevent net-label-only nets from being routed as trace pairs#340
tungnguyentu wants to merge 1 commit into
tscircuit:mainfrom
tungnguyentu:fix/net-label-only-79

Conversation

@tungnguyentu
Copy link
Copy Markdown

Fixes #79

/claim #79

Root Cause

getConnectivityMapsFromInputProblem constructed netConnMap with a direct reference to directConnMap.netMap. When netConnMap.addConnections() ran for net connections, it also mutated directConnMap.netMap — so net-only connections appeared in dcConnMap, causing MspConnectionPairSolver to create MSP trace pairs for pins connected only via netConnections.

Fix

  1. Shallow-copy netMap when constructing netConnMap:

    // Before (bug: shared reference)
    const netConnMap = new ConnectivityMap(directConnMap.netMap)
    // After (fix: independent copy)
    const netConnMap = new ConnectivityMap({ ...directConnMap.netMap })
  2. Filter queuedDcNetIds to only include nets with at least one pin in a directConnection. Net-only nets are handled by NetLabelPlacementSolver, not by trace routing.

Tests

  • MspConnectionPairSolver_netLabelOnly.test.ts — 3 regression tests:
    1. Net-only connections produce 0 MSP pairs
    2. Direct connections still produce pairs (regression guard)
    3. Mixed direct + net connections route only the direct nets
  • Updated MspConnectionPairSolver_repro1 assertion from 4 → 2 pairs (GND is net-only in that fixture, so it should not be routed)
  • All 60 tests pass, 4 skip, 0 fail
  • 8 SVG snapshots updated (net-only nets no longer produce traces — correct behavior)

…circuit#79)

Root cause: `getConnectivityMapsFromInputProblem` passed `directConnMap.netMap`
by reference, so `netConnMap.addConnections()` mutated `directConnMap.netMap`.
This caused `MspConnectionPairSolver` to queue net-only nets for routing.

Fix:
- Shallow-copy netMap when building `netConnMap` to prevent aliasing
- Filter `queuedDcNetIds` to only include nets with at least one pin in a
  direct connection (net-only nets are handled by NetLabelPlacementSolver)

Adds regression tests covering: net-only-only scenario produces 0 MSP pairs,
direct connections still route, mixed scenario routes only direct nets.

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

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

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.

Fix extra net label in repro61, or remove trace

1 participant