Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
506 changes: 505 additions & 1 deletion crates/konnect-core/src/tools/cli.rs

Large diffs are not rendered by default.

97 changes: 97 additions & 0 deletions crates/konnect-core/tests/fixtures/drc_ownership_j1.README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# DRC ownership fixture (issue #413)

`drc_ownership_j1.kicad_pcb` and `drc_ownership_j1.drc.json` are the board and
report pair used to prove that a DRC report item names what owns it.

## Provenance — read this before trusting a byte of it

The pair is **partly KiCad-authored and partly hand-derived**, and the split
matters, so it is spelled out exactly.

### KiCad-authored, verbatim

Everything except the additions listed below is byte-identical to the board and
report `ncolomer` pasted inline in a comment on
[mixelpixx/Konnect#413](https://github.com/mixelpixx/Konnect/issues/413) (no
file was attached; the bytes are in the comment's `j1-repro.kicad_pcb` and
`raw_kicad_cli_drc.json` code blocks), produced on Konnect 0.10.0 / KiCad
10.0.5 / macOS 26.6.2 arm64 with:

```text
kicad-cli pcb drc --format json --severity-all --output raw_kicad_cli_drc.json j1-repro.kicad_pcb
```

The reporter states that the `(footprint …)` block was copied byte-for-byte
from a real board (only two absolute `model` paths redacted), so the J1
footprint, its four `Edge.Cuts` `fp_circle` nodes, its four pads, and every
UUID in them are KiCad's own. That is the load-bearing evidence for this
issue: it shows KiCad **does** emit the nested footprint-graphic UUID
(`7b970478-1e4a-48b6-b01a-35348027ca5e` and its three siblings), so the
`copper_edge_clearance` items can be resolved by exact UUID with no guessing.

The report's `source` field still reads `j1-repro.kicad_pcb` — the reporter's
filename — because the surrounding bytes were left untouched. `date` and
`kicad_version` are likewise the reporter's.

### Hand-derived additions

`kicad-cli` was **not** available on the machine that assembled this fixture,
so the additions below were written by hand, not generated by KiCad. They exist
because the acceptance evidence for #413 also requires a board-owned outline, an
unrelated board graphic, and the two unresolved paths, none of which the
reporter's minimal board contains.

Added to the board, as top-level children of `(kicad_pcb …)`:

- four `Edge.Cuts` `gr_line` segments forming a `(120, 56.5)`–`(160, 100)`
rectangle, UUIDs `e0000000-0000-4000-8000-00000000000{1,2,3,4}` — the board's
own outline, so the fixture has a `owner.kind: "board"` `Edge.Cuts` item
standing beside J1's footprint-owned ones;
- one `F.SilkS` `gr_line` from `(125, 60)` to `(135, 60)`, UUID
`50000000-0000-4000-8000-000000000001` — the unrelated board graphic.

Added to the report, as the last two entries of `violations`:

- a `silk_edge_clearance` warning naming the outline segment
`e0000000-…-000000000004` and the silkscreen segment
`50000000-…-000000000001`, i.e. two board-owned items;
- a `copper_edge_clearance` error whose first item carries **no** `uuid` at all
and whose second carries `ffffffff-ffff-4fff-8fff-ffffffffffff`, a UUID that
appears nowhere in the board. These two items exist only to exercise
`ownership_status: "uuid_missing"` and `ownership_status: "not_found"`.

The obviously synthetic UUID prefixes (`e0000000`, `50000000`, `ffffffff`) are
deliberate: every hand-written item is identifiable at a glance, and no
hand-written UUID can be mistaken for one KiCad wrote.

KiCad has never re-serialized this board, and no `kicad-cli` run produced the
two added violations. Treat the additions as a hand-written approximation of
the KiCad format — good enough for the UUID index, not evidence of what KiCad
emits.

## What the pair covers

