Skip to content

fix(layout): assign automatic netclass priorities after explicit values - #1215

Open
detail-app[bot] wants to merge 2 commits into
mainfrom
detail/bug-fix/fix-layout-guarantee-unique-netclass-priorities-in-5008c4
Open

detail-app[bot] wants to merge 2 commits into
mainfrom
detail/bug-fix/fix-layout-guarantee-unique-netclass-priorities-in-5008c4

Conversation

@detail-app

@detail-app detail-app Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

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.

@detail-app
detail-app Bot requested a review from LK September 6, 2026 02:27
@detail-app detail-app Bot assigned LK Sep 6, 2026
@detail-app detail-app Bot added the detail label Sep 6, 2026

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This report is out of date. Scroll down for Devin Review's latest report on this PR.

Devin Review found 1 potential issue.

Devin Review

Comment thread crates/pcb-layout/src/kicad_project_patch.rs Outdated

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale 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 and Cursor Security Agent both passed with no findings requiring attention; reviewers were not assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@akhilles
akhilles force-pushed the detail/bug-fix/fix-layout-guarantee-unique-netclass-priorities-in-5008c4 branch from d969b08 to 84f5c38 Compare September 7, 2026 15:21
cursor[bot]

This comment was marked as resolved.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@akhilles
akhilles force-pushed the detail/bug-fix/fix-layout-guarantee-unique-netclass-priorities-in-5008c4 branch from 84f5c38 to 0f6921c Compare September 7, 2026 16:08
@akhilles akhilles changed the title fix(layout): guarantee unique netclass priorities in .kicad_pro patching fix(layout): assign automatic netclass priorities after explicit values Sep 7, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Comment on lines +387 to +397
.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)),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants