Add empty-connections early-return guards to all pipeline solvers#659
Open
chengdazhi wants to merge 1 commit into
Open
Add empty-connections early-return guards to all pipeline solvers#659chengdazhi wants to merge 1 commit into
chengdazhi wants to merge 1 commit into
Conversation
Each solver now marks itself solved immediately when there are no connections, traces, or labels to process, returning an empty result instead of running its step loop. This also fixes crashes when the input problem has no chips, where building a Flatbush-backed chip obstacle spatial index with zero items threw inside TraceCleanupSolver, AvailableNetOrientationSolver, and NetLabelNetLabelCollisionSolver.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Passing an input problem with no connections (
directConnections: []/netConnections: [], which yields no MSP pairs and no traces) caused solvers to run their step loops over empty work queues, and a fully empty input (chips: []) crashed outright:TraceCleanupSolver,AvailableNetOrientationSolver, andNetLabelNetLabelCollisionSolverbuild a Flatbush-backedChipObstacleSpatialIndex, and Flatbush throwsUnexpected numItems value: 0when constructed with zero chips.Note: the issue mentions
CapacityMeshSolver.ts/DirectLineSolver.ts; those files don't exist in this repo, so I applied the guard to every solver in the actual pipeline (SchematicTracePipelineSolver's stages).Fix
Add an early-return guard to each pipeline solver: when there are no connections / connection pairs / traces / labels to process, the solver marks itself
solvedin the constructor and returns an empty result (empty traces / labels maps) instead of stepping:MspConnectionPairSolver— nodirectConnectionsand nonetConnectionsSchematicTraceLinesSolver— no MSP connection pairsLongDistancePairSolver— no candidate pairsTraceOverlapShiftSolver— no input tracesNetLabelPlacementSolver— no connection-net groups to labelTraceLabelOverlapAvoidanceSolver— no traces (still runs the finalMergedNetLabelObstacleSolverso downstream stages can readlabelMergingSolver.getOutput())TraceCleanupSolver— no traces (also avoids building the spatial index that crashed onchips: [])Example28Solver— no tracesAvailableNetOrientationSolver— no labels (skips the spatial index construction)RailNetLabelCornerPlacementSolver— no labels needing corner placementTraceAnchoredNetLabelOverlapSolver— no labelsNetLabelTraceCollisionSolver— no traces or no labelsNetLabelNetLabelCollisionSolver— no labels (skips the spatial index construction)Tests
Added
tests/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver_emptyConnections.test.tscovering the pipeline and each solver with empty connections (and the pipeline withchips: []), asserting the solver solves without failing and returns empty traces/labels.bun test— 117 pass, 4 skip, 0 failtsc --noEmitandbiome formatcleanThis PR was prepared with assistance from an AI coding agent.
Closes #657