feat(xtask): add non-Rust inventory command (#212, rollout PR 4/12)#216
Conversation
Fourth PR in the 12-PR file-policy rollout decomposition. First real
Rust code in the ladder. Adds the `xtask` crate with the seed command
that feeds every later file-policy check.
## Scope
- `xtask/` — new non-publishable workspace crate
- `xtask/Cargo.toml` — `publish = false`, inherits edition/license/MSRV
from workspace. Deps: anyhow, clap (derive), serde, serde_json. Other
deps from the rollout spec (globset, toml, walkdir) are deferred to
the PRs that actually need them.
- `xtask/src/main.rs` — clap CLI with `non-rust inventory` subcommand.
- `xtask/src/file_policy.rs` — the inventory implementation.
- `.cargo/config.toml` — adds `xtask = "run --package xtask --"` so
`cargo xtask <cmd>` works.
- `Cargo.toml` — `xtask` added to workspace members.
## Behavior
`cargo xtask non-rust inventory`:
1. Resolves the workspace root from `CARGO_MANIFEST_DIR`.
2. Runs `git ls-files -z` to enumerate tracked files.
3. Classifies each as Rust source (`*.rs`) or non-Rust.
4. Aggregates non-Rust files by extension (descending count, then
alphabetical for ties).
5. Writes:
- `target/policy/non-rust-inventory.md` — human-readable summary.
- `target/policy/non-rust-inventory.json` — structured payload that
PR 5 (#204) `check-file-policy` and PR 6 (#205) `propose` will
consume.
`unsafe_code = "forbid"` is inherited from `[workspace.lints]`.
## Validation
- `cargo check -p xtask --locked` passes.
- `cargo check --workspace --locked` passes.
- `cargo clippy -p xtask --all-targets --locked -- -D warnings` clean.
- `cargo xtask non-rust inventory` ran successfully on this branch and
reported: 1184 tracked, 168 Rust, 1016 non-Rust.
- Both `target/policy/non-rust-inventory.md` and
`target/policy/non-rust-inventory.json` are produced.
Closes #212.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Droid finished @EffortlessSteven's task —— View job Review validation complete. Review validated for PR #216 (feat/xtask-non-rust-inventory-20260511)
Validation result: No candidates to validate. The review summary ("LGTM — no issues found") is consistent with:
Status: approved — no actionable findings. |
Workspace-wide `cargo fmt --all -- --check` wanted the two serde_json::to_string_pretty + fs::write chains on single lines. Caught by CI Lint step. Acceptance: - `cargo fmt --all -- --check` clean. - `cargo xtask non-rust inventory` still works.
|
Droid finished @EffortlessSteven's task —— View job Review validation complete. Review validated for PR #216 (feat/xtask-non-rust-inventory-20260511)
Validation result: No candidates to validate. The review summary ("LGTM — no issues found") is consistent with:
Status: approved — no actionable findings. |
Summary
Fourth PR in the 12-PR file-policy rollout. First real Rust code in the ladder. Adds the
xtaskcrate with the seed command that every later file-policy check will consume.Issue
Closes #212. Refines #180 umbrella. Builds toward PR 5 (#204), PR 6 (#205), PR 7 (#206), PR 8 (#207), and the unified report (PR 9 / #208). Tracks #109.
Scope
xtask/— new non-publishable workspace crate,publish = false.xtask/Cargo.toml— inherits edition/license/MSRV from workspace. Deps: anyhow, clap (derive), serde, serde_json.xtask/src/main.rs— clap CLI withnon-rust inventorysubcommand. Future subcommands (check-file-policy,non-rust propose,check-generated, etc.) attach to the same dispatcher in their PRs.xtask/src/file_policy.rs— the inventory implementation. ~180 lines..cargo/config.toml— addsxtask = "run --package xtask --"socargo xtask <cmd>works workspace-wide.Cargo.toml—xtaskadded to workspace members;Cargo.lockupdated (10 new dep-graph lines).Decisions
Decision: Defer
globset,toml,walkdirfrom the rollout spec's listed deps to the PRs that actually use them.inventoryonly needsgit ls-files, extension matching, and JSON output. PR 5'scheck-file-policywill addtoml(read the allowlists),globset(glob match), etc.Decision: Binary classification (Rust source vs non-Rust). No finer-grained categorization in this PR.
Decision: Use
git ls-files -z(subprocess) rather thanwalkdir..gitignore, doesn't traversetarget/, and matches what the future checker should reason about.Acceptance
cargo check -p xtask --lockedpasses.cargo check --workspace --lockedpasses.cargo clippy -p xtask --all-targets --locked -- -D warningsclean.cargo fmt -p xtask -- --checkclean.cargo xtask non-rust inventoryran on this branch and reported:wrote target/policy (1184 total, 168 Rust, 1016 non-Rust)target/policy/non-rust-inventory.mdandtarget/policy/non-rust-inventory.jsonproduced.unsafe_code = "forbid"inherited from[workspace.lints](nounsafeblocks anywhere).Output preview
Follow-ups
cargo xtask check-file-policy --mode advisoryconsumes this inventory's JSON to reconcile againstpolicy/non-rust-allowlist.toml.cargo xtask non-rust proposewrites draft receipts for unreceipted files surfaced here.