Skip to content

feat(pcb): name the netclass patterns that fit no net - #526

Open
cvaldess wants to merge 1 commit into
mixelpixx:mainfrom
cvaldess:feat/netclass-unmatched-patterns
Open

cvaldess wants to merge 1 commit into
mixelpixx:mainfrom
cvaldess:feat/netclass-unmatched-patterns

Conversation

@cvaldess

Copy link
Copy Markdown
Contributor

Summary

get_netclasses names the netclass patterns that fit no net on the board. Until now only patterns naming a missing class were reported (orphan_patterns); a pattern whose class exists but matches nothing was invisible, and subtracting matched_nets from patterns by hand does not say which pattern is the idle one.

Issue: Closes #525

Approach

The handler already resolves every pattern against the board's nets to build matched_nets. This PR runs the same wildcard_matches the other way: a pattern whose class exists and which fits zero nets goes into a new additive field unmatched_patterns, in the shape of the project file ({ "pattern", "netclass" }) — the same shape as orphan_patterns, so a caller handles both alike. A pattern is listed in one of the two, never both.

The board read already distinguished "parsed" from "could not read/parse" for nets_source; that outcome now also drives the new field. Without a readable board the field is null, not []: an empty list would claim every pattern matched, which is the response-derived-from-the-request shape this tool exists to avoid.

Alternatives considered: a per-class unmatched_patterns beside patterns/matched_nets. Not done — one top-level list mirrors orphan_patterns and keeps the change to one field; the netclass key on each entry makes it just as actionable.

Branch and dependencies

Base branch: upstream/main (3dbfd9a)
Depends on: nothing
Series order: none — independent change
Unique commits owned by this PR: 1

Compatibility and safety

Additive response field only. Nothing renamed or removed; orphan_patterns, patterns, matched_nets, nets_on_board, nets_source keep their meaning. Read-only tool: no file or IPC mutation. Documented in docs/API_MIGRATIONS.md under Unreleased … (minor release), following the existing entries.

Validation

All four gate commands run locally on this exact head (Windows, stable-x86_64-pc-windows-msvc, KiCad 10.0.6 installed so the board-fixture scan runs):

  • cargo fmt --all -- --check — exit 0
  • cargo test --workspace --locked --lib --tests — 29 suites, 1765 passed, 0 failed, 29 ignored (two new tests: a_pattern_fitting_no_net_is_reported_as_unmatched, unmatched_patterns_is_unknown_without_a_readable_board)
  • cargo test --workspace --locked --doc — 8 passed, 0 failed
  • cargo clippy --workspace --locked --all-targets -- -D warnings — exit 0
  • Real-KiCad check: release build exercised over MCP stdio against six real KiCad 10 boards (48–190 nets each).

Measured before/after on a real two-layer board (61 nets) whose project file carries a pattern for a since-renamed net and a glob that never fitted:

before (v0.11.1) after
HV patterns=8 matched=7 patterns=8 matched=7
HV_LOW patterns=2 matched=1 patterns=2 matched=1
orphan_patterns [{"netclass":"Vanished","pattern":"400V"}] same
unmatched_patterns (absent) [{"netclass":"HV","pattern":"Net-(R9-Pad2)"}, {"netclass":"HV_LOW","pattern":"HV_*"}]

On the five unmodified boards (twelve patterns between them) the new field is [], consistent with each class's patterns/matched_nets counts.

Not run: the live IPC tests (the tool is file-only and needs no running KiCad).

Review checklist

  • The diff is focused and contains no generated output, personal data, or unrelated cleanup.
  • The branch includes current upstream/main and has no merge conflicts; CI on this head pending at open time.
  • The branch was based on latest upstream/main, not a release tag.
  • The PR shows only its unique commits and diff; no dependencies.
  • Every review conversation is resolved.
  • New names follow docs/NAMING_CONVENTIONS.md (unmatched_patterns beside orphan_patterns).
  • New behavior and failure paths have regression coverage.
  • File mutations: none (read-only tool).
  • IPC mutations: none.
  • No tools added or removed: counts untouched.

get_netclasses reported orphan_patterns — a pattern naming a class that
does not exist — but a pattern whose class exists and which fits no net on
the board was invisible: the class governs nothing, KiCad's dialog shows the
pattern beside the working ones, and the only way to notice was to subtract
matched_nets from patterns by hand. On a class with several patterns that
subtraction does not even say which one is idle. It is the usual trace of a
renamed net, a pattern carried over from another board, or a glob that
never fitted the net's real name.

One additive response field, unmatched_patterns, lists those patterns in
the shape of the project file, the same shape as orphan_patterns. A pattern
is listed in one of the two, never both. When the board cannot be read or
parsed the field is null rather than an empty list, because an empty list
would claim every pattern matched; nets_source carries the reason as
before.

Measured on a real two-layer KiCad 10 board (61 nets) whose project file
carries a pattern for a since-renamed net and a glob that never fitted:
before, HV shows patterns=8 matched=7 and HV_LOW patterns=2 matched=1;
after, unmatched_patterns names Net-(R9-Pad2) and HV_* and the orphan is
still listed once, under orphan_patterns. On five unmodified boards with
twelve patterns between them the field is empty.
@cvaldess
cvaldess requested a review from mixelpixx as a code owner September 11, 2026 16:08
@neusse neusse added P2 Wanted, not urgent area:routing Traces, autorouting, Specctra/Freerouting status:waiting-on-author Next actor: the PR author — one checklist, 14-day target labels Sep 11, 2026
@neusse

neusse commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

The implementation remains useful and distinct from #222. The only current merge conflict is in docs/API_MIGRATIONS.md; the Rust implementation does not conflict with current main.

Please take the minimum path forward:

  1. Rebase this branch onto current mixelpixx/Konnect:main (8ed319a at this review).
  2. Resolve docs/API_MIGRATIONS.md by retaining both this PR's get_netclasses entry and fix(schematic): validate mutations before commit #527's atomic schematic-validation entry.
  3. Do not otherwise rewrite the implementation unless the rebase exposes a real problem.
  4. Push the refreshed head and let all required CI checks rerun.
  5. Reply here when the new head is ready for review.

The issue and PR are labeled for their current state. Once the refreshed head is conflict-free and green, we can perform the final exact-head review.

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

Labels

area:routing Traces, autorouting, Specctra/Freerouting P2 Wanted, not urgent status:waiting-on-author Next actor: the PR author — one checklist, 14-day target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_netclasses: a pattern whose class exists but fits no net is invisible

2 participants