checkwright 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/payload/canon-kit/SPEC.md +2 -2
- package/payload/canon-kit/checks/check-md-refs.sh +22 -9
- package/payload/canon-kit/checks/check-spec-pointer.sh +6 -2
- package/payload/context-kit/SPEC.md +13 -6
- package/payload/context-kit/lib/toolfloor.sh +1 -1
- package/payload/delegation-kit/README.md +2 -1
- package/payload/delegation-kit/SPEC.md +207 -35
- package/payload/delegation-kit/checks/check-agent-tier-explicit.sh +61 -0
- package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/bad/agents/silent.md +7 -0
- package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/bad/args +1 -0
- package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/bad/expect.txt +1 -0
- package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/agents/explicit-cheap.md +7 -0
- package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/agents/explicit-inherit.md +8 -0
- package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/args +1 -0
- package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/expect.txt +1 -0
- package/payload/delegation-kit/lib/delegation.sh +2 -0
- package/payload/delegation-kit/smoke/install.sh +1 -0
- package/payload/delegation-kit/templates/agent-execution.md +74 -9
- package/payload/gate-sdk/SPEC.md +6 -5
- package/payload/gate-sdk/bin/gen-pre-commit.sh +1 -1
- package/payload/gate-sdk/bin/run-gates.sh +1 -1
- package/payload/gate-sdk/checks/check-graph.sh +3 -3
- package/payload/gate-sdk/checks/check-reads-couples.sh +3 -1
- package/payload/gate-sdk/checks/check-tree-terms.sh +11 -7
- package/payload/gate-sdk/lib/gate.sh +29 -13
- package/payload/lifecycle-kit/SPEC.md +14 -4
- package/payload/lifecycle-kit/templates/lead.md +38 -3
- package/payload/site-kit/SPEC.md +104 -12
- package/payload/site-kit/checks/check-docs-render-fidelity.sh +100 -27
- package/payload/site-kit/gate-tests/check-docs-render-fidelity-batch.test.sh +158 -0
- package/payload/site-kit/lib/site.sh +16 -2
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
#
|
|
5
5
|
# usage: check-docs-render-fidelity.sh [docs-dir] [config-file]
|
|
6
6
|
# defaults SITE_KIT_DOCS_DIR; config-file overrides SITE_KIT_CONFIG_FILE so a
|
|
7
|
-
# fixture supplies its own
|
|
7
|
+
# fixture supplies its own renderer knobs / docs dir.
|
|
8
8
|
set -uo pipefail
|
|
9
9
|
|
|
10
10
|
KIT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
@@ -23,12 +23,28 @@ git rev-parse --git-dir >/dev/null 2>&1 || {
|
|
|
23
23
|
echo "check-docs-render-fidelity: not a git repository — cannot enumerate tracked pages" >&2; exit 2; }
|
|
24
24
|
[[ -d "$DOCS" ]] || { echo "check-docs-render-fidelity: docs dir not found: $DOCS" >&2; exit 2; }
|
|
25
25
|
|
|
26
|
-
probe
|
|
27
|
-
if [[
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
# spec: site-kit/SPEC.md §check-docs-render-fidelity — probe the oracle the gate will actually run, and only that one: a set batch knob is the consumer's statement of which parser is authoritative, so a batch-only setup is never refused over a per-document renderer this run will not invoke
|
|
27
|
+
if [[ ${#SITE_KIT_RENDERER_BATCH[@]} -gt 0 ]]; then
|
|
28
|
+
bprobe=0
|
|
29
|
+
while IFS= read -r -d '' d; do
|
|
30
|
+
[[ -n "${d//[[:space:]]/}" ]] && bprobe=$((bprobe + 1))
|
|
31
|
+
done < <(printf '%s\n\000' '# probe one' '# probe two' | "${SITE_KIT_RENDERER_BATCH[@]}" 2>/dev/null)
|
|
32
|
+
if [[ "$bprobe" -ne 2 ]]; then
|
|
33
|
+
echo "check-docs-render-fidelity: batch renderer '${SITE_KIT_RENDERER_BATCH[*]}' failed its probe" >&2
|
|
34
|
+
echo " (2 documents in, $bprobe non-empty document(s) back)" >&2
|
|
35
|
+
echo " help: SITE_KIT_RENDERER_BATCH must read NUL-terminated documents from stdin and write" >&2
|
|
36
|
+
echo " one NUL-terminated HTML document per input, in order; unset it to fall back to" >&2
|
|
37
|
+
echo " the per-document SITE_KIT_RENDERER contract" >&2
|
|
38
|
+
exit 2
|
|
39
|
+
fi
|
|
40
|
+
else
|
|
41
|
+
probe="$(printf '# probe\n' | "${SITE_KIT_RENDERER[@]}" 2>/dev/null)"; pst=$?
|
|
42
|
+
if [[ "$pst" -ne 0 || -z "$probe" ]]; then
|
|
43
|
+
echo "check-docs-render-fidelity: renderer '${SITE_KIT_RENDERER[*]}' could not run (exit $pst)" >&2
|
|
44
|
+
echo " help: install the Pages parser — ruby plus the kramdown-parser-gfm gem — or point" >&2
|
|
45
|
+
echo " SITE_KIT_RENDERER at a stdin->stdout GFM-to-HTML command" >&2
|
|
46
|
+
exit 2
|
|
47
|
+
fi
|
|
32
48
|
fi
|
|
33
49
|
|
|
34
50
|
listing="$(git ls-files -- "$DOCS")"; st=$?
|
|
@@ -48,15 +64,14 @@ if [[ ${#pages[@]} -eq 0 ]]; then
|
|
|
48
64
|
exit 0
|
|
49
65
|
fi
|
|
50
66
|
|
|
51
|
-
strip_fm='NR==1 && $0=="---" { fm=1; next } fm==1 && $0=="---" { fm=0; next } fm==1 { next } { print }'
|
|
52
|
-
|
|
53
67
|
rendered_scan='
|
|
54
68
|
BEGIN {
|
|
55
|
-
inpre=0; leak=0; h=0; tbl=0; fgn=0
|
|
56
69
|
# spec: site-kit/SPEC.md §check-docs-render-fidelity — the known-HTML-element set is a kit built-in, not a config seam
|
|
57
70
|
split("a abbr address area article aside audio b base bdi bdo blockquote body br button canvas caption cite code col colgroup data datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header hgroup hr html i iframe img input ins kbd label legend li link main map mark menu meta meter nav noscript object ol optgroup option output p param picture pre progress q rp rt ruby s samp script search section select slot small source span strong style sub summary sup table tbody td template textarea tfoot th thead time title tr track u ul var video wbr", A, " ")
|
|
58
71
|
for (i in A) HTMLEL[A[i]]=1
|
|
59
72
|
}
|
|
73
|
+
# spec: site-kit/SPEC.md §check-docs-render-fidelity — BEGINFILE/ENDFILE (GNU awk) reset the per-page state and emit the result the instant the file ends, so one process fed every page html file reproduces what re-execing this program once per page produced
|
|
74
|
+
BEGINFILE { inpre=0; leak=0; h=0; tbl=0; fgn=0 }
|
|
60
75
|
{
|
|
61
76
|
t=$0
|
|
62
77
|
while (match(t, /<h[1-6][ >]/)) { h++; t=substr(t, RSTART+RLENGTH) }
|
|
@@ -85,10 +100,10 @@ BEGIN {
|
|
|
85
100
|
gsub(/<[^>]*>/, "", s)
|
|
86
101
|
if (s ~ /`/) leak=1
|
|
87
102
|
}
|
|
88
|
-
|
|
103
|
+
ENDFILE { print leak+0, h+0, tbl+0 }'
|
|
89
104
|
|
|
90
105
|
source_headings='
|
|
91
|
-
|
|
106
|
+
BEGINFILE { infence=0; fchar=""; flen=0; count=0; prevblank=1; previsatx=0 }
|
|
92
107
|
{
|
|
93
108
|
s=$0; n=0
|
|
94
109
|
while (substr(s,1,1)==" ") { s=substr(s,2); n++ }
|
|
@@ -109,11 +124,11 @@ BEGIN { infence=0; fchar=""; flen=0; count=0; prevblank=1; previsatx=0 }
|
|
|
109
124
|
if (n<=3 && s ~ /^#{1,6}([ \t]|$)/) { count++; prevblank=0; previsatx=1; next }
|
|
110
125
|
prevblank=($0 ~ /^[ \t]*$/); previsatx=0
|
|
111
126
|
}
|
|
112
|
-
|
|
127
|
+
ENDFILE { print count+0 }'
|
|
113
128
|
|
|
114
129
|
# spec: site-kit/SPEC.md §check-docs-render-fidelity — count source GFM table starts (a pipe row followed by a | --- | delimiter row) outside code fences
|
|
115
130
|
source_tables='
|
|
116
|
-
|
|
131
|
+
BEGINFILE { infence=0; fchar=""; flen=0; count=0; prevpipe=0 }
|
|
117
132
|
{
|
|
118
133
|
s=$0; n=0
|
|
119
134
|
while (substr(s,1,1)==" ") { s=substr(s,2); n++ }
|
|
@@ -133,21 +148,79 @@ BEGIN { infence=0; fchar=""; flen=0; count=0; prevpipe=0 }
|
|
|
133
148
|
if ($0 ~ /^[ \t]*$/) { prevpipe=0; next }
|
|
134
149
|
prevpipe = (index($0, "|") > 0) ? 1 : 0
|
|
135
150
|
}
|
|
136
|
-
|
|
151
|
+
ENDFILE { print count+0 }'
|
|
152
|
+
|
|
153
|
+
# spec: site-kit/SPEC.md §check-docs-render-fidelity — one awk process strips front matter from every page at once (a page-indexed temp file per output, gawk's ARGIND keying the filename to the page it came from) rather than re-execing awk once per page; BEGINFILE/ARGIND are GNU awk (already the family's toolchain floor, docs/install.md)
|
|
154
|
+
WORK="$(mktemp -d)" || { echo "check-docs-render-fidelity: could not create a scratch dir" >&2; exit 2; }
|
|
155
|
+
trap 'rm -rf "$WORK"' EXIT
|
|
156
|
+
|
|
157
|
+
for i in "${!pages[@]}"; do : > "$WORK/body.$i"; done
|
|
158
|
+
|
|
159
|
+
awk -v outdir="$WORK" '
|
|
160
|
+
BEGINFILE { outfile = outdir "/body." (ARGIND - 1); fm = 0 }
|
|
161
|
+
FNR==1 && $0=="---" { fm=1; next }
|
|
162
|
+
fm==1 && $0=="---" { fm=0; next }
|
|
163
|
+
fm==1 { next }
|
|
164
|
+
{ print > outfile }
|
|
165
|
+
' "${pages[@]}"
|
|
166
|
+
bst=$?
|
|
167
|
+
fail_closed "$bst" DOCS-RENDER-FIDELITY front-matter-strip
|
|
168
|
+
|
|
169
|
+
bodies=()
|
|
170
|
+
body_files=()
|
|
171
|
+
for i in "${!pages[@]}"; do
|
|
172
|
+
bodies+=("$(<"$WORK/body.$i")")
|
|
173
|
+
body_files+=("$WORK/body.$i")
|
|
174
|
+
done
|
|
175
|
+
|
|
176
|
+
htmls=()
|
|
177
|
+
if [[ ${#SITE_KIT_RENDERER_BATCH[@]} -gt 0 ]]; then
|
|
178
|
+
# spec: site-kit/SPEC.md §check-docs-render-fidelity — command substitution strips NUL, so the framed stream is read through a process substitution: it never passes through $(…), and the loop body stays in this shell
|
|
179
|
+
while IFS= read -r -d '' html; do
|
|
180
|
+
while [[ "$html" == *$'\n' ]]; do html="${html%$'\n'}"; done
|
|
181
|
+
htmls+=("$html")
|
|
182
|
+
done < <(printf '%s\n\000' "${bodies[@]}" | "${SITE_KIT_RENDERER_BATCH[@]}")
|
|
183
|
+
# spec: site-kit/SPEC.md §check-docs-render-fidelity — the count assertion stands in for the per-page exit status process substitution discarded, so it catches renderer death, truncation and framing error alike, and refuses (2) rather than reporting a finding (1)
|
|
184
|
+
if [[ ${#htmls[@]} -ne ${#pages[@]} ]]; then
|
|
185
|
+
echo "check-docs-render-fidelity: batch renderer returned ${#htmls[@]} document(s) for ${#pages[@]} page(s)" >&2
|
|
186
|
+
echo " help: SITE_KIT_RENDERER_BATCH must write exactly one NUL-terminated HTML document per" >&2
|
|
187
|
+
echo " NUL-terminated input document, in order; a short count is a renderer that died" >&2
|
|
188
|
+
echo " mid-stream, truncated its output, or framed it wrongly" >&2
|
|
189
|
+
exit 2
|
|
190
|
+
fi
|
|
191
|
+
else
|
|
192
|
+
for body in "${bodies[@]}"; do
|
|
193
|
+
html="$(printf '%s\n' "$body" | "${SITE_KIT_RENDERER[@]}")"; rst=$?
|
|
194
|
+
fail_closed "$rst" DOCS-RENDER-FIDELITY renderer
|
|
195
|
+
htmls+=("$html")
|
|
196
|
+
done
|
|
197
|
+
fi
|
|
198
|
+
|
|
199
|
+
# spec: site-kit/SPEC.md §check-docs-render-fidelity — each of the three per-page scans batches into one awk process across every page's file (gawk's ENDFILE emits the scan's result line the instant a file finishes, in ARGV order, so one process substitution-free command substitution yields one result line per page) rather than re-execing awk once per page per scan
|
|
200
|
+
html_files=()
|
|
201
|
+
for i in "${!pages[@]}"; do
|
|
202
|
+
printf '%s\n' "${htmls[$i]}" > "$WORK/html.$i"
|
|
203
|
+
html_files+=("$WORK/html.$i")
|
|
204
|
+
done
|
|
205
|
+
|
|
206
|
+
rscan_out="$(awk "$rendered_scan" "${html_files[@]}")"; ast=$?
|
|
207
|
+
fail_closed "$ast" DOCS-RENDER-FIDELITY rendered-scan
|
|
208
|
+
mapfile -t rscan_lines <<< "$rscan_out"
|
|
209
|
+
|
|
210
|
+
heading_out="$(awk "$source_headings" "${body_files[@]}")"; sst=$?
|
|
211
|
+
fail_closed "$sst" DOCS-RENDER-FIDELITY source-scan
|
|
212
|
+
mapfile -t heading_lines <<< "$heading_out"
|
|
213
|
+
|
|
214
|
+
table_out="$(awk "$source_tables" "${body_files[@]}")"; tst=$?
|
|
215
|
+
fail_closed "$tst" DOCS-RENDER-FIDELITY source-table-scan
|
|
216
|
+
mapfile -t table_lines <<< "$table_out"
|
|
137
217
|
|
|
138
218
|
findings=()
|
|
139
|
-
for
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
read -r leak rcount rtbl < <(printf '%s\n' "$html" | awk "$rendered_scan"); ast=$?
|
|
146
|
-
fail_closed "$ast" DOCS-RENDER-FIDELITY rendered-scan
|
|
147
|
-
scount="$(printf '%s\n' "$body" | awk "$source_headings")"; sst=$?
|
|
148
|
-
fail_closed "$sst" DOCS-RENDER-FIDELITY source-scan
|
|
149
|
-
stbl="$(printf '%s\n' "$body" | awk "$source_tables")"; tst=$?
|
|
150
|
-
fail_closed "$tst" DOCS-RENDER-FIDELITY source-table-scan
|
|
219
|
+
for i in "${!pages[@]}"; do
|
|
220
|
+
page="${pages[$i]}"
|
|
221
|
+
read -r leak rcount rtbl <<< "${rscan_lines[$i]}"
|
|
222
|
+
scount="${heading_lines[$i]}"
|
|
223
|
+
stbl="${table_lines[$i]}"
|
|
151
224
|
|
|
152
225
|
[[ "$leak" -eq 1 ]] && findings+=("$page: a code-span corruption symptom (a stray backtick, or a raw non-HTML-element tag) leaked into rendered text — a code span or fenced block failed to parse")
|
|
153
226
|
[[ "$rcount" -gt "$scount" ]] && findings+=("$page: $rcount rendered heading(s) exceed $scount source heading(s) outside code — a code-fenced '#' line was promoted")
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Direct unit test of check-docs-render-fidelity's batch renderer contract
|
|
3
|
+
# (SITE_KIT_RENDERER_BATCH), which the good/bad pair cannot express on its own.
|
|
4
|
+
# The pair sets no renderer knob, so lib/site.sh fills the batch default and the
|
|
5
|
+
# pair already runs the batch path — what it leaves untested is everything that
|
|
6
|
+
# needs a second configuration: the kit's two defaults agreeing, the delta-4
|
|
7
|
+
# fill condition, the per-document fallback, and the two exit-2 refusals.
|
|
8
|
+
#
|
|
9
|
+
# Six assertions:
|
|
10
|
+
# 1. parity — the corpus rendered per-document and batched is byte-identical,
|
|
11
|
+
# which is what makes the zero-config agreement claim an
|
|
12
|
+
# assertion rather than a hope.
|
|
13
|
+
# 2. fill rule — a consumer who pinned SITE_KIT_RENDERER gets an EMPTY batch
|
|
14
|
+
# knob, so an upgrade never swaps a pinned oracle for the
|
|
15
|
+
# kit's unpinned one; unpinned, the default arrives.
|
|
16
|
+
# 3/4. verdicts — the batch path and the per-document fallback return the SAME
|
|
17
|
+
# verdict on the same pages, so the speedup changed no finding.
|
|
18
|
+
# 5. count — a batch renderer that passes the probe but returns the wrong
|
|
19
|
+
# document count exits 2 (fail-closed), never 1.
|
|
20
|
+
# 6. probe — an unresolvable batch command exits 2 rather than silently
|
|
21
|
+
# falling back to a different parser.
|
|
22
|
+
# The gate enumerates tracked pages via git ls-files, so the fixture is a
|
|
23
|
+
# throwaway git repo.
|
|
24
|
+
#
|
|
25
|
+
# Run by run-gate-tests.sh (any <tests-dir>/*.test.sh; must exit 0).
|
|
26
|
+
set -uo pipefail
|
|
27
|
+
source "$(dirname "${BASH_SOURCE[0]}")/../../gate-sdk/lib/test-hermetic.sh"
|
|
28
|
+
|
|
29
|
+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # site-kit/
|
|
30
|
+
GATE="$DIR/checks/check-docs-render-fidelity.sh"
|
|
31
|
+
|
|
32
|
+
fails=0
|
|
33
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
34
|
+
|
|
35
|
+
(
|
|
36
|
+
cd "$tmp" || exit 1
|
|
37
|
+
git init -q
|
|
38
|
+
git config user.email fixture@example.invalid
|
|
39
|
+
git config user.name fixture
|
|
40
|
+
mkdir -p docs
|
|
41
|
+
) || { echo " FAIL: could not init fixture repo"; exit 1; }
|
|
42
|
+
|
|
43
|
+
cat > "$tmp/docs/leak.md" <<'MD'
|
|
44
|
+
# Heading
|
|
45
|
+
|
|
46
|
+
The consequence clause appends after the ` -> <verdict>` arrow, leaving it
|
|
47
|
+
disjoint from the invariant below.
|
|
48
|
+
MD
|
|
49
|
+
|
|
50
|
+
cat > "$tmp/docs/ok.md" <<'MD'
|
|
51
|
+
# Heading
|
|
52
|
+
|
|
53
|
+
The consequence clause appends after the `` -> <verdict> `` arrow, leaving it
|
|
54
|
+
disjoint from the invariant below.
|
|
55
|
+
|
|
56
|
+
| knob | default |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| one | two |
|
|
59
|
+
MD
|
|
60
|
+
|
|
61
|
+
for n in 1 2 3; do printf '# Page %s\n\nBody.\n' "$n" > "$tmp/docs/p$n.md"; done
|
|
62
|
+
|
|
63
|
+
# --- 1. parity: the kit's two defaults agree, document for document ------------
|
|
64
|
+
(
|
|
65
|
+
# shellcheck source=../lib/site.sh
|
|
66
|
+
source "$DIR/lib/site.sh"
|
|
67
|
+
bodies=("$(cat "$tmp/docs/ok.md")" "$(cat "$tmp/docs/leak.md")")
|
|
68
|
+
|
|
69
|
+
one=()
|
|
70
|
+
for b in "${bodies[@]}"; do one+=("$(printf '%s\n' "$b" | "${SITE_KIT_RENDERER[@]}")"); done
|
|
71
|
+
|
|
72
|
+
two=()
|
|
73
|
+
while IFS= read -r -d '' h; do
|
|
74
|
+
while [[ "$h" == *$'\n' ]]; do h="${h%$'\n'}"; done
|
|
75
|
+
two+=("$h")
|
|
76
|
+
done < <(printf '%s\n\000' "${bodies[@]}" | "${SITE_KIT_RENDERER_BATCH[@]}")
|
|
77
|
+
|
|
78
|
+
[[ ${#two[@]} -eq ${#one[@]} ]] \
|
|
79
|
+
|| { echo " FAIL: batch returned ${#two[@]} document(s) for ${#one[@]} page(s)"; exit 1; }
|
|
80
|
+
for i in "${!one[@]}"; do
|
|
81
|
+
[[ "${one[$i]}" == "${two[$i]}" ]] \
|
|
82
|
+
|| { echo " FAIL: document $i diverges between the per-document and batch defaults"; exit 1; }
|
|
83
|
+
done
|
|
84
|
+
exit 0
|
|
85
|
+
) || fails=$((fails + 1))
|
|
86
|
+
|
|
87
|
+
# --- 2. the delta-4 fill condition: a pinned renderer suppresses the default ---
|
|
88
|
+
n_pinned="$( SITE_KIT_RENDERER=(true) ; source "$DIR/lib/site.sh" ; echo "${#SITE_KIT_RENDERER_BATCH[@]}" )"
|
|
89
|
+
[[ "$n_pinned" -eq 0 ]] \
|
|
90
|
+
|| { echo " FAIL: a pinned SITE_KIT_RENDERER still got a batch default ($n_pinned element(s)) — an upgrade would replace the pinned oracle"; fails=$((fails + 1)); }
|
|
91
|
+
n_default="$( source "$DIR/lib/site.sh" ; echo "${#SITE_KIT_RENDERER_BATCH[@]}" )"
|
|
92
|
+
[[ "$n_default" -gt 0 ]] \
|
|
93
|
+
|| { echo " FAIL: an unpinned SITE_KIT_RENDERER got no batch default — the zero-config speedup is not armed"; fails=$((fails + 1)); }
|
|
94
|
+
|
|
95
|
+
# A config that declares the batch knob empty leaves the per-document path in
|
|
96
|
+
# force with the kit's own renderer — the fallback branch, with no second copy
|
|
97
|
+
# of the renderer literal to drift.
|
|
98
|
+
printf '%s\n' '# shellcheck shell=bash' \
|
|
99
|
+
'# comment-tier-exempt: fixture config — an empty batch knob forces the per-document fallback branch' \
|
|
100
|
+
'# shellcheck disable=SC2034 # sourced by the gate under test' \
|
|
101
|
+
'SITE_KIT_RENDERER_BATCH=()' > "$tmp/batch-off.sh"
|
|
102
|
+
|
|
103
|
+
# --- 3/4. both paths, same verdicts -------------------------------------------
|
|
104
|
+
git -C "$tmp" add docs/leak.md
|
|
105
|
+
for mode in batch per-document; do
|
|
106
|
+
cfg=(); [[ "$mode" == per-document ]] && cfg=("$tmp/batch-off.sh")
|
|
107
|
+
out="$( cd "$tmp" && "$GATE" docs "${cfg[@]+"${cfg[@]}"}" 2>&1 )"; rc=$?
|
|
108
|
+
[[ "$rc" -eq 1 ]] \
|
|
109
|
+
|| { echo " FAIL: $mode path: severed span expected exit 1, got $rc: $out"; fails=$((fails + 1)); }
|
|
110
|
+
grep -qF -- "leaked into rendered text" <<<"$out" \
|
|
111
|
+
|| { echo " FAIL: $mode path: red output lacks the span finding: $out"; fails=$((fails + 1)); }
|
|
112
|
+
done
|
|
113
|
+
|
|
114
|
+
git -C "$tmp" rm -q --cached docs/leak.md
|
|
115
|
+
git -C "$tmp" add docs/ok.md
|
|
116
|
+
for mode in batch per-document; do
|
|
117
|
+
cfg=(); [[ "$mode" == per-document ]] && cfg=("$tmp/batch-off.sh")
|
|
118
|
+
out="$( cd "$tmp" && "$GATE" docs "${cfg[@]+"${cfg[@]}"}" 2>&1 )"; rc=$?
|
|
119
|
+
[[ "$rc" -eq 0 ]] \
|
|
120
|
+
|| { echo " FAIL: $mode path: faithful page expected exit 0, got $rc: $out"; fails=$((fails + 1)); }
|
|
121
|
+
done
|
|
122
|
+
|
|
123
|
+
# --- 5. count mismatch is fail-closed (exit 2), not a finding -----------------
|
|
124
|
+
# The stub emits exactly two documents whatever it is fed, so it PASSES the
|
|
125
|
+
# two-document probe and only the corpus count catches it — which is the point:
|
|
126
|
+
# a stub the probe already rejected would never reach the count assertion.
|
|
127
|
+
printf '%s\n' '# shellcheck shell=bash' \
|
|
128
|
+
'# comment-tier-exempt: fixture config — a batch renderer that always emits two documents' \
|
|
129
|
+
'# shellcheck disable=SC2034 # sourced by the gate under test' \
|
|
130
|
+
'SITE_KIT_RENDERER_BATCH=(bash -c '\''printf "<p>a</p>\000<p>b</p>\000"'\'')' > "$tmp/miscount.sh"
|
|
131
|
+
|
|
132
|
+
git -C "$tmp" add docs/p1.md docs/p2.md docs/p3.md
|
|
133
|
+
out="$( cd "$tmp" && "$GATE" docs "$tmp/miscount.sh" 2>&1 )"; rc=$?
|
|
134
|
+
[[ "$rc" -eq 2 ]] \
|
|
135
|
+
|| { echo " FAIL: batch count mismatch expected exit 2 (fail-closed), got $rc: $out"; fails=$((fails + 1)); }
|
|
136
|
+
grep -qF -- "document(s) for" <<<"$out" \
|
|
137
|
+
|| { echo " FAIL: count-mismatch refusal does not name the counts: $out"; fails=$((fails + 1)); }
|
|
138
|
+
|
|
139
|
+
# --- 6. an unresolvable batch renderer refuses, and does not fall back ---------
|
|
140
|
+
printf '%s\n' '# shellcheck shell=bash' \
|
|
141
|
+
'# comment-tier-exempt: fixture config — an unresolvable batch renderer must refuse, never downgrade' \
|
|
142
|
+
'# shellcheck disable=SC2034 # sourced by the gate under test' \
|
|
143
|
+
'SITE_KIT_RENDERER_BATCH=(site-kit-no-such-batch-renderer)' > "$tmp/unresolvable.sh"
|
|
144
|
+
|
|
145
|
+
out="$( cd "$tmp" && "$GATE" docs "$tmp/unresolvable.sh" 2>&1 )"; rc=$?
|
|
146
|
+
[[ "$rc" -eq 2 ]] \
|
|
147
|
+
|| { echo " FAIL: unresolvable batch renderer expected exit 2, got $rc: $out"; fails=$((fails + 1)); }
|
|
148
|
+
grep -qF -- "failed its probe" <<<"$out" \
|
|
149
|
+
|| { echo " FAIL: batch probe refusal does not name the probe: $out"; fails=$((fails + 1)); }
|
|
150
|
+
grep -qF -- "DOCS-RENDER-FIDELITY: clean" <<<"$out" \
|
|
151
|
+
&& { echo " FAIL: unresolvable batch renderer silently fell back to a clean verdict: $out"; fails=$((fails + 1)); }
|
|
152
|
+
|
|
153
|
+
if [[ "$fails" -gt 0 ]]; then
|
|
154
|
+
echo "check-docs-render-fidelity-batch.test: $fails assertion(s) failed"
|
|
155
|
+
exit 1
|
|
156
|
+
fi
|
|
157
|
+
echo "check-docs-render-fidelity-batch.test: ok (defaults agree byte-for-byte; a pinned renderer suppresses the batch default; both paths agree on verdicts; count mismatch and probe failure both exit 2)"
|
|
158
|
+
exit 0
|
|
@@ -25,5 +25,19 @@ unset _st_cfg
|
|
|
25
25
|
declare -p SITE_KIT_ALIASES &>/dev/null || SITE_KIT_ALIASES=()
|
|
26
26
|
declare -p SITE_KIT_EXEMPT_PATHS &>/dev/null \
|
|
27
27
|
|| SITE_KIT_EXEMPT_PATHS=("*/gate-tests/*" "*docs/posts/*")
|
|
28
|
-
declare -p SITE_KIT_RENDERER &>/dev/null
|
|
29
|
-
|
|
28
|
+
if declare -p SITE_KIT_RENDERER &>/dev/null; then
|
|
29
|
+
_st_renderer_overridden=1
|
|
30
|
+
else
|
|
31
|
+
_st_renderer_overridden=0
|
|
32
|
+
SITE_KIT_RENDERER=(ruby -e 'require "kramdown"; require "kramdown-parser-gfm"; STDOUT.write(Kramdown::Document.new(STDIN.read, input: "GFM").to_html)')
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
# spec: site-kit/SPEC.md §lib/site.sh — the one conditional default: filling the batch knob for a consumer who pinned SITE_KIT_RENDERER would replace their pinned oracle with this unpinned one and report clean against a parser build they rejected
|
|
36
|
+
if ! declare -p SITE_KIT_RENDERER_BATCH &>/dev/null; then
|
|
37
|
+
if [[ "$_st_renderer_overridden" -eq 0 ]]; then
|
|
38
|
+
SITE_KIT_RENDERER_BATCH=(ruby -e 'require "kramdown"; require "kramdown-parser-gfm"; d = STDIN.read.split("\x00", -1); d.pop; d.each { |s| STDOUT.write(Kramdown::Document.new(s, input: "GFM").to_html); STDOUT.write("\x00") }')
|
|
39
|
+
else
|
|
40
|
+
SITE_KIT_RENDERER_BATCH=()
|
|
41
|
+
fi
|
|
42
|
+
fi
|
|
43
|
+
unset _st_renderer_overridden
|