Skip to content

ci: move the reserved-prefix guard into a script - #835

Merged
nihalpasham merged 3 commits into
NVIDIA:mainfrom
vyncint:ci/naming-guard-script
Aug 12, 2026
Merged

nihalpasham merged 3 commits into
NVIDIA:mainfrom
vyncint:ci/naming-guard-script

Conversation

@vyncint

@vyncint vyncint commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #834. Both PRs edit the same Still CI-only: sentence in the
Justfile — #834 adds clippy's per-example pass to it, this one removes
naming-guard from it — so they conflicted. Rebasing resolved it with both edits
kept. Review only the second commit (cc59cfc8).

Please merge #834 first. If this one lands first, its squash carries #834's
change too and #834 becomes an empty duplicate.

naming-guard was the last CI gate with real logic and no script: a ~50-line
shell block inline in the workflow. So it could not be run before pushing, could
not be mutation-tested, and just check listed it as CI-only for exactly that
reason
.

scripts/check-reserved-prefixes.sh is that block, moved verbatim in behaviour —
same pattern, same canary self-test, same grep exit-status handling, same two
filters.

The reasoning comes with it

That block's comments are hard-won and worth keeping next to the code:

  • why bare cuda_oxide_ is deliberately not matched — pliron attribute keys,
    rustc --cfg names, dlopen probe symbols and temp directories live in that
    word-space and are not reserved link symbols;
  • why codegen_v1 needs its own alternation arm — the pattern is anchored to the
    opening quote, so a hardcoded modern prefix's embedded cuda_oxide_kernel_
    segment sits mid-string where the kernel arm can never reach it;
  • why a search that cannot run has to fail rather than report empty — the
    ripgrep incident, where rg … || true turned "command not found" into a clean
    result on every commit without reading a file.

Verified equivalent, not merely similar

check result
same verdict as the inline pipeline on this tree both report no violations
injected literal in a fresh file caught, with file and line
pure-comment mention of the prefix still allowed
reserved-oxide-symbols and its 45 legitimate literals still exempt
all nine guards after the rebase green

One deliberate change

The script reports error: on stderr like its eight siblings, rather than
emitting ::error:: annotations. That keeps its output identical locally and in
CI, at the cost of the PR-annotation nicety — the step still fails and the message
is still in the log. Say the word if you would rather keep the annotations; it is
a one-line difference.

The workflow now calls the script, check-guards runs it, and check's CI-only
list drops naming-guard.

`just check` claims to run CI's gates minus a named few, and two of its
recipes were narrower than the jobs they mirror. Both miss
`crates/rustc-codegen-cuda`, which carries its own `[workspace]` for the
rustc_private dylibs so `--workspace` from the root stops at that
boundary. The `test` recipe already handles that crate the same way; these
two never did.

  * clippy: CI lints three scopes -- root workspace, the codegen
    workspace, and once per example. The recipe ran only the first, and
    ran it as `--all-targets --lib --tests`, where the target-selection
    flags narrow what `--all-targets` would have covered and so skip bin
    and example targets CI lints -- `cuda-host/examples/` among them. Now
    `--workspace --all-targets`, matching CI, plus the codegen workspace.
  * doc-check: the docs gate builds this workspace's rustdoc separately
    under `-D warnings` too. That job is mine, from NVIDIA#725, and I did not
    add it here.

The per-example clippy pass stays CI-only, and `check`'s comment now says
so rather than implying clippy is covered in full: it is one clippy run per
example across 200-odd separate workspaces, which belongs in a CI job
rather than in a command someone waits on.

Verified: both widened recipes pass here -- `just clippy` clean across
both workspaces, `just doc-check` builds the codegen rustdoc
warning-free -- so this closes a coverage gap without landing new work.

Signed-off-by: Vyncint Ng <[email protected]>
naming-guard was the last CI gate with real logic and no script: a
50-line shell block inline in the workflow, so it could not be run before
pushing, could not be mutation-tested, and `just check` listed it as
CI-only for exactly that reason.

`scripts/check-reserved-prefixes.sh` is that block, moved verbatim in
behaviour -- same pattern, same canary self-test, same grep exit-status
handling, same two filters. The reasoning comes with it, and it is worth
keeping: it records why bare `cuda_oxide_` is deliberately not matched
(pliron attribute keys, rustc `--cfg` names, dlopen probe symbols and temp
directories live in that word-space and are not reserved link symbols),
why `codegen_v1` needs its own alternation arm, and why a search that
cannot run has to fail rather than report an empty result -- the ripgrep
incident, where `rg ... || true` turned "command not found" into a clean
result on every commit.

The workflow now calls the script, `check-guards` runs it, and `check`'s
CI-only list drops naming-guard.

One deliberate change: the script reports `error:` on stderr like its eight
siblings rather than emitting `::error::` annotations, so its output reads
the same locally and in CI. The step still fails and the message is still
in the log; the PR-annotation nicety is the cost.

Verified equivalent, not just similar: identical verdict to the inline
pipeline on this tree (no violations from either); an injected literal is
caught with file and line; a pure-comment mention is still allowed; and
`reserved-oxide-symbols` stays exempt with its 45 legitimate literals.
`just check-guards` green with nine guards.

Signed-off-by: Vyncint Ng <[email protected]>
@vyncint
vyncint force-pushed the ci/naming-guard-script branch from aaec565 to cc59cfc Compare August 12, 2026 10:32
@nihalpasham nihalpasham added build-related Build scripts, toolchain discovery, or compilation setup refactor Internal restructuring with no behavior change Depends Blocked on another PR/issue or an upstream dependency labels Aug 12, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

