Skip to content

fix(library): separate generated power pins - #520

Merged
neusse merged 1 commit into
mixelpixx:mainfrom
neusse:neusse/fix-power-pin-layout
Sep 11, 2026
Merged

neusse merged 1 commit into
mixelpixx:mainfrom
neusse:neusse/fix-power-pin-layout

Conversation

@neusse

@neusse neusse commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

create_symbol passed raw multi-unit power_pins into the automatic rectangular builder. Pins with no supplied angle therefore landed at the same coordinate, so a generated VCC/GND power unit could short its own supply rails while the tool reported success.

This focused fix applies the existing layout_power_unit() helper when none of the power pins supplies an angle. Any explicit arrangement remains caller-controlled. After layout, duplicate resolved connection points are rejected with a structured power_pins error before the library is written. The response also derives power_pin_count from pins actually generated rather than echoing ignored request data.

Closes #458

Acceptance accounting

  • Multi-unit power pins with no supplied angles use the existing top/bottom power-unit layout.
  • Any explicitly positioned/angled power-pin arrangement is preserved, including multiple pins intentionally entering from the same side.
  • Different pin numbers that resolve to one connection point, including equivalent 0/360-degree inputs, fail before the symbol library is written; legal stacked representations of the same physical pin number remain supported.
  • Handler-level regressions inspect the generated dedicated power unit and cover default layout, explicit mixed arrangements, collision refusal, legal same-number stacking, and truthful output counts.
  • Existing single-unit drawn and triangular-split behavior remains covered.
  • No schema, tool-count, file-format, or dependency change.

Red/green and adversarial evidence

Before the fix:

cargo test -p konnect-core --lib multi_unit_power_pins_are_distributed_within_the_power_unit -- --nocapture
FAILED: VCC and GND both at (-2.54, 0.0)

cargo test -p konnect-core --lib power_pins_without_units_report_zero_written_pins -- --nocapture
FAILED: reported 2, expected 0

After the first fix, adversarial review exposed that unconditional layout reversed explicitly arranged pins. A second review exposed that duplicate raw angles are not sufficient evidence of a collision and that 0/360 degrees are equivalent. The final implementation preserves every arrangement containing an explicit angle, and validates the resolved connection points instead. A final spec pass showed that omitted-angle same-number stacks also have to share a layout slot. The final implementation now preserves that ordinary case as well, and the regression asserts the two resolved anchors remain identical.

Complete local gate on this head:

cargo fmt --all -- --check                                      pass
cargo clippy --workspace --locked --all-targets -- -D warnings  pass
cargo test --workspace --locked --lib --tests                   pass
cargo test --workspace --locked --doc                           pass

Environment-dependent checks requiring a live KiCad GUI remain intentionally ignored by the repository test suite. This change exercises the real public handler and parses the generated .kicad_sym; KiCad CLI has no standalone symbol-library validation command.

Branch, compatibility, and risk

  • Base: current upstream/main at 5afdcbec76b3a8e55f87da778411ee09a98ae45b.
  • Dependencies: none; one unique commit.
  • Compatibility: request and response schemas are unchanged. Correctly generated coordinates replace unsafe coincident defaults; explicit arrangements remain unchanged; invalid collisions now fail atomically.
  • Risk is confined to generated symbol power-pin placement, collision validation, and count reporting. Rollback is reverting the single commit.

@neusse
neusse requested a review from mixelpixx as a code owner September 11, 2026 00:36
@neusse neusse added bug Something isn't working P0 Correctness or data-safety: fix before the next release area:schematic Schematic capture and analysis status:waiting-on-review Next actor: maintainer labels Sep 11, 2026
@neusse
neusse force-pushed the neusse/fix-power-pin-layout branch 3 times, most recently from 069efe7 to 05a5381 Compare September 11, 2026 00:57
@neusse
neusse force-pushed the neusse/fix-power-pin-layout branch from 05a5381 to a7d0c83 Compare September 11, 2026 01:40
@neusse neusse added status:ready-to-merge Next actor: automation or maintainer — exact head reviewed and removed status:waiting-on-review Next actor: maintainer labels Sep 11, 2026
@neusse
neusse merged commit f58b222 into mixelpixx:main Sep 11, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:schematic Schematic capture and analysis bug Something isn't working P0 Correctness or data-safety: fix before the next release status:ready-to-merge Next actor: automation or maintainer — exact head reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create_symbol: power pins sharing an angle are all written at one coordinate, so the symbol shorts its own supply rails

1 participant