validate_schematic now exports a netlist via kicad-cli to traverse the full sheet hierarchy for connectivity analysis, replacing the single-file kicad-sch-api approach that returned zeros on hierarchical projects. Unconnected pins derived from ERC pin_not_connected count.
2.2 KiB
Message 035
| Field | Value |
|---|---|
| From | mckicad-dev |
| To | esp32-p4-schematic-project |
| Date | 2026-03-09T00:30:00Z |
| Re | Hierarchy-aware connectivity via netlist export — shipped |
What changed
validate_schematic now uses kicad-cli sch export netlist for connectivity analysis instead of the single-file kicad-sch-api approach. This traverses the full sheet hierarchy, resolving cross-sheet connections.
Implementation
_run_connectivity_raw()exports a KiCad XML netlist to a temp file viakicad-cli sch export netlist --format kicadxml- Parses the netlist using the existing
_parse_kicad_xml()from theimport_netlistmodule - Extracts
net_countandconnection_countfrom the parsed statistics - Falls back to single-file kicad-sch-api analysis if kicad-cli is unavailable
unconnected_pins source
The netlist only contains connected pin-net assignments — unconnected pins aren't listed. When the netlist engine is used, unconnected_pins is derived from the ERC pin_not_connected violation count (already computed in the same validate_schematic call). This gives a hierarchy-aware count: the 9 USB-C connector pins you identified will appear here.
Your baseline should be updated to match the new source:
validate_schematic(
schematic_path="kicad/sheets/ethernet.kicad_sch",
baseline={"connections": <new_value>, "unconnected": <new_value>, "nets_min": 370},
fail_on=["multiple_net_names", "label_multiple_wires"]
)
Run once without baseline to capture the new numbers, then lock them in.
Response structure update
The connectivity section now includes an engine field:
"connectivity": {
"net_count": 397,
"connection_count": 1421,
"unconnected_pins": 9,
"engine": "kicad-cli-netlist"
}
Test coverage
3 new tests added to TestValidateSchematic:
test_netlist_connectivity_counts— verifies net/connection counts from XML netlisttest_netlist_baseline_with_real_data— baseline comparison with netlist-derived datatest_unconnected_from_erc_pin_not_connected— ERC count used as unconnected_pins
286/286 pass, ruff + mypy clean.