AtlatestRepositorysigil-doc
1
#!/usr/bin/env bash2
# SD-P7 sabotage driver.3
#4
# A gate that cannot demonstrate it fails is not a gate. Each leg plants a real5
# defect, runs the arm that should catch it, and REQUIRES a red. A leg that does6
# not go red ABORTS the driver: "the gate does not catch this" is a finding.7
#8
# FOUR THINGS THIS DRIVER DOES DELIBERATELY, each because the estate has been9
# bitten by its absence:10
#11
# 1. RESTORATION IS UNCONDITIONAL. `trap restore EXIT INT TERM`, not a step12
# that must be reached. SD-P1's leg 8 tripped `set -u` between a forge and13
# its restore and left a corrupted artifact in the worktree.14
# 2. EVERY RESTORE IS VERIFIED BY SHA256 against a copy taken before anything15
# was touched -- never by the exit code of `cp`, which reports success on a16
# wipe.17
# 3. EVERY ANCHOR IS A WHOLE LINE, MATCHED LITERALLY AND REQUIRED TO BE18
# UNIQUE. A leg whose anchor has moved aborts instead of quietly becoming a19
# no-op and reporting a green.20
# 4. A RED IS ASSERTED ON THE NAMED ARM, not on exit status and not merely on21
# "something failed". A compile error fails everything and means something22
# entirely different, so every arm-based leg also requires that OTHER arms23
# still pass -- i.e. that the suite genuinely ran.24
#25
# FABLE'S S-b HAS NO TARGET IN THIS IMPLEMENTATION, and that is a finding rather26
# than an omission. S-b asks for a leg that applies the section-child predicate27
# only at the OUTERMOST section and passes deeper children through unexamined,28
# so that the depth arm reddens while the single-level arm stays green.29
#30
# THERE IS NO SUCH CODE PATH. `@section` builds INSIDE-OUT: the innermost31
# section is constructed first, and each section validates its own children at32
# its own construction. Nothing ever walks a finished tree deciding which levels33
# to check, so there is no traversal to shorten. The depth property is34
# STRUCTURAL, a consequence of construction order, not algorithmic.35
#36
# Measured rather than argued: a leg planting "skip the check when this child37
# list contains a section" left BOTH the depth arm and the single-level arm38
# green, because the inner section's own child list contains no section and is39
# checked normally on the way up.40
#41
# The depth arm is nonetheless LIVE -- legs 2, 6 and 7 all redden it -- so it is42
# not vacuous, it is simply not independent of the single-level arm. Leg 2 now43
# asserts that explicitly, so the claim is gated rather than narrated.44
#45
# TWO LEGS THIS DRIVER NO LONGER HAS, AND WHY -- here rather than buried in a46
# helper comment, because this is where someone auditing the SABOTAGE SET will47
# look, and an absent leg is exactly the thing a reader cannot see.48
#49
# LEG 18 (Fable's S-b) was written, run, and DELETED. See the S-b note above:50
# it has no target. Before that was understood it also died in an instructive51
# way: its replacement text spanned TWO LINES, and `awk -v` cannot carry an52
# embedded newline, so the driver exited 1 with no leg log and no named53
# failure -- the one failure mode this whole file is built to not have. That54
# is why `replace_line` now refuses a multi-line replacement by name.55
#56
# LEG 13's SIGNATURE was rewritten. It quoted the gate's prose, the gate's57
# wording changed when arm 3 grew a second name set, and the leg then could58
# not recognise its own success. It now keys on `author-fourth-name`, the59
# value the leg itself plants, which cannot drift.60
#61
# LAYERS. Legs marked [product] break the shipped code; leg 10 is [assertion]62
# and breaks an expected value in the suite. They answer different questions: an63
# assertion-layer red proves the harness notices when the harness changes; a64
# product-layer red proves the suite executes the loaded product rather than a65
# mirror of itself.66
set -euo pipefail67
repo_dir="$(cd "$(dirname "$0")/.." && pwd)"68
cd "$repo_dir"69
mkdir -p "$repo_dir/build"70
sigil="${SIGIL_D1_COMPILER:-$repo_dir/../task-sigil-language-readers/build/dev/bin/sigil}"71
export SIGIL_REDIRECTS="${SIGIL_D1_REDIRECTS:-$repo_dir/dev-redirects.sgl}"72
work=$(mktemp -d "$repo_dir/build/sd-p7-sabotage.XXXXXX")73
export XDG_CACHE_HOME="$work/cache"75
for tool in sha256sum grep awk sed diff find; do76
command -v "$tool" >/dev/null || { echo "$tool is required by this driver" >&2; exit 1; }77
done78
test -x "$sigil" || { echo "dev compiler not found at $sigil" >&2; exit 1; }80
TARGETS=(81
src/sigil/doc/model.sgl82
src/sigil/doc/private/author-runtime.sgl83
src/sigil/doc/private/parser.sgl84
src/sigil/doc/render/plain.sgl85
test/sd-p7/folio/model.sgl86
test/test-section-profile.sgl87
)88
mkdir -p "$work/pristine"89
for f in "${TARGETS[@]}"; do90
mkdir -p "$work/pristine/$(dirname "$f")"91
cp "$f" "$work/pristine/$f"92
done94
restore() {95
local rc=$? bad=0 want have96
for f in "${TARGETS[@]}"; do97
cp "$work/pristine/$f" "$f"98
want=$(sha256sum < "$work/pristine/$f" | cut -d' ' -f1)99
have=$(sha256sum < "$f" | cut -d' ' -f1)100
if [ "$want" != "$have" ]; then101
echo "RESTORE FAILED BY CONTENT for $f (want $want, have $have)" >&2102
bad=1103
fi104
done105
if [ "$bad" != 0 ]; then106
echo "SD_P7_SABOTAGE_RESTORE_FAILED -- the worktree is NOT clean, fix by hand" >&2107
exit 90108
fi109
echo "SD_P7_SABOTAGE_RESTORED (${#TARGETS[@]} targets verified by sha256)"110
exit "$rc"111
}112
trap restore EXIT INT TERM114
reset_tree() { for f in "${TARGETS[@]}"; do cp "$work/pristine/$f" "$f"; done; }116
# Replace one whole line, matched literally, required to occur exactly once.117
replace_line() {118
local file="$1" from="$2" to="$3" label="$4" n119
# `awk -v` cannot carry an embedded newline, so a multi-line replacement dies120
# as an opaque exit 1 rather than as a named failure. Measured: leg 18 did121
# exactly that. Refuse it here, where the message can say why.122
case "$to" in *"123
"*) echo "LEG REPLACEMENT IS MULTI-LINE, which replace_line cannot apply: $label" >&2; exit 91 ;; esac124
n=$(grep -Fxc -- "$from" "$file" || true)125
if [ "$n" != "1" ]; then126
echo "LEG ANCHOR NOT UNIQUE ($n occurrences): $label" >&2127
echo " in $file: $from" >&2128
exit 91129
fi130
awk -v from="$from" -v to="$to" '{ if ($0 == from) print to; else print }' "$file" > "$work/edit.tmp"131
cp "$work/edit.tmp" "$file"132
grep -Fxq -- "$to" "$file" || { echo "LEG EDIT DID NOT LAND: $label" >&2; exit 91; }133
}135
append_line() { printf '%s\n' "$2" >> "$1"; }137
run_suite() {138
local log="$1"139
"$sigil" -L src -L test -L book test test/test-section-profile.sgl > "$log" 2>&1 || true140
sed -i 's/\x1b\[[0-9;]*m//g' "$log"141
}143
# ARM lines only. The runner also prints a `✓ All tests passed!` banner, which144
# is not an arm; it is subtracted by name rather than by assuming it is there.145
# A CONSTRUCTION-TIME REFUSAL CANNOT BE OBSERVED THROUGH THE TEST RUNNER.146
#147
# Measured, and it cost a run: when a profile refuses at construction the module148
# holding it fails to LOAD, and `sigil test` reports149
#150
# test-section-profile LOAD ERROR:151
# ERROR load failed test/test-section-profile.sgl152
#153
# with the message EMPTY. The red is real and its reason is discarded, so a leg154
# asserting on the refusal text sees nothing and a leg asserting only on "load155
# failed" cannot tell a correct refusal from any compile error whatsoever --156
# which is the difference between a check and a shrug.157
#158
# So these legs import the module DIRECTLY and read the process's own output,159
# where the message survives. This is the better instrument regardless: it160
# observes the refusal rather than a runner's summary of it.161
run_import_probe() {162
local module="$1" log="$2"163
"$sigil" -L src -L test eval "(begin (import $module) (display \"PROBE_LOADED_WITHOUT_REFUSAL\") (newline))" \164
> "$log" 2>&1 || true165
sed -i 's/\x1b\[[0-9;]*m//g' "$log"166
}168
# A refusal-shaped red: the signature must be present AND the module must not169
# have loaded. Without the second half a module that loaded fine while some170
# unrelated text matched would pass.171
expect_refusal() {172
local n="$1" layer="$2" label="$3" signature="$4" log="$5"173
if grep -qF -- "PROBE_LOADED_WITHOUT_REFUSAL" "$log"; then174
printf 'SD_P7_SABOTAGE_%02d [%s] DID NOT GO RED - the module loaded, so nothing was refused: %s\n' \175
"$n" "$layer" "$label" >&2176
tail -20 "$log" >&2177
exit 92178
fi179
if grep -qF -- "$signature" "$log"; then180
printf 'SD_P7_SABOTAGE_%02d [%s] RED %s\n refused at construction: %s\n' \181
"$n" "$layer" "$label" "$signature"182
else183
printf 'SD_P7_SABOTAGE_%02d [%s] DID NOT GO RED WITH THE RIGHT REASON: %s\n' \184
"$n" "$layer" "$label" >&2185
echo "--- expected signature: $signature" >&2186
tail -20 "$log" >&2187
exit 92188
fi189
}191
passing_arms() {192
local ticks banner193
# Leading whitespace is REQUIRED in the anchor: the runner indents arm lines194
# four spaces and the banner two, so `^✓ ` returns a confident zero.195
ticks=$(grep -cE '^[[:space:]]*✓ ' "$1" || true)196
banner=$(grep -cE '^[[:space:]]*✓ All tests passed' "$1" || true)197
echo $((ticks - banner))198
}200
# Signature-based red: the log must contain a string only the planted defect can201
# produce. Used where the defect prevents the suite from loading at all, which202
# is the correct outcome for a construction-time refusal.203
expect_signature() {204
local n="$1" layer="$2" label="$3" signature="$4" log="$5"205
if grep -qF -- "$signature" "$log"; then206
printf 'SD_P7_SABOTAGE_%02d [%s] RED %s\n signature: %s\n' \207
"$n" "$layer" "$label" "$signature"208
else209
printf 'SD_P7_SABOTAGE_%02d [%s] DID NOT GO RED - the gate does not catch this: %s\n' \210
"$n" "$layer" "$label" >&2211
echo "--- expected signature: $signature" >&2212
tail -40 "$log" >&2213
exit 92214
fi215
}217
# Arm-based red: the NAMED arm must stop passing, AND other arms must still218
# pass. Without the second half a compile error satisfies the first half, and a219
# compile error is not evidence that the arm checks anything.220
expect_arm() {221
local n="$1" layer="$2" label="$3" arm="$4" log="$5" now222
now=$(passing_arms "$log")223
if grep -Fq -- "✓ $arm" "$log"; then224
printf 'SD_P7_SABOTAGE_%02d [%s] DID NOT GO RED - the arm still passes: %s\n' \225
"$n" "$layer" "$label" >&2226
echo "--- arm: $arm" >&2227
tail -40 "$log" >&2228
exit 92229
fi230
if [ "$now" -lt 1 ]; then231
printf 'SD_P7_SABOTAGE_%02d [%s] INCONCLUSIVE - NO arm passed, so the suite did not run: %s\n' \232
"$n" "$layer" "$label" >&2233
tail -40 "$log" >&2234
exit 92235
fi236
printf 'SD_P7_SABOTAGE_%02d [%s] RED %s\n arm "%s" no longer passes; %s of %s arms still do\n' \237
"$n" "$layer" "$label" "$arm" "$now" "$BASELINE_ARMS"238
}240
# ---------------------------------------------------------------- BASELINE241
# GREEN FIRST, and its arm count recorded. Without this a leg's red is equally242
# consistent with the suite having been broken before the driver started.243
base_log="$work/leg00-baseline.log"244
run_suite "$base_log"245
grep -qE 'Tests: +[0-9]+ passed' "$base_log" \246
|| { tail -40 "$base_log"; echo "baseline reported no summary" >&2; exit 93; }247
if grep -qE '[0-9]+ failed' "$base_log"; then248
tail -40 "$base_log"; echo "baseline is not green -- sabotage would prove nothing" >&2; exit 93249
fi250
BASELINE_ARMS=$(passing_arms "$base_log")251
test "$BASELINE_ARMS" -gt 0 || { echo "baseline passed zero arms" >&2; exit 93; }252
echo "SD_P7_SABOTAGE_00 baseline suite GREEN, ${BASELINE_ARMS} arms"254
E2E="a folio-shaped profile builds a @section holding @task children, end to end"255
REFUSAL="a structural container is refused as a section child, and a work item is not"256
LAUNDER="a manuscript cannot launder a structural container through a section"257
NARROW="a profile may widen the section child set but never narrow it"258
VACUOUS="the constructor refuses the values that would make its own checks vacuous"259
FLOOR="a profile's predicates must be able to say no"260
DEPTH="the section-child predicate applies at every depth, not only the outermost"261
UNDESCRIBED="a profile without a describer emits today's wording, unlocated"262
DEFAULT="sigil/doc's own profile is today's policy, and its seam is unchanged"263
AMBIENT="the ambient profile is restored, including when the thunk raises"265
# Leg 17's anchor. `document->plain` returning the empty string is caught by266
# `test/test-model.sgl:5` -- `(> (string-length (document->plain …)) 500)` -- and267
# by nothing in arms 1-3, which is what makes it a test OF ARM 4 rather than a268
# test of whichever arm happens to fire first.269
PLAIN_ANCHOR_FROM=' (define (document->plain root) (render root))))'270
PLAIN_ANCHOR_TO=' (define (document->plain root) "")))'272
WIDE_CHILD=" (or (block-node? x) (folio-work-item? x) (folio-relational-node? x) (folio-structural-container? x)))"273
REAL_CHILD=" (or (block-node? x) (folio-work-item? x) (folio-relational-node? x)))"275
# ---------------------------------------------------------------- LEG 01276
# THE §6a ROW'S NAMED SABOTAGE, in the shape the MECHANISM catches: the folio277
# profile's section-child predicate is widened to admit structural containers278
# while its declaration still refuses them. The PROFILE must fail to construct,279
# which happens when `(sd-p7 folio model)` loads -- so the suite cannot even280
# start, and the signature is what makes that a refusal rather than a crash.281
reset_tree282
replace_line test/sd-p7/folio/model.sgl "$REAL_CHILD" "$WIDE_CHILD" "leg 1: widen folio-section-child?"283
log="$work/leg01.log"; run_import_probe "(sd-p7 folio model)" "$log"284
expect_refusal 1 product "predicate widened, declaration intact" \285
"admits a witness the profile declares refused" "$log"287
# ---------------------------------------------------------------- LEG 02288
# THE SAME WIDENING WITH THE DECLARATION DELETED TOO. This is the shape a real289
# future widening would take, and leg 1 does not cover it: with the declaration290
# gone the profile constructs happily and only the ARMS can catch it. Leg 1291
# proves the mechanism works; leg 2 proves the arms are load-bearing without it.292
reset_tree293
replace_line test/sd-p7/folio/model.sgl "$REAL_CHILD" "$WIDE_CHILD" "leg 2: widen folio-section-child?"294
# THE REPLACEMENT WITNESS MUST STILL BE REFUSED BY THE WIDENED PREDICATE, or295
# the profile fails to construct and this leg tests the MECHANISM again instead296
# of the arms. Measured: the first spelling used a `related` node, which the297
# widened predicate ADMITS, so the profile refused at construction, the suite298
# could not load, and the driver correctly reported INCONCLUSIVE rather than299
# accepting a red for the wrong reason. A `text` node is in folio's vocabulary300
# and outside the widened child set, which is exactly what is needed.301
replace_line test/sd-p7/folio/model.sgl \302
" (list (make-milestone \"m-witness\" \"a refused container\" '() witness-location)" \303
" (list (make-text \"a refused inline node\" witness-location)" \304
"leg 2: replace the refused milestone witness"305
replace_line test/sd-p7/folio/model.sgl \306
" (make-phase \"p-witness\" \"a refused container\" '() witness-location)))" \307
" ))" \308
"leg 2: drop the refused phase witness"309
log="$work/leg02.log"; run_suite "$log"310
expect_arm 2 product "widened AND declaration deleted -> the arms catch it" "$REFUSAL" "$log"311
expect_arm 2 product "widened AND declaration deleted -> the manuscript arm too" "$LAUNDER" "$log"312
# THE DEPTH ARM IS LIVE, gated here rather than asserted in prose. It cannot be313
# reddened INDEPENDENTLY of the single-level arm -- see the note on Fable's S-b in314
# this file's header -- so its ability to fail is demonstrated where it can be.315
expect_arm 2 product "widened AND declaration deleted -> the depth arm too" "$DEPTH" "$log"316
# CAUTION 1 (Fable): the two assertions above are satisfied by an ERROR STRING317
# GOING MISSING, which a fixture failing to evaluate for an unrelated reason318
# also produces. That is a red for the wrong cause, and a marker proving the arm319
# RAN rather than that it CHECKED.320
#321
# So this leg additionally demands POSITIVE EVIDENCE OF ACCEPTANCE: with the322
# predicate widened, the laundering manuscript must BUILD and the resulting tree323
# must actually contain a milestone inside a section inside a task. Note it324
# asserts the SHAPE, never the describer's wording -- keying on text I had just325
# made configurable would rebuild the same defect one layer over.326
accept_log="$work/leg02-acceptance.log"327
"$sigil" -L src -L test eval '(begin328
(import (sigil doc) (sd-p7 folio model))329
(load "test/fixtures/sd-p7-folio-laundering.sgd")330
(let* ((doc (eval (quote document)))331
(task (let scan ((xs (note-children doc)))332
(cond ((null? xs) #f) ((task? (car xs)) (car xs)) (else (scan (cdr xs))))))333
(section (and task (let scan ((xs (task-children task)))334
(cond ((null? xs) #f) ((section? (car xs)) (car xs))335
(else (scan (cdr xs)))))))336
(smuggled (and section (let scan ((xs (section-children section)))337
(cond ((null? xs) #f) ((milestone? (car xs)) (car xs))338
(else (scan (cdr xs))))))))339
(if smuggled340
(begin (display "LAUNDERED: milestone ") (display (milestone-id smuggled))341
(display " inside section ") (display (section-id section))342
(display " inside task ") (display (task-id task)) (newline))343
(begin (display "NOT-LAUNDERED") (newline)))))' > "$accept_log" 2>&1 || true344
sed -i 's/\x1b\[[0-9;]*m//g' "$accept_log"345
if grep -q "^LAUNDERED: milestone m-smuggled inside section smuggling inside task t-wrapper$" "$accept_log"; then346
printf 'SD_P7_SABOTAGE_02 [product] RED %s\n positive evidence: %s\n' \347
"the widened predicate genuinely ACCEPTS the laundered tree" \348
"$(grep '^LAUNDERED:' "$accept_log")"349
else350
echo "SD_P7_SABOTAGE_02 INCONCLUSIVE - the manuscript did not build a laundered tree, so the arms' red is not attributable to acceptance" >&2351
tail -20 "$accept_log" >&2352
exit 92353
fi355
# ---------------------------------------------------------------- LEG 03356
# ANTI-NARROWING REMOVED. Its input is neutered rather than its scoring, so the357
# check still runs and simply has nothing to check -- the exact shape of a358
# vacuous guard.359
reset_tree360
replace_line src/sigil/doc/model.sgl \361
" (core-block-witnesses)" \362
" '()" \363
"leg 3: neuter the anti-narrowing witness set"364
log="$work/leg03.log"; run_suite "$log"365
expect_arm 3 product "anti-narrowing check neutered" "$NARROW" "$log"367
# ---------------------------------------------------------------- LEG 04368
# THE ANTI-VACUITY GUARD REMOVED. Without it a profile may declare a bare369
# symbol refused and pass the refusal check for free.370
reset_tree371
replace_line src/sigil/doc/model.sgl \372
" (append admitted refused)" \373
" '()" \374
"leg 4: neuter the vocabulary check on declared witnesses"375
log="$work/leg04.log"; run_suite "$log"376
expect_arm 4 product "anti-vacuity guard neutered" "$VACUOUS" "$log"378
# ---------------------------------------------------------------- LEG 05379
# `make-section-with-profile` IGNORES THE PROFILE. Gate 3 of the three.380
reset_tree381
replace_line src/sigil/doc/model.sgl \382
" (make-section-checked (content-profile-record-section-child-predicate profile)" \383
" (make-section-checked block-node?" \384
"leg 5: make-section-with-profile ignores its profile"385
log="$work/leg05.log"; run_suite "$log"386
expect_arm 5 product "section constructor ignores the profile" "$E2E" "$log"388
# ---------------------------------------------------------------- LEG 06389
# `author-normalize` REVERTS TO THE CLOSED ENUMERATION. Gate 1 of the three, and390
# the one a manuscript hits FIRST -- measured, and the reason this phase is not391
# confined to `make-section`.392
reset_tree393
replace_line src/sigil/doc/private/author-runtime.sgl \394
" ((author-node? value) value)" \395
" ((document-node? value) value)" \396
"leg 6: author-normalize back to document-node?"397
log="$work/leg06.log"; run_suite "$log"398
expect_arm 6 product "author-normalize back to the closed enumeration" "$E2E" "$log"400
# ---------------------------------------------------------------- LEG 07401
# `author-flatten` REVERTS. Gate 2 of the three, and the leg that justifies the402
# AMBIENT design: `author-flatten` is called lexically from inside403
# `(sigil doc author)`, so no prelude rebinding could ever have reached it.404
reset_tree405
replace_line src/sigil/doc/private/author-runtime.sgl \406
" ((author-node? (car xs)) (walk (cdr xs) (cons (car xs) out)))" \407
" ((document-node? (car xs)) (walk (cdr xs) (cons (car xs) out)))" \408
"leg 7: author-flatten back to document-node?"409
log="$work/leg07.log"; run_suite "$log"410
expect_arm 7 product "author-flatten back to the closed enumeration" "$E2E" "$log"412
# ---------------------------------------------------------------- LEG 08413
# `with-content-profile` LOSES ITS `dynamic-wind`. Restoration becomes a step414
# that must be reached, so a manuscript that raises leaves a delegating415
# language's profile installed for whatever runs next.416
# The restore moves INTO the thunk, so a normal return still restores and a417
# RAISE does not -- which is precisely "a recovery that only runs on the happy418
# path", and precisely what the arm's raising case exists to catch. A leg that419
# simply deleted the restore would redden the arm's easy half as well and prove420
# less.421
reset_tree422
replace_line src/sigil/doc/private/author-runtime.sgl \423
" (dynamic-wind swap! thunk swap!)))))" \424
" (let ((r (begin (swap!) (thunk)))) (swap!) r)))))" \425
"leg 8: restore only on the happy path"426
log="$work/leg08.log"; run_suite "$log"427
expect_arm 8 product "ambient profile restored only on the happy path" "$AMBIENT" "$log"429
# ---------------------------------------------------------------- LEG 09430
# THE FOUR-ARGUMENT `make-section` IS SILENTLY WIDENED. `#lang sigil/doc` and431
# every direct caller would start accepting children they have always refused.432
reset_tree433
replace_line src/sigil/doc/model.sgl \434
" (make-section-checked block-node? #f id title children loc))" \435
" (make-section-checked (lambda (x) #t) #f id title children loc))" \436
"leg 9: make-section admits anything"437
log="$work/leg09.log"; run_suite "$log"438
expect_arm 9 product "make-section silently widened" "$DEFAULT" "$log"440
# ---------------------------------------------------------------- LEG 12441
# THE MECHANISM PROTECTS `sigil/doc`'s OWN PROFILE TOO, not only folio's. Widen442
# the DEFAULT profile's section-child predicate and its own declared refused443
# witnesses -- a `text` and a `list-item` -- make it refuse to construct.444
# `document-node?`, not `(lambda (x) #t)`. The floor on refusal runs BEFORE the445
# declaration check, so a totally permissive predicate fails at the floor with a446
# different message and this leg would then be testing the floor -- which leg 14447
# already covers. Widening to `document-node?` is also the realistic mistake: it448
# passes the floor and the anti-narrowing check and is caught only by the449
# profile's own declaration, which is the property this leg exists to pin.450
reset_tree451
replace_line src/sigil/doc/model.sgl \452
" (make-content-profile \"sigil/doc\" document-node? block-node?" \453
" (make-content-profile \"sigil/doc\" document-node? document-node?" \454
"leg 12: widen the default profile's section-child predicate"455
log="$work/leg12.log"; run_import_probe "(sigil doc)" "$log"456
expect_refusal 12 product "default profile widened past its own declaration" \457
"admits a witness the profile declares refused" "$log"459
# ---------------------------------------------------------------- LEG 10460
# ASSERTION LAYER, deliberately: one expected task id in the suite is perturbed.461
# This proves the end-to-end arm's assertions are live rather than decorative --462
# a different question from every leg above, all of which broke the product.463
reset_tree464
replace_line test/test-section-profile.sgl \465
" (assert-equal \"t-predicate\" (task-id (cadr children)))" \466
" (assert-equal \"t-perturbed\" (task-id (cadr children)))" \467
"leg 10: perturb an expected task id"468
log="$work/leg10.log"; run_suite "$log"469
expect_arm 10 assertion "an expected task id perturbed" "$E2E" "$log"471
# ---------------------------------------------------------------- LEG 14472
# THE FLOOR ON REFUSAL, neutered at its input. Without it, `(lambda (x) #t)`473
# satisfies the vocabulary guard for free and a profile can declare a junk474
# predicate instead of a junk witness. Adversarial review found this hole; this475
# leg is what stops it being reopened.476
reset_tree477
replace_line src/sigil/doc/model.sgl \478
" (let ((non-nodes (non-node-witnesses)))" \479
" (let ((non-nodes '()))" \480
"leg 14: neuter the floor on refusal"481
log="$work/leg14.log"; run_suite "$log"482
expect_arm 14 product "floor on refusal neutered" "$FLOOR" "$log"484
# ---------------------------------------------------------------- LEG 15485
# THE `admitted` CHECK, which nothing covered until review asked. Every profile486
# in the tree satisfies it trivially, so its deletion was invisible.487
reset_tree488
replace_line src/sigil/doc/model.sgl \489
" admitted" \490
" '()" \491
"leg 15: neuter the admitted-witness check"492
log="$work/leg15.log"; run_suite "$log"493
expect_arm 15 product "admitted-witness check neutered" "$VACUOUS" "$log"495
# ---------------------------------------------------------------- LEG 16496
# THE CORE-BLOCK FLOOR ON `refused`, which closes the identity-discrimination497
# route past the sampled anti-narrowing check.498
reset_tree499
replace_line src/sigil/doc/model.sgl \500
" (profile-require-none who \"core block floor\" block-node?" \501
" (profile-require-none who \"core block floor\" (lambda (x) #f)" \502
"leg 16: neuter the core-block floor on refused witnesses"503
log="$work/leg16.log"; run_suite "$log"504
expect_arm 16 product "core-block floor on refused witnesses neutered" "$FLOOR" "$log"506
# ---------------------------------------------------------------- LEG 19507
# THE DESCRIBER MUST NOT REACH THE DEFAULT PATH. Make `make-section` pass the508
# default profile's describer instead of `#f` -- the "why build the message509
# twice" tidy-up. Under this design the describer is the ONLY thing that can add510
# a location, so the leak shows up as a location appearing where there was none.511
reset_tree512
replace_line src/sigil/doc/model.sgl \513
" (make-section-checked block-node? #f id title children loc))" \514
" (make-section-checked block-node? (lambda (node) \"located: child belongs to the wrong semantic category\") id title children loc))" \515
"leg 19: a describer reaches the default path"516
log="$work/leg19.log"; run_suite "$log"517
expect_arm 19 product "describer leaked into the default path" "$UNDESCRIBED" "$log"519
# ---------------------------------------------------------------- LEG 11520
# CAN GATE ARM 2 -- THE CONSTRUCTION DIFFERENTIAL -- FAIL AT ALL?521
#522
# Every leg above reddens the SUITE. Arm 2 exists precisely to cover what the523
# suite does not, so nothing above it establishes that arm 2 can fire, and an524
# equality check that cannot fail is the most convincing vacuous gate there is.525
#526
# The planted defect is therefore chosen to be INVISIBLE TO THE SUITE and527
# visible to the differential: `code-block-language` returns `#f` instead of the528
# stored language. `test/test-section-profile.sgl` never touches a code block,529
# so arm 1 stays green and the gate REACHES arm 2 -- which compares 32 recorded530
# `(language "...")` fields across the baseline's 22 manuscripts.531
reset_tree532
replace_line src/sigil/doc/model.sgl \533
" (define code-block? code-block-record?) (define (code-block-language x) (copy-string-or-false (code-block-record-language x))) (define (code-block-content x) (string-copy (code-block-record-content x))) (define (code-block-location x) (safe-location (code-block-record-location x)))" \534
" (define code-block? code-block-record?) (define (code-block-language x) #f) (define (code-block-content x) (string-copy (code-block-record-content x))) (define (code-block-location x) (safe-location (code-block-record-location x)))" \535
"leg 11: code-block-language drops the stored language"536
if bash test/gate-sd-p7.sh > "$work/leg11.log" 2>&1; then537
echo "SD_P7_SABOTAGE_11 [product] DID NOT GO RED - the construction differential accepted a changed document" >&2538
tail -30 "$work/leg11.log" >&2539
exit 92540
fi541
# The gate must have got PAST arm 1. If it died at arm 1 this leg proves the542
# SUITE caught the defect and says nothing whatever about arm 2, which is the543
# only question it was asked.544
grep -q '^SD_P7_GATE_01 ' "$work/leg11.log" \545
|| { echo "SD_P7_SABOTAGE_11 INCONCLUSIVE - the gate died before reaching arm 2" >&2; tail -30 "$work/leg11.log" >&2; exit 92; }546
expect_signature 11 product "a document field changed, invisible to the suite" \547
"arm 02: constructed documents changed" "$work/leg11.log"549
# ---------------------------------------------------------------- LEG 13550
# CAN GATE ARM 3 FAIL AT ALL? The arm derives the set of runtime names the551
# parser emits and compares it against the documented set. Add a fourth552
# emission site and the arm must refuse.553
reset_tree554
append_line src/sigil/doc/private/parser.sgl " ;; (list 'author-fourth-name)"555
if bash test/gate-sd-p7.sh > "$work/leg13.log" 2>&1; then556
echo "SD_P7_SABOTAGE_13 [product] DID NOT GO RED - gate arm 3 accepted a fourth emitted name" >&2557
tail -30 "$work/leg13.log" >&2558
exit 92559
fi560
# THE SIGNATURE IS THE LEG'S OWN PLANTED VALUE, not a quotation of the gate's561
# prose. The first spelling expected "emitted runtime names have moved" and the562
# arm now says "emitted AUTHOR-RUNTIME names have moved" -- I rewrote the arm to563
# pin two name sets and left the leg quoting the old wording. The gate failed564
# exactly as intended and the leg could not recognise its own success: taxonomy565
# shape 10, in the driver that exists to catch shape 10.566
#567
# `author-fourth-name` is what THIS leg appends, so the check cannot drift when568
# the arm's wording changes again. The `arm 03` half is asserted separately so a569
# failure at some other arm cannot satisfy it.570
grep -q "SD_P7_GATE_FAILED: arm 03:" "$work/leg13.log" \571
|| { echo "SD_P7_SABOTAGE_13 DID NOT GO RED AT ARM 03" >&2; tail -20 "$work/leg13.log" >&2; exit 92; }572
expect_signature 13 product "a fourth runtime name added to the parser" \573
"author-fourth-name" "$work/leg13.log"575
# ---------------------------------------------------------------- LEG 17576
# CAN GATE ARM 4 -- THE FULL-SUITE REGRESSION -- FAIL AT ALL?577
#578
# The coverage table has to have a row for every arm. Arm 4 was observed red for579
# real during this phase (a load-path error made four suites fail to load), but580
# that was an ENVIRONMENT change, not a planted product defect, so it does not581
# establish that arm 4 catches a regression in the code.582
#583
# The defect must be invisible to arms 1-3, or the gate dies earlier and this584
# leg certifies an arm it never reached: a renderer change is invisible to the585
# phase suite (which renders nothing), to the construction differential (which586
# compares `document->datum`, not rendered text), and to the name derivation.587
reset_tree588
replace_line src/sigil/doc/render/plain.sgl \589
"$PLAIN_ANCHOR_FROM" "$PLAIN_ANCHOR_TO" "leg 17: break the plain renderer"590
if bash test/gate-sd-p7.sh > "$work/leg17.log" 2>&1; then591
echo "SD_P7_SABOTAGE_17 [product] DID NOT GO RED - the full-suite regression accepted a broken renderer" >&2592
tail -30 "$work/leg17.log" >&2593
exit 92594
fi595
for marker in SD_P7_GATE_01 SD_P7_GATE_02 SD_P7_GATE_03; do596
grep -q "^$marker " "$work/leg17.log" \597
|| { echo "SD_P7_SABOTAGE_17 INCONCLUSIVE - the gate died before arm 4 (missing $marker)" >&2598
tail -30 "$work/leg17.log" >&2; exit 92; }599
done600
expect_signature 17 product "a renderer defect, invisible to arms 1-3" \601
"arm 04: a test failed" "$work/leg17.log"603
reset_tree604
# The count is DERIVED from the legs this file actually runs, not restated: a605
# driver that says "12 legs" while running 11 is the stale-constant shape.606
legs=$(grep -cE '^expect_(arm|signature) [0-9]+' "$0")607
echo "SD_P7_SABOTAGE_COMPLETE ${legs} red assertions, all satisfied at their named arm"