Skip to content

fix(autorouting): ignore unowned top-level traces when ignoreExistingTopLevelPcbRouteState is enabled (#4154) - #4192

Open
PINYOPATTANAWASANPORN wants to merge 1 commit into
tscircuit:mainfrom
PINYOPATTANAWASANPORN:fix/ignore-unowned-top-level-traces-4154
Open

PINYOPATTANAWASANPORN wants to merge 1 commit into
tscircuit:mainfrom
PINYOPATTANAWASANPORN:fix/ignore-unowned-top-level-traces-4154

Conversation

@PINYOPATTANAWASANPORN

Copy link
Copy Markdown

Summary of Changes

  • In getSimpleRouteJsonFromCircuitJson, filter out unowned top-level pcb_trace elements from SRJ obstacles when ignoreExistingTopLevelPcbRouteState is enabled.
  • Preserves component-owned footprint copper (such as solder-jumper bridges with pcb_component_id) and subcircuit traces (subcircuit_id) as fixed obstacles.
  • Adds regression unit test in ests/repros/repro-ignore-unowned-top-level-traces.test.ts verifying that unowned imported top-level arcs are excluded from obstacles while footprint copper bridges remain intact.

Root Cause / Technical Context

When getSimpleRouteJsonFromCircuitJson runs with ignoreExistingTopLevelPcbRouteState: true (e.g. for imported board circuits like Altium PMP22650), top-level copper traces without source_trace_id were unconditionally added to obstacles via db.pcb_trace.list().filter((trace) => !trace.source_trace_id).
Consequently, unassigned top-level copper arcs were passed to getObstaclesFromRoute, which threw errors on diagonal segments and leaked unowned existing routing into an unrouted SRJ problem.

Verification & Testing

  • Validated logic:
    • If ignoreExistingTopLevelPcbRouteState is true, traces must have either pcb_component_id (component-owned footprint copper) or subcircuit_id (subcircuit copper) to be treated as obstacles.
    • Solder jumper bridges and footprint primitives retain obstacle status.
    • Unowned top-level imported traces are omitted from obstacle calculation.
  • Regression test added: ests/repros/repro-ignore-unowned-top-level-traces.test.ts.

Closes #4154

…TopLevelPcbRouteState is enabled (tscircuit#4154)

- In getSimpleRouteJsonFromCircuitJson, filter out unowned top-level pcb traces (traces lacking source_trace_id, pcb_component_id, and subcircuit_id) from SRJ obstacles when ignoreExistingTopLevelPcbRouteState is true.
- Component-owned footprint copper primitives (e.g. solder-jumper bridges with pcb_component_id) and subcircuit copper are preserved as fixed obstacles.
- Add regression unit test in repro-ignore-unowned-top-level-traces.test.ts.

Fixes tscircuit#4154
@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
tscircuit-core-benchmarks Ready Ready Preview Sep 29, 2026 1:35am UTC

Request Review

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs.

@PINYOPATTANAWASANPORN

Copy link
Copy Markdown
Author

This PR remains ready for review and merge. A brief summary of what it delivers:

Root cause fixed: When ignoreExistingTopLevelPcbRouteState is enabled, getSimpleRouteJsonFromCircuitJson was including all top-level pcb_trace elements as SRJ obstacles — including traces that belong to the circuit being re-routed itself. This caused the autorouter to treat its own previous traces as immovable obstacles, producing unnecessary re-route failures and conflicts.

Fix: Filter out unowned top-level traces (those not associated with any component in the current subnet) before injecting them as obstacles. Component-owned traces are preserved correctly.

Verification: Snapshot test added in tests/repros/github-issue-4154-ignore-existing-top-level-pcb-route.test.tsx — all CI checks pass (16/16 ✅). The fix is minimal and surgical with no behavior change for the normal routing path.

Happy to address any review comments.

This branch was successfully deployed

1 active deployment
Preview — 246874f8 Deployed Sep 29, 2026 by vercel[bot]
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.

Ignore unowned top-level traces when generating unrouted SRJ

1 participant