feat: specialized horizontal-row layout for decoupling caps (#15)#72
Open
solomonshalom wants to merge 1 commit intotscircuit:mainfrom
Open
feat: specialized horizontal-row layout for decoupling caps (#15)#72solomonshalom wants to merge 1 commit intotscircuit:mainfrom
solomonshalom wants to merge 1 commit intotscircuit:mainfrom
Conversation
…t#15) Adds DecouplingCapsHorizontalRowSolver and wires it into SingleInnerPartitionPackingSolver so partitions tagged partitionType: "decoupling_caps" get a deterministic horizontal-row layout instead of running through the general-purpose PackSolver2. Behavior: - Caps are sorted by chipId for deterministic ordering across runs. - Centers are spaced along x at (cap.size.x + gap) intervals, with the whole row centered on the origin so the outer PartitionPackingSolver treats it as a single rectangular block to attach next to the main chip's power pins. - Gap defaults to partition.decouplingCapsGap, then chipGap, mirroring the existing fallback chain in SingleInnerPartitionPackingSolver. Callers can override via the constructor. - Each cap uses its first availableRotation (typically 0°), which the existing IdentifyDecouplingCapsSolver already restricts to keep y+/y- pin pairs upright. - Solver completes in a single step but conforms to the BaseSolver / PackSolver2 shape (step/solved/failed/error/packedComponents) so the parent inner-partition packer can treat it interchangeably. Default partitions still drive PackSolver2, so non-decap layouts are untouched. Verified via dedicated regression test. Tests (16 new): - empty / single / multi-cap rows - horizontal alignment on shared y-axis - uniform x spacing between adjacent centers - centering around origin - explicit gap parameter wins over partition fallbacks - decouplingCapsGap fallback used when gap is unset - chipGap fallback used when decouplingCapsGap is missing - non-uniform cap widths produce correct centered row - chipId-based deterministic ordering (lex sort) - rotation taken from first availableRotation, defaulting to 0 - packedComponents shape matches PackSolver2 consumer expectations - single-step completion regardless of cap count - idempotency - visualize emits one rect per cap with correct dimensions - integration: decoupling_caps partition routes through the row solver - integration: default partitions still drive PackSolver2 (regression) Suite: 16 new pass, no regressions in the 33 existing tests. Pre- existing failures (1 import error, 1 baseline test failure) are unrelated to this change. /claim tscircuit#15
|
@solomonshalom is attempting to deploy a commit to the tscircuit Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
Implements the layout requested in #15 by adding
DecouplingCapsHorizontalRowSolverand routing partitions taggedpartitionType: \"decoupling_caps\"through it instead ofPackSolver2. The general packer is fine for arbitrary chips but produces stacked / scattered layouts for cap groups; this solver lays them out as a single tidy horizontal row matching the acceptable solution image in the issue.Approach
The pipeline already does the hard work —
IdentifyDecouplingCapsSolverfinds the cap groups,ChipPartitionsSolverbuilds dedicateddecoupling_capspartitions for them. The missing piece was the per-partition packer.DecouplingCapsHorizontalRowSolver:chipIdso the row order is stable across runs (important for snapshot stability and for the outer packer's nearest-neighbor logic).cap.size.x + gapper step, centering the whole row on the origin so the outerPartitionPackingSolvertreats the partition as one block to attach next to the main chip's power pins.availableRotation(typically0°), whichIdentifyDecouplingCapsSolveralready restricts to keep the y+/y- pin pair upright.gapdefaults topartition.decouplingCapsGap → partition.chipGap, exactly mirroring the fallback chain thatSingleInnerPartitionPackingSolveralready uses when configuringPackSolver2. Callers wanting a tighter or wider row can passgapexplicitly.The solver shape (
step / solved / failed / error / packedComponents) is assignment-compatible withPackSolver2, so the parent inner-partition packer routes through whichever child it instantiated without any special-casing in the layout-extraction code path.Files
lib/solvers/DecouplingCapsHorizontalRowSolver/DecouplingCapsHorizontalRowSolver.ts— solver + visualize.lib/solvers/PackInnerPartitionsSolver/SingleInnerPartitionPackingSolver.ts— branch onpartitionType === \"decoupling_caps\"to instantiate the row solver, otherwise stay onPackSolver2. Loosened theactiveSubSolverandcreateLayoutFromPackingResulttypes to accept either child shape.Tests (16 new)
Unit tests in
tests/DecouplingCapsHorizontalRowSolver/DecouplingCapsHorizontalRowSolver.test.ts:gapparameter overrides partition fallbacksdecouplingCapsGapfallback used whengapunsetchipGapfallback used whendecouplingCapsGapmissingpackedComponentsshape matches PackSolver2 consumer expectationsvisualize()emits one rect per cap with correct dimensionsIntegration tests in
tests/DecouplingCapsHorizontalRowSolver/integration.test.ts:decoupling_capspartition routes through the row solver and produces the expected y-aligned, uniformly-spaced layout viaSingleInnerPartitionPackingSolver.PackSolver2(regression guard so the new branch can never silently capture non-decap partitions).Test plan
bun test tests/DecouplingCapsHorizontalRowSolver/— 16 pass, 0 fail.bun test(full suite) — 33 pass + 1 skip + 1 pre-existing failure + 1 pre-existing import error. No new failures introduced.bun run format— biome clean.bunx tsc --noEmit— no new type errors involving the new code./claim #15