Skip to content

Make KiCad symbol the source of truth for component metadata#671

Merged
akhilles merged 7 commits intomainfrom
less-zen
Mar 29, 2026
Merged

Make KiCad symbol the source of truth for component metadata#671
akhilles merged 7 commits intomainfrom
less-zen

Conversation

@akhilles
Copy link
Copy Markdown
Contributor

@akhilles akhilles commented Mar 29, 2026

Don't bother generating the duplicate metadata in the component .zen file.


Note

Medium Risk
Changes how Component() derives footprint/datasheet/part and default skip_bom, which can alter netlist/BOM outputs for existing packages if symbol properties are missing or differ from previous .zen metadata.

Overview
Makes KiCad .kicad_sym metadata the single source of truth for components. The component .zen generator now emits a minimal wrapper (symbol + pins + optional skip flags) and stops generating/consuming duplicated fields like mpn/manufacturer/part, datasheet, footprint, and pin_defs.

Updates build/runtime to inherit more from symbols. Component() now (a) resolves datasheets from the symbol Datasheet property, supporting local paths resolved relative to the symbol file and normalized to package://..., and (b) defaults skip_bom from the KiCad symbol in_bom flag (inverted) when not explicitly set; KiCad placeholder values (~/empty) are filtered consistently.

Adjusts import/search pipelines and stdlib/tests to match. pcb import patches the symbol Footprint property to the generated local footprint stem; pcb search/datasheet resolution can read either URL or local datasheet refs from symbols; stdlib generics/tests migrate pin mappings to use pin-number keys and snapshots are updated.

Written by Cursor Bugbot for commit 287252e. This will update automatically on new commits. Configure here.


Open with Devin

- Generated .zen files are now minimal wrappers (symbol, pins, pin_defs,
  optional skip_bom/skip_pos); no longer emit part, datasheet, or footprint.
- Component() inherits footprint, datasheet, and part from the symbol and
  package manifest at evaluation time.
- pcb import patches canonical MPN, manufacturer, and datasheet path into
  the KiCad symbol properties when generating components.
- Deduplicate KiCad placeholder checks into shared helpers in pcb-eda.
- Add regression test for local symbol datasheet inheritance.
@akhilles akhilles requested a review from LK March 29, 2026 01:46
devin-ai-integration[bot]

This comment was marked as resolved.

Component() now falls back to !symbol.in_bom when skip_bom is not
explicitly set. KiCad symbol parser defaults in_bom to true (matching
KiCad convention) when the property is omitted.
Imported KiCad symbols retain their original Footprint property (e.g.
'lib:fp' form). Since imported components are local files rather than
packages, the KiCad footprint fallback inference path cannot resolve
them, causing 'Footprint property is not inferable' errors at build
time.

Rewrite the symbol's Footprint property to the local footprint stem
after rendering, so Component() can infer the footprint file path.
Generated .zen files no longer emit pin_defs; duplicate pin signal names
(e.g. multiple NC/GND pads) naturally merge into a single io() declaration.
The Component(pin_defs=...) API remains available for manual use.
devin-ai-integration[bot]

This comment was marked as resolved.

Use symbol's native signal names directly in pins dict. The io() names
(P1, P2) remain unchanged.
Update parameter table: footprint, skip_bom, and datasheet now document
their symbol-derived defaults inline.
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

🐛 1 issue in files not directly in the diff

🐛 merge_symbols always overrides parent in_bom=no due to new default in_bom: true (crates/pcb-eda/src/kicad/symbol_library.rs:631-633)

The PR changes parse_symbol to initialize in_bom: true at crates/pcb-eda/src/kicad/symbol.rs:170, but the merge_symbols function at crates/pcb-eda/src/kicad/symbol_library.rs:631 only conditionally overrides the parent's value:

if child.in_bom {
    merged.in_bom = child.in_bom;
}

Before this PR, the default was false (from Default::default()), so a child symbol without an explicit (in_bom ...) declaration would have in_bom = false, the condition wouldn't fire, and the parent's value was preserved. Now, every child symbol without explicit (in_bom no) gets in_bom = true from the new default, the condition always fires, and the parent's in_bom = false is silently overridden to true. Since this PR adds the feature where Component() inherits skip_bom from !final_symbol.in_bom (crates/pcb-zen-core/src/lang/component.rs:1571), components using extends-resolved symbols whose parent has (in_bom no) will incorrectly get skip_bom = false instead of skip_bom = true.

View 9 additional findings in Devin Review.

Open in Devin Review

devin-ai-integration[bot]

This comment was marked as resolved.

@akhilles akhilles enabled auto-merge (rebase) March 29, 2026 02:40
@akhilles akhilles disabled auto-merge March 29, 2026 02:40
@akhilles akhilles enabled auto-merge (squash) March 29, 2026 02:40
@github-actions
Copy link
Copy Markdown

Build Performance

Board Base (median) Head (median) Change
demo/DM0001 188ms ±4 185ms ±5 -1.4%
demo/DM0002 164ms ±2 162ms ±2 -1.0%
demo/DM0003 182ms ±2 186ms ±6 +2.6%
arduino/Nano 119ms ±1 128ms ±3 1.07× ±0.03 slower
arduino/UNOQ 223ms ±8 225ms ±8 +0.8%

Measured with hyperfine. Times show median ±stddev.

@akhilles akhilles merged commit 4649ce9 into main Mar 29, 2026
12 checks passed
@akhilles akhilles deleted the less-zen branch March 29, 2026 02:42
@hexdae
Copy link
Copy Markdown
Contributor

hexdae commented Mar 29, 2026

@akhilles I wonder what the right way to handle symbol datasheet path should be. It would be great to encode a real PDF file, and footprints do support this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants