feat: add Cargo.toml manifest checker for Rust dependencies - #21
Merged
Conversation
Adds pkg/cargo, wires it into main.go's checker registry, and documents it in CLAUDE.md/README.md. Per #4: Cargo's default requirement operator is caret, so a bare version like `serde = "1.2.3"` means `^1.2.3`, not an exact pin - only an explicit `=1.2.3` counts. pins.ExactVersion is called with requireOperator=true for this, matching pyproject.toml's Poetry-table handling. git-pkgs/manifests' Cargo.toml parser doesn't populate Declarations the way npm/pypi/maven/github_actions do, so this checker builds its own scope+name location key from Dependencies instead, the same fallback pkg/golang uses for go.mod. Also adds 5 benchmark/cases.json cases (cargo-01..04 fresh + a cargo-05 existing-manifest case) following the HTTP-client/JSON/ logging/domain-4th-pick archetype used for the other ecosystems.
algomaster99
commented
Aug 24, 2026
Cut the design-notes comment on pkg/cargo/cargo.go down to its non-obvious points (caret-default gotcha, why pins are keyed by scope+name, unverified resolution coverage), and move the local-path/ workspace-dep detail inline next to the ExactVersion call it explains, instead of a standalone paragraph.
Adds the recorded hook/nohook runs for the five cargo cases, ignores target/ (Cargo's build cache, analogous to node_modules/), and extends the "why some ecosystems need this more than others" table: `cargo add` resolves the latest version like `go get`/`npm install` do, so there's usually nothing stale for the hook to catch. Cargo has one more wrinkle though — exactness (`=`) is opt-in rather than implicit, so a manifest scaffolded by hand can carry an unpinned, stale version the hook never sees; cargo-01-reqwest's hook run is a live example of this happening. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
algomaster99
commented
Aug 24, 2026
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.
Adds support for checking Rust
Cargo.tomlmanifests, enabling the hook to detect and block writes that pin crates to outdated versions.Summary
Implements a new
cargopackage that checksCargo.tomlfiles for exactly-pinned (=) dependencies that are older than the latest released version. This brings Rust/Cargo support to yul alongside the existing npm, PyPI, Maven, Go, and GitHub Actions checkers.Key Changes
New
pkg/cargopackage with manifest parsing and version checking:parseCargoPins()extracts exactly-pinned dependencies fromCargo.tomlusing git-pkgs/manifests, handling string-form (serde = "=1.0.0"), table-form ({ version = "=1.0.0" }), and special cases (local paths, workspace dependencies)CheckCargoToml()diffs before/after manifests and reports mismatches only for changed dependencies, reusing the sharedpins.Difflogic"1.2.3") as caret ranges (^1.2.3), not exact pins, per Cargo's default semantics — only=prefix counts as exactruntime/,development/,build/) since the parser doesn't expose per-declaration locationsIntegration into main hook:
cargo.CheckerintonewCheckers()inmain.goREADME.mdto documentCargo.tomlsupportComprehensive test coverage (
pkg/cargo/cargo_test.go):=prefix required)Benchmark cases added for empirical evaluation:
Implementation Notes
pkg/golangandpkg/pyprojectfor ecosystems where the manifest parser doesn't expose stable per-declaration locationspkg:cargodata, matching existing behavior for other ecosystemsrequireOperator=trueinpins.ExactVersion()to enforce the=prefix, documenting the Cargo-specific gotcha explicitlyhttps://claude.ai/code/session_014uMpiDuvuN7HV9fgPZaQu2