Skip to content

fix: detect via-pad copper conflicts during placement checks - #481

Closed
hrithik18k wants to merge 3 commits into
tscircuit:mainfrom
hrithik18k:repro/241-placement-misses-via-pad-copper
Closed

hrithik18k wants to merge 3 commits into
tscircuit:mainfrom
hrithik18k:repro/241-placement-misses-via-pad-copper

Conversation

@hrithik18k

@hrithik18k hrithik18k commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

A manually placed via can overlap a different-net SMD pad with its copper annulus while its drill remains outside the pad. Current placement validation returns no error for this short, while the existing via-to-pad clearance checker detects it during routing validation.

Placement checks now run checkViaPadClearance(). Routing-only callers retain their existing detection, and runAllChecks() deduplicates matching clearance diagnostics so a conflict is reported once. Drill-in-pad permission remains independent of different-net copper clearance.

Scope and prior work

This is a follow-up to #241, not the original geometry fix. The reproduction was merged in #242 and the geometry fix in #243. Later, #359 deliberately separated drill-in-pad manufacturing policy from different-net copper clearance: checkViasInPads() became drill-only, while checkViaPadClearance() remained in routing validation.

This PR preserves that separation and the merged geometry implementation. Its additional behavior is to run the existing copper-clearance checker during placement too, so a pre-routing placement check can report an already-present different-net copper conflict. It does not revert #359 or classify same-net copper-only contact as via-in-pad.

RC-car board evidence — intentionally introduced fault

The original RC-car board does not contain this fault. The test fault was intentionally introduced into a modified copy to demonstrate the validation gap. This is design-level regression evidence, not a fabricated-hardware failure report.

The fixture retains the complete routed 60 x 45 mm ESC/servo carrier. It adds one GND via near R1.pin1 (ESC_GPIO) and one bottom-layer spur connecting that via to existing ground copper. Every original component, net and route is preserved. The drill stays outside the SMD pad while the annular copper overlaps its corner.

Copper under test Placement before fix Placement after fix Gerber shorts, both layers
Original RC-car board 0 errors 0 errors 0; exit 0
Same board with intentional fault 0 errors 1 error at R1.pin1 1 top-layer short; exit 1

Before/after snapshots show the same faulty copper under different checker implementations. The checker fix detects the fault; it does not repair the copper. The before result runs the actual pinned @tscircuit/checks@0.0.264 package; the after result runs this PR's source.

Before: placement misses the intentional fault After: placement reports the intentional fault
Before: same intentionally faulty RC-car copper, zero placement errors After: same intentionally faulty RC-car copper, one placement error

Before, corner detail · After, corner detail

Fixture, exact modification and reproduction commands · Original Gerber transcript · Faulty Gerber transcript · Gerber short bitmap

Regression coverage

  • Converts the original minimal TSX reproduction into a passing placement regression and updates its native SVG snapshot.
  • Covers corner overlap, insufficient clearance without overlap, separated copper, a 37-degree rotated pad, same-net contact, disjoint copper layers, via-in-pad allowance, readable named/unnamed diagnostics and diagnostic deduplication without losing distinct conflicts.
  • The RC-car regression asserts unchanged original records, exactly one added via and spur, a clean original control, no drill-in-pad finding, and actual old/new placement outputs. Four new native snapshots cover the full board and the corner detail.
  • The opt-in Gerber evidence script checks actual CLI exit codes and requires exactly 0 shorts for the control and 1 for the intentionally faulty board. It uses tscircuit@0.0.3016, Gerber mode, all layers and 40 pixels/mm. The normal test suite does not download/run the external CLI.

Validation

  • Full suite: 691 pass, 0 fail.
  • bun run build passes, including declarations.
  • RC-car snapshot comparison passes after regeneration.
  • Gerber control: no shorts, exit 0. Intentionally faulty board: one short, exit 1.
  • Biome formatting and git diff --check pass.

The full-suite run used the fixture's exact Git bytes locally because Windows checkout line-ending conversion otherwise fails an unrelated fixture SHA-256 assertion. No unrelated fixture changes are included.

@hrithik18k hrithik18k changed the title test: reproduce missing placement error for via-pad corner overlap fix: detect via-pad copper conflicts during placement checks Oct 24, 2026
@hrithik18k

Copy link
Copy Markdown
Contributor Author

Closing this PR because the original issue #241 was already fixed by #243, following the reproduction in #242. Later, #359 deliberately separated drill-in-pad placement policy from different-net copper clearance: drill overlap is handled by checkViasInPads(), and copper clearance remains covered by checkViaPadClearance() in routing/full validation.

Rechecking the intentionally faulty RC-car fixture confirms that upstream full checks already detect the same via-to-pad copper short as this PR. The original RC-car board is clean; its fault was intentionally introduced only for the regression evidence.

This PR adds earlier reporting through the placement runner, rather than a missing fix for the original issue. That would be a separate behavior proposal, and the tested CLI also needs diagnostic-category integration before it can be claimed as an end-to-end placement-command fix. It is therefore unnecessary to keep this PR open as a fix for #241.

The original geometry fix and the later drill/copper distinction remain intact. No merge is needed from this PR.

@hrithik18k hrithik18k closed this Oct 25, 2026
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.

1 participant