ci(rust): add build/test/clippy gate; make crates clippy-clean#300
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
The only Rust CI was CodeQL in build-mode `none` (buildless), so nothing
ever compiled or tested robot-repo-automaton / shared-context / dashboard
— which is how the non-compiling content-match path reached `main` before
it was fixed in the prior PR. Add `.github/workflows/rust.yml`: a per-crate
matrix running `cargo build --all-targets`, `cargo test`, and
`cargo clippy --all-targets -- -D warnings` (blocking), with
`cargo fmt --check` informational (there is pre-existing formatting drift —
~180 hunks — that is intentionally not gated yet).
To make the clippy gate pass, fix the existing findings:
- fixer.rs: drop a no-op `.replace("hyperpolymath", "hyperpolymath")`.
- registry_guard.rs: use `split_once('/')` instead of a manual `splitn(2)`.
- exclusion_registry.rs: rename the inherent `from_str` -> `parse` (it is
not a `FromStr` impl; matches `Catalog::parse`) and use `if let Ok(..)`
instead of `.ok()` + `if let Some(..)`.
- hypatia.rs / main.rs: accept `&Path` instead of `&PathBuf`.
- Cargo.toml (robot-repo-automaton + shared-context): drop the ignored
`+spec-1.1.0` build metadata from the `toml` version requirement
(resolution-neutral; silences the cargo warning).
- benches: import `std::hint::black_box` (criterion's re-export is deprecated).
All three crates are clippy `-D warnings` clean; 101 + 84 tests pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RozeeLxpJsd3WWFngaZWz3
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.
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 testedrobot-repo-automaton/shared-context/dashboard. That's exactly how the non-compiling content-match path reachedmainbefore #299 fixed it. This closes that gap.The gate —
.github/workflows/rust.ymlPer-crate matrix (modeled on
e2e.yml: SHA-pinned checkout,permissions: contents: read, SPDX header):cargo build --all-targetscargo testcargo 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 dedicatedcargo fmtpass can flip it to blocking later.Clippy fixes (to make the gate green)
fixer.rs.replace("hyperpolymath", "hyperpolymath")registry_guard.rssplitn(2, '/')split_once('/')exclusion_registry.rsfrom_strshadowsFromStrfrom_str→parse(matchesCatalog::parse; 2 internal call sites)exclusion_registry.rs.ok()+if let Someif let Ok(..)hypatia.rs,main.rs&PathBufarg&PathCargo.toml×2toml = "1.1.2+spec-1.1.0"+specbuild-metadata (resolution-neutral; silences cargo warning)benches/fleet_benchmarks.rscriterion::black_boxstd::hint::black_box(one import swap covers all call sites)Verification
All three crates: clippy
-D warningsclean, build clean. Tests: 101 (robot-repo-automaton) + 84 (shared-context) pass. Locally simulated the full matrix (build + test + clippy) green per crate;rust.ymlparses as valid YAML.🤖 Generated with Claude Code
https://claude.ai/code/session_01RozeeLxpJsd3WWFngaZWz3
Generated by Claude Code