Repository navigation
ci: extend the license inventory guard to the example workspaces - #664
Conversation
`cargo deny check` resolves the root workspace, and the guard added in NVIDIA#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 NVIDIA#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 NVIDIA#663 Signed-off-by: Vyncint Ng <[email protected]>
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]>
|
Pushed Verified Your other #662 follow-up — a second pass over |
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.
|
The guard architecture is consistent with the #662 first half (presence-only, no network, same CI job) and the design choices held up under review — first-party by absence of a lock source field, exemption list validated against disk, parse self-tests against the silent-blindness failure mode. I pushed one commit on top:
|
`cargo deny check` resolves the root workspace. Every example under crates/rustc-codegen-cuda/examples/ sets its own `[workspace]`, so the root run stops at that boundary and the license, source and advisory policies never see any crate an example pulls on its own. NVIDIA#664 closed the inventory half of this; this closes the policy half. The gap is 131 distinct crates: the root workspace resolves 139 third-party crates, and the example locks add 131 beyond it. All 187 examples add at least one. I had written in NVIDIA#663 that this was "not a violation today". That was wrong. Running the policy over the example workspaces finds a live advisory: error[vulnerability]: Invalid pointer dereference in `fmt::Pointer` impl crossbeam-epoch 0.9.18 — RUSTSEC-2026-0204 crossbeam-epoch v0.9.18 └── crossbeam-deque v0.8.6 └── rayon-core v1.13.0 └── rayon v1.12.0 └── hashmap_v2 v0.1.0 so this also bumps crossbeam-epoch to 0.9.20 in the two rayon examples, without which the new guard would fail on the tree it is added to. Both still build. The guard runs one cargo-deny per distinct third-party dependency set rather than one per example: because each example depends on cuda-core and friends by path, every lock re-lists the root workspace's own transitive crates, and grouping by the exact set of (name, version) pairs collapses 187 workspaces to 27 runs. That is an equivalence rather than a sample -- licenses, sources and advisories are per-crate properties, so two workspaces resolving an identical crate set get an identical verdict, and `bans.multiple-versions` is "warn" and cannot change the exit status. cutile_inter_kernel is exempt, because it cannot satisfy the policy as written: error[source-not-allowed]: detected 'git' source not explicitly allowed (x7) error[unlicensed]: cuda-bindings = 0.1.0 is unlicensed The first would need cutile-rs added to `[sources] allow-git`, the second a license field on a crate this repository does not own. Both are policy calls, so the example is listed rather than the policy loosened -- the same reason it is already exempt from the inventory guard. As there, every exempt name is checked against the examples on disk, so a typo or a rename fails the run instead of quietly exempting nothing, or everything. Measured: 186 of 187 example workspaces satisfy deny.toml unchanged. Refs NVIDIA#663 Signed-off-by: Vyncint Ng <[email protected]>
* ci: enforce deny.toml over the example workspaces `cargo deny check` resolves the root workspace. Every example under crates/rustc-codegen-cuda/examples/ sets its own `[workspace]`, so the root run stops at that boundary and the license, source and advisory policies never see any crate an example pulls on its own. #664 closed the inventory half of this; this closes the policy half. The gap is 131 distinct crates: the root workspace resolves 139 third-party crates, and the example locks add 131 beyond it. All 187 examples add at least one. I had written in #663 that this was "not a violation today". That was wrong. Running the policy over the example workspaces finds a live advisory: error[vulnerability]: Invalid pointer dereference in `fmt::Pointer` impl crossbeam-epoch 0.9.18 — RUSTSEC-2026-0204 crossbeam-epoch v0.9.18 └── crossbeam-deque v0.8.6 └── rayon-core v1.13.0 └── rayon v1.12.0 └── hashmap_v2 v0.1.0 so this also bumps crossbeam-epoch to 0.9.20 in the two rayon examples, without which the new guard would fail on the tree it is added to. Both still build. The guard runs one cargo-deny per distinct third-party dependency set rather than one per example: because each example depends on cuda-core and friends by path, every lock re-lists the root workspace's own transitive crates, and grouping by the exact set of (name, version) pairs collapses 187 workspaces to 27 runs. That is an equivalence rather than a sample -- licenses, sources and advisories are per-crate properties, so two workspaces resolving an identical crate set get an identical verdict, and `bans.multiple-versions` is "warn" and cannot change the exit status. cutile_inter_kernel is exempt, because it cannot satisfy the policy as written: error[source-not-allowed]: detected 'git' source not explicitly allowed (x7) error[unlicensed]: cuda-bindings = 0.1.0 is unlicensed The first would need cutile-rs added to `[sources] allow-git`, the second a license field on a crate this repository does not own. Both are policy calls, so the example is listed rather than the policy loosened -- the same reason it is already exempt from the inventory guard. As there, every exempt name is checked against the examples on disk, so a typo or a rename fails the run instead of quietly exempting nothing, or everything. Measured: 186 of 187 example workspaces satisfy deny.toml unchanged. Refs #663 Signed-off-by: Vyncint Ng <[email protected]> * ci(example-policy): check per lock file, key on source, drop --config, add --locked and parse floors Four hardenings layered on the guard, none architectural: - Group and check per lock file rather than per example directory, so a nested sub-workspace's own resolved graph is policy-checked instead of only contributing to its parent's grouping key. An exemption still covers every lock under the exempt example. - Include the source string in the grouping triple: the sources policy judges where a crate comes from, so the same (name, version) from crates.io and from a git fork must not share a representative. - Drop --config: cargo-deny resolves deny.toml by walking up from the manifest directory (verified on 0.19 and 0.20), while a top-level --config flag only exists on 0.20, so the flag made the script fail on every older cargo-deny for no coverage gain. Add --locked so a stale lock fails the run instead of being silently re-resolved away from the graph that determined its grouping. - Add the sibling guard's parse self-test floors (>= 20 lock files, >= 100 parsed packages) so regex rot fails loudly instead of collapsing every workspace into one vacuous group. Also refresh crossbeam-epoch to 0.9.20 in dependency-licenses.csv to match the bumped hashmap_v2/v3 locks, and correct the measured counts (187 lock files, 26 representative runs). Verified: the guard passes end to end against this tree (26 representatives, advisories/bans/licenses/sources ok), the exempt-typo and missing-locks paths fail loudly by name, the inventory guard stays green after the CSV refresh, and hashmap_v2/v3 build and PASS the smoketest on sm_120 with the patched crossbeam-epoch. --------- Signed-off-by: Vyncint Ng <[email protected]> Co-authored-by: nihalpasham <[email protected]>
Each guard exempts cutile_inter_kernel and justifies it the same way:
check-dependency-licenses.sh:
Whether those belong in the inventory is the open question in #663
check-example-license-policy.sh:
Both are policy calls for a maintainer, and they are the open question
in #663 ... Delete the entry once that is settled.
#663 closed on 2026-08-10. I closed it, saying both halves were enforced in CI,
and that was overstated: #664 and #681 did cover every *other* example
workspace, but this one is on both exemption lists, so its ~60 git-pulled
crates get neither a CSV row nor a `cargo deny check`. Two readers are now sent
to a resolved thread to find a decision that was never made.
The decisions are unchanged and still the maintainer's:
* `deny.toml`'s `allow-git` lists only pliron, not cutile-rs;
* the `unlicensed` error names cutile-rs's own vendored `cuda-bindings`
0.1.0, not this repository's crate of the same name -- ours is 0.2.1 and
inherits the workspace license -- so that one is not ours to fix at all.
So this repoints both comments at #953, which tracks exactly those two, and
says plainly what the exemption withholds: not just the inventory rows, but the
policy check too, making this the one such hole in the tree. The previous
wording let a reader of the inventory guard assume `cargo deny` still covered
these crates.
Comment-only. Both guards pass unchanged: 55 declared crates recorded, every
example workspace's third-party crates covered, and deny.toml holding over
every example outside POLICY_EXEMPT_EXAMPLES.
Signed-off-by: Vyncint Ng <[email protected]>
Addresses #663.
cargo deny checkresolves the root workspace, and the guard from #662 checks that same graph. Every example undercrates/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, with no license gate over any of them.Not a violation today:
deny.toml's allow-list plausibly covers all 68. The problem is that nothing would say so if it did not.What the guard now does
For each example lock file, every package must be covered — in the root graph, in the CSV, or carrying no
sourcefield.That last case is a path dependency, first-party by construction. Name matching is avoided deliberately:
cutile_inter_kernelpullscuda-core,cuda-asyncandcuda-bindingsby git rather than by path, so a heuristic over crate names would misfile first-party crates as third-party. I only found that by checking, having assumed the opposite.Lock files are parsed directly rather than via
cargo metadata— resolving 178 workspaces would be slow and would need the network. The existingcargo-deny / license-manifestjob already runs this script and stays CPU-only, so there is no workflow change.It also skips the 172 examples that declare only path dependencies, so in practice this checks 6 workspaces.
Rows added
Eight crates, for the five small examples:
tokio,tokio-macrosasync_mlp,async_vecaddrayon,rayon-corehashmap_v2,hashmap_v3crossbeam-deque,-epoch,-utilsrayonlibmlibm_mathEvery license, repository and description is read from that crate's own manifest rather than transcribed from memory —
libmis plainMIT, not the dual license the others use, which is exactly the sort of thing worth not guessing in a license file.Following #631 and #662: the CSV edit is insert-only (
git diff --numstatis8 0, no existing row modified), rows land in the file's existingLC_ALL=Corder, and CRLF endings are preserved via binary I/O.The one thing left open
cutile_inter_kernelsits inINVENTORY_EXEMPT_EXAMPLES. Its git dependency oncutile-rsresolves ~60 further crates —wasm-bindgen,wit-bindgen,wasmparser,windows-targets— that exist in this tree only to build one interop example. Whether those belong in the inventory is the question in #663, and I would rather leave a documented, single-line lever than add 60 rows on a guess. Delete that one entry and the guard requires the rows instead.Names in that list are validated against the examples on disk, so a typo or a rename fails the run rather than quietly exempting nothing — or everything. Given that this PR exists because a guard's coverage stopped short of what it appeared to check, an exemption that could silently widen seemed worth closing off.
Verification
CPU-only; no GPU, CUDA toolkit or LLVM.
mainrayon)rayoncutile_inter_kernel3–6 follow the #643 lesson, and #662's locale bug: a guard that cannot fail loudly is the defect, not the coverage gap.
bash -nclean, the root-workspace half still reports its 51 crates unchanged, andCONTRIBUTING.mdgains four lines so the rule is discoverable before CI enforces it.Not included
crates/rustc-codegen-cudais its own workspace too, and was the follow-up suggested on #662 — but I measured it and its 93-package graph is a strict subset of the root's 160, socargo deny checkalready covers every third-party crate the shipped backend uses. Only the first-partyrustc_codegen_cudacrate itself lacks a row. Nothing to enforce there; noted in #663 rather than changed here.