| acceptance case (#413) | fixture item |
| ------------------------------------- | --------------------------------------------------------- |
| board's top-level `Edge.Cuts` outline | `gr_line` `e0000000-…-000000000004`, `owner.kind: board` |
| `Edge.Cuts` circle nested in J1 | `fp_circle` `7b970478-…`, `owner.kind: footprint`, ref J1 |
| a pad belonging to J1 | `pad` `5bc25fc3-…`, `owner.kind: footprint`, ref J1 |
| an unrelated board graphic | `gr_line` `50000000-…-000000000001` on `F.SilkS` |
| a report item with no UUID | first item of the last violation, `uuid_missing` |
| a report item with an unknown UUID | `ffffffff-ffff-4fff-8fff-ffffffffffff`, `not_found` |

Footprint ownership does not make a finding false. J1's `Edge.Cuts` circles are
still fabrication geometry — real cutouts at footprint-relative positions.
Ownership tells a caller which remedy applies: moving J1 moves the pad and the
cutout together and cannot change their mutual clearance, so the footprint
definition or the rule is what needs review.

## Tests using this fixture

- `crates/konnect-core/src/tools/cli.rs`, module `drc_ownership_tests` — parses
the committed pair and asserts the ownership of every item. No `kicad-cli`.
- `crates/konnect-core/src/tools/cli.rs`,
`run_drc_enriches_items_from_the_board_it_ran_on` — `#[ignore]`d, needs a real
`kicad-cli` on PATH. Copies the board to a temp directory, runs the real
`pcb drc`, and asserts ownership on whatever KiCad reports that run. It does
not compare against the committed JSON.
190 changes: 190 additions & 0 deletions crates/konnect-core/tests/fixtures/drc_ownership_j1.drc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
{
"$schema": "https://schemas.kicad.org/drc.v1.json",
"coordinate_units": "mm",
"date": "2026-09-04T09:36:36",
"ignored_checks": [
{
"description": "Footprint has no courtyard defined",
"key": "missing_courtyard"
},
{
"description": "Track endpoint not centered on via",
"key": "track_not_centered_on_via"
},
{
"description": "Tuning profile track geometries",
"key": "tuning_profile_track_geometries"
},
{
"description": "Footprint doesn't match symbol's footprint filters",
"key": "footprint_filters_mismatch"
},
{
"description": "Footprint component type doesn't match footprint pads",
"key": "footprint_type_mismatch"
}
],
"included_severities": [
"error",
"warning",
"exclusion"
],
"kicad_version": "10.0.5",
"schematic_parity": [],
"source": "j1-repro.kicad_pcb",
"unconnected_items": [],
"violations": [
{
"description": "Board edge clearance violation (board setup constraints edge clearance 0.5000 mm; actual 0.1000 mm)",
"items": [
{
"description": "Circle of J1 on Edge.Cuts",
"pos": {
"x": 136.19,
"y": 93.375
},
"uuid": "7b970478-1e4a-48b6-b01a-35348027ca5e"
},
{
"description": "Pad 1 [GND] of J1 on F.Cu",
"pos": {
"x": 136.19,
"y": 94.865
},
"uuid": "5bc25fc3-1886-4e08-a602-7e08cc66255e"
}
],
"severity": "error",
"type": "copper_edge_clearance"
},
{
"description": "Board edge clearance violation (board setup constraints edge clearance 0.5000 mm; actual 0.1000 mm)",
"items": [
{
"description": "Circle of J1 on Edge.Cuts",
"pos": {
"x": 138.73,
"y": 93.375
},
"uuid": "5480471a-80a9-4087-b1bb-5820a43bc37e"
},
{
"description": "Pad 2 [VCC] of J1 on F.Cu",
"pos": {
"x": 138.73,
"y": 91.885
},
"uuid": "909332de-07b2-478e-aef4-f0eacb8aa7ed"
}
],
"severity": "error",
"type": "copper_edge_clearance"
},
{
"description": "Board edge clearance violation (board setup constraints edge clearance 0.5000 mm; actual 0.1000 mm)",
"items": [
{
"description": "Circle of J1 on Edge.Cuts",
"pos": {
"x": 141.27,
"y": 93.375
},
"uuid": "d974e677-146d-4d20-ba87-97bbf3244250"
},
{
"description": "Pad 3 [SCL] of J1 on F.Cu",
"pos": {
"x": 141.27,
"y": 94.865
},
"uuid": "c478f8e6-457c-4d11-a0a8-6ad9316ac5be"
}
],
"severity": "error",
"type": "copper_edge_clearance"
},
{
"description": "Board edge clearance violation (board setup constraints edge clearance 0.5000 mm; actual 0.1000 mm)",
"items": [
{
"description": "Circle of J1 on Edge.Cuts",
"pos": {
"x": 143.81,
"y": 93.375
},
"uuid": "e052f2ec-907f-4c92-b5dc-ba51e6db24cb"
},
{
"description": "Pad 4 [SDA] of J1 on F.Cu",
"pos": {
"x": 143.81,
"y": 91.885
},
"uuid": "ee491ce7-d8ad-4347-b3d6-05f22e4ac0fe"
}
],
"severity": "error",
"type": "copper_edge_clearance"
},
{
"description": "Footprint 'PinSocket_1x04_P2.54mm_Vertical_SMD_low_profile_Pin1Left' not found in library 'Connector_PinSocket_2.54mm'",
"items": [
{
"description": "Footprint J1",
"pos": {
"x": 140.0,
"y": 93.375
},
"uuid": "b432574a-bdcd-4387-8d5e-65f34938c3a0"
}
],
"severity": "warning",
"type": "lib_footprint_issues"
},
{
"description": "Silkscreen clipped by board edge",
"items": [
{
"description": "Segment on Edge.Cuts",
"pos": {
"x": 120.0,
"y": 100.0
},
"uuid": "e0000000-0000-4000-8000-000000000004"
},
{
"description": "Segment on F.Silkscreen",
"pos": {
"x": 125.0,
"y": 60.0
},
"uuid": "50000000-0000-4000-8000-000000000001"
}
],
"severity": "warning",
"type": "silk_edge_clearance"
},
{
"description": "Board edge clearance violation (board setup constraints edge clearance 0.5000 mm; actual 0.1000 mm)",
"items": [
{
"description": "Segment on Edge.Cuts",
"pos": {
"x": 160.0,
"y": 56.5
}
},
{
"description": "Track [SDA] on F.Cu",
"pos": {
"x": 159.9,
"y": 57.0
},
"uuid": "ffffffff-ffff-4fff-8fff-ffffffffffff"
}
],
"severity": "error",
"type": "copper_edge_clearance"
}
]
}
Loading
Loading