gates: wire inert assertions and pin sweep subjects
Bare !-inverted assertions are exempt from set -e and could never fail: gate-d3's cache-record ban, gate-d6's change-control pair, gate-d6- customization's theme-identity pair, gate-glossary's A-entry ban, and gate-semantic-structures' video-id ban. Each is now if <cmd>; then fail.
Backend/boundary sweeps of the form if rg <files>; then fail pass vacuously when a subject file is missing (rg exit 2 reads as clean, so a rename silently disarms the ban): gate-d0, gate-d2, gate-d4a, gate-d6, and gate-d6- customization now pin their subjects with test -f (compgen -G for the manuscript glob) before sweeping.
Every converted block was demonstrated RED on planted input and GREEN on clean input, running the shipped block text under set -euo pipefail. Original patterns, flags, and file lists are unchanged; only the status wiring moved.
test/gate-d0.sh | 5 +++++
test/gate-d2.sh | 4 ++++
test/gate-d3.sh | 8 +++++++-
test/gate-d4a.sh | 4 ++++
test/gate-d6-customization.sh | 18 ++++++++++++++++--
test/gate-d6.sh | 16 ++++++++++++++--
test/gate-glossary.sh | 9 ++++++++-
test/gate-semantic-structures.sh | 8 +++++++-
8 files changed, 65 insertions(+), 7 deletions(-)test/gate-d0.shmodified
sigil="${SIGIL_D1_COMPILER:-$repo_dir/../task-sigil-language-readers/build/dev/bin/sigil}"redirects="${SIGIL_D1_REDIRECTS:-$repo_dir/dev-redirects.sgl}"XDG_CACHE_HOME="$cache_dir" SIGIL_REDIRECTS="$redirects" "$sigil" -L src -L test test test/test-model.sgl --report# Assert the swept subjects EXIST before sweeping them: `if rg` cannot tell a# missing file (exit 2) from a clean one (exit 1), so a rename of the semantic# core would silently disarm this ban (found 2026-08-24).test -f src/sigil/doc/model.sgltest -f src/sigil/doc/traversal.sglif rg -n -i '(html|sxml|css|typst|latex|slate|class=|tag:)' src/sigil/doc/model.sgl src/sigil/doc/traversal.sgl; then echo "backend vocabulary leaked into semantic core" >&2 exit 1test/gate-d2.shmodified
export SIGIL_REDIRECTS="$redirects"mkdir -p "$cache_dir/real"# Subject-existence pins: `if rg` reads a missing file (exit 2) the same as a# clean one (exit 1); a renamed semantic core would disarm this sweep silently.test -f src/sigil/doc/model.sgltest -f src/sigil/doc/traversal.sglif rg -n -i '(html|sxml|css|typst|latex|slate|class=|tag:)' src/sigil/doc/model.sgl src/sigil/doc/traversal.sgl; then echo "backend vocabulary leaked into semantic core" >&2; exit 1fitest/gate-d3.shmodified
# Failed forgeries never create a successful verification cache record.expect_fail 'got marker "".*exit:' "$gate_dir/forge-file-again.log" \ "${cli[@]}" test/fixtures/d3-adversarial.sgd --example forge-file! rg -q 'cached' "$gate_dir/forge-file-again.log"# `if rg; then fail`, never a bare `! rg` -- bash exempts `!`-inverted# commands from `set -e`, so the bare form could never fail (inert 2026-08-24).# Subject presence: expect_fail above dies if the log was not written.if rg -q 'cached' "$gate_dir/forge-file-again.log"; then echo 'D3: a failed forgery produced a successful verification cache record' >&2 exit 1fiexpect_fail 'got marker "".*signal:' "$gate_dir/signal.log" \ setsid -f --wait "${cli[@]}" test/fixtures/d3-adversarial.sgd --no-cache --example signal# The private decoder rejects stale nonces and symlinks even when their payloadtest/gate-d4a.shmodified
echo D4A_GATE_03_SECOND_CHAPTER_AUTHORING_CONTRACT# The semantic adapter must not grow into a site generator. Press owns these.# Subject-existence pins: to `if rg`, a missing file (exit 2) reads as clean# (exit 1), so a rename would disarm this boundary sweep silently.test -f src/sigil/doc/render/html.sgltest -f src/sigil/doc/publication.sglif rg -n -i '<html|<head|stylesheet|site-nav|sitemap|robots\.txt|write-file|copy-file|output-directory' \ src/sigil/doc/render/html.sgl src/sigil/doc/publication.sgl; then echo 'D4A renderer leaked Press/site-generation responsibility' >&2test/gate-d6-customization.shmodified
generate_alternate alternate-bcmp "$gate_dir/alternate-a.typ" "$gate_dir/alternate-b.typ"cmp "$gate_dir/alternate-a.pdf" "$gate_dir/alternate-b.pdf"! cmp -s "$gate_dir/default-a.typ" "$gate_dir/alternate-a.typ"! cmp -s "$gate_dir/default-a.pdf" "$gate_dir/alternate-a.pdf"# `if cmp; then fail`, never a bare `! cmp` -- bash exempts `!`-inverted# commands from `set -e`, so the bare form could never fail: theming that# silently stopped applying would have passed (inert 2026-08-24).if cmp -s "$gate_dir/default-a.typ" "$gate_dir/alternate-a.typ"; then echo 'D6C: alternate theme produced a .typ IDENTICAL to the default' >&2 exit 1fiif cmp -s "$gate_dir/default-a.pdf" "$gate_dir/alternate-a.pdf"; then echo 'D6C: alternate theme produced a .pdf IDENTICAL to the default' >&2 exit 1fi"$qpdf_bin" --check "$gate_dir/alternate-a.pdf" >"$gate_dir/alternate-qpdf.txt" 2>&1"$pdfinfo_bin" "$gate_dir/alternate-a.pdf" >"$gate_dir/alternate-pdfinfo.txt""$pdftotext_bin" -layout "$gate_dir/alternate-a.pdf" "$gate_dir/alternate.txt"rg -q 'Chapter II Change the Question' "$gate_dir/practical-compact.txt"echo D6C_GATE_07_CHECKED_IN_PRACTICAL_SIGIL_ALTERNATE_EDITION# Subject-existence pins: to `if rg`, a missing file (exit 2, empty output)# reads the same as a clean one, and an unmatched glob does too -- either would# disarm these sweeps silently.test -f src/sigil/doc/print.sglif rg -n -i 'typst|paper|margin|font|color|\.typ' src/sigil/doc/print.sgl \ | rg -v '^[0-9]+:[[:space:]]*;'; then echo 'D6 customization backend leakage into print policy' >&2 exit 1ficompgen -G 'book/practical-sigil/*.sgd' > /dev/nullif rg -n 'typst-theme|print-options|make-typst-length' book/practical-sigil/*.sgd; then echo 'D6 customization leaked build policy into manuscripts' >&2 exit 1test/gate-d6.shmodified
"$sigil" -L src test/build-d6-change-control.sgl "$gate_dir/changed.typ""$typst_bin" compile --root "$repo_dir" --creation-timestamp 0 --pdf-standard a-2b \ --jobs 1 "$gate_dir/changed.typ" "$gate_dir/changed.pdf"! cmp -s "$gate_dir/practical-a.typ" "$gate_dir/changed.typ"! cmp -s "$gate_dir/practical-a.pdf" "$gate_dir/changed.pdf"# Change-control assertions must be `if cmp; then fail`, never a bare `! cmp`# -- bash exempts `!`-inverted commands from `set -e`, so the bare form could# never fail: a build that IGNORED its input would have passed (inert 2026-08-24).if cmp -s "$gate_dir/practical-a.typ" "$gate_dir/changed.typ"; then echo 'D6 change control: changed input produced an IDENTICAL .typ' >&2 exit 1fiif cmp -s "$gate_dir/practical-a.pdf" "$gate_dir/changed.pdf"; then echo 'D6 change control: changed input produced an IDENTICAL .pdf' >&2 exit 1fi"$pdftotext_bin" "$gate_dir/changed.pdf" "$gate_dir/changed.txt"rg -q 'D6 changed-content witness 7391' "$gate_dir/changed.txt"echo D6_GATE_03B_CONTENT_CHANGE_INVALIDATES_SOURCE_AND_PDFecho D6_GATE_07B_OFFLINE_HIGHLIGHT_COPYABLE_AND_RASTER_COLORS# The print adapter owns neither Press routing nor any typesetter implementation.# Subject-existence pins: to `if rg`, a missing file (exit 2) reads as clean.test -f src/sigil/doc/print.sgltest -f src/sigil/doc/render/typst.sglif rg -n -i 'press|site-nav|sitemap|robots\.txt|<html|write-pdf|line-break|font-shap|paginate' \ src/sigil/doc/print.sgl src/sigil/doc/render/typst.sgl; then echo 'D6 boundary violation' >&2test/gate-glossary.shmodified
rg -q '2\.2\. E' "$gate_dir/document.txt"rg -q 'binding \(page 4\)' "$gate_dir/document.txt"rg -q 'links a symbol to a location' "$gate_dir/document.txt"! rg -q '2\.[0-9]+\. A$' "$gate_dir/document.txt"# `if rg; then fail`, never a bare `! rg` -- bash exempts `!`-inverted# commands from `set -e`, so the bare form could never fail (inert 2026-08-24).# Subject presence: the positive assertions above prove document.txt exists# and carries real glossary content.if rg -q '2\.[0-9]+\. A$' "$gate_dir/document.txt"; then echo 'GLOSSARY: a bare "A" entry appears in the rendered list (alphabetization/filter regression)' >&2 exit 1fiecho GLOSSARY_GATE_03_REAL_ALPHABETIZED_LINKED_PDFecho GLOSSARY_GATE_GREENtest/gate-semantic-structures.shmodified
"$pdftotext_bin" -layout "$gate_dir/document.pdf" "$gate_dir/document.txt"rg -q '3\. Nested three' "$gate_dir/document.txt"rg -q 'Action.*Binding' "$gate_dir/document.txt"! rg -q 'demo-video-id' "$gate_dir/document.txt"# `if rg; then fail`, never a bare `! rg` -- bash exempts `!`-inverted# commands from `set -e`, so the bare form could never fail (inert 2026-08-24).# Subject presence: the positive assertions above prove document.txt exists.if rg -q 'demo-video-id' "$gate_dir/document.txt"; then echo 'SEMANTIC-STRUCTURES: video id leaked into print output (video policy regression)' >&2 exit 1fiecho SEMANTIC_STRUCTURES_GATE_03_REAL_PDF_LIST_TABLE_VIDEO_POLICYecho SEMANTIC_STRUCTURES_GATE_GREEN