test: pin different-net trace crossings per bug report - #718
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Adds a helper that counts places where traces on different nets properly cross, and a test that pins the current count for every imported bug report. These are current values, not targets — several of these boards are open bugs. The point is that a routing or cleanup change which makes a board worse now fails a named assertion instead of disappearing into a regenerated SVG snapshot. Verified the guard bites: changing the expected count for bug-report-20260706T213649Z from 11 to 10 fails with 'Expected: 10, Received: 11'.
tscircuit#727 (TraceOverlapShiftSolver) fixed the RP2040 USB-C overlap and moved bug-report-20260707T092615Z from 2 different-net crossings to 3. Measured either side of that merge: ca7e80c (before) TOTAL 40, this board 2 be20aa7 (tscircuit#727) TOTAL 41, this board 3 Pinned at the current value with a comment recording the change, and reported it on tscircuit#727 so the trade is visible rather than absorbed.
f4d9840 to
c56a75e
Compare
A crossings-only count is one-sided: two nets that cross can always be made to stop crossing by running them along each other instead, which reads as a single line and hides a connection. Counting only crossings scores that as an improvement. tscircuit#727 is the concrete case. On bug-report-20260707T092615Z it moved the board from 2 crossings / 1 overlap to 3 crossings / 0 overlaps, and both numbers involve the same pair of segments (C_SENSE.2-C1.2 and available-net-orientation-13-BAT_POS) — it separated two nets drawn on top of each other across a 0.141 span and left them crossing at a point. That is a trade in the right direction, but a crossings-only guard flags it as a regression. Pinning both quantities makes the trade visible instead of scoring it.
|
Updated this to pin overlaps as well as crossings, because I found the one-sided version scoring a good change as a bad one. I had used the earlier version of this counter to report a "regression" from #727. It was not a regression. Counting different-net collinear overlaps too: Same pair of segments on both sides, on the single board that moved: #727 separated two nets that had been drawn on top of each other and left them crossing at a point instead — the right trade, since an overlap looks like one trace and hides that two nets are there. That is the argument for pinning both. A crossings-only guard is gameable in one specific direction: any crossing can be eliminated by making the two nets run along each other, and a one-sided counter reads that as an improvement. Pinning both makes the trade explicit — a PR that moves a board from Still measurement-only — no
Verification, since a guard that cannot fail is worth nothing:
|
40a6b14 to
b6bab95
Compare
Why
Nearly every bug report in
tests/bug-reports/is verified by an SVG snapshot. That catches change, but not quality — a trace crossing that appears or disappears is a handful of pixels in a large regenerated SVG, and easy to approve without noticing.Different-net crossings are the thing several of these reports are actually about, so I measured them across every imported board:
40 crossings across 19 boards. None of that was visible from CI before.
What this adds
tests/fixtures/traceCrossings.ts—getTraceCrossings(traces), mirroring the shape of the existinggetTraceLabelCollisionshelper next to it. Counts only proper crossings between segments on different nets; shared endpoints on the same net are excluded, since traces legitimately meet there.tests/different-net-trace-crossings.test.ts— pins the count per board, one named test each.These numbers are the current state, not a target. Several of these boards are open bugs and the counts should come down. The value is that they can't quietly go up: a routing or cleanup change that makes a board worse now fails an assertion that names the board, instead of sliding into a regenerated snapshot.
There's also a guard test asserting the pinned set matches what's on disk, so a newly imported bug report can't go unmeasured.
Verification
bug-report-20260706T213649Zfrom 11 to 10 and gotExpected: 10, Received: 11. A pinning test that can't fail is worse than no test.tsc --noEmitclean, biome clean.One implementation note: I initially read traces from
netLabelNetLabelCollisionSolver, the last pipeline step — but itsgetOutput()returns onlynetLabelPlacements.tsccaught it. Final trace geometry comes fromtraceCleanupSolver2, which is what this reads now.Follow-up
If this is useful, the natural next step is fixing the worst boards and lowering the numbers in the same PR.
bug-report-20260706T213649Zat 11 is the obvious first target — happy to take that on.Diff: 2 new files, no existing file touched.