Skip to content

refactor: extract local autorouter strategies - #2898

Merged
seveibar merged 1 commit into
mainfrom
agent/local-autorouter-strategies
Jul 28, 2026
Merged

refactor: extract local autorouter strategies#2898
seveibar merged 1 commit into
mainfrom
agent/local-autorouter-strategies

Conversation

@seveibar

@seveibar seveibar commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • move default local-autorouter construction out of Group.ts
  • introduce a small strategy interface for router creation and cache policy
  • keep the strategy registry empty so every current preset follows the unchanged default path
  • add a focused regression proving the default strategy remains cacheable and constructs TscircuitAutorouter with the original SimpleRouteJson

This is deliberately behavior-neutral. It creates the extension point needed by specialized autorouters without including fanout presets, fanout dependencies, multi-stage routing, or breakout behavior.

Validation

  • bunx tsc --noEmit
  • focused autorouter tests: 3 passing, 0 failing
  • git diff --check
  • all GitHub test, type-check, format, smoke-test, and Vercel checks passing

@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
tscircuit-core-benchmarks Ready Ready Preview, Comment Jul 28, 2026 3:24pm

Request Review

@seveibar
seveibar marked this pull request as ready for review July 28, 2026 18:09
@seveibar
seveibar merged commit 9b0b1bd into main Jul 28, 2026
10 checks passed
@seveibar
seveibar deleted the agent/local-autorouter-strategies branch July 28, 2026 18:09
Comment on lines +1 to +30
import {
type AutorouterOptions,
TscircuitAutorouter,
} from "./CapacityMeshAutorouter"
import type { GenericLocalAutorouter } from "./GenericLocalAutorouter"
import type { SimpleRouteJson } from "./SimpleRouteJson"
import type { NormalizedAutorouterConfig } from "./getPresetAutoroutingConfig"

export interface LocalAutorouterStrategyContext {
simpleRouteJson: SimpleRouteJson
commonAutorouterOptions: AutorouterOptions
}

export interface LocalAutorouterStrategy {
cacheable: boolean
create: (context: LocalAutorouterStrategyContext) => GenericLocalAutorouter
}

const defaultLocalAutorouterStrategy: LocalAutorouterStrategy = {
cacheable: true,
create: ({ simpleRouteJson, commonAutorouterOptions }) =>
new TscircuitAutorouter(simpleRouteJson, commonAutorouterOptions),
}

const localAutorouterStrategies = new Map<string, LocalAutorouterStrategy>()

export const getLocalAutorouterStrategy = (
preset: NormalizedAutorouterConfig["preset"],
): LocalAutorouterStrategy =>
localAutorouterStrategies.get(preset ?? "") ?? defaultLocalAutorouterStrategy

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.

The file name localAutorouterStrategies.ts uses camelCase, but the project's convention for utility files is kebab-case (e.g., should-skip-autorouting-because-of-placement-errors.ts, get-bounds-of-pcb-components.ts, getPresetAutoroutingConfig also exists but the dominant pattern in the autorouting directory includes kebab-case files). File names should be consistent with the project's naming conventions. This file should be renamed to local-autorouter-strategies.ts to match the kebab-case pattern used by other utility files in the project (e.g., should-skip-autorouting-because-of-placement-errors.ts). The corresponding test file and import in Group.ts should also be updated accordingly.

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

Fix in Graphite


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

@tscircuitbot

Copy link
Copy Markdown
Contributor

Thank you for your contribution! 🎉

PR Rating: ⭐⭐
Impact: Minor

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


KrishnaX12 added a commit to KrishnaX12/core that referenced this pull request Jul 29, 2026
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