fix: check_wire_collisions now detects wires that short two pins of the same component

Previously, the endpoint suppression logic skipped any wire where at least
one endpoint touched a pin, hiding the case where both endpoints are pins
of the same component (a direct pin-to-pin short through the body).

Replace the single endpoint_matches_pin loop with separate start_at_pin /
end_at_pin checks; suppress only when exactly one endpoint is at a pin.
Add regression test to cover this case.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Eugene Mikhantyev
2026-03-15 12:46:50 +00:00
parent 1bfa608729
commit 6b09d93df2
2 changed files with 35 additions and 12 deletions

View File

@@ -654,19 +654,25 @@ def check_wire_collisions(schematic_path: Path) -> List[Dict[str, Any]]:
if not _line_segment_intersects_aabb(sx, sy, ex, ey, bx1, by1, bx2, by2):
continue
# Check if either wire endpoint matches a pin of this symbol
endpoint_matches_pin = False
for px, py in sd["pin_set"]:
if (abs(sx - px) < pin_tolerance and abs(sy - py) < pin_tolerance):
endpoint_matches_pin = True
break
if (abs(ex - px) < pin_tolerance and abs(ey - py) < pin_tolerance):
endpoint_matches_pin = True
break
# Check which endpoints land on a pin of this symbol
start_at_pin = any(
abs(sx - px) < pin_tolerance and abs(sy - py) < pin_tolerance
for px, py in sd["pin_set"]
)
end_at_pin = any(
abs(ex - px) < pin_tolerance and abs(ey - py) < pin_tolerance
for px, py in sd["pin_set"]
)
if not endpoint_matches_pin:
sym = sd["sym"]
collisions.append({
# Suppress only when exactly ONE endpoint is at a pin: the wire arrives
# from elsewhere and terminates at this component (a valid connection).
# If BOTH endpoints match pins of this same component, the wire shorts
# two pins while traversing the body — that IS a collision.
if (start_at_pin or end_at_pin) and not (start_at_pin and end_at_pin):
continue
sym = sd["sym"]
collisions.append({
"wire": {
"start": {"x": sx, "y": sy},
"end": {"x": ex, "y": ey},