From d8fdeb3855011e580ddeab5b8069881e7bebc766 Mon Sep 17 00:00:00 2001 From: Avni Singhal <202451026@iiitvadodara.ac.in> Date: Wed, 2 Dec 2026 16:55:59 +0530 Subject: [PATCH] Re-run ERC and parity when .kicad_pro settings change --- docs/validate.md | 4 ++-- src/copper_pilot_cli/validate/default.yaml | 4 ++-- tests/test_validate.py | 23 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/docs/validate.md b/docs/validate.md index caf5789..34e9ae1 100644 --- a/docs/validate.md +++ b/docs/validate.md @@ -259,8 +259,8 @@ registered builtin; a `{items}` placeholder is present when `scope` is not | S0 Intake | `intake.tools` (kicad-cli 9/10), `intake.project` (netlist export; parts, nets, sheets, layers indexed), `intake.intent` (advisory: project index and plan present) | — | | S1 Architecture | — | `arch.review` (block diagram, power tree and budget, protection, clocks, boot path; intelligence effort) | | S2 Parts | `parts.bom_fields` (Value, Footprint, MPN, LCSC `C#####`, Datasheet; DNP and mechanical parts exempt), `pcb.models_3d` (ungated: every footprint `(model ...)` path resolves through `${KIPRJMOD}`, `${KICADn_3DMODEL_DIR}`, KiCad's configured path variables and the system 3D directory, P1 per missing file; parts with a body but no model, P2) | `parts.lcsc`, `parts.symbols`, `parts.footprints` (per part) | -| S3 Schematic | `sch.erc` | `sch.conventions` (per sheet), `sch.circuits` (per sheet; requires `arch.review`, `parts.symbols`, `sch.erc`), `sch.ratings` | -| S4 Netlist→layout | `pcb.parity` (schematic parity + unconnected items), `pcb.rules` (board rules and net classes ≥ fab limits) | — | +| S3 Schematic | `sch.erc` (re-runs when ERC severities, the pin map or exclusions in `.kicad_pro` change) | `sch.conventions` (per sheet), `sch.circuits` (per sheet; requires `arch.review`, `parts.symbols`, `sch.erc`), `sch.ratings` | +| S4 Netlist→layout | `pcb.parity` (schematic parity + unconnected items; re-runs when DRC severities or exclusions in `.kicad_pro` change), `pcb.rules` (board rules and net classes ≥ fab limits) | — | | S5 Placement | `pcb.connector_edge` (ungated: USB, RJ45, HDMI, DisplayPort, DVI, barrel/audio jacks and D-Sub sit on the board edge with the mating face pointing out; the face is taken from the pad centroid to the Fab/courtyard body centre; P1 when facing inward or along the edge or not on an edge, P2 when set back more than 2.5 mm; headers, board-to-board, vertical and ambiguous parts are not judged) | `pcb.placement` (requires `pcb.parity`, `parts.footprints`) | | S6 Routing SI/PI | — | `pcb.power_routing`, `pcb.signal_integrity` (per net class) | | S7 DFM/DFA | `pcb.drc` | `dfm.fab`, `dfa.assembly`, `pcb.silkscreen` (advisory) | diff --git a/src/copper_pilot_cli/validate/default.yaml b/src/copper_pilot_cli/validate/default.yaml index 840accf..1368a49 100644 --- a/src/copper_pilot_cli/validate/default.yaml +++ b/src/copper_pilot_cli/validate/default.yaml @@ -168,7 +168,7 @@ checks: kind: builtin builtin: erc requires: [intake.project] - inputs: [sch, libs] + inputs: [sch, libs, pro] - id: sch.conventions stage: S3 @@ -223,7 +223,7 @@ checks: kind: builtin builtin: parity requires: [intake.project] - inputs: [sch, pcb] + inputs: [sch, pcb, pro] - id: pcb.rules stage: S4 diff --git a/tests/test_validate.py b/tests/test_validate.py index 9042529..f496583 100644 --- a/tests/test_validate.py +++ b/tests/test_validate.py @@ -959,6 +959,29 @@ async def test_cache_reuse_and_invalidation(tmp_path) -> None: assert not any(result.cached for result in fourth.results) +@pytest.mark.asyncio +async def test_erc_and_parity_rerun_when_project_settings_change(tmp_path) -> None: + # KiCad keeps ERC and DRC/parity severities, the pin map and exclusions in + # .kicad_pro, so a settings-only change must not reuse ERC or parity results. + make_project(tmp_path) + kicad = FakeKicad() + turn = FakeTurn() + options = RunOptions(gate=GateMode.FULL) + await runner_for(tmp_path, options=options, kicad=kicad, turn=turn).run() + + project_file = tmp_path / "board" / "board.kicad_pro" + project = json.loads(project_file.read_text(encoding="utf-8")) + project["erc"] = {"rule_severities": {"pin_to_pin": "error"}} + project_file.write_text(json.dumps(project), encoding="utf-8") + kicad.calls.clear() + second = await runner_for(tmp_path, options=options, kicad=kicad, turn=turn).run() + cached = {r.check_id for r in second.results if r.cached} + assert "sch.erc" not in cached and "pcb.parity" not in cached + assert "erc" in kicad.calls and "drc+parity" in kicad.calls + # Checks that do not read project settings still hit the cache. + assert "sch.conventions" in cached and "arch.review" in cached + + @pytest.mark.asyncio async def test_error_results_are_never_cached(tmp_path) -> None: make_project(tmp_path)