Repository navigation
EAI-7199: Add CI guard pinning the first-party crate dependency graph - #422
Conversation
rocm-cli's workspace has layering invariants (rocmd must never depend on rocm; rocm-dash-core stays pure; rocm-dash-tui has no rocm-core edge) that were previously enforced by nothing. Add `cargo xtask check-crate-edges`, which pins the allowed first-party dependency edges via `cargo metadata` and fails CI on anything outside that allowlist, naming the offending edge and the rule it breaks. Wired into the existing `clippy` CI job right after the MANIFEST.md check. Dev-dependency edges are exempt since Cargo already permits those to cycle. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The guard does not detect stale allowlist entries, allowing removed dependencies to be reintroduced without review.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
What changed in this PR
Adds a CI guard for approved first-party Rust crate dependency edges.
Changes:
- Adds
check-crate-edgestoxtask. - Defines and tests dependency-layer invariants.
- Runs the guard in the CI clippy job.
| File | Description |
|---|---|
xtask/src/main.rs |
Registers the new command. |
xtask/src/crate_edges.rs |
Implements the dependency-edge guard and tests. |
.github/workflows/ci.yml |
Adds the guard to CI. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
check-crate-edges only checked that every real edge is in ALLOWLIST, never the reverse. A dependency removed from a crate's Cargo.toml left its allowlist entry behind, silently permitting the same edge to be reintroduced later without the review this guard exists to force (#422 review comment). Make the check bidirectional: an ALLOWLIST entry with no matching edge now fails too, naming itself as stale. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
check() now dedupes enforced edges via a BTreeSet so a first-party crate declared under both a normal and build dependency no longer reports the same violation twice. affected::load_graph, crate_edges::load_edges, and manifest::load_metadata all duplicated the same cargo metadata subprocess/error-handling boilerplate; that now lives once in paths::run_cargo_metadata. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
|
Reviewed this at A few things I checked specifically rather than taking on trust: The allowlist is an exact match for the real graph. I derived the first-party edge set independently from The CI gate covers the change that would actually introduce a bad edge. This was my main worry: adding a dependency touches only a The "can't allowlist your way out" test really does run on the PR that would do it. Copilot's stale-entry point is genuinely closed at head, not just claimed — Two non-blocking notes:
|
rominf
left a comment
There was a problem hiding this comment.
Approving on the strength of the review in #422 (comment) — nothing blocking found.
To be explicit about what this covers: it reflects a diff-level read of the change plus a few targeted checks I ran myself (deriving the first-party edge set from cargo metadata and confirming it matches ALLOWLIST exactly, confirming the rust path filter includes **/Cargo.toml so a manifest-only PR can't slip past the guard, and confirming the anti-allowlist-abuse test is actually selected by cargo xtask affected). It is not a substitute for CI, which was already green at this commit, and I did not run the test suite locally.
The two notes in that comment are non-blocking and don't need to hold up the merge.
|
Thanks for the thorough re-derivation and verification — good catches on both notes.
|

Summary
cargo xtask check-crate-edges: pins the allowlist of permitted first-party crate dependency edges (derived fromcargo metadata --no-deps) and fails with a specific rule-violation message when an edge outside it appears, or when an allowlist entry has no matching edge left in the graph (a removed dependency whose entry wasn't cleaned up).clippyCI job, right after the existingcargo xtask manifest --checkstep, under the samerust-changes gate.rocmdmust never depend onrocm(the reverse,rocm -> rocmd, is the allowed/expected direction),rocm-dash-coremust stay a pure leaf crate, androcm-dash-tuimust not depend onrocm-core.rocm-dash-daemon's test-only dev-dep onrocm-core).Why: this is Phase 0 of the EAI-7768 modularization epic — sequenced first because it protects the whole refactor and lands with an empty exception list (zero current violations on
main). A literal cycle check would be a no-op (Cargo's resolver already rejects those); the value is entirely in the allowlist, which catches any new first-party coupling, not just the three named invariants — bidirectionally, so both a new undeclared edge and a stale entry left behind by a removed dependency get caught.Risk: low. Pure CI-tooling addition — no production code paths touched, no new external dependencies (reuses
xtask's existingserde/anyhow), and the check currently passes onmainwith zero grandfathered entries.Non-goals: documenting the invariants in AGENTS.md/README (flagged separately via a comment on EAI-8045, which already touches those files for the related module-per-subsystem convention) and a local pre-commit hook for the guard (CI-only for now, matching the ticket's scope).
Test plan
cargo test -p xtask— 147 passed (9 new tests incrate_edges, including a fixture-based test that a deliberately-injected disallowed edge fails with the correct message, and a real-workspace regression test).cargo run -p xtask -- check-crate-edgesexits 0 against the current workspace.cargo clippy -p xtask --all-targets -- -D warningsandcargo fmt --all -- --checkboth clean.cargo xtask manifest --checkunaffected (no new external dependency introduced).cargo metadata's actual first-party edge graph exactly (25 edges, no gaps or stale entries), and that removing an entry from the allowlist causes the check to fail with the expected message before restoring it.N/A: not a bug fix, so the
expectations.tomlchecklist item doesn't apply.