fix(rules): match canonical Cargo.toml patterns case-insensitively
Problem Statement
Review rule matching currently depends on callers normalizing file paths before invoking the resolver. For example, the review agent and ocr rules check call the resolver with a lowercased path.
This creates an awkward rule-authoring behavior for filenames whose canonical spelling contains uppercase characters, such as Rust's Cargo.toml:
- The actual manifest filename is conventionally
Cargo.toml. - A system rule written as
**/cargo.tomllooks misspelled and can be flagged during review. - A system rule written as the canonical
**/Cargo.tomlmay fail if the resolver receives a lowercased path and performs a case-sensitive glob match. - The correctness of rule matching depends on each call site remembering to lowercase the path.
This is easy to miss on case-insensitive development environments, but it is confusing for maintainers and risky for case-sensitive filesystems such as Linux.
Proposed Solution
Make rule matching case-insensitive inside the resolver itself by normalizing both the incoming path and each expanded glob pattern before matching.
This allows built-in and user-defined rules to use canonical filenames where appropriate, for example:
"**/Cargo.toml": "cargo_toml.md"
The resolver should still match both:
crates/service/Cargo.tomlcrates/service/cargo.toml
Tests should cover canonical Cargo.toml and lowercased path matching so future rule additions do not rely on call-site-specific lowercasing behavior.
Alternatives Considered
- Keep using lowercased patterns such as
**/cargo.toml: this works with current lowercased call sites, but makes canonical filenames look incorrect and hides the resolver dependency on caller behavior. - Only change the system rule to
**/Cargo.toml: this is semantically correct, but can break matching when the resolver receives lowercased paths. - Require all callers to lowercase paths before resolving: this preserves current behavior, but keeps the normalization contract implicit and easy to violate.
Affected Area
Review Rules
Additional Context
This came up while adding built-in Rust and Cargo manifest review rules in #74. A review comment correctly pointed out that Rust's manifest file is named Cargo.toml, not cargo.toml. The underlying issue is that rule matching should allow canonical pattern spelling without depending on call-site path normalization.