Repository navigation
ci: enforce deny.toml over the example workspaces - #681
Merged
nihalpasham merged 2 commits intoAug 7, 2026
Merged
Conversation
vyncint
force-pushed
the
ci/cargo-deny-example-workspaces
branch
from
August 6, 2026 16:22
db9e224 to
981b9eb
Compare
`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]>
…, 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.
Collaborator
|
Gist: This closes the policy half of #663 the same way the merged #664 closed the inventory half: same script shape, same CI job, same single documented exemption. Running it over the tree immediately surfaced a live advisory ( I pushed one commit on top:
Guard re-run clean end to end (26 representatives); hashmap_v2/v3 build and pass the smoketest on sm_120. Closes #663. |
nihalpasham
approved these changes
Aug 7, 2026
This was referenced Aug 10, 2026
nihalpasham
pushed a commit
that referenced
this pull request
Aug 12, 2026
The one-word follow-up from the #805 review. The root `cargo deny check` was the only cargo-deny invocation in the tree without `--locked`: the backend-workspace run added beside it in #805 has it, and so does every per-example run in check-example-license-policy.sh since #681. It is not only an inconsistency. Without `--locked` the root run re-resolves on the way past, so it can rewrite the very Cargo.lock it is judging. Deleting one package block from the committed lock and running each form shows the difference: * `cargo deny --locked check` stops at exit 1 with "cannot update the lock file /.../Cargo.lock because --locked was passed to prevent this"; * `cargo deny check` exits 0 and leaves Cargo.lock rewritten. So a stale committed lock currently passes this gate unnoticed, and the gate hides the evidence by fixing it in place. That is the same reasoning already written down for the example workspaces -- the committed lock is what the policy must judge -- and the same reasoning check-dependency-licenses.sh states for its `cargo metadata --locked`. No behaviour change today: the root lock is current, and both forms report `advisories ok, bans ok, licenses ok, sources ok` at exit 0. The flag only fires once the lock drifts. The two prose mentions of `cargo deny check` in comments are left alone. Both describe which graph the root run reaches, which the flag does not change, and threading `--locked` through sentences about workspace boundaries would add noise rather than accuracy. Verified: `just check-guards` green end to end, the workflow still parses as YAML, and Cargo.lock is bit-identical after the mutation test. Signed-off-by: Vyncint Ng <[email protected]>
This was referenced Aug 16, 2026
nihalpasham
pushed a commit
that referenced
this pull request
Aug 17, 2026
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]>
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.
Closes the policy half of #663. #664 closed the inventory half.
Problem
cargo deny checkresolves the root workspace. Every example undercrates/rustc-codegen-cuda/examples/sets its own[workspace], so the root runstops at that boundary and the license, source and advisory policies never see a
crate an example pulls on its own.
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 was wrong that this was harmless
#663 says "This is not a violation today". Running the policy over the example
workspaces disproves that:
It affects
hashmap_v2andhashmap_v3, and nothing reports it. My originalcount of 68 was also low — I had counted only the six examples with declared
third-party dependencies, missing transitive build-dep graphs (
bindgen,clang-sys,libloading,zerocopy).Change
scripts/check-example-license-policy.shrunscargo deny checkover theexample workspaces, and a new
example-policyjob incargo-deny.ymlcallsit.
ci.ymlalreadyuses:that whole workflow, so no change is needed there.crossbeam-epoch0.9.18 → 0.9.20 in the two rayon examples. Without it theguard would fail on the tree it is added to. Both examples still build
(
cargo oxide build hashmap_v2/hashmap_v3).One run per dependency set, not per example
Each example depends on
cuda-coreand friends by path, so every lock re-liststhe root workspace's own transitive crates — which is why all 187 look like they
pull third-party code. Grouping examples by their exact set of third-party
(name, version)pairs collapses 187 workspaces to 27 runs.That is an equivalence, not a sample: licenses, sources and advisories are
per-crate properties, so two workspaces resolving an identical crate set get an
identical verdict.
bans.multiple-versionsis a graph property, butdeny.tomlsets it to
warn, so it cannot change the exit status. The script asserts therepresentatives cover every crate.
cutile_inter_kernel is exempt
It cannot satisfy the policy as written:
The first would need cutile-rs in
[sources] allow-git; the second a licensefield on a crate this repository does not own. Both are policy calls for you, 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.
Verification
All local, no GPU needed:
deny.tomlunchanged once theadvisory is fixed; the 187th is the exempt one above.
cargo deny checkat the root — stilladvisories ok, bans ok, licenses ok, sources okbash scripts/check-dependency-licenses.sh— still passes with the newlockfiles, so the bump needs no new CSV rows
cargo oxide build hashmap_v2andhashmap_v3— both produce PTXThe
example-policyjob getstimeout-minutes: 15rather than 10: it installscargo-deny and then resolves 27 workspaces, so it does more work than the two
existing jobs.
Refs #663