Repository navigation
ci: verify dependency-licenses.csv covers what the workspace declares - #662
Merged
nihalpasham merged 2 commits intoAug 5, 2026
Merged
Conversation
The CSV is the license inventory the README points at, and CONTRIBUTING asks contributors to update it by hand. Nothing verified it, so it fell behind by eight directly declared third-party dependencies (clap, futures, object, serde, serde_json, sha2, toml, trybuild) and thirteen workspace members. Dev-only deps are in scope by the file's own precedent: expect-test is dev-only and recorded, so trybuild's absence was an omission rather than a scope question. Add scripts/check-dependency-licenses.sh, run it from cargo-deny.yml, and add the twenty-one missing rows. The two jobs now cover the two halves: cargo deny check enforces the license policy over the whole resolved graph from deny.toml, while this guard enforces that the human-readable inventory still lists what the workspace declares. The guard checks presence, not versions. Twenty-four existing rows already disagree with the resolved graph, which is ordinary Cargo.lock drift, so a version check would fail on every routine bump without saying anything about licensing. It requires workspace members and direct dependencies rather than all 160 resolved packages, because deny.toml's allow-list already covers every transitive crate. It does not reject extra rows, because libmathdx-sys legitimately records a first-party crate from outside the root workspace. Following NVIDIA#643, the guard fails closed: it refuses to run without cargo or python3 instead of reporting success, and a parse self-test rejects a CSV whose layout no longer yields package names. The CSV edit is insert-only and preserves the file's CRLF line endings. Fixes NVIDIA#661 Signed-off-by: Vyncint Ng <[email protected]>
Both comm inputs are produced with LC_ALL=C sort, but comm itself ran under the ambient locale. Under en_US.UTF-8 dictionary collation the pair rustc-hash/rustc_apfloat is out of order, so GNU comm exits 1 with 'input is not in sorted order' and set -euo pipefail aborts the script even when the CSV is complete. CI's C.UTF-8 was unaffected, but CONTRIBUTING.md tells contributors to run the script locally. Export LC_ALL=C once after set -euo pipefail so every sort and comm in the script agrees on byte-wise ordering regardless of the caller's locale.
Collaborator
|
Verified this end to end:
I pushed one commit on top:
Follow-ups that can be filed separately: Thanks for closing the loop on the inventory. Closes #661. |
nihalpasham
approved these changes
Aug 5, 2026
vyncint
added a commit
to vyncint/cuda-oxide
that referenced
this pull request
Aug 5, 2026
Suggested by @nihalpasham reviewing NVIDIA#662. Without it the guard may resolve and rewrite Cargo.lock to satisfy its own query, which means a check that can modify its own input -- and in CI it would quietly paper over a stale lockfile rather than reporting one. Verified: `cargo metadata --locked --format-version 1` exits 0 against the committed lockfile, and the guard still reports both halves OK. Signed-off-by: Vyncint Ng <[email protected]>
nihalpasham
added a commit
that referenced
this pull request
Aug 6, 2026
* ci: extend the license inventory guard to the example workspaces `cargo deny check` resolves the root workspace, and the guard added in #662 checks that same graph against dependency-licenses.csv. Every example under crates/rustc-codegen-cuda/examples/ sets its own `[workspace]`, so neither sees any of them. Six examples declare third-party dependencies, pulling 68 distinct crates recorded in neither place, and nothing enforced the license policy over them. The guard now also reads the example lock files. A package counts as covered when it appears in the root graph, has a CSV row, or carries no `source` field -- that last case being a path dependency, first-party by construction. Name matching is avoided deliberately: cutile_inter_kernel pulls cuda-core and its siblings by git rather than by path, so a heuristic over names would misfile first-party crates as third-party. Lock files are parsed directly rather than through `cargo metadata`, because resolving 178 separate workspaces would be slow and would need the network. The existing `cargo-deny / license-manifest` job already runs this script and stays CPU-only. Rows added for the eight crates the five small examples pull: tokio and tokio-macros (MIT), rayon, rayon-core and crossbeam-{deque,epoch,utils} (MIT OR Apache-2.0), and libm (MIT). Each license, repository and description is read from the crate's own manifest rather than transcribed. The CSV edit is insert-only -- `git diff --numstat` is `8 0` -- rows land in the file's existing LC_ALL=C order, and its CRLF line endings are preserved. cutile_inter_kernel is listed in INVENTORY_EXEMPT_EXAMPLES for now: its git dependency on cutile-rs resolves ~60 further crates that exist in this tree only to build one interop example, and whether those belong in the inventory is the open question in #663. Deleting the entry requires the rows instead. Names in that list are checked against the examples on disk, so a typo or a rename fails the run rather than quietly exempting nothing -- or everything. Verified: passes clean; fails naming the crate when a new row is deleted; fails naming cutile_inter_kernel when the exemption is dropped; fails with "no such example" on a typo'd exemption; and the lock-parse self-test fires when the glob matches nothing. Refs #663 Signed-off-by: Vyncint Ng <[email protected]> * ci: pass --locked to cargo metadata in the license guard Suggested by @nihalpasham reviewing #662. Without it the guard may resolve and rewrite Cargo.lock to satisfy its own query, which means a check that can modify its own input -- and in CI it would quietly paper over a stale lockfile rather than reporting one. Verified: `cargo metadata --locked --format-version 1` exits 0 against the committed lockfile, and the guard still reports both halves OK. Signed-off-by: Vyncint Ng <[email protected]> * review: sweep nested example lockfiles into the guard The lockfile glob was depth-1 only, so a Cargo.lock inside a nested sub-workspace (cutile_inter_kernel/simt already has one, with 59 registry-sourced packages) was never opened and a future example with a nested workspace would escape the guard silently. Search recursively and attribute each lockfile to its top-level example so the exemption list keeps working however deep the lock sits. Also drop the stale '178 separate workspaces' count from the comment. --------- Signed-off-by: Vyncint Ng <[email protected]> Co-authored-by: nihalpasham <[email protected]>
nihalpasham
added a commit
that referenced
this pull request
Aug 11, 2026
…805) * ci: guard the book's CLI command reference against subcommand drift The follow-up offered on #794. That PR added a Command reference table because the book documented 11 of the CLI's 15 subcommands; `test`, `fmt`, `update` and `emit-ltoir` appeared nowhere. Nothing stops the table falling behind again -- adding a variant to the clap enum is a one-line change and no build compares the two. `scripts/check-cli-doc-coverage.sh` compares the `Commands` enum in `crates/cargo-oxide/src/main.rs` against the rows under `### Command reference`, in both directions. A missing row is the common case; a row for a command that no longer exists is worse, because a reader trusts it and gets `unrecognized subcommand`. Subcommands come from the enum rather than from `cargo oxide --help`: the enum is the definition, reading it needs no cargo and no build, and that keeps the guard in the same source-only class as its siblings. A guard that needed a backend build to answer a documentation question would not get run. The parse is cross-checked against the built binary -- both report the same 15 commands, with no disagreement. Deliberately not required to appear: anything carrying `hide = true` (`__materializer-provenance` today) and clap's generated `help`, which is not in the enum at all. Descriptions are out of scope, because clap's short help is the doc-comment first line while the table's cells add MyST backticks around names like `cuda-gdb`; comparing them literally would fail on correct prose. While wiring it up: `check-guards` was running five of the seven guards. The crate-inventory and toolchain-parity jobs went into status-guard.yml in #793 and #790 without being added to the recipe, so `just check` could pass while status-guard failed -- exactly the drift #729 and #788 built that recipe to prevent. My omission; all three are in now, and the stale counts in its comment ("the status-guard pair", "two of the four") are fixed. Verified: passes on the clean tree (15 documented, 1 hidden excluded), and seven mutations each fail naming the cause -- new subcommand, deleted row, invented row, a row for the hidden command, a rename, and both parse self-tests. `just check-guards` is green end to end. Signed-off-by: Vyncint Ng <[email protected]> * ci: cover the codegen backend's own workspace in both license guards The second pass asked for in the #662 review: "a second pass over `crates/rustc-codegen-cuda` (its own workspace, invisible to both cargo-deny and this guard today)". Still true, and it had already cost a row. That crate carries its own `[workspace]` for the rustc-private dylibs, so it is a third resolution alongside the root and the examples, and neither existing guard reached it. The inventory guard read the root workspace through `cargo metadata`, which stops at that boundary; the policy side ran `cargo deny check` on the root and a script over the examples. **Inventory, and a live omission.** `rustc_codegen_cuda` had no row in dependency-licenses.csv at all -- the largest first-party crate in the tree, missing from the inventory, while every other member carried a `1st Party (workspace)` row. Nothing could have caught it. The guard now unions the declared crates of both first-party workspaces, which takes it from 41 to 55, and the missing row is added. **Policy.** `cargo deny` now runs over that workspace too, in the same job as the root run so the install is shared. This is narrower than it looks and worth stating precisely: all 82 of its third-party crate *names* also appear in the root graph, so nothing is unlicensed today. What differs is versions -- 17 (name, version) pairs resolve there and nowhere else, including `anyhow 1.0.100`, `libc 0.2.187` and `linkme 0.3.35` -- and advisory and license verdicts are per version, so an advisory against one of those 17 is invisible to the root run. Verified: * the inventory guard passes with the row (55 crates) and, with the row removed again, fails naming exactly `rustc_codegen_cuda`; * banning `anyhow =1.0.100`, a backend-only version, leaves the root run at `bans ok` and makes the backend run fail with `error[banned]` -- the new leg covers crates the root one cannot see; * `cargo deny --manifest-path crates/rustc-codegen-cuda/Cargo.toml --locked check` is clean on the current tree, so the policy half is prevention rather than a fix; * `just check-guards` green end to end, and both workflow files parse. No `--config` on the new run: cargo-deny walks up from the manifest directory to the repository-root deny.toml, the same resolution the example-policy script already relies on. Stacked on #803, which adds the CLI-reference guard to the same `check-guards` recipe -- review only the second commit. Signed-off-by: Vyncint Ng <[email protected]> --------- Signed-off-by: Vyncint Ng <[email protected]> Co-authored-by: nihalpasham <[email protected]>
nihalpasham
added a commit
that referenced
this pull request
Aug 23, 2026
…checks (#1132) * ci(licenses): the guard's own workspace-root list is a claim nothing checks `check-dependency-licenses.sh` reaches each first-party workspace with one `declared_crates` pass per root, because `cargo metadata` stops at a `[workspace]` boundary. Which roots exist was hard-coded, and nothing compared that list against the tree -- which is exactly how the guard has failed twice: * #662 found `crates/rustc-codegen-cuda` unread. The backend, the largest first-party crate in the tree, had no CSV row while every other member did. * #1114 found `crates/cuda-macros/tests/device-only` unread, and its member `device-only-kernels` likewise unrecorded. Both times the guard printed OK. That is the failure mode this repo's guards are built to refuse, and it is the one this guard had: a short list is indistinguishable from a complete one, a count cannot tell them apart, and the comment saying "Both first-party workspaces" was itself the wrong number for months. #1114's review asked for the self-check; this is it. The list becomes two named arrays and is compared against `git ls-files -- '*Cargo.toml'` filtered to manifests declaring `[workspace]`, both directions: * a manifest on disk that no pass reads fails, naming it, and says to add it as first-party or as vendored; * a name in the arrays that is no longer such a manifest fails as stale, since a renamed root left behind is a permanent hole. `crates/fuzzer/rustlantis` is the one vendored root, listed separately with the reason: third-party code attributed in THIRD_PARTY_NOTICES whose dependencies are not ours to record, excluded by `check-spdx-headers.sh` on the same grounds. Roots under `crates/rustc-codegen-cuda/examples` stay out of scope here because the second half of the script already resolves those, including the two nested sub-workspaces, from their committed lock files. Verified, four ways: | mutation | result | |---|---| | drop the device-only root from the list | fails, naming that manifest | | add a name that is not a manifest | fails as stale, naming it | | a new tracked `[workspace]` manifest appears | fails, naming it | | the `[workspace]` scan pattern rots | refuses: "the scan broke, so a clean result means nothing" | Unmutated the guard reports "OK: dependency-licenses.csv records all 59 declared crates" and the example half is unchanged. `bash -n` clean. `git` is added to the `require_tool` list it already uses for `cargo` and `python3`. Signed-off-by: Vyncint Ng <[email protected]> * ci(licenses): derive workspace roots with Cargo Resolve every tracked manifest through Cargo, compare named non-example roots in both directions, and require each example workspace to have an adjacent tracked lock. Signed-off-by: nihalp <[email protected]> --------- Signed-off-by: Vyncint Ng <[email protected]> Signed-off-by: nihalp <[email protected]> Co-authored-by: nihalp <[email protected]>
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.
Fixes #661. Branched from
main; touches four files and overlaps none of the seven open PRs (checked file-by-file against #650, #652, #653, #654, #655, #658, #659).What was wrong
dependency-licenses.csvis the "tracked license inventory" the README points at, and CONTRIBUTING asks contributors to update it by hand. Nothing verified it, and it had fallen behind by 8 of 28 directly declared third-party dependencies and 13 of 23 workspace members.clapfuturesobjectserdeserde_jsonsha2tomltrybuildPlus
cargo-oxide,cuda-artifact-finalizer,cuda-async,cuda-intrinsics,cuda-intrinsics-gen,cuda-oxide-codegen,fuzzer,libnvvm-sys,mir-transforms,nvjitlink-sys,nvvm-transforms,oxide-artifacts,reserved-oxide-symbols.Dev-only deps are in scope by the file's own precedent —
expect-testis dev-only and is recorded — sotrybuild's absence is an omission by the existing standard, not a scope question. Andtempfilearrived with its row in #417, so the convention works when remembered; these 21 are where it wasn't.What this adds
scripts/check-dependency-licenses.sh, run fromcargo-deny.ymlas a second job, plus the 21 rows. The two jobs then cover the two halves of one concern:cargo deny checkenforces the license policy over the whole resolved graph fromdeny.toml; this guard enforces that the human-readable inventory still lists what the workspace declares.Where I drew the scope lines, and why
Presence, not versions. 24 of the 81 existing rows already disagree with the resolved graph (
anyhow1.0.100 vs 1.0.103,syn2.0.114 vs 3.0.3, …). That is ordinaryCargo.lockdrift. A version check would fail on every routine bump while saying nothing about licensing. I also deliberately did not refresh those 24 numbers — they would go stale again immediately, and that churn is the reason not to enforce them.Direct dependencies, not the full graph. The resolve graph has 160 packages; the CSV has 81, of which 50 are transitive-only. Requiring all 109 transitive crates would be a large mechanical change for no licensing gain, since
deny.toml's[licenses]allow-list already covers every transitive crate. Existing transitive rows stay welcome but optional.No stale-row rule.
libmathdx-sysis not in the root workspace graph — it is the first-party sys crate underexamples/mathdx_ffi_test/. Because the CSV legitimately covers first-party crates from outside the root workspace, a "no extra rows" rule would flag it wrongly.Verification
CPU-only. No GPU, no CUDA toolkit, no LLVM —
cargo metadataresolves the graph without running build scripts, which is why the new job needs neither.mainsha2)sha2oxide-artifacts)oxide-artifactspython3absent fromPATHcargoabsent fromPATH5–7 are deliberate, following #643: that guard reported success for three months because
rg ... || trueturned a missing binary into an empty result set.Two details worth calling out because they are easy to get wrong here:
git diff --numstatis21 0, no existing row modified — and rows land in the file's establishedLC_ALL=Corder without reordering anything.\r). Writing this file in text mode is what produced a whole-file 81-row diff in docs: record the pliron git pin in dependency-licenses.csv #631, so the insertion used binary I/O.All 102 rows still parse as 9-field CSV, every new row's license intersects
deny.toml's allow-list,bash -nis clean, and both sibling guards (check-error-example-status.sh, reserved-prefix) still pass.Two things I found but did not fix
rustlantishas no automated license coverage.crates/fuzzer/rustlantis/is tracked third-party source, dual MIT/Apache-2.0, carrying its ownLICENSE-APACHEandLICENSE-MIT— so CONTRIBUTING's vendored-file rule is satisfied. Butcrates/fuzzer/Cargo.tomlsetsexclude = ["rustlantis/"]and it is a separate workspace, so cargo-deny never sees it and the CSV does not record it. It is the only in-tree third-party code with no automated license coverage. Recording it needs a newDependency Typevalue such as3rd Party (vendored)— a schema decision for you, not one I should invent. It is also not linked into any artifact, so its license does not propagate into distributed binaries.Happy to move the job out of
cargo-deny.ymlinto its own guard workflow (alongsidenaming-guard/status-guard) if you would rather keep that file strictly about cargo-deny — I put it there because the concern is dependency licensing and it gets the weekly schedule for free.