From 138d4fda834558e6e2dc19da670c9ca1acceb85a Mon Sep 17 00:00:00 2001 From: ShiboSoftwareDev Date: Sun, 2 Aug 2026 11:25:11 +0200 Subject: [PATCH 1/4] fix: use physical duplicate lane placement --- lib/DuplicateCongestedPortSolver.ts | 11 ++++------- ...congested-port-sufficient-capacity.test.ts | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/DuplicateCongestedPortSolver.ts b/lib/DuplicateCongestedPortSolver.ts index 2e47e77..51f793f 100644 --- a/lib/DuplicateCongestedPortSolver.ts +++ b/lib/DuplicateCongestedPortSolver.ts @@ -562,9 +562,6 @@ export class DuplicateCongestedPortSolver extends BaseSolver { const availableLaneCount = physicalLanePoints?.length const capacityIsInsufficient = availableLaneCount !== undefined && availableLaneCount < useCount - const capacityLimitedLanePoints = capacityIsInsufficient - ? physicalLanePoints - : undefined const duplicateCount = capacityIsInsufficient ? Math.max(0, availableLaneCount - 1) : useCount - 1 @@ -578,10 +575,10 @@ export class DuplicateCongestedPortSolver extends BaseSolver { regionById, ) const sourcePoint = getPortPoint(sourcePort) - if (capacityLimitedLanePoints?.[0]) { + if (physicalLanePoints?.[0]) { const sourcePortData = toObjectRecord(sourcePort.d) - sourcePortData.x = capacityLimitedLanePoints[0].x - sourcePortData.y = capacityLimitedLanePoints[0].y + sourcePortData.x = physicalLanePoints[0].x + sourcePortData.y = physicalLanePoints[0].y sourcePort.d = sourcePortData } const duplicatePortIds: string[] = [] @@ -598,7 +595,7 @@ export class DuplicateCongestedPortSolver extends BaseSolver { ) const offset = (duplicatePortProximity * duplicateIndex) / (duplicateCount + 1) - const duplicatePoint = capacityLimitedLanePoints?.[duplicateIndex] ?? { + const duplicatePoint = physicalLanePoints?.[duplicateIndex] ?? { x: sourcePoint.x + duplicateDirection.x * offset, y: sourcePoint.y + duplicateDirection.y * offset, } diff --git a/tests/solver/duplicate-congested-port-sufficient-capacity.test.ts b/tests/solver/duplicate-congested-port-sufficient-capacity.test.ts index fa38b76..4b546a5 100644 --- a/tests/solver/duplicate-congested-port-sufficient-capacity.test.ts +++ b/tests/solver/duplicate-congested-port-sufficient-capacity.test.ts @@ -70,15 +70,22 @@ const createFixture = (): SerializedHyperGraph => ({ ], }) -test("preserves legacy duplicate placement when the boundary has enough capacity", () => { - const legacySolver = new DuplicateCongestedPortSolver(createFixture()) - const capacityAwareSolver = new DuplicateCongestedPortSolver(createFixture(), { +test("uses physical duplicate placement when the boundary has enough capacity", () => { + const solver = new DuplicateCongestedPortSolver(createFixture(), { minimumDuplicatePortSpacing: 0.2, duplicatePortWidth: 0.1, }) - legacySolver.solve() - capacityAwareSolver.solve() + solver.solve() - expect(capacityAwareSolver.getOutput()).toEqual(legacySolver.getOutput()) + const lanePorts = solver + .getOutput() + .ports.filter( + (port) => + port.portId === "shared" || port.d?.duplicatedFromPortId === "shared", + ) + expect(lanePorts).toHaveLength(2) + expect( + Math.abs(Number(lanePorts[0]!.d?.y) - Number(lanePorts[1]!.d?.y)), + ).toBeCloseTo(0.2) }) From 21566314d5facd628e10f59702547ddebf992c16 Mon Sep 17 00:00:00 2001 From: ShiboSoftwareDev Date: Sun, 2 Aug 2026 11:26:00 +0200 Subject: [PATCH 2/4] ci: generate physical lane fix snapshot --- .github/workflows/bun-test.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bun-test.yml b/.github/workflows/bun-test.yml index ff846d8..777ea2f 100644 --- a/.github/workflows/bun-test.yml +++ b/.github/workflows/bun-test.yml @@ -29,12 +29,14 @@ jobs: run: bun install - name: Run tests - run: bun test + run: BUN_UPDATE_SNAPSHOTS=1 bun test - name: Upload snapshot artifacts if: always() uses: actions/upload-artifact@v4 with: name: test-snapshots - path: tests/**/__snapshots__/*.diff.png + path: | + tests/**/__snapshots__/*.diff.png + tests/solver/__snapshots__/duplicate-congested-port-physical-placement-repro.snap.svg if-no-files-found: ignore From 299a5240fe1a00d989e058fabc046b36d3f844da Mon Sep 17 00:00:00 2001 From: ShiboSoftwareDev Date: Sun, 2 Aug 2026 11:27:35 +0200 Subject: [PATCH 3/4] test: update hosted physical lane snapshot --- .github/workflows/bun-test.yml | 6 ++---- ...plicate-congested-port-physical-placement-repro.snap.svg | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bun-test.yml b/.github/workflows/bun-test.yml index 777ea2f..ff846d8 100644 --- a/.github/workflows/bun-test.yml +++ b/.github/workflows/bun-test.yml @@ -29,14 +29,12 @@ jobs: run: bun install - name: Run tests - run: BUN_UPDATE_SNAPSHOTS=1 bun test + run: bun test - name: Upload snapshot artifacts if: always() uses: actions/upload-artifact@v4 with: name: test-snapshots - path: | - tests/**/__snapshots__/*.diff.png - tests/solver/__snapshots__/duplicate-congested-port-physical-placement-repro.snap.svg + path: tests/**/__snapshots__/*.diff.png if-no-files-found: ignore diff --git a/tests/solver/__snapshots__/duplicate-congested-port-physical-placement-repro.snap.svg b/tests/solver/__snapshots__/duplicate-congested-port-physical-placement-repro.snap.svg index abe98e5..24cf8e4 100644 --- a/tests/solver/__snapshots__/duplicate-congested-port-physical-placement-repro.snap.svg +++ b/tests/solver/__snapshots__/duplicate-congested-port-physical-placement-repro.snap.svg @@ -1,4 +1,4 @@ -Actual lane spacing: 0.025 mm / 0.200 mm requiredRed = 0.1 mm trace Orange = trace + clearance Teal = shared boundary