Skip to content

ci: pin the lock on the root cargo-deny run - #806

Merged
nihalpasham merged 1 commit into
NVIDIA:mainfrom
vyncint:ci/root-deny-locked
Aug 12, 2026
Merged

nihalpasham merged 1 commit into
NVIDIA:mainfrom
vyncint:ci/root-deny-locked

Conversation

@vyncint

@vyncint vyncint commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

The one-word follow-up from the #805 review — "Your --locked note on the root
run is a one-word follow-up; we'll take it."

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

form exit effect
cargo deny --locked check 1 cannot update the lock file /…/Cargo.lock because --locked was passed to prevent this
cargo deny check 0 left Cargo.lock rewritten

So a stale committed lock passes this gate today unnoticed, and the gate hides
the evidence by fixing it in place. That is the 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 gives for its
cargo metadata --locked ("a check that can rewrite its own input is not a
check").

No behaviour change today

The root lock is current: both forms report advisories ok, bans ok, licenses ok, sources ok at exit 0. The flag only fires once the lock drifts.

Scope

Two command lines — the workflow step and the check-guards recipe — plus a
comment recording why. I left the two prose mentions of cargo deny check in
comments alone: both describe which graph the root run reaches, which this flag
does not change, and threading --locked through sentences about workspace
boundaries would add noise rather than accuracy. Say the word if you'd rather
they matched verbatim.

Verification

  • just check-guards green end to end (nine legs).
  • .github/workflows/cargo-deny.yml still parses as YAML; the check job now
    runs cargo deny --locked check then the backend run.
  • All three executable cargo-deny invocations now pin the lock; the only
    remaining unpinned matches are backticked prose.
  • Cargo.lock bit-identical after the mutation test (git diff clean).

The one-word follow-up from the NVIDIA#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 NVIDIA#805 has it, and so does every
per-example run in check-example-license-policy.sh since NVIDIA#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 nihalpasham added build-related Build scripts, toolchain discovery, or compilation setup QoL-improvement Quality-of-life improvement; not a correctness fix supply-chain Dependency policy: licenses, sources, security advisories, lock files labels Aug 12, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

Gist: closes the gap #805 left: the root cargo-deny run could silently re-resolve a stale lock while the backend run asserted it. Now every executable cargo-deny invocation is locked, matching the repo's own "a check that can rewrite its own input is not a check" rule.

Verified here:

  • two command-line edits plus the comment; applies cleanly on main; workflow and Justfile mirror each other;
  • global --locked confirmed against cargo-deny 0.19.4 (asserts Cargo.lock unchanged);
  • remaining cargo deny check matches on main are prose only.

Landing once CI is green.

@nihalpasham
nihalpasham merged commit 1d30100 into NVIDIA:main Aug 12, 2026
41 checks passed
nihalpasham pushed a commit that referenced this pull request Aug 17, 2026
`check-device-only-build.sh` is the only guard in scripts/ that resolves a
Cargo graph without `--locked`. Its sibling states the rule it is missing:

    # `--locked` so the guard reads the committed resolution rather than
    # silently updating Cargo.lock to satisfy itself: a check that can
    # rewrite its own input is not a check.
        -- scripts/check-dependency-licenses.sh

check-example-license-policy.sh passes `--locked` too, and #806 added it to
all three executable `cargo deny` invocations for the same reason.

It matters more here than in either of those, because this guard's whole
assertion is about the *resolved* graph -- "cuda-host, cuda-core and
cuda-bindings are absent from it". A resolution free to move is not the one
the repository committed, and `crates/cuda-macros/tests/device-only/Cargo.lock`
is tracked.

Reproduced on a clean tree by deleting the `cuda-device` package block from
that committed lock:

    before:  OK: device-only graph is host-free (8 packages).
             OK: ... type-checks with the CUDA environment unset.
             exit=0        # and `git diff` on the lock came back empty --
                           # cargo had quietly resolved it back

    after:   error: cargo metadata failed for .../device-only/Cargo.toml
             exit=1        # lock left exactly as the mutation made it

So the guard both passed on a corrupt input and repaired that input on its
way past, which is the failure mode that leaves nobody with a reason to
look. `cargo check` gets the flag as well, for the same reason and so the
two invocations cannot disagree about which resolution is under test.

The error path now names the lock file, since "commit the updated lock"
is the fix and re-resolving is what we just stopped doing silently.

Verified: clean tree passes unchanged; the mutation above now fails and
leaves the lock alone; restoring the lock passes again.

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 QoL-improvement Quality-of-life improvement; not a correctness fix 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