Skip to content

ci: cover the codegen backend's own workspace in both license guards - #805

Merged
nihalpasham merged 3 commits into
NVIDIA:mainfrom
vyncint:ci/backend-workspace-license-coverage-stacked
Aug 11, 2026
Merged

nihalpasham merged 3 commits into
NVIDIA:mainfrom
vyncint:ci/backend-workspace-license-coverage-stacked

Conversation

@vyncint

@vyncint vyncint commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Stacked on #803, which adds the CLI-reference guard to the same
check-guards recipe. Review only the second commit (5a80b3e1). If #803
lands first this rebases cleanly; if it is rejected I will re-cut from main.

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. Neither guard reached
it: the inventory guard reads the root workspace via cargo metadata, which
stops at that boundary, and the policy side ran cargo deny check on the root
plus a script over the examples.

Inventory — a live omission

rustc_codegen_cuda had no row in dependency-licenses.csv at all. The
largest first-party crate in the tree, absent from the inventory, while every
other member carries a 1st Party (workspace) row. Nothing existed that could
have caught it.

The guard now unions the declared crates of both first-party workspaces — 41 → 55
— and the row is added.

Policy — narrower than it looks

cargo deny now runs over that workspace too, in the same job as the root run so
the cargo install is shared.

I want to be precise about what this actually buys, because the obvious framing
overstates it. All 82 of the backend's third-party crate names also appear
in the root graph, so nothing there is unlicensed or ungoverned today. What
differs is versions: 17 (name, version) pairs resolve in that workspace and
nowhere else — anyhow 1.0.100, libc 0.2.187, hashbrown 0.17.0,
linkme 0.3.35, and 13 more. Advisory and license verdicts are per version, so
an advisory against one of those 17 is invisible to the root run. That is the gap
this closes.

Verification

  • Inventory guard passes with the row (55 crates); with the row removed again it
    fails naming exactly rustc_codegen_cuda.
  • The policy leg discriminates. 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]: crate 'anyhow = 1.0.100' is explicitly banned. So it covers
    crates the root run genuinely cannot see, rather than re-checking the same set.
  • cargo deny --manifest-path crates/rustc-codegen-cuda/Cargo.toml --locked check
    is clean on the current tree, so the policy half is prevention, not a fix.
  • just check-guards green end to end (9 legs); both workflow files parse as
    YAML.
  • deny.toml restored bit-identical after the mutation tests.

No --config on the new run: cargo-deny walks up from the manifest directory to
the repository-root deny.toml, the same resolution check-example-license-policy.sh
already relies on.

Note

--locked is on the new run, matching the examples script — a stale lock fails
rather than being silently re-resolved. The root cargo deny check above it does
not pass --locked; I left that alone rather than widen this PR, but it is a
one-word change if you want the two consistent.

The follow-up offered on NVIDIA#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
NVIDIA#793 and NVIDIA#790 without being added to the recipe, so `just check` could pass
while status-guard failed -- exactly the drift NVIDIA#729 and NVIDIA#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]>
The second pass asked for in the NVIDIA#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 NVIDIA#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]>
@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 Depends Blocked on another PR/issue or an upstream dependency labels Aug 11, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

Gist: the follow-up the #662 review asked for. The backend's own workspace was invisible to both guards: no inventory row for the largest first-party crate, and 17 version-distinct resolutions never checked against advisories. The second cargo-deny run reuses the example-policy invocation (no --config, walk-up to the root deny.toml), and the inventory script unions both workspaces instead of special-casing.

Verified here:

  • full just check-guards green on the branch;
  • inventory covers all 55 declared crates (was 41);
  • cargo deny --manifest-path crates/rustc-codegen-cuda/Cargo.toml --locked check passes all four checks.

Merging after #803 (the branch stacks it). Your --locked note on the root run is a one-word follow-up; we'll take it.

@nihalpasham
nihalpasham merged commit eefc28c into NVIDIA:main Aug 11, 2026
41 checks passed
@nihalpasham nihalpasham removed the Depends Blocked on another PR/issue or an upstream dependency label Aug 11, 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]>
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 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