Repository navigation
tools: a check that cannot list or read part of the tree ends with a named error instead of passing - #173
Conversation
83bd9e0 to
e95d2ce
Compare
There was a problem hiding this comment.
Verdict: MUST_FIX: Remove the intermittent self-test failure and consolidate the repeated self-test runner.
Must fix
1. Supply the no-file fixtures without a background writer
tools/check-loads.sh:84 and tools/check-loads.sh:91. Both functions return without reading stdin. If the background printf runs after the reader closes and SIGPIPE is ignored, its “Broken pipe” message enters out. The assertions at lines 85 and 92 then fail on a correct tree; blk_loadscan returns 1 and check-recipes fails. Repeated runs reproduced the line 84 race; delaying either writer reproduced both failures.
Fixing these two inputs now prevents intermittent failures in every check-recipes run. Replace the two assignments, respectively:
rc=0 out=$( (raw_loads <<< '2:kern::load(x)' && printf '%s' "$hits") 2>&1) || rc=$? rc=0 out=$( (families_of && printf '%s' "$families") 2>&1 <<< $'#[cuda_module]\nmod kern {') || rc=$?The here-strings preserve the test that stdin must remain unread.
2. Give the four shell self-test runners one owner (R14)
tools/check-recipes.sh:197 and tools/check-recipes.sh:218. All four new wrappers repeat the same execution, failure report and last-line output rule.
Consolidating them now removes repeated bodies and four output-variable names before another checker copies them. Replace the four function definitions with:
blk_scancheck() {
local checker=$1 out
if ! out=$(bash "$(dirname "$0")/check-$checker.sh" --self-test 2>&1); then
printf '%s\n' "$out" >&2
echo "check-recipes: the check-$checker self-test failed" >&2
return 1
fi
printf '%s\n' "${out##*$'\n'}"
}
blk_unsafecount() { blk_scancheck unsafe; }
blk_archscan() { blk_scancheck arch; }
blk_loadscan() { blk_scancheck loads; }
blk_commentscan() { blk_scancheck comments; }This keeps the parallel blocks and their outputs. The function bodies shrink from 32 lines to 13; one helper and two local names replace four output-variable names.
Non-blocking
⚠ Cover the lever scanner's refusal: tools/check-levers.sh:186. This check has no automated refusal fixture. Removing onerror=unlisted restores the unreadable-directory escape. Add a fixture in the existing check-recipes harness that asserts the named error and exit 2; dropping the callback must fail it.
Checked
Duplicates: all four added runner bodies repeat the same execution, failure report and last-line rule.
Complexity: no Rust file changed; diagnostics reports that dryer and crapper did not run. The diff changes tools, outside engine hot paths.
Silent failure: the load helpers return without reading stdin when given no files. The lever walk reports a listing failure and exits 2; removing its callback silently skips that input.
Tests: delayed writers with SIGPIPE ignored reproduced both failures. Both no-file guard mutants fail with the proposed here-strings. Runner outputs and exit codes match on success and failure; both inline replacements parse in the full script.
Escape catalog: the retained must-fix findings do not match C1–C4.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
| rc=0 out=$( (raw_loads <(printf '// kern::load(x)\n') \ | ||
| <(printf 'kern::load(anchor).map(|loaded| loaded.as_cuda_module().clone())\n') && printf '%s' "$hits") 2>&1) || rc=$? | ||
| expect comment-and-idiom "$rc $out" "0 " | ||
| rc=0 out=$( (raw_loads < <(printf '2:kern::load(x)\n') && printf '%s' "$hits") 2>&1) || rc=$? |
There was a problem hiding this comment.
With SIGPIPE ignored, a late background writer can report a broken pipe after raw_loads returns; a here-string keeps the no-input assertion deterministic.
| rc=0 out=$( (raw_loads < <(printf '2:kern::load(x)\n') && printf '%s' "$hits") 2>&1) || rc=$? | |
| rc=0 out=$( (raw_loads <<< '2:kern::load(x)' && printf '%s' "$hits") 2>&1) || rc=$? |
| rc=0 out=$( (families_of <(printf '#[cuda_module]\npub mod kern {\n') <(printf '#[cuda_module]\n// x\nmod other;\n') && | ||
| printf '%s ' $families) 2>&1) || rc=$? | ||
| expect families "$rc $out" "0 kern other " | ||
| rc=0 out=$( (families_of && printf '%s' "$families") 2>&1 < <(printf '#[cuda_module]\nmod kern {\n')) || rc=$? |
There was a problem hiding this comment.
With SIGPIPE ignored, a late background writer can report a broken pipe after families_of returns; supply the unused fixture synchronously.
| rc=0 out=$( (families_of && printf '%s' "$families") 2>&1 < <(printf '#[cuda_module]\nmod kern {\n')) || rc=$? | |
| rc=0 out=$( (families_of && printf '%s' "$families") 2>&1 <<< $'#[cuda_module]\nmod kern {') || rc=$? |
…er.sh check-comments.sh kept the rule in its own `g`: grep's 1 (no line) is an answer and any other status ends the check by name. The checks that read an empty grep result as "nothing found" need the same rule, so it moves to tools/grep-answer.sh as grep_answer <tool> <grep arguments>, sourced the way tools/arch.sh is, and check-comments.sh calls it in place of `g`. The verdicts are unchanged. The refusal line no longer repeats grep's arguments (a caller may pass hundreds of files) and reads "check-comments: grep exit 2 (its message above), no verdict"; grep's own message above it names the file or the pattern.
…ith exit 70 instead of counting zero count ended its grep pipeline with `|| true`, so a file grep could not read (exit 2) printed a count over the lines it did read and returned success, and the ratchet accepted the count as below its pin. count now runs grep through grep_answer, so grep's "no line" is 0, and any nonzero status of the pipeline (grep, wc or tr) ends the check. collect read each directory through a process substitution, whose status nothing saw, and skipped a directory `[ -d ]` could not see, so a crate directory find could not enter counted zero the same way. collect now lists the whole crate directory once through list_rs, which ends the check on a find failure, and keeps src, tests, benches and build.rs from that list. The listing takes the crate's build.rs whatever its type, as the old `[ -f ]` followed a link: a build.rs that is a link is counted, and a broken one reaches grep and ends the check. The crate list and the ratchet read check their find and grep the same way. The argument check read only the first argument; any argument list other than none or `--self-test` now ends the check with 64. check-unsafe.sh --self-test runs count, list_rs and collect on fixed input and missing paths, and collect on a crate in a temporary directory: its build.rs a link (counted with src and benches, not examples) or a broken link (exit 70), and a tr on PATH that fails after grep, and the script with an extra argument. check-recipes.sh runs it through blk_scancheck, which runs a check's --self-test and prints its last line, or its full output and a named error.
The architecture listing and the five rules' scans (rule 1's find and grep, and the grep pipelines of rules 2 to 5) move into functions that take the paths to read and set the variable their rule reports, and the rules call them with the same paths as before. No scan changes: on this tree the architecture list and every scan's result are the same as before, byte for byte. The next commit tests the listing and each scan on a missing path, which needs a scan it can call with another path.
…no verdict instead of passing
Each scan ended its pipeline with `|| true`, and four of the five sent grep's stderr to /dev/null, so a file grep
could not read (exit 2) was read as a file with no hit: with one .rs file at mode 000 the check ended `check-arch: ok`,
exit 0. Rule 1's find did the same for a directory it could not enter. The architecture listing's find sent its
stderr to /dev/null, so with a crate directory at mode 000 the check ended with exit 1, the violation code, and no
line. Every grep of the scans now runs through grep_answer, so grep's "no line" is an answer and any other failing
stage, or rule 1's find, ends the check by rule with exit 2, the code the check already gives an unknown argument.
The listing's find ends it the same way and names the directory. Rule 4's three patterns run as one grep (`-e` each),
whose status is the pipeline's, where a `{ grep; grep; grep; }` group gave only its last grep's; the lines it finds
are the same after `sort -u`.
Rule 2's awk took the keys pattern with -v, which processes escapes: BSD awk and gawk read each `\.` as `.`, any
character, and gawk also printed a warning on stderr. It now reads the pattern from ENVIRON, so its second pass
matches the same literal dot as the grep; on this tree the result is the same.
check-arch.sh --self-test runs the listing on a missing path (no verdict), and each scan on a missing path (no
verdict) and on /dev/null (clean: nothing on stdout or stderr). check-recipes.sh runs it.
…d ends the check with exit 70 instead of passing The load scan read its find, xargs and grep pipeline through a process substitution and ended it with `|| true`, so a file the later grep could not read, or a find that failed, printed an error and left no hit, and the check passed. xargs also folds grep's 1 and 2 into one status. The family scan, which runs first over the same files and more (`find | sort | xargs awk`), stopped on such a file with xargs' status and no line of its own: 1 on the Mac, the violation code here, and 123 from GNU xargs. The .rs files under crates/ are now listed once, with find checked. The family scan runs awk on that list, and the load scan hands the list's src/ paths to one grep through grep_answer (about 860 and 800 paths, well under ARG_MAX). The grep takes -H, so a list of one file still prints the file name the next stage reads its hit by. A failing stage of either ends the check with 70, and grep's "no line" is an answer. The hits are read from a variable. Any argument list other than none or `--self-test` ends the check with 64. check-loads.sh --self-test runs the load scan on fixed input (a load in one file and in two, no load, another family's load, a comment and the idiom), the family scan on two families, both with no file and on a missing file, and the script with an extra argument. check-recipes.sh runs it.
…d-word scan are functions The listing of the .rs files under crates/*/src and crates/*/tests moves into rs_files, which takes the crates directory, the comment reader's call into comment_lines, which takes the files, and the retired-word scan (the line grep and the wrapped-word awk) into retired; RETIRED_WORDS moves up with them. No scan changes: on this tree the listing is the same 858 paths and the check's output is the same as before, byte for byte, under bash 3.2 and bash 5. The next commit tests each on input that cannot be read, which needs a listing it can call with another path and a reader and a scan it can call alone.
… ends the check with no verdict instead of passing
The .rs listing fed find's output to the loop through a process substitution, so find's status was lost: with one
directory under crates/<crate>/src at mode 000 the check read the files it could list and ended `check-comments: ok`,
exit 0. A crate directory at mode 000 dropped out earlier, at the crates/*/src glob. rs_files now lists the whole
crates directory in one find whose status it checks, and keeps the src and tests paths of each crate; a directory it
cannot enter ends the check. On this tree the listing is the same 858 paths.
The retired-word scan used git grep, which reports a file or a directory it cannot open only on stderr ("failed to
stat", "could not open directory") and still exits 0 or 1, so an unreadable tracked file, a tracked directory or an
untracked one at mode 000 passed as one with no retired word. grep_answer cannot own this: git grep's status does not
carry the failure. Both git greps of the scan (the line search, and the listing the wrapped-word awk reads) now run
through gg, which keeps git grep's stderr apart from its output and ends the check on any message there or on a
status other than 0 or 1. The listing is NUL-separated, so it goes through a temporary file, and an awk that cannot
read a listed file ends the check too. An ignored directory at mode 000 stays silent (git does not enter it), and a
tracked file deleted from the work tree is skipped without a message, as before. The patterns and the awk program are
unchanged.
These end with exit 2, the code the check already gives a grep that cannot read under tools/ (grep_answer under set
-e). The comment reader's failure (an .rs file it cannot open stops it with exit 1) now ends with 2 as well, its own
code in the message; it ended with that code, so an unreadable source looked like a violation. 1 stays a violation,
and the header now lists the exit codes. Any argument list other than none or `--self-test` ends the check with 64,
and grep-answer.sh is sourced at the top, as in the other checks.
check-comments.sh --self-test runs the listing on a directory in a temporary place (src and tests kept, benches,
build.rs and oxide-ice-unroll left out) and on a missing path, the reader on a missing file, the scan with a git
that reports an unreadable directory in either git grep, fails, or lists a file that is not there, and the script with
an extra argument. check-recipes.sh runs it.
…he check instead of skipping it os.walk skips a directory it cannot list unless it gets an onerror, and five checks walked the tree without one. With a violation planted in a directory at mode 000, each ended green, exit 0: check-levers (an in-place env read under crates/app/src, or a BLOOMERY_* name no row names under tools/), check-defaults (an off-default pin under crates/gpu-gates/src), check-ptx-names (a kernel with no row under crates/gpu/src), check-recipes' draft-read block (a printf of the draft path in a script under tools/) and boxq-check's codes-check (a script under tools/ that produces one of the box queue's exit codes). check-defaults also skipped a crate's tests/ when `os.path.isdir` answered False, which it does for a tests/ inside a crate directory at mode 000. check-levers also skipped a build.rs that `os.path.isfile` did not see, such as a broken link, and stopped on a source it could not read with a traceback and exit 1, its violation code. Each walk now has an onerror that ends the check the tool's own way: check-levers with exit 2 (no verdict, now in its header), check-defaults with its named error (exit 65), check-ptx-names with the exit 2 main_check already gives an unreadable input, the draft-read block with exit 2 and a line that names the directory, which the block returns instead of reporting a draft-path hit, and boxq-check with its existing unreadable refusal (exit 69). A top that is not there still yields nothing (a crate with no tests/; check-defaults now asks isdir of the crate directory, not of its tests/), and check-ptx-names still refuses a crate src/ that is not there by name. check-levers takes a crate's build.rs whenever the name exists, a link included, and reads every file through one reader that ends the check with exit 2 and the path when it cannot open or read it. The self-tests of check-defaults (gpu-gates/src and a crate's tests/), check-ptx-names and boxq-check and the draft-read block's fixtures each walk a directory at mode 000 when not run as root (a mode does not bind root); boxq-check's also runs on a tools/ that is a file. check-levers.sh gets a --self-test that runs the check on a temporary tree whose crates/c/src is a file, (not as root) holds a directory at mode 000, whose build.rs is a broken link, and whose .cargo is a file; each wants exit 2 and the line that names the path. The check moves into a function of the root it reads for that, and any argument list other than none or `--self-test` ends it with 64. check-recipes.sh runs the self-test.
Twenty-five blocks ran a tool's --self-test with the same body: run it, and on failure print its full output and a named error, else print its last line. tool_selftest SCRIPT is that body once, and each of those blocks is a one-line call. blk_scancheck runs the check-*.sh self-tests through it with the path composed, as before, so the scripts recipes.py reads check-recipes as running stay the same. The error names the script's path under tools/ without `.sh` (ref/lease, release/build). blk_cardtests, blk_carry and blk_gpugate keep their own bodies: the first runs a script with no --self-test, the second also holds the release-build recipe's order, and the third keeps the full transcript for the proc leg.
e95d2ce to
4ff5ef4
Compare
|
Fixed in the same eight commits plus a ninth, rebased onto main
The t0 failure, A further review of the branch found more of the same kind, fixed in the commits that own each script:
Runs at
The PR body's "What I ran" section has the commands and the numbers. |
There was a problem hiding this comment.
Verdict: CLEAN: The remaining finding concerns test coverage and is non-blocking.
Non-blocking
⚠ Test the literal-dot rule directly: tools/check-arch.sh:149.
The test scans empty input. Restoring awk -v keys="$KEYS" changes \. to ., but BSD awk emits no warning, so lits-clean still passes; the PR body reports this.
Add a fixture with "blk." and "deepseek2x" on one line and assert no hit. Also assert that a real dotted architecture prefix is reported. These assertions cover the matching behavior on macOS.
Checked
Duplicates: the cited scanner uses the shared grep-status owner in tools/grep-answer.sh.
Complexity: no Rust file changed; diagnostics report that dryer and crapper did not run.
Silent failure: scan_lits propagates scan errors to nov; grep_answer distinguishes an empty result from a read error.
Tests: running the exact awk filter and its -v mutant confirmed that both pass empty input. The proposed negative fixture produces no hit at head and one with the mutant; both report a real dotted prefix.
Gates: rule 2 retains its existing exclusion filters.
Escape catalog: no C1–C4 exception applies to this finding.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
The review is done and the contribution check passed, so I'm merging this. |
What and why
Closes #151.
tools/check-unsafe.shended its count with|| true, so a source file or crate directory it could not read counted as zero, and the ratchet passed because a count below its pin only prints "can come down".tools/check-arch.sh,tools/check-loads.shandtools/check-comments.shlost a failing grep, find or git grep the same way, and five Python checks (check-levers.sh,check-defaults.py,check-ptx-names.py,boxq-check.py codes-checkand the draft-read block ofcheck-recipes.sh) walked the tree withos.walk, which skips a directory it cannot list. Each of them now ends with a named error when it cannot list or read what it checks. The shell checks share one sourced rule for grep's exit status, and every changed check has a self-test case for the new refusal, run bytools/check-recipes.sh, whose tool self-test blocks now share one runner. The new check-arch self-test also exposed an existing bug in rule 2: its awk took the keys pattern through-v, so BSD awk and gawk read\.as any character.The defect
With
crates/gpu-vision/src/attn.rsat mode 000, the basecheck-unsafe.shprintedPermission deniedthree times, counted 65 blocks forgpu-visioninstead of 97, and endedcheck-unsafe: ok, exit 0. Withcrates/gpuat mode 000 it countedgpuas 0/0/0 against its pins 1747/194/10 and still endedok, exit 0:collectskipped every directory that[ -d ]could not see, and read eachfindthrough a process substitution whose status nothing checked.check-arch.shhad the same|| trueat the end of each scan, and four of the five sent grep's stderr to/dev/null. The same unreadable file left it atcheck-arch: ok, exit 0, so a violation in that file would pass. Its architecture listing also sentfind's stderr to/dev/null: with a crate directory at mode 000 the check ended with exit 1, its violation code, and printed nothing.check-loads.shread its load scan (find | sort | xargs grep | grep ...) through a process substitution ending in|| true, so a file the grep stage could not read left no hit and the scan passed. Its family scan (find | sort | xargs awk) runs first and did stop on such a file, but with xargs' status and no line of its own: 1 on macOS, which is the violation code, and 123 from GNU xargs.check-comments.shread its file list throughdone < <(find "${dirs[@]}" ...), and a crate directory that thecrates/*/srcglob could not see was left out beforefindran. Withcrates/app/src/arch/qwen3moeat mode 000 it endedcheck-comments: okover 856 files instead of 858, exit 0; withcrates/gpuat mode 000, over 710 files, exit 0. Its retired-word scan runsgit grep --untracked, which printsfailed to statorcould not open directoryon stderr and still exits 0 or 1. WithREADME.md,docs/or an untracked directory at mode 000 the check endedok, exit 0, so a retired word there would pass.The Python walks had no
onerror. With a violation planted in a directory at mode 000, each check ended green, exit 0: check-levers (an in-place env read undercrates/app/src, or aBLOOMERY_*name no row names undertools/), check-defaults (an off-default pin undercrates/gpu-gates/src), check-ptx-names (a kernel with no row undercrates/gpu/src), the draft-read block (a printf of the draft path in a script undertools/) and boxq-check's codes-check (a script undertools/that produces one of the box queue's exit codes). check-levers also skipped abuild.rsthatos.path.isfiledid not see, such as a broken link, and stopped on a source it could not read with a Python traceback and exit 1, its violation code.The commits
tools: one owner for a check's grep exit rule, sourced from grep-answer.sh.tools/check-comments.shalready had the rule in its owng: grep's 1 (no line) is an answer, and any other status ends the check. It moves totools/grep-answer.shasgrep_answer <tool> <grep arguments>, sourced the waytools/arch.shis. Because grep's 1 returns 0, a pipeline ofgrep_answerstages underpipefailfails only on a real error in one of its stages.check-comments.shcalls it in place ofg, and its verdicts are unchanged. Its refusal line no longer repeats grep's arguments, because a caller may pass hundreds of files; grep's own message above it names the file or the pattern.check-unsafe: a source that cannot be listed or read ends the count with exit 70 instead of counting zero.countruns grep throughgrep_answer, and any nonzero status of its pipeline (grep,wcortr) ends the check:check-unsafe: cannot count the lines of a source file (exit 2, above), exit 70. The header already gives 70 to a check that cannot read what it counts.collectlists the whole crate directory once throughlist_rs, which ends the check on afindfailure (cannot list the .rs files under crates/<crate> (find failed, above)), and keepssrc,tests,benchesandbuild.rsfrom that list. So a crate directory thatfindcannot enter ends the check. So does any directory under it, counted or not, such as an unreadableexamples/. I took that over a per-directory walk, because the walk cannot tell a missing directory from one it cannot see.build.rswhatever its type, because the old[ -f ]followed a link. Abuild.rsthat is a link is counted as before, and a broken one reaches grep and ends the check. Other links under the crate are not followed, as before.findand grep the same way. An unreadable ratchet now ends withcannot read tools/unsafe-ratchet.txt (exit 2, above)instead of "holds no crate line".--self-test --unknownran the self-test. Any argument list other than none or--self-testnow ends the check with 64.counta here-string, so noprintfis left writing into a pipe thatcountnever reads. An extra-argument case runs the script with'' extra.check-recipes.shgetsblk_scancheck <checker>, which runstools/check-<checker>.sh --self-testand prints its last line, or its full output and a named error. Each checker's block in this and later commits is one line that calls it.check-arch: each scan is a function of the paths it reads. The architecture listing and the scans of rules 1 to 5 move into functions that take the paths to read and set the variable their rule reports, so the self-test can call each one with a missing path. Nothing else changes: on this tree the architecture list and every scan's result (the hits, the dispatch spans and the spawn counts) are the same as before, byte for byte.check-arch: a scan whose grep or find cannot read the tree ends with no verdict instead of passing. Every grep of the scans runs throughgrep_answer, and a failing stage, or rule 1'sfind, ends the check by rule with exit 2, the code the script already gives an unknown argument (for examplecheck-arch: rule 2 cannot read crates tools/ref (exit 2, above), no verdict). The architecture listing'sfindkeeps its stderr and ends the check the same way, naming the directory. Rule 4's three patterns run as one grep with three-e. The old{ grep; grep; grep; }group returned only its last grep's status. The lines rule 4 finds are the same aftersort -u. Rule 2's awk took the keys pattern with-v, which processes escapes, so BSD awk and gawk read each\.in it as., any character, and gawk also printedawk: warning: escape sequence `\.' treated as plain `.'on stderr. The awk now reads the pattern fromENVIRON, so its second pass matches the same literal dot as the grep. On this tree the result is the same.check-loads: a source file the family or load scan cannot list or read ends the check with exit 70 instead of passing. The.rsfiles undercrates/are listed once, withfindchecked. The family scan runs awk on that list and the load scan hands the list'ssrc/paths to one grep throughgrep_answer(about 860 and 800 paths, well under ARG_MAX), so neither goes through xargs, which reports grep's 1 and 2 as the same status. The grep takes-H: with a list of one file it printed no file name, and the next stage, which readsfile:line:text, dropped the hit. A failing stage of either ends the check with 70 and a line that names the scan, and grep's "no line" is an answer. The hits are read from a variable, not a process substitution. Any argument list other than none or--self-testends the check with 64. The self-test runs the load scan on one file and on two, and hands the two cases that must not read stdin a here-string, so no writer is left running when the scan returns, and it puts the missing file after the readable one, because BSD awk stops at a file it cannot open.check-comments: the source listing, the comment reader and the retired-word scan are functions. The.rslisting moves intors_files, which takes the crates directory, the comment reader's call intocomment_lines, which takes the files, and the retired-word scan (the line search and the wrapped-word awk) intoretired, so the self-test can call each alone. Nothing else changes: on this tree the listing is the same 858 paths and the check's output is the same as before, byte for byte.check-comments: a source or a tree file the scans cannot list or read ends the check with no verdict instead of passing.rs_fileslists the wholecratesdirectory in onefindwhose status it checks, leaves outoxide-ice-unrollas before, and keeps each crate'ssrcandtestspaths. A directory it cannot enter, a crate directory included, ends the check:check-comments: cannot list the .rs files under crates (exit 1, above), no verdict. The status is the pipeline's,findorsort, so the line does not name the stage.grep_answercannot own thegit grepcase, because git grep's status does not carry the failure. Both git greps of the scan (the line search, and the listing the wrapped-word awk reads) now run throughgg, which keeps git grep's stderr apart from its output and ends the check on any message there or on a status other than 0 or 1:check-comments: git grep cannot read every file of the tree (above), no verdict. The listing is NUL-separated, so it goes through a temporary file that anEXITtrap removes, and an awk that cannot read a listed file ends the check too. An ignored directory at mode 000 stays silent, because git does not enter it, and a tracked file deleted from the work tree is skipped without a message, as before. The patterns and the awk program do not change.tools/could not read (grep_answerunderset -e). A failing comment reader (tools/check-comment-only.py --comments, which stops with exit 1 on an.rsfile it cannot open) now ends with 2 as well and names its own code in the message; before, it ended with that code, so an unreadable source looked like a violation. 1 stays a violation, and the header now lists the exit codes. Any argument list other than none or--self-testends the check with 64, andgrep-answer.shis sourced at the top, as in the other checks.tools: a Python check's tree walk that cannot list a directory ends the check instead of skipping it. Each walk gets anonerrorthat ends the check the tool's own way: check-levers with exit 2 (no verdict, now in its header), check-defaults with its named error (exit 65), check-ptx-names with the exit 2 itsmain_checkalready gives an unreadable input, the draft-read block with exit 2 and a line that names the directory, which the block returns instead of reporting a draft-path hit, and boxq-check with its existingunreadablerefusal (exit 69). A top that is not there still yields nothing, so a crate with notests/is fine, and check-ptx-names still refuses a cratesrc/that is not there by name. check-levers takes a crate'sbuild.rswhenever the name exists, a link included, and reads every file through one reader that ends the check with exit 2 and the path when it cannot open or read it. It moves into a function of the root it reads and gets a--self-testthat runs it on a temporary tree whosecrates/c/srcis a file, (when not run as root) holds a directory at mode 000, whosebuild.rsis a broken link, and whose.cargois a file; any argument list other than none or--self-testends it with 64. check-defaults also skipped a crate'stests/whenos.path.isdiranswered False, which it does for atests/inside a crate directory at mode 000; it now asksisdirof the crate directory instead, and its self-test hides a crate'stests/as well asgpu-gates/src/bin. boxq-check's self-test runs codes-check on atools/that is a file and (when not run as root) on a directory at mode 000 undertools/that holds anexit 81script.check-recipes: a tool's self-test block runs through one runner. Twenty-five blocks ran a tool's--self-testwith the same body: run it, and on failure print its full output and a named error, else print its last line.tool_selftest SCRIPTis that body once, and each of those blocks is one line.blk_scancheckruns the check-*.sh self-tests through it with the path composed, as before (below). The failure line names the script's path undertools/without.sh(ref/lease,release/build).blk_cardtests,blk_carryandblk_gpugatekeep their own bodies: the first runs a script with no--self-test, the second also holds the release-build recipe's order, and the third keeps the full transcript for the proc leg.check-recipes.shruns the five shell self-tests throughblk_scancheckas the blocksunsafecount,archscan,loadscan,commentscanandleverscan, and already runs the self-tests ofcheck-defaults.py,check-ptx-names.pyandboxq-check.py.blk_scancheckcomposes the checker's path ("check-$1.sh") on purpose. A literalcheck-levers.sh,check-arch.shorcheck-comments.shincheck-recipes.shputs that script in the scriptstools/recipes.pyreadscheck-recipesas running; through thetools/ref/card-tests/run.shstring in check-levers' FIXTURES that set then reachestools/ref/lcpp-warm.sh, whose${LCPPBIN}read makescheck-recipesnever skip, andrecipes.py --self-testfails. With the composed path that set is the same as main's at the head, and the filesscript_closuregivescheck-recipesare main's plustools/grep-answer.sh. The shell self-tests use fixed input, paths that do not exist, and small fixtures in amktemp -ddirectory that they remove: a crate whosebuild.rsis a link or a broken link, a crates directory for the listing, and atronPATHthat fails after grep. check-comments' self-test puts a shell function in place ofgitthat warns, fails, or lists a file that is not there. check-levers' self-test is the one shell case that makes a directory unreadable (mode 000), and it runs that case only when not run as root; its other cases run as any user. Each changed shell check's self-test also runs the script once with an extra argument and wants 64. A missing path ends in.rsbecause BSD grep with-r --include='*.rs'skips a missing directory operand without an error. The Python cases need a directory at mode 000, so they run only when the test is not run as root, because a mode does not bind root; boxq-check'stools/that is a file runs as any user.Same defect elsewhere
tools/recipes.pyalso walks trees (_host_sources,shipped_filesand the data digest). I did not check those walks in this change. The otheros.walkusers (tools/seed-target.sh,tools/type-census.py's self-test andtools/review/*.py) are not pass/fail checks over the tree.tools/lds-scan.shkeeps its own copy of grep's exit rule ([ "$rc" -le 1 ] || fail ...); it is correct and outside the check scripts this change touches.justfileat the top ofcheck-recipes.shend in|| true, but an unreadablejustfilestopspython3 tools/recipes.py check, the script's first block, with exit 2.Code shape
grep_answerintools/grep-answer.shis the one owner of grep's exit rule for the check-*.sh scripts;check-comments.sh'sgis gone. Incheck-unsafe.sh,countandlist_rsare the one owner for counting and for listing; incheck-loads.sh, one listing feeds both scans.check-comments.sh'sggis not a grep exit rule: it reads git's stderr, because git grep's status does not report the failure. Each Python check keeps its walk'sonerrornext to its own exit code, because the four checks end in four different ways.|| trueendings, the2>/dev/nullon the scans and on the architecture listing, the process substitutions (check-comments' included), check-loads' xargs stages and check-comments' git grep pre-pass are gone.\.as any character.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up. No Rust changes.Duplication found or removed (
path:line), or "none":tools/check-comments.sh:38(g), nowgrep_answerintools/grep-answer.sh, which check-unsafe, check-arch and check-loads use too. Intools/check-recipes.sh,tool_selftestreplaces the body that 25 older self-test blocks repeated (blk_boxtracks,blk_loadgroups,blk_lcppfitand the others), andblk_scancheckruns the five check-*.sh self-tests through it. The five shell self-tests each define a three-lineexpectand the same tally; one sourced owner would trade those for a new file and fivesourcelines, so I left them.What I ran
At the head,
4ff5ef4bThe commits are
df1c160e,522bc685,d2faac01,ae6c4952,f1475c92,3d492fc3,e52b721f,4ecd736aand4ff5ef4b, on98eb61db. The Linux runs are on an aarch64 Ubuntu 24.04 host (GNU grep 3.11, GNU Awk 5.2.1, bash 5.2.21, Python 3.12.3) as a normal user. The macOS runs are on an Apple M4 Pro (macOS 27.0.1) under/bin/bash3.2.57 and bash 5.3.20.The same lines come out on the Linux host and on macOS under both shells. On the Linux host each of the nine commits on its own parses and passes every self-test it has. Each of the five shell self-tests ran 20 times there with the default SIGPIPE and 20 times with SIGPIPE ignored by the parent, with 0 failures in all ten loops. On the real tree each check exits 0: check-arch
ok, check-unsafe 25 crates, 2691 blocks, 381 fns and 26 impls, each at its pin, check-loads 77 families, check-comments 865 files, check-leversok, andboxq-check.py codes-checkno other tool or recipe produces them.Each clause reverted alone, in the work tree at the head:
onerrorbuild.rsback toos.path.isfileopentools/and.cargowalk back toos.walk-Hcountwithout its no-file return-v keys="$KEYS"\.as.without a warningonerrortools/that is a file)tests/walk back toos.walkCommit 9 changes only the name in a folded block's failure line. With it, the scripts
tools/recipes.pyreadscheck-recipesas running are the same as on main.just mac-static 98eb61dbat4ff5ef4bon an Apple M5 (macOS 27.0.1), with check-recipes' parallel blocks limited to three at a time: ok in 134 s. fmt-check has 0 diff blocks, lint has 41 warnings (the ratchet's 41), every check exits 0, and check-recipes prints the five checkers'self-test oklines and the other self-test blocks' lines and endscheck-recipes: ok. Its blocks includerecipes.py --self-test, which holdscheck-recipesto its never-skip answer.At the previous head,
ba79929cThese runs were made at
643f3afa, which has the same tree asba79929c(basecdb6638e); only a commit message differs. Besides the Linux host above, they used an Ubuntu 24.04 container as root, whereawkis mawk 1.3.4. The five shell self-tests printedself-test okas root in the container too. Each ran 50 times on the Linux host with the default SIGPIPE and 50 times with it ignored, with 0 failures in all ten loops. At the reviewede95d2cea, two loops with SIGPIPE ignored failed check-loads 40 and 35 times in 50 (no-file 34 times and families-no-file 7 times in the second), one failed check-unsafe 0 times, and the default loop failed check-arch 50 times in 50 on gawk (lits-clean).On the real tree,
bash tools/check-arch.shprintedcheck-arch: ok, exit 0, at both heads. On the Linux host stdout was the same at both, and stderr was 56 bytes (the gawk warning) ate95d2ceaand empty at643f3afa. There stderr was empty in the root container (mawk) too, and on macOS the two heads printed the same with no stderr. As root in the container, the check-levers walk withoutonerrorturned src-file red.bash tools/check-recipes.shon the Linux host printed the fiveself-test oklines from its blocks. The host has nocargo, nojustand no numpy, so the blocks that need them were red there (rc 2). Upstream3e191b1bon the same host gave the same red blocks, and the only other lines that differed were the newleverscanline and the draft-read count, 151 shell files against 150, because commit 1 addstools/grep-answer.sh.just mac-static 3e191b1bon an Apple M5, a diff against an ancestor of that base: ok in 117 s, fmt 0 diff blocks, lint 41, every check exit 0.Earlier runs
The runs in this section were made at earlier heads of the same commits. Since then the commits changed in the self-test inputs, rule 2's awk,
blk_scancheck, check-levers and its self-test, check-loads' grep, the argument checks and boxq-check, gained commit 9, and were rebased onto98eb61db. The runs by hand are on an Apple M4 Pro (macOS 27.0.1) with BSD grep 2.6.0, BSD find and BSD xargs, under both the system/bin/bash3.2.57 (the shell the headers name) and bash 5.3.20, each script run by the same shell as its test. The commits areb5f83464,7464fde8,f111bf94,cfc30efe,de7f04c8,54a9d3c6,3dd980a6ande95d2cea, on84f77b01. The runs below were made before the rebase onto84f77b01, at5bd39561onfadec9d0.git range-diffshows each commit's patch unchanged by the rebase except for one context comment line that main changed intools/check-recipes.sh. Of the files these commits touch, main changed onlytools/check-ptx-names.pyin between (#170 added the tables beside the base table); ate95d2ceaits--self-testpasses andcheckprintscheck-ptx-names: ok (3 binaries, 551 rows = 551 declared entries; 2 tables beside it read for stale rows). The two shells gave the same output in every run below.Each commit on its own: the self-tests that exist at that commit pass,
check-recipes.shparses, andcheck-unsafe.sh,check-arch.sh,check-loads.sh,check-comments.sh,check-levers.sh,check-defaults.pyandcheck-ptx-names.pyprint the same output as the scripts offadec9d0on its tree, and in the copy described below the base scripts and the head's print the same output on one tree. On this tree that includescheck-loads: 77 #[cuda_module] families, every load through the shared slot,check-comments: ok (858 files, 130264 comment lines; tools/ cites no doc by line number, 0 allowed by CITE_ALLOW; no retired word, 1 line(s) allowed by WORD_ALLOW)andcheck-ptx-names: ok (3 binaries, 551 rows = 551 declared entries); check-unsafe counts 25 crates, 2689 blocks, 381 fns and 26 impls, each at its pin. The draft-read block counts the shell scripts undertools/, 151 on the branch and 150 onfadec9d0, because commit 1 addstools/grep-answer.sh; its verdict is the same.FAIL-first. Each clause reverted alone, in a copy at the head, turns its own self-test cases red under both shells (or python3):
countback to|| truecountreading the whole pipeline's status as grep'scountwith plain grep, every nonzero status refusedcountwithout its no-file return, so grep reads stdinlist_rswithout itsfindchecklist_rswith-type fonly (nobuild.rslink)collectwithoutbuild.rsin its filtercollectwithoutbenchesin its filtercollectreadinglist_rsthrough a process substitution (the original wiring)collectwithout|| exit $?afterlist_rsfind 2>/dev/nullwith no checkfindback to2>/dev/null || true|| truegrep -vplain|| truers_fileswithout itsfindcheckrs_fileswithouttests/in its filter, or without theoxide-ice-unrollprunecomment_linesback to|| exit $?git grepgit grepggwithout its stderr checkggtaking any git grep status as an answeronerroronerroronerrorFor example,
countback to|| true:On the real tree, in a copy of the head (
git archive, thengit initandgit addso git grep sees the files as tracked), one change at a time, the base scripts against this change:crates/gpu-vision/src/attn.rsat 000ok, gpu-vision 65 blocks against 97, exit 0cannot count the lines of a source file (exit 2, above), exit 70crates/app/src/archat 000 (a directory undersrc)ok, exit 0cannot list the .rs files under crates/app (find failed, above), exit 70crates/gpuat 000 (a crate directory)ok, gpu 0/0/0 against 1747/194/10, exit 0cannot list the .rs files under crates/gpu (find failed, above), exit 70tools/unsafe-ratchet.txtat 000cannot read tools/unsafe-ratchet.txt (exit 2, above), exit 70cratesat 000cannot list the crate directories under crates/ (find failed, above), exit 70crates/serve/build.rsa link to a file with one more unsafe blockserve blocks 7 above the pin 6, exit 1ok, exit 0cannot count the lines of a source file (exit 2, above), exit 70crates/serve/build.rsa broken linkok, exit 0crates/gpu-vision/src/attn.rsat 000ok, exit 0rule 2 cannot read crates tools/ref (exit 2, above), no verdict, exit 2crates/app/src/arch/qwen3moeat 000ok, exit 0 (grep printedPermission denied12 times)rule 1 cannot list the directories of deepseek2 under crates (find exit 1, above), no verdict, exit 2crates/app/src/archorcrates/gpuat 000cannot list the architecture directories under crates (find exit 1, above), no verdict, exit 2crates/gpu-vision/src/attn.rsat 000cannot read a source file to collect the #[cuda_module] families (awk failed, above), exit 70crates/gpuat 000findprintsPermission denied, exit 1cannot list the .rs files under crates (find failed, above), exit 70rope2d_kernels::load(ctx)incrates/app/src/lib.rsraw generated-module load, exit 1crates/app/src/arch/qwen3moeat 000ok (856 files, ...), exit 0cannot list the .rs files under crates (find exit 1, above), no verdict, exit 2crates/gpuat 000ok (710 files, ...), exit 0crates/gpu-vision/src/attn.rsat 000the comment reader failed (rc 1, above), no verdict, exit 2README.mdat 000ok (858 files, ...), exit 0 (git grep printedfailed to statfour times)git grep cannot read every file of the tree (above), no verdict, exit 2docsat 000ok, exit 0zzplant/a.mdwith a retired wordok, exit 0git grep cannot read every file of the tree (above), no verdict, exit 2crates/app/src/zzplant/a.rsok, exit 0cannot list crates/app/src/zzplant (Permission denied), no verdict, exit 2crates/appat 000ok, exit 0cannot list crates/app/src (Permission denied), no verdict, exit 2tools/zzplant/x.shnames a variable no row namesok, exit 0cannot list tools/zzplant (Permission denied), no verdict, exit 2crates/gpu-gates/src/zzplant/a.rsok, exit 0crates/gpu-gates/src/zzplant: cannot list the directory (Permission denied), exit 65crates/modelat 000crates/modelit could not see), exit 1crates/model/tests: cannot list the directory (Permission denied), exit 65crates/gpu/src/zzplant/a.rsok, exit 0cannot read <the copy>/crates/gpu/src/zzplant: Permission denied, exit 2crates/gpuat 000crates/gpu/src is not there, exit 1cannot read <the copy>/crates/gpu/src: Permission denied, exit 2tools/zzplant/x.shprints the draft pathdraft reads: cannot read tools/zzplant (Permission denied), no verdict, exit 2just mac-static upstream/mainat5bd39561on an Apple M5 (macOS 27.0.1), with upstream/main then at54ceee74: ok in 118 s. fmt-check has 0 diff blocks, lint has 41 warnings (the ratchet's 41), and every check it runs exits 0.check-recipes.shprintscheck-unsafe: self-test ok,check-arch: self-test ok,check-loads: self-test okandcheck-comments: self-test okfrom the new blocks,check-recipes: draft reads go through dspark_model (151 shell files, the printf fixture is red), and ends withcheck-recipes: ok. Again at the same commits rebased onto166921f5(heada7589688): ok in 125 s, every check exits 0.just mac-teston the same machine: 1196 passed, 1 failed, 179 ignored, the same in two runs. The failure isbloomery-refset'sarch::draft::tests::a_plain_target_with_no_draft_beside_is_the_family_path:placesreturns the beside path under both/var/folders/...and/private/var/folders/..., because the test's temporary directory is under/var, a link to/private/var. It fails the same way on that machine at upstream's own4a50226c, and this change has no Rust changes.Limits of these runs and of the change:
e95d2ceapassed check-arch, check-comments, check-levers, check-loads and check-unsafe on the real tree, so Linux's git prints nothing on stderr there that would end check-comments..rsfile check-levers cannot read now ends it with exit 2 and the path; its self-test covers that through a brokenbuild.rslink. check-defaults gives its named error, exit 65, and check-ptx-names exit 2, for the same kind of file.tools/that is a file, the extra-argument cases) do not depend on the user.Hardware (if the change is for a machine)
Not a machine-specific change.
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.