chore: add dev rig — CI, pre-commit hooks, release-plz#4
Conversation
Add project development infrastructure: - CLAUDE.md with build commands, architecture overview, and conventions - Pre-commit hook (cargo fmt --check, clippy -D warnings) in .githooks/ - GitHub Actions CI workflow (fmt, clippy, test) on PRs and main - release-plz config and workflow for automated versioning and releases - rust-toolchain.toml pinning stable with rustfmt and clippy
- Run cargo fmt across codebase to fix pre-existing formatting issues - Add concurrency group to CI workflow to cancel stale runs - Add cargo test to pre-commit hook for parity with CI - Fix language support listing (Java is in progress, not shipped) - Fix docs: typo (doc: → docs:) per conventional commits spec - Add .claude/worktrees/ to .gitignore
📝 WalkthroughWalkthroughAdds local pre-commit checks and GitHub Actions workflows for CI and releases, pins the Rust toolchain, updates project docs/configs, and applies non-functional formatting refactors across multiple Rust source files. (No public API or behavioral changes.) Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Summary
This PR establishes development infrastructure for the Zift project, including CI pipeline, pre-commit hooks, and automated release workflows. The changes are well-structured and align with conventional commit practices.
Critical Issue
Permission inconsistency in release-plz workflow: The release-plz-release job specifies pull-requests: read which conflicts with the workflow-level pull-requests: write permission. This will cause the release action to fail when attempting to update pull requests. The job-level permission takes precedence and must be corrected to pull-requests: write.
Assessment
Once the permission issue is resolved, this PR will provide a solid foundation for automated testing, formatting enforcement, and semantic versioning. The infrastructure choices (GitHub Actions, release-plz, pre-commit hooks) are appropriate for a Rust project of this type.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
CLAUDE.md (1)
19-21: Document the CI-exact formatting check command for clarity.Line 19 says
cargo fmt(writes changes), while CI enforcescargo fmt -- --check. Adding the check command here helps contributors preflight exactly what CI runs.Suggested patch
cargo test -cargo fmt # required before committing +cargo fmt # format locally +cargo fmt -- --check cargo clippy -- -D warnings🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@CLAUDE.md` around lines 19 - 21, Update the CLAUDE.md formatting instructions to match the CI command: replace or augment the plain "cargo fmt" line with the exact check invocation "cargo fmt -- --check" (or add it alongside "cargo fmt") so contributors run the same check CI enforces; keep the existing "cargo clippy -- -D warnings" line as-is. Ensure the guidance mentions this is the CI-exact preflight command and mirrors the current diff lines referencing "cargo fmt" and "cargo clippy -- -D warnings".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/release-plz.yml:
- Around line 11-52: Add a workflow-level concurrency block to serialize all
release jobs (so release-plz-release and release-plz-pr cannot run concurrently)
by adding a top-level concurrency key with a stable group string (e.g., group:
release-plz-${{ github.ref }} or release-plz-${{ github.workflow }}) and set
cancel-in-progress appropriately (false to let running jobs finish) so only one
release workflow for the same group runs at a time; update the workflow YAML to
include this concurrency block above the jobs section.
In `@src/scanner/matcher.rs`:
- Around line 71-76: The bounds error message in the ZiftError::General
construction inside the scanner/matcher logic reports the maximum as
compiled.capture_names.len(), which is off-by-one; update the message to show
the highest valid index (compiled.capture_names.len().saturating_sub(1) or
formatted as `{}` using `len - 1`) so it reads "max <highest_valid_index>" and
keep the same context including compiled.rule.id and capture.index to locate the
code.
---
Nitpick comments:
In `@CLAUDE.md`:
- Around line 19-21: Update the CLAUDE.md formatting instructions to match the
CI command: replace or augment the plain "cargo fmt" line with the exact check
invocation "cargo fmt -- --check" (or add it alongside "cargo fmt") so
contributors run the same check CI enforces; keep the existing "cargo clippy --
-D warnings" line as-is. Ensure the guidance mentions this is the CI-exact
preflight command and mirrors the current diff lines referencing "cargo fmt" and
"cargo clippy -- -D warnings".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1cb95ced-0bc1-4084-b998-2f4d546d009f
📒 Files selected for processing (22)
.githooks/pre-commit.github/workflows/ci.yml.github/workflows/release-plz.yml.gitignoreCLAUDE.mdrelease-plz.tomlrust-toolchain.tomlsrc/cli.rssrc/commands/rules.rssrc/commands/scan.rssrc/config.rssrc/output/json.rssrc/output/text.rssrc/rego/grouping.rssrc/rego/templates.rssrc/rego/validator.rssrc/rules/embedded.rssrc/rules/mod.rssrc/scanner/discovery.rssrc/scanner/imports.rssrc/scanner/matcher.rssrc/types.rs
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/scanner/matcher.rs (1)
67-77:⚠️ Potential issue | 🟡 MinorUse
saturating_sub(1)in the error message to guard against potentialusizeunderflow.While the
capture_namesvector is guaranteed to be non-empty at runtime (thecompile_queryfunction requires a@matchcapture to exist), the subtraction at line 75 can technically underflow. Usecompiled.capture_names.len().saturating_sub(1)to ensure safe error reporting.Proposed fix
.ok_or_else(|| { ZiftError::General(format!( "rule '{}': capture index {} out of range (max {})", compiled.rule.id, capture.index, - compiled.capture_names.len() - 1, + compiled.capture_names.len().saturating_sub(1), )) })?;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/scanner/matcher.rs` around lines 67 - 77, The error message building in the block that accesses compiled.capture_names for capture.index can underflow when subtracting 1 from compiled.capture_names.len(); update the error string construction (the ZiftError::General creation used when .get(...) returns None) to use compiled.capture_names.len().saturating_sub(1) instead of compiled.capture_names.len() - 1 to prevent usize underflow while keeping the same diagnostic text; locate the code around the capture_names access in function/method handling compiled and capture.index and replace the subtraction with saturating_sub(1).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@src/scanner/matcher.rs`:
- Around line 67-77: The error message building in the block that accesses
compiled.capture_names for capture.index can underflow when subtracting 1 from
compiled.capture_names.len(); update the error string construction (the
ZiftError::General creation used when .get(...) returns None) to use
compiled.capture_names.len().saturating_sub(1) instead of
compiled.capture_names.len() - 1 to prevent usize underflow while keeping the
same diagnostic text; locate the code around the capture_names access in
function/method handling compiled and capture.index and replace the subtraction
with saturating_sub(1).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 02783fb9-8af7-428d-b168-2e9e6981ec30
📒 Files selected for processing (2)
.github/workflows/release-plz.ymlsrc/scanner/matcher.rs
✅ Files skipped from review due to trivial changes (1)
- .github/workflows/release-plz.yml
Summary
Adds development infrastructure: CI pipeline, pre-commit hooks, automated releases, and project conventions.
Changes
.githooks/pre-commit) —cargo fmt --check,cargo clippy -D warnings,cargo test.github/workflows/ci.yml) — fmt, clippy, test on PRs and main pushes; concurrency group to cancel stale runsrelease-plz.toml+.github/workflows/release-plz.yml) — automated version bumps, changelogs, and GitHub releases via conventional commitsrust-toolchain.toml— pins stable with rustfmt and clippy componentscargo fmt— applied across existing codebase to pass CI checks.gitignore— added.claude/settings.local.jsonand.claude/worktrees/Testing
Summary by CodeRabbit
Chores
Documentation
Style