Skip to content

ci(naming-guard): make the reserved-prefix guard actually run - #644

Merged
nihalpasham merged 1 commit into
NVIDIA:mainfrom
vyncint:fix/naming-guard-fail-open
Aug 3, 2026
Merged

nihalpasham merged 1 commit into
NVIDIA:mainfrom
vyncint:fix/naming-guard-fail-open

Conversation

@vyncint

@vyncint vyncint commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #643.

What was wrong

The naming-guard step searches with rg, which the ubuntu-latest image does not ship. rg ... || true turned the resulting command not found into an empty result set, so the guard printed OK and exited 0 on every commit since fc0aae62 (2026-05-03) without ever reading a file.

From the latest main run (30748062109, conclusion success):

/home/runner/work/_temp/fb92a9b1-....sh: line 7: rg: command not found
OK: no hardcoded reserved-prefix literals outside reserved-oxide-symbols.

The step also finishes in ~6s, which is about what a search that reads nothing costs.

What this changes

Search with grep. It is in the runner's base image, so the tool cannot go missing. This is also why the diff does not just apt-get install ripgrep: that keeps the dependency and adds ~15s per run, and the || true would still hide a future failure.

Fail closed. grep exits 0 with matches, 1 with none, and >= 2 on error. Only 1 is treated as clean, so a search that cannot run fails the job rather than being mistaken for an empty result.

Self-test. This guard's failure mode is silently matching nothing, so before a clean result is believed it must match a known violation in a throwaway fixture. That is the part that would have caught the original bug on the day it was introduced.

One real violation, now fixed. With a working search, the guard's own pattern finds:

crates/llvm-export/tests/export_test.rs:1392:        "cuda_oxide_device_246e25db_standalone_export"

That is LEGACY_DEVICE_PREFIX plus a base name, built by hand. Line 810 of the same file already does it the sanctioned way, so this now uses reserved_oxide_symbols::LEGACY_DEVICE_PREFIX. The constructed symbol is byte-identical and the test still asserts the prefix is stripped to standalone_export.

Verification

CPU-only; no CUDA toolkit or GPU. I extracted the step's run: block from the YAML and exercised it six ways:

# Scenario Expected Result
1 Reworked guard, violation fixed pass exit 0
2 Reworked guard, violation restored fail exit 1, names file and line
3 Current guard, violation present, rg absent — exit 0, reproduces the bug with CI's two log lines
4 Reworked guard, search tool absent fail exit 1 via the self-test
5 Reworked guard, fresh violation in a new file fail exit 1
6 Reworked guard, prefix only in // and /// comments pass exit 0, exemption preserved

cargo test -p llvm-export --all-targets: 100 passed, 0 failed. cargo clippy -p llvm-export --all-targets -- -D warnings: clean. cargo fmt --check: clean.

The reserved-oxide-symbols literal guard check on this PR is the real signal: it should now take longer than 6s and still pass.

One open question, deliberately not bundled here

The step comment says it rejects any hardcoded cuda_oxide_* prefix, but the pattern matches only kernel|device|instantiate. The crate also owns CONSTANT_PREFIX, ARTIFACT_ANCHOR_PREFIX, and PTX_MERGE_REQUIRED_PREFIX. Widening the alternation surfaces one more hit:

crates/cuda-core/src/embedded.rs:236:            Some("cuda_oxide_artifact_anchor_246e25db_linked_0_0_0"),

artifact_anchor_symbol("linked", "0.0.0") produces exactly that string, but cuda-core does not currently depend on reserved-oxide-symbols, so fixing it adds a dev-dependency edge. That is a policy call rather than a bug, so I left it out. Happy to add it here or in a follow-up, whichever you prefer.

The guard shelled out to `rg`, which the ubuntu-latest image does not
ship. `rg ... || true` turned the resulting "command not found" into an
empty result set, so the step printed OK and exited 0 on every commit
since it was added without ever reading a file.

Search with `grep`, which is in the runner's base image, and treat only
grep's exit status 1 (no matches) as clean, so a search that cannot run
fails the job instead of passing it. Add a self-test that requires the
search to match a known violation in a temporary fixture before a clean
result is believed: this guard's failure mode is silently matching
nothing, so it has to prove it can still match.

Fix the one violation that exposes. An llvm-export test hardcoded the
legacy device prefix rather than building it from
`reserved_oxide_symbols::LEGACY_DEVICE_PREFIX`; the symbol it constructs
is byte-identical, and the test still asserts the prefix is stripped to
`standalone_export`.

Fixes NVIDIA#643

Signed-off-by: Vyncint Ng <[email protected]>
@nihalpasham nihalpasham added bug Something isn't working build-related Build scripts, toolchain discovery, or compilation setup labels Aug 3, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

Verified this end to end:

  • ran your exact pipeline against main and it finds exactly one violation,
  • the export_test line this PR fixes, so the guard comes back green and armed.
  • The canary self-test is good, it would have caught the original failure on day one, and failing closed on grep exit >= 2 removes the whole class.
  • Deferring the pattern-widening question (the other three prefixes) to a separate discussion is okay.

@nihalpasham
nihalpasham merged commit a77daf8 into NVIDIA:main Aug 3, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working build-related Build scripts, toolchain discovery, or compilation setup

Projects

None yet

Development

Successfully merging this pull request may close these issues.

naming-guard never runs: the reserved-prefix check shells out to ripgrep, which ubuntu-latest does not ship

2 participants