Skip to content

tools: a check that cannot list or read part of the tree ends with a named error instead of passing - #173

Merged
juliankang4 merged 9 commits into
midagedev:mainfrom
juliankang4:dgx-spark-check-unsafe-read-errors
Oct 14, 2026
Merged

juliankang4 merged 9 commits into
midagedev:mainfrom
juliankang4:dgx-spark-check-unsafe-read-errors

Conversation

@juliankang4

@juliankang4 juliankang4 commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

Closes #151.

tools/check-unsafe.sh ended 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.sh and tools/check-comments.sh lost 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-check and the draft-read block of check-recipes.sh) walked the tree with os.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 by tools/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.rs at mode 000, the base check-unsafe.sh printed Permission denied three times, counted 65 blocks for gpu-vision instead of 97, and ended check-unsafe: ok, exit 0. With crates/gpu at mode 000 it counted gpu as 0/0/0 against its pins 1747/194/10 and still ended ok, exit 0: collect skipped every directory that [ -d ] could not see, and read each find through a process substitution whose status nothing checked.

check-arch.sh had the same || true at the end of each scan, and four of the five sent grep's stderr to /dev/null. The same unreadable file left it at check-arch: ok, exit 0, so a violation in that file would pass. Its architecture listing also sent find'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.sh read 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.sh read its file list through done < <(find "${dirs[@]}" ...), and a crate directory that the crates/*/src glob could not see was left out before find ran. With crates/app/src/arch/qwen3moe at mode 000 it ended check-comments: ok over 856 files instead of 858, exit 0; with crates/gpu at mode 000, over 710 files, exit 0. Its retired-word scan runs git grep --untracked, which prints failed to stat or could not open directory on stderr and still exits 0 or 1. With README.md, docs/ or an untracked directory at mode 000 the check ended ok, 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 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), the 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-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 Python traceback and exit 1, its violation code.

The commits

  1. tools: one owner for a check's grep exit rule, sourced from grep-answer.sh. tools/check-comments.sh already had the rule in its own g: grep's 1 (no line) is an answer, and any other status ends the check. It moves to tools/grep-answer.sh as grep_answer <tool> <grep arguments>, sourced the way tools/arch.sh is. Because grep's 1 returns 0, a pipeline of grep_answer stages under pipefail fails only on a real error in one of its stages. check-comments.sh calls it in place of g, 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.
  2. check-unsafe: a source that cannot be listed or read ends the count with exit 70 instead of counting zero.
    • count runs grep through grep_answer, and any nonzero status of its pipeline (grep, wc or tr) 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.
    • collect lists the whole crate directory once through list_rs, which ends the check on a find failure (cannot list the .rs files under crates/<crate> (find failed, above)), and keeps src, tests, benches and build.rs from that list. So a crate directory that find cannot enter ends the check. So does any directory under it, counted or not, such as an unreadable examples/. I took that over a per-directory walk, because the walk cannot tell a missing directory from one it cannot see.
    • The listing takes the crate's own build.rs whatever its type, because the old [ -f ] followed a link. A build.rs that 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.
    • The crate list and the ratchet read check their find and grep the same way. An unreadable ratchet now ends with cannot read tools/unsafe-ratchet.txt (exit 2, above) instead of "holds no crate line".
    • The argument check read only the first argument, so --self-test --unknown ran the self-test. Any argument list other than none or --self-test now ends the check with 64.
    • The self-test's no-file case hands count a here-string, so no printf is left writing into a pipe that count never reads. An extra-argument case runs the script with '' extra.
    • check-recipes.sh gets blk_scancheck <checker>, which runs tools/check-<checker>.sh --self-test and 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.
  3. 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.
  4. 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 through grep_answer, and a failing stage, or rule 1's find, ends the check by rule with exit 2, the code the script already gives an unknown argument (for example check-arch: rule 2 cannot read crates tools/ref (exit 2, above), no verdict). The architecture listing's find keeps 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 after sort -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 printed awk: warning: escape sequence `\.' treated as plain `.' on stderr. The awk 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.
  5. check-loads: a source file the family or load scan cannot list or read ends the check with exit 70 instead of passing. The .rs files under crates/ are 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), 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 reads file: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-test ends 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.
  6. check-comments: the source listing, the comment reader and the retired-word scan are functions. The .rs listing 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 search and the wrapped-word awk) into retired, 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.
  7. check-comments: a source or a tree file the scans cannot list or read ends the check with no verdict instead of passing.
    • rs_files lists the whole crates directory in one find whose status it checks, leaves out oxide-ice-unroll as before, and keeps each crate's src and tests paths. 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, find or sort, so the line does not name the stage.
    • grep_answer cannot own the git grep case, 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 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: 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 an EXIT trap 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.
    • These end with exit 2. That is the code the script already gave when a grep under tools/ could not read (grep_answer under set -e). A failing comment reader (tools/check-comment-only.py --comments, which stops with exit 1 on an .rs file 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-test ends the check with 64, and grep-answer.sh is sourced at the top, as in the other checks.
  8. tools: a Python check's tree walk that cannot list a directory ends the check instead of skipping it. Each walk gets 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 its 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, so a crate with no tests/ is fine, 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. It moves into a function of the root it reads and gets a --self-test that runs it on a temporary tree whose crates/c/src is a file, (when not run as root) holds a directory at mode 000, whose build.rs is a broken link, and whose .cargo is a file; any argument list other than none or --self-test ends it with 64. 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; it now asks isdir of the crate directory instead, and its self-test hides a crate's tests/ as well as gpu-gates/src/bin. boxq-check's self-test runs codes-check on a tools/ that is a file and (when not run as root) on a directory at mode 000 under tools/ that holds an exit 81 script.
  9. check-recipes: a tool's self-test block runs through one runner. 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 one line. blk_scancheck runs the check-*.sh self-tests through it with the path composed, as before (below). The failure line 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.

check-recipes.sh runs the five shell self-tests through blk_scancheck as the blocks unsafecount, archscan, loadscan, commentscan and leverscan, and already runs the self-tests of check-defaults.py, check-ptx-names.py and boxq-check.py. blk_scancheck composes the checker's path ("check-$1.sh") on purpose. A literal check-levers.sh, check-arch.sh or check-comments.sh in check-recipes.sh puts that script in the scripts tools/recipes.py reads check-recipes as running; through the tools/ref/card-tests/run.sh string in check-levers' FIXTURES that set then reaches tools/ref/lcpp-warm.sh, whose ${LCPPBIN} read makes check-recipes never skip, and recipes.py --self-test fails. With the composed path that set is the same as main's at the head, and the files script_closure gives check-recipes are main's plus tools/grep-answer.sh. The shell self-tests use fixed input, paths that do not exist, and small fixtures in a mktemp -d directory that they remove: a crate whose build.rs is a link or a broken link, a crates directory for the listing, and a tr on PATH that fails after grep. check-comments' self-test puts a shell function in place of git that 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 .rs because 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's tools/ that is a file runs as any user.

Same defect elsewhere

  • tools/recipes.py also walks trees (_host_sources, shipped_files and the data digest). I did not check those walks in this change. The other os.walk users (tools/seed-target.sh, tools/type-census.py's self-test and tools/review/*.py) are not pass/fail checks over the tree.
  • tools/lds-scan.sh keeps its own copy of grep's exit rule ([ "$rc" -le 1 ] || fail ...); it is correct and outside the check scripts this change touches.
  • The greps over the justfile at the top of check-recipes.sh end in || true, but an unreadable justfile stops python3 tools/recipes.py check, the script's first block, with exit 2.

Code shape

  • No second copy. grep_answer in tools/grep-answer.sh is the one owner of grep's exit rule for the check-*.sh scripts; check-comments.sh's g is gone. In check-unsafe.sh, count and list_rs are the one owner for counting and for listing; in check-loads.sh, one listing feeds both scans. check-comments.sh's gg is 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's onerror next to its own exit code, because the four checks end in four different ways.
  • Model code holds only architecture facts. No model code changes.
  • Dead code is gone. The || true endings, the 2>/dev/null on 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.
  • No silent failure. This is the change: a path a check cannot list or read is a named exit (70 for check-unsafe and check-loads, 2 for check-arch, check-comments, check-levers, check-ptx-names and the draft-read block, 65 for check-defaults, 69 for boxq-check codes-check). The limits below name what is left.
  • Comments state what is true now.
  • No relaxed gate. No pin, band or tolerance moves. The checks refuse more than before, except rule 2's awk in check-arch, which no longer reads \. as any character.
  • cargo fmt and cargo clippy are 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), now grep_answer in tools/grep-answer.sh, which check-unsafe, check-arch and check-loads use too. In tools/check-recipes.sh, tool_selftest replaces the body that 25 older self-test blocks repeated (blk_boxtracks, blk_loadgroups, blk_lcppfit and the others), and blk_scancheck runs the five check-*.sh self-tests through it. The five shell self-tests each define a three-line expect and the same tally; one sourced owner would trade those for a new file and five source lines, so I left them.

What I ran

At the head, 4ff5ef4b

The commits are df1c160e, 522bc685, d2faac01, ae6c4952, f1475c92, 3d492fc3, e52b721f, 4ecd736a and 4ff5ef4b, on 98eb61db. 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/bash 3.2.57 and bash 5.3.20.

$ for c in arch unsafe loads comments levers; do bash tools/check-$c.sh --self-test | tail -1; done
check-arch: self-test ok
check-unsafe: self-test ok
check-loads: self-test ok
check-comments: self-test ok
check-levers: self-test ok
$ for p in check-defaults check-ptx-names boxq-check; do python3 tools/$p.py --self-test | tail -1; done
check-defaults: self-test ok
check-ptx-names: self-test ok
boxq-check self-test: 2 cases ok
$ bash tools/check-loads.sh --self-test --unknown; echo $?
check-loads: unknown argument '--self-test --unknown' (none, --self-test)
64

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-levers ok, and boxq-check.py codes-check no other tool or recipe produces them.

Each clause reverted alone, in the work tree at the head:

Clause reverted Red cases on Linux (gawk) On macOS, both shells
check-levers walk without onerror src-file, mode-000, cargo-file the same
check-levers build.rs back to os.path.isfile broken-build-link the same
check-levers source read back to a plain open broken-build-link the same
check-levers tools/ and .cargo walk back to os.walk cargo-file the same
check-levers argument check on the first argument only extra-argument the same
check-loads first grep without -H one-file the same
check-loads load scan without its no-file return no-file the same
check-loads family scan without its no-file return families-no-file the same
check-loads, check-unsafe, check-comments argument check on the first argument only extra-argument (each) the same
check-unsafe count without its no-file return no-file the same
check-arch rule 2's awk back to -v keys="$KEYS" lits-clean none: BSD awk reads \. as . without a warning
boxq-check walk without onerror codes (a tools/ that is a file) the same
check-defaults crate tests/ walk back to os.walk crates/model/tests the same

Commit 9 changes only the name in a folded block's failure line. With it, the scripts tools/recipes.py reads check-recipes as running are the same as on main.

just mac-static 98eb61db at 4ff5ef4b on 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 ok lines and the other self-test blocks' lines and ends check-recipes: ok. Its blocks include recipes.py --self-test, which holds check-recipes to its never-skip answer.

At the previous head, ba79929c

These runs were made at 643f3afa, which has the same tree as ba79929c (base cdb6638e); only a commit message differs. Besides the Linux host above, they used an Ubuntu 24.04 container as root, where awk is mawk 1.3.4. The five shell self-tests printed self-test ok as 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 reviewed e95d2cea, 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.sh printed check-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) at e95d2cea and empty at 643f3afa. 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 without onerror turned src-file red.

bash tools/check-recipes.sh on the Linux host printed the five self-test ok lines from its blocks. The host has no cargo, no just and no numpy, so the blocks that need them were red there (rc 2). Upstream 3e191b1b on the same host gave the same red blocks, and the only other lines that differed were the new leverscan line and the draft-read count, 151 shell files against 150, because commit 1 adds tools/grep-answer.sh.

just mac-static 3e191b1b on 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 onto 98eb61db. 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/bash 3.2.57 (the shell the headers name) and bash 5.3.20, each script run by the same shell as its test. The commits are b5f83464, 7464fde8, f111bf94, cfc30efe, de7f04c8, 54a9d3c6, 3dd980a6 and e95d2cea, on 84f77b01. The runs below were made before the rebase onto 84f77b01, at 5bd39561 on fadec9d0. git range-diff shows each commit's patch unchanged by the rebase except for one context comment line that main changed in tools/check-recipes.sh. Of the files these commits touch, main changed only tools/check-ptx-names.py in between (#170 added the tables beside the base table); at e95d2cea its --self-test passes and check prints check-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.sh parses, and check-unsafe.sh, check-arch.sh, check-loads.sh, check-comments.sh, check-levers.sh, check-defaults.py and check-ptx-names.py print the same output as the scripts of fadec9d0 on 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 includes check-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) and check-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 under tools/, 151 on the branch and 150 on fadec9d0, because commit 1 adds tools/grep-answer.sh; its verdict is the same.

$ bash tools/check-unsafe.sh --self-test
check-unsafe: self-test ok
$ bash tools/check-arch.sh --self-test
check-arch: self-test ok
$ bash tools/check-loads.sh --self-test
check-loads: self-test ok
$ bash tools/check-comments.sh --self-test
check-comments: self-test ok
$ python3 tools/check-defaults.py --self-test
check-defaults: self-test ok
$ python3 tools/check-ptx-names.py --self-test
check-ptx-names: self-test ok

FAIL-first. Each clause reverted alone, in a copy at the head, turns its own self-test cases red under both shells (or python3):

Clause reverted Red cases
check-unsafe count back to || true missing-file, missing-beside-readable, broken-build-link, later-stage
count reading the whole pipeline's status as grep's the same four
count with plain grep, every nonzero status refused no-line
count without its no-file return, so grep reads stdin no-file
list_rs without its find check missing-dir, missing-crate
list_rs with -type f only (no build.rs link) linked-build, broken-build-link
collect without build.rs in its filter linked-build, broken-build-link
collect without benches in its filter linked-build
collect reading list_rs through a process substitution (the original wiring) missing-crate
collect without || exit $? after list_rs missing-crate
check-arch listing back to find 2>/dev/null with no check arches
check-arch rule 1's find back to 2>/dev/null || true cross-find
check-arch rule 1 to 5, each scan back to plain grep and || true cross-grep, lits, archread, archpath, spawns (one each)
check-arch rule 1 to 5, each first grep plain with the check kept cross-clean, lits-clean, archread-clean, archpath-clean, spawns-clean (one each)
check-arch rule 2's first grep -v plain lits, lits-clean
check-loads load scan back to || true missing-file
check-loads load scan's first grep plain no-load
check-loads load scan's family grep plain no-load, other-family
check-loads load scan without its no-file return no-file
check-loads family scan without its status check families-missing-file
check-loads family scan without its no-file return families-no-file
check-comments rs_files without its find check missing-dir
rs_files without tests/ in its filter, or without the oxide-ice-unroll prune listing
comment_lines back to || exit $? reader
the line search as a plain git grep unreadable
the listing as a plain git grep unreadable-listing
gg without its stderr check unreadable, unreadable-listing
gg taking any git grep status as an answer git-failed
the wrapped-word awk without its status check listed-unreadable
check-defaults walk without onerror a directory the scanner cannot list is not refused
check-ptx-names walk without onerror a directory it cannot list: rc 0, want 2
draft-read block walk without onerror the fixture 'a directory the walk cannot list'

For example, count back to || true:

check-unsafe: self-test missing-file: got [0 0], want [70 check-unsafe: cannot count the lines of a source file (exit 2, above)]
check-unsafe: self-test missing-beside-readable: got [0 1], want [70 check-unsafe: cannot count the lines of a source file (exit 2, above)]
check-unsafe: self-test broken-build-link: got [0 0], want [70 check-unsafe: cannot count the lines of a source file (exit 2, above)]
check-unsafe: self-test later-stage: got [0 ], want [70 check-unsafe: cannot count the lines of a source file (exit 1, above)]
check-unsafe: self-test: 4 failed

On the real tree, in a copy of the head (git archive, then git init and git add so git grep sees the files as tracked), one change at a time, the base scripts against this change:

Change to the copy Base This change
crates/gpu-vision/src/attn.rs at 000 check-unsafe ok, gpu-vision 65 blocks against 97, exit 0 cannot count the lines of a source file (exit 2, above), exit 70
crates/app/src/arch at 000 (a directory under src) check-unsafe ok, exit 0 cannot list the .rs files under crates/app (find failed, above), exit 70
crates/gpu at 000 (a crate directory) check-unsafe ok, gpu 0/0/0 against 1747/194/10, exit 0 cannot list the .rs files under crates/gpu (find failed, above), exit 70
tools/unsafe-ratchet.txt at 000 check-unsafe "holds no crate line", exit 70 cannot read tools/unsafe-ratchet.txt (exit 2, above), exit 70
crates at 000 check-unsafe "no crate directory", exit 70 cannot list the crate directories under crates/ (find failed, above), exit 70
crates/serve/build.rs a link to a file with one more unsafe block check-unsafe serve blocks 7 above the pin 6, exit 1 the same, exit 1
the same link with its target at 000 check-unsafe ok, exit 0 cannot count the lines of a source file (exit 2, above), exit 70
crates/serve/build.rs a broken link check-unsafe ok, exit 0 the same refusal, exit 70
crates/gpu-vision/src/attn.rs at 000 check-arch ok, exit 0 rule 2 cannot read crates tools/ref (exit 2, above), no verdict, exit 2
crates/app/src/arch/qwen3moe at 000 check-arch ok, exit 0 (grep printed Permission denied 12 times) rule 1 cannot list the directories of deepseek2 under crates (find exit 1, above), no verdict, exit 2
crates/app/src/arch or crates/gpu at 000 check-arch: no output, exit 1 cannot list the architecture directories under crates (find exit 1, above), no verdict, exit 2
crates/gpu-vision/src/attn.rs at 000 check-loads: awk cannot open it, exit 1 cannot read a source file to collect the #[cuda_module] families (awk failed, above), exit 70
crates/gpu at 000 check-loads: find prints Permission denied, exit 1 cannot list the .rs files under crates (find failed, above), exit 70
a raw rope2d_kernels::load(ctx) in crates/app/src/lib.rs check-loads raw generated-module load, exit 1 the same, exit 1
crates/app/src/arch/qwen3moe at 000 check-comments ok (856 files, ...), exit 0 cannot list the .rs files under crates (find exit 1, above), no verdict, exit 2
crates/gpu at 000 check-comments ok (710 files, ...), exit 0 the same refusal, exit 2
crates/gpu-vision/src/attn.rs at 000 check-comments: the comment reader fails, exit 1 (the violation code) the comment reader failed (rc 1, above), no verdict, exit 2
README.md at 000 check-comments ok (858 files, ...), exit 0 (git grep printed failed to stat four times) git grep cannot read every file of the tree (above), no verdict, exit 2
docs at 000 check-comments ok, exit 0 the same refusal, exit 2
an untracked zzplant/a.md with a retired word check-comments reports it, exit 1 the same, exit 1
the same, its directory at 000 check-comments ok, exit 0 git grep cannot read every file of the tree (above), no verdict, exit 2
an in-place env read in crates/app/src/zzplant/a.rs check-levers reports it, exit 1 the same, exit 1
the same, its directory at 000 check-levers ok, exit 0 cannot list crates/app/src/zzplant (Permission denied), no verdict, exit 2
crates/app at 000 check-levers ok, exit 0 cannot list crates/app/src (Permission denied), no verdict, exit 2
tools/zzplant/x.sh names a variable no row names check-levers reports it, exit 1 the same, exit 1
the same, its directory at 000 check-levers ok, exit 0 cannot list tools/zzplant (Permission denied), no verdict, exit 2
an off-default pin in crates/gpu-gates/src/zzplant/a.rs check-defaults reports it, exit 1 the same, exit 1
the same, its directory at 000 check-defaults ok, exit 0 crates/gpu-gates/src/zzplant: cannot list the directory (Permission denied), exit 65
crates/model at 000 check-defaults: 14 problems (rows whose pins and twins under crates/model it could not see), exit 1 crates/model/tests: cannot list the directory (Permission denied), exit 65
a kernel with no row in crates/gpu/src/zzplant/a.rs check-ptx-names reports it, exit 1 the same, exit 1
the same, its directory at 000 check-ptx-names ok, exit 0 cannot read <the copy>/crates/gpu/src/zzplant: Permission denied, exit 2
crates/gpu at 000 check-ptx-names: refused, crates/gpu/src is not there, exit 1 cannot read <the copy>/crates/gpu/src: Permission denied, exit 2
tools/zzplant/x.sh prints the draft path the draft-read block reports it, exit 1 the same, exit 1
the same, its directory at 000 the draft-read block passes, exit 0 draft reads: cannot read tools/zzplant (Permission denied), no verdict, exit 2

just mac-static upstream/main at 5bd39561 on an Apple M5 (macOS 27.0.1), with upstream/main then at 54ceee74: 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.sh prints check-unsafe: self-test ok, check-arch: self-test ok, check-loads: self-test ok and check-comments: self-test ok from the new blocks, check-recipes: draft reads go through dspark_model (151 shell files, the printf fixture is red), and ends with check-recipes: ok. Again at the same commits rebased onto 166921f5 (head a7589688): ok in 125 s, every check exits 0.

just mac-test on the same machine: 1196 passed, 1 failed, 179 ignored, the same in two runs. The failure is bloomery-refset's arch::draft::tests::a_plain_target_with_no_draft_beside_is_the_family_path: places returns 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 own 4a50226c, and this change has no Rust changes.

Limits of these runs and of the change:

  • The Linux runs are on aarch64. CI's t0 runner is x86_64 with the same Ubuntu tools. Its run at the reviewed e95d2cea passed 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.
  • A check lists the tree, then reads what it listed. A file created after the listing is not read. A file removed or made unreadable in between ends the check with no verdict, because the read fails.
  • The cases for a directory at mode 000 (the Python ones and check-levers' mode-000) are skipped when the self-test runs as root.
  • A single .rs file check-levers cannot read now ends it with exit 2 and the path; its self-test covers that through a broken build.rs link. check-defaults gives its named error, exit 65, and check-ptx-names exit 2, for the same kind of file.
  • The new cases of this round were not run as root. Those that do not use a mode (check-levers' broken-build-link and cargo-file, boxq-check's 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 초안 리뷰는 제가 직접 했습니다.

@juliankang4
juliankang4 force-pushed the dgx-spark-check-unsafe-read-errors branch from 83bd9e0 to e95d2ce Compare October 14, 2026 07:40
@github-actions github-actions Bot added the tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo label Oct 14, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment thread tools/check-loads.sh Outdated
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=$?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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=$?

Comment thread tools/check-loads.sh Outdated
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=$?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With SIGPIPE ignored, a late background writer can report a broken pipe after families_of returns; supply the unused fixture synchronously.

Suggested change
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.
@juliankang4
juliankang4 force-pushed the dgx-spark-check-unsafe-read-errors branch from e95d2ce to 4ff5ef4 Compare October 14, 2026 14:24
@juliankang4

Copy link
Copy Markdown
Collaborator Author

Fixed in the same eight commits plus a ninth, rebased onto main 98eb61db; the head is 4ff5ef4b. Compared with the reviewed e95d2cea, git range-diff shows commits 1, 3 and 6 unchanged, the other five changed as below, and commit 9 new.

  • The two no-file fixtures in check-loads.sh take here-strings, as suggested (f1475c92). With SIGPIPE ignored by the parent, 50 runs of check-loads.sh --self-test at e95d2cea failed 40 times on an aarch64 Ubuntu 24.04 host (no-file and families-no-file), and 0 times at an earlier head with the same fixtures. At 4ff5ef4b it failed 0 times in 20 with SIGPIPE ignored and 0 in 20 with the default. Removing either no-file return turns its case red with the here-strings in place. check-loads' families-missing-file could leave a writer behind the same way: it named the missing file first, and BSD awk stops there before it opens the second operand. It names the readable file first now. check-unsafe's no-file case piped printf into count, which could only add a broken-pipe message to a stderr the case does not compare; it takes a here-string now too (522bc685).
  • One runner: blk_scancheck <checker> came in the suggested form, and commit 9 (4ff5ef4b) goes one step further. Twenty-five older blocks of check-recipes.sh (blk_boxtracks, blk_loadgroups, blk_lcppfit and the others) had the same run, failure report and last-line rule, so tool_selftest SCRIPT now owns that body, each of those blocks is one line, and blk_scancheck is tool_selftest "check-$1.sh". blk_cardtests, blk_carry and blk_gpugate keep their own bodies, because each does something more. The failure line now names the script's path under tools/ (ref/lease, release/build).
  • On the non-blocking item: check-levers has a --self-test (4ecd736a), which check-recipes.sh runs through blk_scancheck levers. It runs the check on a temporary tree whose crates/c/src is a file, (when not run 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. Dropping onerror=unlisted turns src-file, mode-000 and cargo-file red. The fixture lives in check-levers and not inline in check-recipes.sh, and blk_scancheck composes the checker's path, because a literal check-levers.sh (or check-arch.sh, check-comments.sh) in check-recipes.sh puts that script in the scripts tools/recipes.py reads check-recipes as running. Through the tools/ref/card-tests/run.sh string in check-levers' FIXTURES, that set then reaches tools/ref/lcpp-warm.sh, whose ${LCPPBIN} read makes check-recipes never skip, and recipes.py --self-test fails with "smoke (a batch in a batch) or check-recipes has the wrong never-skip". With the composed path, that set at the head is the same as main's, and the files script_closure gives check-recipes are main's plus tools/grep-answer.sh. The check-recipes item is keyed on the whole tree (recipes.py --self-test asserts that), so a change to a checker still moves its key.

The t0 failure, check-arch: self-test: 1 failed, comes from a line older than this PR. The CI log shows only the count; on the aarch64 Ubuntu host with gawk the failing case is lits-clean. Rule 2's awk took the keys pattern as -v keys="$KEYS", and -v processes escapes. gawk turns each \. into . and prints awk: warning: escape sequence `\.' treated as plain `.' on stderr, which the clean case reads through 2>&1. BSD awk makes the same . without a warning, and mawk keeps the backslash, so the self-test passed on macOS and in an Ubuntu container with mawk. With BSD awk and gawk, the second pass on the real tree also matched "deepseek2 followed by any character, not only a dot. The awk now reads the pattern from ENVIRON (ae6c4952). On the gawk host check-arch's self-test failed 50 times in 50 at e95d2cea; at 4ff5ef4b it passes 20 of 20 with either SIGPIPE setting, and reverting the awk to -v turns lits-clean red again.

A further review of the branch found more of the same kind, fixed in the commits that own each script:

  • check-levers 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. It now takes build.rs whenever the name exists and reads every file through one reader that ends with exit 2 and the path (4ecd736a).
  • tools/boxq-check.py codes-check walked tools/ with a plain os.walk, so a script that produces one of the box queue's codes under a directory at mode 000 passed. Its walk now raises the existing unreadable refusal, exit 69, with a case for a tools/ that is a file and one for a directory at mode 000 (4ecd736a).
  • check-loads' first grep printed no file name when it got one file, so the next stage dropped the hit. It takes -H now, with a one-file case (f1475c92).
  • check-unsafe, check-loads, check-comments and check-levers read only their first argument, so --self-test --unknown ran the self-test. Any argument list other than none or --self-test now ends with 64, and each self-test has an extra-argument case.
  • check-defaults' self-test now also hides a crate's tests/ (its walk there had no case), and comments that described the old behaviour were rewritten.

Runs at 4ff5ef4b:

  • On the aarch64 Ubuntu 24.04 host (GNU Awk 5.2.1, GNU grep 3.11, bash 5.2.21, Python 3.12.3), as a normal user: the five shell self-tests and the check-defaults.py, check-ptx-names.py and boxq-check.py self-tests pass; each shell self-test passes 20 of 20 with the default SIGPIPE and 20 of 20 with it ignored; on the real tree each check exits 0 with the same counts as before (check-unsafe 25 crates, 2691 blocks, 381 fns, 26 impls; check-loads 77 families; check-comments 865 files); and each of the nine commits passes the self-tests it has.
  • Each clause reverted alone turns its own case red, on that host and on macOS under /bin/bash 3.2.57 and bash 5.3.20 (the PR body has the table). check-arch's -v revert is red only with gawk, as before.
  • just mac-static 98eb61db on an Apple M5: ok in 134 s (fmt 0 diff blocks, lint 41 = the ratchet), and check-recipes.sh, whose blocks include recipes.py --self-test, ends check-recipes: ok.

The PR body's "What I ran" section has the commands and the numbers.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit 541c740 into midagedev:main Oct 14, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

check-unsafe: source read errors become successful zero counts

1 participant