Repository navigation
ci: pin the lock on the root cargo-deny run - #806
Merged
Merged
Conversation
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]>
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:
Landing once CI is green. |
nihalpasham
approved these changes
Aug 12, 2026
3 of 4 tasks
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]>
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.
The one-word follow-up from the #805 review — "Your
--lockednote on the rootrun is a one-word follow-up; we'll take it."
The root
cargo deny checkwas the only cargo-deny invocation in the treewithout
--locked. The backend-workspace run added beside it in #805 has it, andso has every per-example run in
check-example-license-policy.shsince #681.It is not only an inconsistency
Without
--lockedthe root run re-resolves on the way past, so it can rewritethe very
Cargo.lockit is judging. Deleting one package block from thecommitted lock and running each form:
cargo deny --locked checkcannot update the lock file /…/Cargo.lock because --locked was passed to prevent thiscargo deny checkCargo.lockrewrittenSo 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.shgives for itscargo metadata --locked("a check that can rewrite its own input is not acheck").
No behaviour change today
The root lock is current: both forms report
advisories ok, bans ok, licenses ok, sources okat exit 0. The flag only fires once the lock drifts.Scope
Two command lines — the workflow step and the
check-guardsrecipe — plus acomment recording why. I left the two prose mentions of
cargo deny checkincomments alone: both describe which graph the root run reaches, which this flag
does not change, and threading
--lockedthrough sentences about workspaceboundaries would add noise rather than accuracy. Say the word if you'd rather
they matched verbatim.
Verification
just check-guardsgreen end to end (nine legs)..github/workflows/cargo-deny.ymlstill parses as YAML; thecheckjob nowruns
cargo deny --locked checkthen the backend run.remaining unpinned matches are backticked prose.
Cargo.lockbit-identical after the mutation test (git diffclean).