Skip to content

Refactor Board DRC to aggregated async checks and prevent duplicate runs#1990

Open
seveibar wants to merge 3 commits intomainfrom
codex/update-checks-based-on-configuration
Open

Refactor Board DRC to aggregated async checks and prevent duplicate runs#1990
seveibar wants to merge 3 commits intomainfrom
codex/update-checks-based-on-configuration

Conversation

@seveibar
Copy link
Contributor

@seveibar seveibar commented Mar 2, 2026

Motivation

  • Consolidate many individual PCB DRC routines into a smaller set of aggregated check runners to simplify maintenance and coordination of checks.
  • Ensure netlist checks run even when routing is disabled while routing/placement checks obey routingDisabled/pcbDisabled configuration.
  • Run DRC work asynchronously and avoid duplicate/overlapping runs during long-running autoroute flows.

Description

  • Replaced many individual check imports with runAllNetlistChecks, runAllPlacementChecks, and runAllRoutingChecks from @tscircuit/checks and removed the old per-check invocation/insert logic.
  • Added _drcChecksInProgress flag and guards to avoid re-entrancy, and compute shouldRunNetlistChecks, shouldRunPlacementChecks, and shouldRunRoutingChecks to conditionally assemble which aggregated checks to run.
  • Collected check promises, awaited Promise.all, and insert results with db.insertAll(checkResults.flat()) instead of inserting per-check results inline.
  • Queued the DRC run via _queueAsyncEffect("board:drc-checks", ...) and set _drcChecksComplete/_drcChecksInProgress appropriately in a try/finally block.
  • Bumped dependency versions in package.json for @tscircuit/checks and @tscircuit/circuit-json-util, and updated a DRC test snapshot to match the new error id format.

Testing

  • Ran the DRC unit test tests/drc/pcb-port-not-connected-error.test.tsx and updated its inline snapshot to reflect the new error id, with the test passing.
  • Executed the modified DRC logic path in CI unit tests (DRC-related tests) and observed the aggregated checks complete and insert results without duplicate runs.

Codex Task

@vercel
Copy link

vercel bot commented Mar 2, 2026

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

Project Deployment Actions Updated (UTC)
tscircuit-core-benchmarks Ready Ready Preview, Comment Mar 2, 2026 5:04am

Request Review

Comment on lines +556 to +558
// Routing checks should only run once child subcircuits are fully routed.
// Netlist checks should always run, even when routing is disabled.
if (shouldRunRoutingChecks && !this._areChildSubcircuitsRouted()) return
Copy link
Contributor

Choose a reason for hiding this comment

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

Critical logic bug: When shouldRunRoutingChecks is true but children aren't routed yet, this early return prevents ALL checks from running, including netlist checks. This violates the PR requirement that "netlist checks should always run, even when routing is disabled."

If routing is enabled but children aren't routed, netlist and placement checks are blocked unnecessarily. The early return should be moved inside the conditional check assembly logic to only skip adding routing checks, not prevent all checks:

// Remove the early return here
// if (shouldRunRoutingChecks && !this._areChildSubcircuitsRouted()) return

if (this._drcChecksComplete || this._drcChecksInProgress) return

const runDrcChecks = async (circuitJson: AnyCircuitElement[]) => {
  const checksToRun: Promise<AnyCircuitElement[]>[] = []

  // Only add routing checks if children are routed
  if (shouldRunRoutingChecks && this._areChildSubcircuitsRouted()) {
    checksToRun.push(
      runAllRoutingChecks(circuitJson) as Promise<AnyCircuitElement[]>,
    )
  }
  // ... placement and netlist checks continue regardless
}
Suggested change
// Routing checks should only run once child subcircuits are fully routed.
// Netlist checks should always run, even when routing is disabled.
if (shouldRunRoutingChecks && !this._areChildSubcircuitsRouted()) return
// Routing checks should only run once child subcircuits are fully routed.
// Netlist checks should always run, even when routing is disabled.

Spotted by Graphite

Fix in Graphite


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

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.

1 participant