Skip to content

feat: enforce strict kernel name#290

Merged
drbh merged 3 commits into
mainfrom
strict-kernel-dir-name
Feb 17, 2026
Merged

feat: enforce strict kernel name#290
drbh merged 3 commits into
mainfrom
strict-kernel-dir-name

Conversation

@drbh
Copy link
Copy Markdown
Collaborator

@drbh drbh commented Feb 17, 2026

This PR enforces that kernel names:

  • Start with a lowercase letter (a-z)
  • Contain only lowercase letters, digits, and dashes
  • End with a lowercase letter or digit
  • Are at least 2 characters long

Comment thread build2cmake/src/main.rs Outdated
Comment on lines +215 to +232
fn validate_name(name: &str) -> Result<()> {
// Pattern requires at least 2 characters: start letter + end letter/digit
let pattern = Regex::new(r"^[a-z][-a-z0-9]*[a-z0-9]$").expect("Invalid regex pattern");

if !pattern.is_match(name) {
bail!(
"Invalid kernel name `{name}`. Name must:\n\
- Start with a lowercase letter (a-z)\n\
- Contain only lowercase letters, digits, and dashes\n\
- End with a lowercase letter or digit\n\
- Be at least 2 characters long\n\
Examples: `my-kernel`, `relu2d`, `flash-attention`"
);
}

Ok(())
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Really nice! I like strong typing, maybe we could have a KernelName type where the constructor/deserializer does the validation? In that way we can guarantee that it's validated everywhere.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

great idea, will update shortly

Copy link
Copy Markdown
Member

@danieldk danieldk left a comment

Choose a reason for hiding this comment

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

Really nice!!!

@drbh drbh merged commit 45127e6 into main Feb 17, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants