Skip to content

Clear grounded load pairs from bodies level with the pair - #214

Open
zkasuran wants to merge 1 commit into
tscircuit:mainfrom
zkasuran:fix/grounded-load-pair-neighbor-overlap
Open

Clear grounded load pairs from bodies level with the pair#214
zkasuran wants to merge 1 commit into
tscircuit:mainfrom
zkasuran:fix/grounded-load-pair-neighbor-overlap

Conversation

@zkasuran

@zkasuran zkasuran commented Aug 8, 2026

Copy link
Copy Markdown

What

GroundedLoadPairSolver re-stacks each grounded two-component load chain (a two-pin part feeding another two-pin part down to ground) vertically under its main-chip pin, then calls movePairBelowObstacles to drop the pair down until it clears any body sitting in its column.

That clearance pass used the wrong guard. It only treated a body as an obstacle when the body's top edge was above the pair's top edge:

if (bounds.maxY <= pairBounds.maxY) continue

A body that ended up level with the pair (its top at or below the pair top) was skipped even when it overlapped the pair, so the pair was left sitting on top of it.

Repro

tests/repros/repro-grounded-load-pair-neighbor-overlap.test.ts runs the existing repro44 e2e circuit with the requested chipGap widened to 1. At that gap the packer parks R2 level with the R3/D1 grounded load pair. Before this change the pair landed directly on top of R2, an overlap of about 0.29 in area. A larger requested gap producing overlapping chips is clearly wrong.

This is not specific to repro44. I found it by widening chipGap on the fixtures, then reproduced the same guard failing on many small generated circuits at the default chipGap of 0.2.

Fix

Skip a body only when it already sits entirely below the pair, since dropping the pair further would move it toward that body rather than clear it. Any body that still overlaps the pair's vertical span, including one level with the pair, is now cleared:

if (bounds.maxY <= pairBounds.minY) continue

Verification

On this branch:

  • bun test: 90 pass, 1 skip, 0 fail. The new repro fails without the fix and passes with it.
  • bunx tsc --noEmit: clean.
  • bun run format:check: clean.

No existing snapshots changed.

AI assistance

I authored and verified this change. AI assistance (Claude, Anthropic) was used while writing the fix and the test. I reviewed the diff and traced the overlap through the pipeline to GroundedLoadPairSolver, then verified locally before submitting. bun test, bunx tsc --noEmit and bun run format:check all pass.

GroundedLoadPairSolver stacks each grounded two-component chain vertically
under its main-chip pin, then drops the pair down to clear bodies sitting in
its column. The clearance pass skipped any body whose top edge was not above
the pair's top edge, so a chip parked level with the pair (top at or below the
pair top) was ignored and left overlapping.

Drop the pair below every body it still overlaps while keeping the existing
guard against bodies that already sit fully beneath it. A wider requested chip
gap can no longer stack a pair on top of a neighbour.

Adds a repro built from the repro44 e2e circuit at a wider chip gap, where the
R3/D1 grounded load pair used to land on top of R2.
@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
matchpack Ready Ready Preview Aug 8, 2026 6:28am

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.

1 participant