Skip to content

Add pcbTracePaths for reusable pre-generated fanout routes - #837

Merged
seveibar merged 1 commit into
mainfrom
feat/saved-fanout-trace-paths
Sep 9, 2026
Merged

Add pcbTracePaths for reusable pre-generated fanout routes#837
seveibar merged 1 commit into
mainfrom
feat/saved-fanout-trace-paths

Conversation

@seveibar

@seveibar seveibar commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Adds pcbTracePaths to BreakoutProps (used by <breakout> and <fanout>) so pre-generated port-to-exit routes can be stored as JSON and reused without generated Circuit JSON IDs. Exports FanoutTracePath and fanoutTracePath, with wire/via validation and unit-aware distances normalized to millimeters.

The prop is optional and preserves existing automatic fanout defaults. Its declaration documents the coordinate frame, physical layer semantics, automatic-routing precedence, and duplicate-exit restrictions. Runtime route placement and preservation are implemented in the companion core PR: tscircuit/core#3809.

Validation: all 481 tests pass; typecheck, package build, and formatting pass. Ran all four required documentation generators and included the generated output.

Comment on lines +53 to +94
test("saved fanout paths reject invalid geometry and layer transitions", () => {
const wire = { route_type: "wire", x: 0, y: 0, width: 0.2, layer: "top" }
for (const invalid of [
{ connection: "", route: [wire, wire] },
{ connection: "U1.1", route: [] },
{ connection: "U1.1", route: [wire] },
{ connection: "U1.1", route: [wire, { ...wire, x: Number.NaN }] },
{ connection: "U1.1", route: [wire, { ...wire, width: 0 }] },
{ connection: "U1.1", route: [wire, { ...wire, layer: "bottom" }] },
{
connection: "U1.1",
route: [
wire,
{
route_type: "via",
x: 1,
y: 1,
from_layer: "top",
to_layer: "bottom",
},
],
},
{
connection: "U1.1",
route: [
{
route_type: "via",
x: 0,
y: 0,
from_layer: "top",
to_layer: "bottom",
},
wire,
],
},
{
connection: "U1.1",
route: [wire, { ...path.route[1], from_layer: "inner1" }, path.route[2]],
},
])
expect(fanoutTracePath.safeParse(invalid).success).toBe(false)
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This file contains two test(...) calls (one at line 26 and another at line 53). The style guide rule states that a *.test.ts file may have AT MOST one test(...). The second test should be moved to a separate, numbered file. For example, split into fanout-trace-paths1.test.ts (containing the first test: 'breakout retains JSON-serializable saved routes and normalizes distances') and fanout-trace-paths2.test.ts (containing the second test: 'saved fanout paths reject invalid geometry and layer transitions').

Spotted by Graphite (based on custom rule: Custom rule)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@seveibar
seveibar merged commit 144c27a into main Sep 9, 2026
5 checks passed
@tscircuitbot

Copy link
Copy Markdown
Contributor

Thank you for your contribution! 🎉

PR Rating: ⭐⭐⭐
Impact: Major

Track your contributions and see the leaderboard at: tscircuit Contribution Tracker


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.

2 participants