Gist: the last inline CI guard becomes a checked-in script, joining the eight check-*.sh siblings that just check-guards runs. The extraction preserves the regex, canary self-test, grep exit-status discrimination, and both filters byte-for-byte, and adds fail-closed hardening (missing-grep check, LC_ALL=C, cd-to-repo-root).

Verified here:

  • script output equivalent to the inline block on the current tree; canary still catches a planted cuda_oxide_kernel_ literal with file:line;
  • disclosed delta only: plain stderr error: lines instead of ::error:: annotations — fine as-is, the annotation add-back is a one-liner if we ever want inline PR annotations.

Lands after #834 (this branch stacks it); one stale Justfile docstring line will be tidied at landing.

Signed-off-by: nihalpasham <[email protected]>

# Conflicts:
#	Justfile
@nihalpasham nihalpasham removed the Depends Blocked on another PR/issue or an upstream dependency label Aug 12, 2026
@nihalpasham
nihalpasham merged commit 15fa9d9 into NVIDIA:main Aug 12, 2026
42 checks passed
nihalpasham added a commit that referenced this pull request Aug 13, 2026
…s in CI (#853)

The open-source review of commit 15fa9d9 confirmed everything from #812
fixed and left two items, both addressed here:

1. Source headers: scripts/check-book-api-names.sh and
   scripts/check-reserved-prefixes.sh landed after #812 merged (#819,
   #835) without the standard SPDX header. Both now carry it.

2. Third-party notices: the rangemap sub-crate under
   crates/fuzzer/rustlantis/ carries its own LICENSE-APACHE and
   LICENSE-MIT copies, which THIRD_PARTY_NOTICES did not mention. The
   Rustlantis entry now names that path; both texts are byte-identical
   to the rustlantis top-level ones.

The review also suggested a CI guard, since headers have now drifted
twice. scripts/check-spdx-headers.sh requires the two-line header on
every tracked *.rs *.sh *.py *.cu *.c *.h *.ll file outside the
vendored rustlantis subtree, with a checked exemption for the two
CUTLASS-derived BSD-3-Clause helpers the review accepted as-is. It runs
as a fourth job of the cargo-deny workflow and from 'just check-guards',
and CONTRIBUTING's License Headers section points at it.

Signed-off-by: nihalpasham <[email protected]>
nihalpasham added a commit that referenced this pull request Aug 17, 2026
… not (#957)

* build(just): check-guards runs the naming guard too, and says it does not

`check-guards` has run `scripts/check-reserved-prefixes.sh` since #835, but
both places that describe its scope name only two workflows:

  # Run the status-guard and cargo-deny CI jobs (needs cargo-deny, python3)
  # `check-guards` covers the status-guard and cargo-deny workflows in full

That script is naming-guard.yml's `reserved-symbols-guard` job, not a
status-guard one. The recipe is correct; the description undersells it, which is
the direction that costs someone a redundant CI round trip -- a contributor
touching a `cuda_oxide_*` literal reads this, concludes the reserved-prefix
guard is CI-only, and finds out after pushing.

Names all three workflows in both places. The mapping now checks out job for
job: status-guard's seven, naming-guard's one, and cargo-deny's four are the
eleven scripts plus two `cargo deny` invocations this recipe runs.

Comment-only; `just --list` and `just -n check-guards` are unchanged apart from
the wording.

Signed-off-by: Vyncint Ng <[email protected]>

* build(just): repair the check-guards detail paragraph too

The paragraph above the recipe still described coverage as status-guard
plus "all three cargo-deny jobs": it listed five of status-guard's
seven jobs (book-api-names and device-only-build were missing), the
cargo-deny workflow has four jobs (the SPDX source-headers job was
missing), and the naming-guard's reserved-prefix search went unnamed,
which is the same undersell this PR exists to remove. Also widen "either
workflow" to all three and rewrap the over-long merged line in the
check header comment.

---------

Signed-off-by: Vyncint Ng <[email protected]>
Co-authored-by: nihalpasham <[email protected]>
nihalpasham pushed a commit that referenced this pull request Aug 17, 2026
`check-spdx-headers.sh` globs `*.rs *.sh *.py *.cu *.c *.h *.ll`. Eight
tracked first-party files fall outside that list and are therefore unchecked:

  cuda-oxide-book/_static/css/custom.css
  cuda-oxide-book/_static/css/lightbox.css
  cuda-oxide-book/_static/css/nvidia-sphinx-theme.css
  cuda-oxide-book/_static/js/lightbox.js
  cuda-oxide-book/_static/js/spa-nav.js
  cuda-oxide-book/_templates/footer.html
  cuda-oxide-book/_templates/globaltoc.html
  flake.nix

All eight already carry the standard two-line header, so this changes no
file and fails nothing today. That is exactly the hazard the guard's own
header describes: the OSRB review fixed 32 files in #812, and the next two
scripts to land (#819, #835) arrived without headers because nothing was
watching that extension. The same is true here one file type over -- a new
book stylesheet or template can land bare and CI stays green.

CONTRIBUTING already names HTML's comment form in the header policy, so
these files are in policy scope; only the guard's glob was short.

Verified: the guard passes unchanged over the extended scope (1803 files,
up from 1795), and stripping the header from `flake.nix` or from
`_static/js/spa-nav.js` now fails the run, where before it passed.

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 refactor Internal restructuring with no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants