fix(layout): assign automatic netclass priorities after explicit values - #1215
detail-app[bot] wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Stale comment
Not approved: this is a functional layout-sync change to
.kicad_pronetclass priority assignment, not a small fixup, so it needs human review. Cursor Bugbot and Cursor Security Agent both passed with no findings requiring attention; reviewers were not assigned.Sent by Cursor Approval Agent: Pull Request Router and Approver
d969b08 to
84f5c38
Compare
There was a problem hiding this comment.
Stale comment
Not approved: Cursor Bugbot was present but completed as skipped, so the required automated-review signal did not finish successfully. This is also a functional layout-sync change, not a small fixup, so it needs human review. Reviewers were not assigned.
Sent by Cursor Approval Agent: Pull Request Router and Approver
84f5c38 to
0f6921c
Compare
There was a problem hiding this comment.
Devin Review found 1 new potential issue.
2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| .chain( | ||
| netclasses | ||
| .iter() | ||
| .filter(|nc| nc.name != "Default") | ||
| .filter(|nc| { | ||
| class_index | ||
| .get(&nc.name) | ||
| .is_none_or(|&idx| classes[idx].get("priority").is_none()) | ||
| }) | ||
| .filter_map(|nc| nc.priority.map(i64::from)), | ||
| ) |
There was a problem hiding this comment.
🟡 Automatic classes outrank explicit priorities
When one new netclass requests a priority and another omits it, next_non_default_priority places the automatic class above the request. When both match a net, the unspecified class wins because the priority contract makes higher values stronger.
Prompt for agents
The initialization of next_non_default_priority now includes every explicit priority that will be written to a new or priority-less class. Since automatic assignment consumes max + 1 and higher values have higher netclass-resolution precedence, any automatic class outranks every explicitly prioritized new class. Adjust automatic allocation so it avoids reserved values without assigning stronger precedence than explicitly requested priorities. Preserve existing stored priorities, intentional explicit ties, deterministic ordering, and patch idempotency. Add a test with overlapping explicit and automatic classes that verifies the explicit higher-priority class remains stronger.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Akhil’s review follow-up: the cited board_config.zen comment contradicts the actual KiCad 10.0.5 resolver. KiCad sorts lower numeric priorities first and applies the sorted list in reverse, so later lower-numbered classes override higher-numbered ones: https://github.com/KiCad/kicad-source-mirror/blob/10.0.5/common/project/net_settings.cpp#L928-L955 . Thus the automatic max+1 classes have LOWER precedence than explicit classes, not higher. The added regression checks explicit 0 versus automatic 1 and 2. No allocator inversion is justified; that would introduce exactly the runtime behavior this comment warns about. The documentation/semantic discrepancy remains flagged for human product review and is intentionally unchanged in this PR.
There was a problem hiding this comment.
Not approved: this is a functional layout-sync change to .kicad_pro netclass priority assignment, not a small fixup, so it needs human review. Cursor Bugbot passed with no unresolved findings requiring attention; Cursor Security Agent was not present. Reviewers were not assigned.
Sent by Cursor Approval Agent: Pull Request Router and Approver


Reserve explicit netclass priorities before layout sync assigns automatic values, so class names do not affect the requested values. Preserve existing priorities and explicit ties because KiCad resolves ties by netclass name. Add a regression check for ordering, preserved ties, ignored requests on existing classes, and repeated sync.