Skip to content

Add same-net trace segment alignment#438

Open
trigga6006 wants to merge 5 commits into
tscircuit:mainfrom
trigga6006:codex/tscircuit-same-net-align
Open

Add same-net trace segment alignment#438
trigga6006 wants to merge 5 commits into
tscircuit:mainfrom
trigga6006:codex/tscircuit-same-net-align

Conversation

@trigga6006
Copy link
Copy Markdown

@trigga6006 trigga6006 commented May 26, 2026

/claim #29
/claim #34

Summary

  • Add a final TraceCleanupSolver phase that aligns nearby overlapping internal H/V segments sharing the same globalConnNetId.
  • Preserve endpoint-only segments so pin anchors do not drift.
  • Reject candidate alignments that would introduce intersections with different-net traces.
  • Add focused regression tests for same-net alignment, different-net no-op, endpoint preservation, and collision rejection.

This covers both:

Verification

  • bun test tests\solvers\TraceCleanupSolver\alignNearbySameNetSegments.test.ts tests\examples\example29.test.ts tests\examples\example34.test.ts
  • bun test
  • bunx tsc --noEmit
  • bun run build
  • git diff --check

Note: bun run format:check failed locally on the repo-wide baseline CRLF/LF formatting mismatch across existing files; touched files were formatted with Biome directly. Remote CI format-check passes on this PR.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 26, 2026

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

Project Deployment Actions Updated (UTC)
schematic-trace-solver Ready Ready Preview, Comment May 26, 2026 10:45pm

Request Review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 44d4e912d9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

tracePath: candidatePath,
}

if (intersectsDifferentNet(candidateTrace, output)) continue
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Prevent same-net alignment from routing through obstacles

This acceptance path only verifies orthogonality and intersectsDifferentNet, so the new alignment phase can move a segment through chip/box obstacles (and other non-trace blockers) without being rejected. Earlier cleanup passes explicitly validate against static obstacle rectangles and label bounds, but this phase omits those checks entirely; in a layout where two same-net segments are close on opposite sides of a component, the shorter one can be snapped across the component and still be accepted.

Useful? React with 👍 / 👎.

anchorSegment.fixedCoord,
)

if (!isOrthogonalPath(candidatePath)) continue
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject self-intersecting candidate paths before applying

Checking only isOrthogonalPath is insufficient here: an orthogonal path can still self-intersect after moving an internal segment. Because the subsequent collision filter skips traces with the same mspPairId, the candidate is never tested against non-adjacent segments of its own trace, so a zig-zag trace can be transformed into a self-crossing polyline and committed.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant