Skip to content

ci: enforce deny.toml over the example workspaces - #681

Merged
nihalpasham merged 2 commits into
NVIDIA:mainfrom
vyncint:ci/cargo-deny-example-workspaces
Aug 7, 2026
Merged

nihalpasham merged 2 commits into
NVIDIA:mainfrom
vyncint:ci/cargo-deny-example-workspaces

Conversation

@vyncint

@vyncint vyncint commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Closes the policy half of #663. #664 closed the inventory half.

Problem

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 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:

error[vulnerability]: Invalid pointer dereference in `fmt::Pointer` impl for `Atomic` and `Shared`
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
Solution: Upgrade to >=0.9.20

It affects hashmap_v2 and hashmap_v3, and nothing reports it. My original
count 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.sh runs cargo deny check over the
    example workspaces, and a new example-policy job in cargo-deny.yml calls
    it. ci.yml already uses: that whole workflow, so no change is needed there.
  • crossbeam-epoch 0.9.18 → 0.9.20 in the two rayon examples. Without it the
    guard 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-core and friends by path, so every lock re-lists
the 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-versions is a graph property, but deny.toml
sets it to warn, so it cannot change the exit status. The script asserts the
representatives cover every crate.

cutile_inter_kernel is exempt

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
bans ok, licenses FAILED, sources FAILED

The first would need cutile-rs in [sources] allow-git; the second a license
field 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:

bash scripts/check-example-license-policy.sh
  Checking deny.toml over 27 representative example workspaces.
  ... advisories ok, bans ok, licenses ok, sources ok   (x27)
  OK: deny.toml holds over every example workspace outside POLICY_EXEMPT_EXAMPLES.
  • 186 of 187 example workspaces satisfy deny.toml unchanged once the
    advisory is fixed; the 187th is the exempt one above.
  • cargo deny check at the root — still advisories ok, bans ok, licenses ok, sources ok
  • bash scripts/check-dependency-licenses.sh — still passes with the new
    lockfiles, so the bump needs no new CSV rows
  • cargo oxide build hashmap_v2 and hashmap_v3 — both produce PTX

The example-policy job gets timeout-minutes: 15 rather than 10: it installs
cargo-deny and then resolves 27 workspaces, so it does more work than the two
existing jobs.

Refs #663

`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]>
@vyncint vyncint reopened this Aug 6, 2026
…, 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.
@nihalpasham nihalpasham added enhancement New feature or request build-related Build scripts, toolchain discovery, or compilation setup supply-chain Dependency policy: licenses, sources, security advisories, lock files examples Example kernels and host harnesses under crates/rustc-codegen-cuda/examples labels Aug 7, 2026
@nihalpasham

Copy link
Copy Markdown
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 (RUSTSEC-2026-0204 via crossbeam-epoch in the rayon examples), so the gap pretty helpful.

I pushed one commit on top:

  • dropped the top-level --config flag (0.20-only; every 0.19 install failed all 26 runs) in favor of cargo-deny's manifest-dir walk-up, verified on 0.19.4 and 0.20; added --locked so a stale lock fails loudly;
  • checking is per lock file, so a nested sub-workspace's own graph is genuinely policy-checked rather than only folded into its parent's grouping key;
  • the source string joins the grouping key (the same name+version from crates.io and from a git fork are different policy questions);
  • parse self-test floors mirroring ci: extend the license inventory guard to the example workspaces #664's guard; crossbeam-epoch CSV row refreshed to 0.9.20.

Guard re-run clean end to end (26 representatives); hashmap_v2/v3 build and pass the smoketest on sm_120.

Closes #663.

@nihalpasham
nihalpasham merged commit 11b2f49 into NVIDIA:main Aug 7, 2026
35 checks passed
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]>
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-related Build scripts, toolchain discovery, or compilation setup enhancement New feature or request examples Example kernels and host harnesses under crates/rustc-codegen-cuda/examples supply-chain Dependency policy: licenses, sources, security advisories, lock files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants