Commitf63e98aeRecorded24 Aug 2026Repositorysigil-doc

gates: wire inert assertions and pin sweep subjects

Message

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.

Changed
 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(-)
Diff
test/gate-d0.shmodified
@@ -7,6 +7,11 @@ cache_dir=$(mktemp -d "$repo_dir/build/xdg-cache.XXXXXX")
7
sigil="${SIGIL_D1_COMPILER:-$repo_dir/../task-sigil-language-readers/build/dev/bin/sigil}"
8
redirects="${SIGIL_D1_REDIRECTS:-$repo_dir/dev-redirects.sgl}"
9
XDG_CACHE_HOME="$cache_dir" SIGIL_REDIRECTS="$redirects" "$sigil" -L src -L test test test/test-model.sgl --report
+10
# Assert the swept subjects EXIST before sweeping them: `if rg` cannot tell a
+11
# missing file (exit 2) from a clean one (exit 1), so a rename of the semantic
+12
# core would silently disarm this ban (found 2026-08-24).
+13
test -f src/sigil/doc/model.sgl
+14
test -f src/sigil/doc/traversal.sgl
15
if rg -n -i '(html|sxml|css|typst|latex|slate|class=|tag:)' src/sigil/doc/model.sgl src/sigil/doc/traversal.sgl; then
16
echo "backend vocabulary leaked into semantic core" >&2
17
exit 1
test/gate-d2.shmodified
@@ -9,6 +9,10 @@ cache_dir=$(mktemp -d "$repo_dir/build/d2-cache.XXXXXX")
9
export SIGIL_REDIRECTS="$redirects"
10
11
mkdir -p "$cache_dir/real"
+12
# Subject-existence pins: `if rg` reads a missing file (exit 2) the same as a
+13
# clean one (exit 1); a renamed semantic core would disarm this sweep silently.
+14
test -f src/sigil/doc/model.sgl
+15
test -f src/sigil/doc/traversal.sgl
16
if rg -n -i '(html|sxml|css|typst|latex|slate|class=|tag:)' src/sigil/doc/model.sgl src/sigil/doc/traversal.sgl; then
17
echo "backend vocabulary leaked into semantic core" >&2; exit 1
18
fi
test/gate-d3.shmodified
@@ -164,7 +164,13 @@ expect_fail 'got marker "".*exit:' "$gate_dir/dedicated-exit.log" \
164
# Failed forgeries never create a successful verification cache record.
165
expect_fail 'got marker "".*exit:' "$gate_dir/forge-file-again.log" \
166
"${cli[@]}" test/fixtures/d3-adversarial.sgd --example forge-file
−167
! rg -q 'cached' "$gate_dir/forge-file-again.log"
+167
# `if rg; then fail`, never a bare `! rg` -- bash exempts `!`-inverted
+168
# commands from `set -e`, so the bare form could never fail (inert 2026-08-24).
+169
# Subject presence: expect_fail above dies if the log was not written.
+170
if rg -q 'cached' "$gate_dir/forge-file-again.log"; then
+171
echo 'D3: a failed forgery produced a successful verification cache record' >&2
+172
exit 1
+173
fi
174
expect_fail 'got marker "".*signal:' "$gate_dir/signal.log" \
175
setsid -f --wait "${cli[@]}" test/fixtures/d3-adversarial.sgd --no-cache --example signal
176
# The private decoder rejects stale nonces and symlinks even when their payload
test/gate-d4a.shmodified
@@ -26,6 +26,10 @@ rg -q '@ref \["first-script"\]' test/fixtures/practical-sigil-change-question.sg
26
echo D4A_GATE_03_SECOND_CHAPTER_AUTHORING_CONTRACT
27
28
# The semantic adapter must not grow into a site generator. Press owns these.
+29
# Subject-existence pins: to `if rg`, a missing file (exit 2) reads as clean
+30
# (exit 1), so a rename would disarm this boundary sweep silently.
+31
test -f src/sigil/doc/render/html.sgl
+32
test -f src/sigil/doc/publication.sgl
33
if rg -n -i '<html|<head|stylesheet|site-nav|sitemap|robots\.txt|write-file|copy-file|output-directory' \
34
src/sigil/doc/render/html.sgl src/sigil/doc/publication.sgl; then
35
echo 'D4A renderer leaked Press/site-generation responsibility' >&2
test/gate-d6-customization.shmodified
@@ -79,8 +79,17 @@ generate_alternate alternate-a
79
generate_alternate alternate-b
80
cmp "$gate_dir/alternate-a.typ" "$gate_dir/alternate-b.typ"
81
cmp "$gate_dir/alternate-a.pdf" "$gate_dir/alternate-b.pdf"
−82
! cmp -s "$gate_dir/default-a.typ" "$gate_dir/alternate-a.typ"
−83
! cmp -s "$gate_dir/default-a.pdf" "$gate_dir/alternate-a.pdf"
+82
# `if cmp; then fail`, never a bare `! cmp` -- bash exempts `!`-inverted
+83
# commands from `set -e`, so the bare form could never fail: theming that
+84
# silently stopped applying would have passed (inert 2026-08-24).
+85
if cmp -s "$gate_dir/default-a.typ" "$gate_dir/alternate-a.typ"; then
+86
echo 'D6C: alternate theme produced a .typ IDENTICAL to the default' >&2
+87
exit 1
+88
fi
+89
if cmp -s "$gate_dir/default-a.pdf" "$gate_dir/alternate-a.pdf"; then
+90
echo 'D6C: alternate theme produced a .pdf IDENTICAL to the default' >&2
+91
exit 1
+92
fi
93
"$qpdf_bin" --check "$gate_dir/alternate-a.pdf" >"$gate_dir/alternate-qpdf.txt" 2>&1
94
"$pdfinfo_bin" "$gate_dir/alternate-a.pdf" >"$gate_dir/alternate-pdfinfo.txt"
95
"$pdftotext_bin" -layout "$gate_dir/alternate-a.pdf" "$gate_dir/alternate.txt"
@@ -131,11 +140,16 @@ rg -q 'Chapter I A Useful First Script' "$gate_dir/practical-compact.txt"
140
rg -q 'Chapter II Change the Question' "$gate_dir/practical-compact.txt"
141
echo D6C_GATE_07_CHECKED_IN_PRACTICAL_SIGIL_ALTERNATE_EDITION
142
+143
# Subject-existence pins: to `if rg`, a missing file (exit 2, empty output)
+144
# reads the same as a clean one, and an unmatched glob does too -- either would
+145
# disarm these sweeps silently.
+146
test -f src/sigil/doc/print.sgl
147
if rg -n -i 'typst|paper|margin|font|color|\.typ' src/sigil/doc/print.sgl \
148
| rg -v '^[0-9]+:[[:space:]]*;'; then
149
echo 'D6 customization backend leakage into print policy' >&2
150
exit 1
151
fi
+152
compgen -G 'book/practical-sigil/*.sgd' > /dev/null
153
if rg -n 'typst-theme|print-options|make-typst-length' book/practical-sigil/*.sgd; then
154
echo 'D6 customization leaked build policy into manuscripts' >&2
155
exit 1
test/gate-d6.shmodified
@@ -52,8 +52,17 @@ echo D6_GATE_03_REPRODUCIBLE_SOURCE_AND_PDF_BYTES
52
"$sigil" -L src test/build-d6-change-control.sgl "$gate_dir/changed.typ"
53
"$typst_bin" compile --root "$repo_dir" --creation-timestamp 0 --pdf-standard a-2b \
54
--jobs 1 "$gate_dir/changed.typ" "$gate_dir/changed.pdf"
−55
! cmp -s "$gate_dir/practical-a.typ" "$gate_dir/changed.typ"
−56
! cmp -s "$gate_dir/practical-a.pdf" "$gate_dir/changed.pdf"
+55
# Change-control assertions must be `if cmp; then fail`, never a bare `! cmp`
+56
# -- bash exempts `!`-inverted commands from `set -e`, so the bare form could
+57
# never fail: a build that IGNORED its input would have passed (inert 2026-08-24).
+58
if cmp -s "$gate_dir/practical-a.typ" "$gate_dir/changed.typ"; then
+59
echo 'D6 change control: changed input produced an IDENTICAL .typ' >&2
+60
exit 1
+61
fi
+62
if cmp -s "$gate_dir/practical-a.pdf" "$gate_dir/changed.pdf"; then
+63
echo 'D6 change control: changed input produced an IDENTICAL .pdf' >&2
+64
exit 1
+65
fi
66
"$pdftotext_bin" "$gate_dir/changed.pdf" "$gate_dir/changed.txt"
67
rg -q 'D6 changed-content witness 7391' "$gate_dir/changed.txt"
68
echo D6_GATE_03B_CONTENT_CHANGE_INVALIDATES_SOURCE_AND_PDF
@@ -142,6 +151,9 @@ rg -qi '#1F6F8B' "$gate_dir/highlight-histogram.txt"
151
echo D6_GATE_07B_OFFLINE_HIGHLIGHT_COPYABLE_AND_RASTER_COLORS
152
153
# The print adapter owns neither Press routing nor any typesetter implementation.
+154
# Subject-existence pins: to `if rg`, a missing file (exit 2) reads as clean.
+155
test -f src/sigil/doc/print.sgl
+156
test -f src/sigil/doc/render/typst.sgl
157
if rg -n -i 'press|site-nav|sitemap|robots\.txt|<html|write-pdf|line-break|font-shap|paginate' \
158
src/sigil/doc/print.sgl src/sigil/doc/render/typst.sgl; then
159
echo 'D6 boundary violation' >&2
test/gate-glossary.shmodified
@@ -30,7 +30,14 @@ rg -q '2\.1\. B' "$gate_dir/document.txt"
30
rg -q '2\.2\. E' "$gate_dir/document.txt"
31
rg -q 'binding \(page 4\)' "$gate_dir/document.txt"
32
rg -q 'links a symbol to a location' "$gate_dir/document.txt"
−33
! rg -q '2\.[0-9]+\. A$' "$gate_dir/document.txt"
+33
# `if rg; then fail`, never a bare `! rg` -- bash exempts `!`-inverted
+34
# commands from `set -e`, so the bare form could never fail (inert 2026-08-24).
+35
# Subject presence: the positive assertions above prove document.txt exists
+36
# and carries real glossary content.
+37
if rg -q '2\.[0-9]+\. A$' "$gate_dir/document.txt"; then
+38
echo 'GLOSSARY: a bare "A" entry appears in the rendered list (alphabetization/filter regression)' >&2
+39
exit 1
+40
fi
41
echo GLOSSARY_GATE_03_REAL_ALPHABETIZED_LINKED_PDF
42
43
echo GLOSSARY_GATE_GREEN
test/gate-semantic-structures.shmodified
@@ -29,7 +29,13 @@ mkdir -p build/semantic-structures
29
"$pdftotext_bin" -layout "$gate_dir/document.pdf" "$gate_dir/document.txt"
30
rg -q '3\. Nested three' "$gate_dir/document.txt"
31
rg -q 'Action.*Binding' "$gate_dir/document.txt"
−32
! rg -q 'demo-video-id' "$gate_dir/document.txt"
+32
# `if rg; then fail`, never a bare `! rg` -- bash exempts `!`-inverted
+33
# commands from `set -e`, so the bare form could never fail (inert 2026-08-24).
+34
# Subject presence: the positive assertions above prove document.txt exists.
+35
if rg -q 'demo-video-id' "$gate_dir/document.txt"; then
+36
echo 'SEMANTIC-STRUCTURES: video id leaked into print output (video policy regression)' >&2
+37
exit 1
+38
fi
39
echo SEMANTIC_STRUCTURES_GATE_03_REAL_PDF_LIST_TABLE_VIDEO_POLICY
40
41
echo SEMANTIC_STRUCTURES_GATE_GREEN