Fix extra net label in repro61, or remove trace#523
Open
qlufiq-collab wants to merge 19 commits into
Open
Conversation
## 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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
[anti-stale]
[anti-stale]
[anti-stale]
[anti-stale]
[anti-stale]
[anti-stale]
[anti-stale]
[anti-stale]
[anti-stale]
[anti-stale]
[anti-stale]
[anti-stale]
[anti-stale]
[anti-stale]
[anti-stale]
[anti-stale]
[anti-stale]
[anti-stale]
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.
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-clonedirectConnMap.netMapbefore passing it to thenetConnMapconstructor, preventingaddConnections()calls onnetConnMapfrom mutatingdirectConnMapvia shared reference.lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver.ts— Queue onlydirectConnMapnet IDs (notnetConnMap) 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 skipbunx tsc --noEmit→ cleanbun run format:check→ no issuesNotes
Root cause 1:
new ConnectivityMap(directConnMap.netMap)stored a live reference. SubsequentnetConnMap.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