Skip to content

Fix extra net label in repro61, or remove trace#523

Open
qlufiq-collab wants to merge 19 commits into
tscircuit:mainfrom
qlufiq-collab:bounty/tscircuit/schematic-trace-solver-79
Open

Fix extra net label in repro61, or remove trace#523
qlufiq-collab wants to merge 19 commits into
tscircuit:mainfrom
qlufiq-collab:bounty/tscircuit/schematic-trace-solver-79

Conversation

@qlufiq-collab

@qlufiq-collab qlufiq-collab commented Jun 11, 2026

Copy link
Copy Markdown

Summary

Fix spurious wire traces being drawn between pins that share only a net-label connection (no direct wire). The README documents the contract: "Net connections will not be routed, net labels are placed instead." Two bugs violated this contract, causing extra traces and net labels to appear (as reported in the repro61 scenario from tscircuit/core#1503).

Changes

  • lib/solvers/MspConnectionPairSolver/getConnectivityMapFromInputProblem.ts — Deep-clone directConnMap.netMap before passing it to the netConnMap constructor, preventing addConnections() calls on netConnMap from mutating directConnMap via shared reference.
  • lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver.ts — Queue only directConnMap net IDs (not netConnMap) for MSP pair creation, so net-label-only nets no longer produce wire traces.
  • tests/solvers/MspConnectionPairSolver/MspConnectionPairSolver_netOnly.test.ts — New test reproducing the repro61 scenario: two capacitors with only net connections produce zero MSP pairs.
  • tests/solvers/MspConnectionPairSolver/MspConnectionPairSolver_repro1.test.ts — Update expected pair count from 4 to 2 (GND net is label-only, not a direct connection).
  • tests/repros/trace-overlap-box-resistor.test.ts — Update assertion: U1.3-R2.2 (GND net connection) correctly produces no trace.
  • tests/examples/__snapshots__/*.snap.svg — Regenerated 10 snapshots reflecting correct removal of spurious traces.
  • tests/repros/__snapshots__/*.snap.svg — Regenerated 2 snapshots.

Test Plan

  • bun test tests/solvers/MspConnectionPairSolver/MspConnectionPairSolver_netOnly.test.ts → 2 pass (net-only pairs = 0, no directConnMap leak)
  • bun test → 68 pass, 0 fail, 4 skip
  • bunx tsc --noEmit → clean
  • bun run format:check → no issues

Notes

Root cause 1: new ConnectivityMap(directConnMap.netMap) stored a live reference. Subsequent netConnMap.addConnections(...) mutated the directConnMap, making net-only pins appear to be in the direct-wire connectivity set.

Root cause 2: queuedDcNetIds = Object.keys(netConnMap.netMap) iterated every net including label-only ones, so the MSP solver created wire-trace pairs for connections that should only get labels.

Closes #79

## Summary

Fix spurious wire traces being drawn between pins that share only a net-label connection (no direct wire). The README documents the contract: "Net connections will not be routed, net labels are placed instead." Two bugs violated this contract, causing extra traces and net labels to appear (as reported in the repro61 scenario from tscircuit/core#1503).

## Changes

- `lib/solvers/MspConnectionPairSolver/getConnectivityMapFromInputProblem.ts` — Deep-clone `directConnMap.netMap` before passing it to the `netConnMap` constructor, preventing `addConnections()` calls on `netConnMap` from mutating `directConnMap` via shared reference.
- `lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver.ts` — Queue only `directConnMap` net IDs (not `netConnMap`) for MSP pair creation, so net-label-only nets no longer produce wire traces.
- `tests/solvers/MspConnectionPairSolver/MspConnectionPairSolver_netOnly.test.ts` — New test reproducing the repro61 scenario: two capacitors with only net connections produce zero MSP pairs.
- `tests/solvers/MspConnectionPairSolver/MspConnectionPairSolver_repro1.test.ts` — Update expected pair count from 4 to 2 (GND net is label-only, not a direct connection).
- `tests/repros/trace-overlap-box-resistor.test.ts` — Update assertion: U1.3-R2.2 (GND net connection) correctly produces no trace.
- `tests/examples/__snapshots__/*.snap.svg` — Regenerated 10 snapshots reflecting correct removal of spurious traces.
- `tests/repros/__snapshots__/*.snap.svg` — Regenerated 2 snapshots.

## Test Plan

- `bun test tests/solvers/MspConnectionPairSolver/MspConnectionPairSolver_netOnly.test.ts` → 2 pass (net-only pairs = 0, no directConnMap leak)
- `bun test` → 68 pass, 0 fail, 4 skip
- `bunx tsc --noEmit` → clean
- `bun run format:check` → no issues

## Notes

Root cause 1: `new ConnectivityMap(directConnMap.netMap)` stored a live reference. Subsequent `netConnMap.addConnections(...)` mutated the directConnMap, making net-only pins appear to be in the direct-wire connectivity set.

Root cause 2: `queuedDcNetIds = Object.keys(netConnMap.netMap)` iterated every net including label-only ones, so the MSP solver created wire-trace pairs for connections that should only get labels.

Closes tscircuit#79

Bounty: tscircuit#79
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
schematic-trace-solver Ready Ready Preview, Comment Jul 4, 2026 7:17pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix extra net label in repro61, or remove trace

1 participant