feat: add generic repository validation commands#2
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a set of generic repository validation subcommands to cntryl-tools, intended to replace downstream, repo-specific Python checks with shared Rust implementations configured via .cntryl/repository.toml.
Changes:
- Introduces new CLI subcommands:
validate-docs,validate-benchmarks,check-module-sizes, andtest-watchdog. - Implements repository policy loading via
.cntryl/repository.toml(using thetomlcrate) to keep project-specific rules out of the binary. - Documents the new commands and configuration in the README.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/repository_checks.rs | Adds implementations for doc/link validation, benchmark contract validation, module size checks, and an integration-test watchdog runner. |
| src/main.rs | Wires new repository-check commands into the Clap CLI. |
| README.md | Documents new commands and provides a sample .cntryl/repository.toml policy configuration. |
| Cargo.toml | Adds the toml dependency needed for repository policy parsing. |
| Cargo.lock | Locks new transitive dependencies for toml. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+104
to
+124
| for (target, anchor) in markdown_links(&text) { | ||
| if target.is_empty() || target.contains("://") || target.starts_with("mailto:") { | ||
| continue; | ||
| } | ||
| let target_path = path.parent().unwrap_or(&root).join(&target); | ||
| let target_path = target_path.canonicalize().unwrap_or(target_path); | ||
| if !target_path.is_file() | ||
| && !(target_path.is_dir() && target_path.join("README.md").is_file()) | ||
| { | ||
| errors.push(format!("{name}: broken local link {target}")); | ||
| } | ||
| if let Some(anchor) = anchor { | ||
| let target_name = relative(&root, &target_path); | ||
| if !headings | ||
| .get(&target_name) | ||
| .is_some_and(|ids| ids.contains(&slug(&anchor))) | ||
| { | ||
| errors.push(format!("{name}: broken anchor {target}#{anchor}")); | ||
| } | ||
| } | ||
| } |
Comment on lines
+385
to
+406
| fn production_lines(text: &str) -> usize { | ||
| let mut count = 0; | ||
| let mut skip = false; | ||
| let mut depth = 0i32; | ||
| for line in text.lines() { | ||
| let trimmed = line.trim(); | ||
| if !skip && trimmed.contains("#[cfg(test)]") { | ||
| skip = true; | ||
| continue; | ||
| } | ||
| if skip { | ||
| depth += line.matches('{').count() as i32; | ||
| depth -= line.matches('}').count() as i32; | ||
| if depth <= 0 && (line.contains('{') || line.contains(';')) { | ||
| skip = false; | ||
| } | ||
| } else if !trimmed.is_empty() && !trimmed.starts_with("//") { | ||
| count += 1; | ||
| } | ||
| } | ||
| count | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cntryl-toolscommandsvalidate-docs,validate-benchmarks,check-module-sizes, andtest-watchdog.cntryl/repository.tomlVerification
cargo fmt --checkcargo testcargo clippy --all-targets -- -D warningscargo run -- validate-docs --root /Users/jrepanich/Code/cntryl/midgecargo run -- validate-benchmarks --root /Users/jrepanich/Code/cntryl/midgecargo run -- check-module-sizes --root /Users/jrepanich/Code/cntryl/midgeConsumers
Closes #1.