fix(robot-repo-automaton): make ContentMatch detection compile#299
Merged
Conversation
`detect_content_match` read file contents with `std::fs::read` (→ `Vec<u8>`) and passed `&content` to a string `regex::Regex::is_match`, which wants `&str`. The crate therefore never compiled and the whole `DetectionMethod::ContentMatch` detection path was dead code. Switch to `std::fs::read_to_string`. This fixes the type error and also implements the "skip non-UTF8" intent already stated in the comment just above (`read_to_string` returns `Err` on non-UTF8 bytes, which the `if let Ok` then skips), matching the sibling content scan in `hypatia.rs`. Add a regression test for the previously-uncompilable path: a positive regex match, a non-match, and a non-UTF8 file that must be skipped without panicking. `cargo build` is clean and all 101 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RozeeLxpJsd3WWFngaZWz3
hyperpolymath
added a commit
that referenced
this pull request
Jun 21, 2026
Items #2 (clippy sweep) and #1 (close the CI gap) from the follow-up list, as one PR — the lint fixes and the gate that enforces them belong together so CI is self-consistent. ## Why The only Rust CI was CodeQL in build-mode `none` (**buildless**) — nothing compiled or tested `robot-repo-automaton` / `shared-context` / `dashboard`. That's exactly how the non-compiling content-match path reached `main` before #299 fixed it. This closes that gap. ## The gate — `.github/workflows/rust.yml` Per-crate matrix (modeled on `e2e.yml`: SHA-pinned checkout, `permissions: contents: read`, SPDX header): - `cargo build --all-targets` - `cargo test` - `cargo clippy --all-targets -- -D warnings` *(blocking)* - `cargo fmt --check` *(informational, `continue-on-error`)* — there's ~180 hunks of **pre-existing** formatting drift; gating it would mean a giant reformat that buries this change, so it's surfaced but not yet enforced. A dedicated `cargo fmt` pass can flip it to blocking later. ## Clippy fixes (to make the gate green) | File | Finding | Fix | |---|---|---| | `fixer.rs` | `.replace("hyperpolymath", "hyperpolymath")` | no-op — removed | | `registry_guard.rs` | manual `splitn(2, '/')` | `split_once('/')` | | `exclusion_registry.rs` | `from_str` shadows `FromStr` | rename inherent `from_str` → `parse` (matches `Catalog::parse`; 2 internal call sites) | | `exclusion_registry.rs` | `.ok()` + `if let Some` | `if let Ok(..)` | | `hypatia.rs`, `main.rs` | `&PathBuf` arg | `&Path` | | `Cargo.toml` ×2 | `toml = "1.1.2+spec-1.1.0"` | drop ignored `+spec` build-metadata (resolution-neutral; silences cargo warning) | | `benches/fleet_benchmarks.rs` | deprecated `criterion::black_box` | import `std::hint::black_box` (one import swap covers all call sites) | ## Verification All three crates: **clippy `-D warnings` clean**, build clean. Tests: **101** (robot-repo-automaton) + **84** (shared-context) pass. Locally simulated the full matrix (build + test + clippy) green per crate; `rust.yml` parses as valid YAML. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01RozeeLxpJsd3WWFngaZWz3 --- _Generated by [Claude Code](https://claude.ai/code/session_01RozeeLxpJsd3WWFngaZWz3)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
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.
Fixes the pre-existing
robot-repo-automatonbuild error noted (out of scope) in #298.The bug
Detector::detect_content_matchread file contents withstd::fs::read(→Vec<u8>) and passed&contentto a stringregex::Regex::is_match, which wants&str:So the crate never compiled, and the entire
DetectionMethod::ContentMatchdetection path (dispatched atdetector.rs:149) was dead. CI didn't catch it because the rust CodeQL job runs build-modenone(buildless) — nothing in CI did a fullcargo build/testof this crate.The fix (one line)
Switch to
std::fs::read_to_string. This both fixes the type error and implements the "skip non-UTF8" intent already written in the comment directly above the read (read_to_stringreturnsErron non-UTF8 bytes, which the existingif let Okskips). It matches the sibling content scan inhypatia.rs:433-435, which already usesread_to_string+is_match(&content).I considered
regex::bytes::Regexinstead, but that changes detection semantics and contradicts the stated non-UTF8-skipping intent —read_to_stringis the smaller, intent-preserving fix.Regression test
Added
test_content_match_detects_and_skips_non_utf8(this path had zero coverage since it never compiled): asserts a positive regex match is detected, a non-match yields nothing, and a non-UTF8 file is skipped without panicking.Verification
OPENSSL_NO_VENDOR=1 cargo build— clean.cargo test— 101 passed, 0 failed (was 100; +1 new test).cargo fmt --check—detector.rsis clean. (Pre-existing rustfmt drift incatalog.rs/confidence.rsis untouched and out of scope, consistent with Deletion-guard PR-body marker, BotId::Oikosbot, rhodibot link fix #298.)Scope is
detector.rsonly (+58/−1, no file deletions).🤖 Generated with Claude Code
https://claude.ai/code/session_01RozeeLxpJsd3WWFngaZWz3
Generated by Claude Code