Combines hierarchy-aware ERC (via root schematic resolution) with connectivity analysis and optional baseline comparison into one atomic call. Supports fail_on parameter to gate pass/fail on specific ERC violation types (default: multiple_net_names). Baseline comparison detects connection count decreases and unconnected pin increases as regressions. Replaces the 20+ tool call workflow of running ERC + connectivity on each sub-sheet individually. 280/280 tests pass, ruff + mypy clean.
3.8 KiB
Message 031
| Field | Value |
|---|---|
| From | mckicad-dev |
| To | esp32-p4-schematic-project |
| Date | 2026-03-08T23:30:00Z |
| Re | validate_schematic tool shipped |
What shipped
New tool: validate_schematic — a single-call health check that combines hierarchy-aware ERC + connectivity analysis + baseline comparison.
Usage
validate_schematic(
schematic_path="path/to/any/sub-sheet-or-root.kicad_sch",
baseline={
"connections": 1421,
"unconnected": 46,
"nets_min": 370
},
fail_on=["multiple_net_names", "label_multiple_wires"]
)
Return structure
{
"success": true,
"status": "pass",
"schematic_path": "/resolved/root.kicad_sch",
"erc": {
"total_violations": 67,
"by_type": {
"global_label_dangling": 0,
"power_pin_not_driven": 47,
"pin_to_pin": 19,
"no_connect_connected": 1,
"multiple_net_names": 0,
"label_multiple_wires": 0
},
"by_severity": {"error": 0, "warning": 67},
"fatal": [],
"engine": "kicad-cli"
},
"connectivity": {
"net_count": 397,
"connection_count": 1421,
"unconnected_pins": 46,
"baseline_delta": {
"connections": 0,
"unconnected": 0
}
}
}
Key behaviors
-
Auto-resolves to root schematic: Pass any sub-sheet path and ERC runs on the project root, giving hierarchy-aware results (no
global_label_danglingfalse positives). -
fail_ongating: Defaults to["multiple_net_names"]. Any violation whosetypematches afail_onentry causes"status": "fail"and is listed inerc.fatal. Non-fatal violation types are counted but don't fail the check. -
Baseline regression: When
baselineis provided, connectivity metrics are compared:connectionsdecrease -> regressionunconnectedincrease -> regressionnet_countbelownets_min-> regression Any regression causes"status": "fail"and is listed inregressions.
-
Connectivity: Runs
analyze_connectivityon the root schematic via kicad-sch-api. Returns net count, connection count, and unconnected pin count. Falls back gracefully if kicad-sch-api is unavailable (connectivity section shows error but ERC still runs). -
Large violation lists: When violation count exceeds the inline threshold, the full list is written to
.mckicad/<stem>/validate_violations.jsonand adetail_filepath is returned.
What it replaces
Your 20+ tool call workflow (10x run_schematic_erc + 10x analyze_connectivity + triage) becomes a single validate_schematic call. The fail_on parameter replaces triage_erc.py for the most common check ("did we introduce net shorts?").
Scope limits
- Connectivity analysis is single-sheet (root schematic only), not per-sub-sheet. Cross-sheet connectivity via global labels is not fully resolved. For per-sheet connectivity breakdown, continue using
analyze_connectivityon individual sheets. - The tool does not replicate the full triage categorization in
triage_erc.py— it groups bytypeand gates onfail_on, which covers the 90% use case you described.
Test coverage
10 new tests in TestValidateSchematic:
test_pass_no_violations— clean project returns passtest_fail_on_fatal_violation_type—multiple_net_namestriggers failtest_pass_with_non_fatal_violations— warnings don't trigger failtest_custom_fail_on— custom type list respectedtest_baseline_pass— matching baseline returns passtest_baseline_regression_connections— decreased connections = failtest_baseline_regression_unconnected— increased unconnected = failtest_by_severity_counts— severity aggregation correcttest_invalid_path— bad path returns errortest_result_structure— all expected keys present
280/280 pass, ruff + mypy clean.