test: sweep the sabotage scripts too, and assert the executable bit
Two gaps in gate-portability, both found while merging SD-P8 rather than by any check in the repository.
POPULATION. active_scripts was (test/gate-.sh test/build-d3-bytecode-base.sh tools/.sh) -- test/sabotage-*.sh was in nothing. Seven sabotage scripts had no absolute-path check and no bash -n parse, and those are exactly the scripts run rarely and under time pressure. One glob entry; every existing check applies to whatever is in the list.
MODE. Nothing in this repository checked file mode, and the gap is structural rather than an oversight: every check here looks at CONTENT. bash -n parses, rg greps, sha256sum hashes, git diff shows. None of them can see a permission bit. So a rewrite-and-replace -- awk > tmp && mv, a non-inplace sed, an editor's atomic save, a cp from a scratch copy -- drops the execute bit silently and no instrument in the tree notices. It surfaces only in git's own create mode 100644 line at merge time, which nobody reads adversarially. Two independent instances in this estate on 2026-08-23, one of them mine.
The check reads git ls-files -s, NOT the filesystem: the index is what ships and what a fresh clone gets, and a local chmod +x that was never staged would make a filesystem check pass while still handing the next person a non-executable file.
IT ITERATES active_scripts, THE SAME ARRAY THE SWEEP USES. An earlier revision of this commit re-listed two of the four globs while its comment claimed the population was "derived" -- it was not, and extending active_scripts later would have silently left the mode check behind. That is a comment lying about the code beneath it. Sharing the array makes it structural instead of a promise, and widening cost nothing: measured, tools/*.sh and the d3 base script are already 100755 with shebangs. 27 scripts checked before, 30 now.
AND EVERY ENTRY MUST BE A REAL FILE. A glob matching nothing leaves the LITERAL PATTERN in the array, so both consumers quietly examine less than they claim and a total-count floor cannot see it -- dropping tools/*.sh takes 30 to 28, above any floor worth setting. Per-entry existence is what makes the denominator honest and what catches a directory renamed out from under this file.
SABOTAGE-TESTED, four arms and a positive control, each plant verified to have landed before its run was believed:
A execute bit stripped IN THE INDEX on tools/import-sweep.sh, filesystem
left at 755 -> exit 1, names file, mode and fix. That file is in the NEWLY
covered globs: it was unprotected before this change, so the arm also
demonstrates the coverage gain rather than asserting it.
B shebang filter matched nothing -> "examined only 0 scripts"
C untracked script with a shebang -> "not tracked, so its mode cannot ship"
D a glob matching nothing -> "'test/NOSUCH-*.sh' is not a file"
restored -> PORTABILITY_GATE_MODES 30 ... / PORTABILITY_GATE_GREENAn earlier run of arm B reported exit 0 because its sed plant failed to apply; the arms now check the plant landed before believing the result.
test/gate-portability.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 67 insertions(+), 1 deletion(-)test/gate-portability.shmodified
repo_dir="$(cd "$(dirname "$0")/.." && pwd)"cd "$repo_dir"active_scripts=(test/gate-*.sh test/build-d3-bytecode-base.sh tools/*.sh)# POPULATION. `test/sabotage-*.sh` was absent from this list until 2026-08-23,# so seven sabotage scripts were swept by NOTHING -- no absolute-path check, no# `bash -n` parse. A syntax error in one surfaced only when somebody ran it, and# those are exactly the scripts run rarely and under time pressure. Adding the# glob costs one entry; every check below already applies to whatever is in it.active_scripts=(test/gate-*.sh test/sabotage-*.sh test/build-d3-bytecode-base.sh tools/*.sh)# EVERY ENTRY MUST BE A REAL FILE, because an unexpanded glob is not an error.## When a glob matches nothing, bash leaves the LITERAL PATTERN in the array. Both# consumers below would then quietly examine less than they claim: the mode loop# skips it via `test -f`, and a reader seeing "30 scripts" would have no way to# know one of four globs contributed zero. A floor on the total cannot catch it# either -- dropping `tools/*.sh` takes 30 to 28, comfortably above any floor# worth setting. Checking each entry is what makes the denominator honest, and it# is the check that catches a DIRECTORY being renamed out from under this file.for entry in "${active_scripts[@]}"; do test -f "$entry" || { echo "PORTABILITY_GATE: '$entry' is not a file." >&2 echo " A glob in active_scripts matched nothing, so bash left the pattern itself" >&2 echo " in the array and everything below is examining fewer scripts than it says." >&2 exit 1; }doneabsolute_path_pattern='(^|[^$A-Za-z0-9_])/(bin|sbin|usr|opt|Users|home|tmp|var|etc|run|nix|gnu)/'if ! printf 'tool=/%s\n' 'opt/portability-sensitivity/tool' \rg -q 'SIGIL_COMPILER_REPO' test/build-d3-bytecode-base.shrg -q 'D3_BYTECODE_BASE_DIR' test/build-d3-bytecode-base.sh# EVERY SCRIPT WITH A SHEBANG MUST BE EXECUTABLE IN THE INDEX.## Nothing in this repository checked file MODE until 2026-08-23, and the gap is# structural rather than an oversight: every check here looks at CONTENT. `bash# -n` parses, `rg` greps, `sha256sum` hashes, `git diff` shows. **None of them# can see a permission bit.** So a rewrite-and-replace -- `awk … > tmp && mv`, a# non-inplace `sed`, an editor's atomic save, a `cp` from a scratch copy -- drops# the execute bit silently and no instrument in the tree notices. It surfaces# only in git's own `create mode 100644` line at merge time, which nobody reads# adversarially. Two independent instances in this estate on one day.## THE INDEX, NOT THE FILESYSTEM. `git ls-files -s` is what ships and what a# fresh clone gets; a local `chmod +x` that was never staged would make a# filesystem check pass and still hand the next person a non-executable file.## IT ITERATES `active_scripts` -- THE SAME ARRAY THE SWEEP USES -- so the two# cannot drift. An earlier version re-listed two of the four globs and its# comment claimed the population was "derived"; it was not, and extending# `active_scripts` would have silently left the mode check behind. Sharing the# array makes that structural rather than a promise. The shebang test does the# filtering, which is why widening it to `tools/*.sh` and the d3 base script# cost nothing: measured, all three are already 100755 with shebangs.mode_checked=0mode_bad=0for script in "${active_scripts[@]}"; do test -f "$script" || continue head -1 "$script" | rg -q '^#!' || continue mode_checked=$((mode_checked + 1)) mode=$(git ls-files -s -- "$script" | awk '{print $1}') test -n "$mode" || { echo "PORTABILITY_GATE: $script is not tracked, so its mode cannot ship" >&2; mode_bad=$((mode_bad + 1)); continue; } if [ "$mode" != "100755" ]; then echo "PORTABILITY_GATE: $script has a shebang but is $mode in the index, not 100755" >&2 echo " A rewrite-and-replace drops the execute bit and no content check can see it." >&2 echo " Fix with: chmod +x $script && git update-index --chmod=+x $script" >&2 mode_bad=$((mode_bad + 1)) fidonetest "$mode_checked" -ge 20 \ || { echo "PORTABILITY_GATE: the mode check examined only $mode_checked scripts; its globs are not matching the tree" >&2; exit 1; }test "$mode_bad" -eq 0 || { echo "PORTABILITY_GATE: $mode_bad script(s) with a shebang are not executable in the index" >&2; exit 1; }echo "PORTABILITY_GATE_MODES $mode_checked scripts with a shebang, all 100755 in the index"bash -n "${active_scripts[@]}"echo PORTABILITY_GATE_GREEN