Skip to content

Remove micro-detours from simplified routes, add debug script and regression test#652

Closed
0hmX wants to merge 1 commit intomainfrom
codex/investigate-triangle-formation-bug-in-circuit-11
Closed

Remove micro-detours from simplified routes, add debug script and regression test#652
0hmX wants to merge 1 commit intomainfrom
codex/investigate-triangle-formation-bug-in-circuit-11

Conversation

@0hmX
Copy link
Copy Markdown
Contributor

@0hmX 0hmX commented Mar 12, 2026

Motivation

  • Eliminate tiny triangular detours and near-duplicate points in simplified PCB traces produced by convertHdRouteToSimplifiedRoute to reduce spurious kinks in output.
  • Provide a repro/debug helper to inspect where such micro-detours originate in the pipeline for dataset01 circuit011.
  • Add a regression test to prevent reintroduction of the micro-triangle issue.

Description

  • Implemented sanitizeLayerPoints and small geometry helpers (distance) along with constants to detect and remove near-duplicate points and micro-detours based on chord length, edge sizes, and perpendicular distance.
  • Integrated sanitizeLayerPoints into convertHdRouteToSimplifiedRoute for both layer transitions and the final layer emission so wires are emitted from cleaned point lists.
  • Added scripts/debug-dataset01-circuit011-solver3.ts to reproduce and inspect candidate tiny-triangle detours across solver stages.
  • Added regression test tests/bugs/dataset01-circuit011-solver3-no-micro-triangle.test.ts and a convenience script entry debug:dataset01:circuit011:solver3 in package.json.

Testing

  • Ran the new regression test tests/bugs/dataset01-circuit011-solver3-no-micro-triangle.test.ts via bun test and it passed.
  • Executed the project's test suite via bun test to ensure no regressions and the suite passed.

Codex Task

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 12, 2026

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

Project Deployment Actions Updated (UTC)
capacity-node-autorouter Ready Ready Preview, Comment Mar 12, 2026 1:14pm

Request Review

@tscircuitbot
Copy link
Copy Markdown

🏃 Benchmark This PR

Run benchmarks by commenting on this PR:

/benchmark [solver-name|all] [scenario-limit] --concurrency <n> --effort <n>

Examples:

  • /benchmark -> AutoroutingPipelineSolver, all scenarios (default concurrency uses the benchmark runner CPU count)
  • /benchmark AutoroutingPipelineSolver -> one solver, all scenarios
  • /benchmark all 20 -> all solvers, first 20 scenarios
  • /benchmark AutoroutingPipelineSolver 20 --concurrency 8 -> one solver, 20 scenarios, 8 workers
  • /benchmark AutoroutingPipelineSolver 20 --effort 2 -> one solver, 20 scenarios, 2x effort

Any PR whose title contains [BENCHMARK TEST] will automatically run the benchmark workflow on PR updates.

Comment on lines +43 to +44
if (Math.min(distAB, distBC) >= MICRO_DETOUR_MIN_TINY_EDGE) continue
if (Math.max(distAB, distBC) <= MICRO_DETOUR_MIN_LARGE_EDGE) continue
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.

Logic gap in micro-detour detection. When distAB = 0.005 (tiny) and distBC = 0.025 (medium), the conditions:

  • Line 43: Math.min(0.005, 0.025) = 0.005 < 0.01 ✓ (passes)
  • Line 44: Math.max(0.005, 0.025) = 0.025 <= 0.03 ✓ (skips removal)

This creates a gap where triangles with one very small edge (< 0.01) and one medium edge (between 0.01 and 0.03) are NOT removed, potentially leaving micro-detours in the output.

// Consider adjusting line 44 to:
if (Math.max(distAB, distBC) < MICRO_DETOUR_MIN_LARGE_EDGE) continue
// Or removing this check entirely if all micro-detours should be caught

This may cause the regression test to pass while still allowing some micro-triangular detours through, as the test only checks chord < 0.08 without the edge size constraints.

Spotted by Graphite

Fix in Graphite


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

@0hmX 0hmX closed this Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants