forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB1f91eddTahinli2 months ago3507 commits

verify-fixture-library.sh466 lines, 23.1 KiBHistoryRawDownload
1#!/usr/bin/env bash
2# verify-fixture-library.sh — preflight: does the on-disk fixture library match
3# what the tests actually reach for?
4#
5# CHECKS
6# SHAPE the manifest exists, is non-empty, and every row has 5 columns
7# RESOLVE every referenced path exists, and every referenced DIRECTORY is
8# non-empty (a present-but-empty corpus is the same false green as
9# an absent one)
10# DRIFT regenerating the manifest from source reproduces the committed
11# file -- so a host whose library is behind the code fails here
12# instead of reporting a green suite full of SKIPs
13#
14# TWO FAILURE MODES ARE DISTINGUISHED, because they have different fixes:
15# (i) the fixture ROOT itself is absent. Root `fixtures/` is .gitignore:2,
16# so no linked worktree ever has it: every vector gate skips GREEN in
17# every worktree run. Fix: link or provision the library, not the code.
18# (ii) a path under a PRESENT root is absent (or an empty dir). Fix: the
19# generator named in the row, or the pin is genuinely missing.
20#
21# ENFORCEMENT ENV: EC_REQUIRE_FIXTURES=1 -- the same env the per-crate `require_fixture` asserts
22# honour, so one convention covers the fleet batch units and a local run:
23# set -> any absent referenced path is RED, and the drift diff is RED
24# unset -> the same findings are printed SKIP-shaped and the exit stays 0,
25# so an unprepared local checkout is not blocked
26#
27# EXIT STATUS is the LIBRARY verdict: mode i, mode ii, or drift. The four
28# code-shape invariants (forbidden root-fixture path, pin tracking, .gitignore
29# negation, pin-reading gate census) are REPORTED with their own count and fail
30# only under EC_FIXTURE_SHAPE_STRICT=1. That split is deliberate: a shape
31# violation is a defect in a file this preflight does not own, and a batch that
32# cannot start because another crate has two open lines helps nobody -- but the
33# findings are printed, counted, and one env var away from being fatal, so
34# nothing is hidden. Set EC_FIXTURE_SHAPE_STRICT=1 in a tree whose shape
35# violations you intend to fix.
36#
37# Usage: scripts/verify-fixture-library.sh
38# Env: EC_FIXTURES=<dir> fixture root, as every generator takes
39# EC_REQUIRE_FIXTURES=1|0 enforcement (see above)
40#
41# ENUMERATION BLIND SPOT: the scan is grep-derived, so a fixture name that is
42# not a string literal in the same file (a row of
43# fixtures/real-library-manifest.tsv, a name in scripts/vectors.sha256, a
44# format! interpolation) is not enumerated individually. Its parent directory
45# is, and RESOLVE requires that directory to exist and be non-empty. This is a
46# preflight against silent drift, not a proof that every byte a test reads is
47# present.
48#
49# THE TWO ROOTS (lane-av1clipprobe). This script validates `$EC_FIXTURES`,
50# defaulting to `$ROOT/fixtures`. The gates used to read `$ROOT/fixtures`
51# UNCONDITIONALLY, so pointing EC_FIXTURES at a library elsewhere printed
52# `resolve 0 missing` and `GREEN` here while every clip gate skipped -- a green
53# preflight over gates reading a tree nobody validated. The clip-reading gates
54# now resolve through the same precedence this script does (EC_FIXTURES first,
55# `$ROOT/fixtures` otherwise: `crates/ec-av1/src/library_fixture.rs`), so the
56# verdict below and the bytes the tests read are the same tree in every
57# combination, and mode (i) below fires exactly when the gates will skip.
58
59set -uo pipefail
60
61ROOT=$(cd -- "$(dirname -- "$0")/.." && pwd)
62MANIFEST=$ROOT/scripts/fixture-library.tsv
63FIXTURES=${EC_FIXTURES:-$ROOT/fixtures}
64REQUIRE=${EC_REQUIRE_FIXTURES:-0}
65# Code-shape invariants fail only when explicitly made fatal: `scripts/
66# verify-fixture-library.sh --strict` or EC_FIXTURE_SHAPE_STRICT=1. The default
67# flips to fatal when the last live violation is fixed.
68SHAPE=${EC_FIXTURE_SHAPE_STRICT:-1}
69# `--strict` on the command line is the same switch, so the default can be
70# flipped with a one-character edit the moment the last shape violation lands.
71case " $* " in
72 *" --strict "*) SHAPE=1 ;;
73esac
74LINK_SCRIPT=$ROOT/scripts/link-fixtures.sh
75
76fail=0
77shape_fail=0
78shape_violations=0
79note() { [ "$REQUIRE" = 0 ] || echo "$@"; }
80
81echo "verify-fixture-library: root=$ROOT fixtures=$FIXTURES EC_REQUIRE_FIXTURES=${REQUIRE:-0}"
82# The gates' root is the SAME string, by the reconciliation documented above --
83# printed here so a reader comparing this verdict against a gate's SKIP line
84# never has to guess which of two directories the two sides meant.
85echo "verify-fixture-library: the clip gates resolve $FIXTURES too (EC_FIXTURES first, else \$ROOT/fixtures)"
86
87# --- SHAPE ---------------------------------------------------------------
88if [ ! -f "$MANIFEST" ]; then
89 echo "FAIL: $MANIFEST is missing -- run scripts/gen-fixture-library.sh" >&2
90 exit 1
91fi
92rows=$(grep -cv '^#' "$MANIFEST")
93if [ "$rows" -eq 0 ]; then
94 echo "FAIL: $MANIFEST has no rows" >&2
95 exit 1
96fi
97malformed=$(awk -F'\t' '!/^#/ && NF != 7 { print NR": "$0 }' "$MANIFEST")
98if [ -n "$malformed" ]; then
99 echo "FAIL: malformed rows in $MANIFEST (want 7 tab-separated columns):" >&2
100 echo "$malformed" >&2
101 exit 1
102fi
103note " shape: $rows rows"
104
105# --- ROOT MODE (i) --------------------------------------------------------
106root_present=1
107[ -d "$FIXTURES" ] || root_present=0
108if [ "$root_present" -eq 0 ]; then
109 tag=SKIP
110 [ "$REQUIRE" != 0 ] && tag=FAIL
111 echo "$tag [mode i]: fixture root $FIXTURES does not exist." >&2
112 echo " Root fixtures/ is .gitignore:2, so a linked worktree never has it --" >&2
113 echo " that is why the vector gates skip GREEN here. Fix the TREE, not the" >&2
114 echo " code: provision the library, or run the fixture-linking script once" >&2
115 if [ -x "$LINK_SCRIPT" ]; then
116 echo " it lands: $LINK_SCRIPT"
117 else
118 echo " it exists (scripts/link-fixtures.sh -- another lane; not in this tree yet)."
119 fi
120 [ "$REQUIRE" != 0 ] && fail=1
121fi
122
123# --- RESOLVE --------------------------------------------------------------
124missing=()
125empty=()
126while IFS=$'\t' read -r path required_by class prov status tracked sum; do
127 case $path in
128 \#* | '') continue ;;
129 esac
130 case $class in
131 absent-pin) continue ;; # known gap, reported as a finding
132 esac
133 case $path in
134 fixtures) abs=$FIXTURES ;;
135 fixtures/*) abs=$FIXTURES/${path#fixtures/} ;;
136 *) abs=$ROOT/$path ;;
137 esac
138 if [ ! -e "$abs" ]; then
139 missing+=("$path <- $required_by ($class, generator: $prov)")
140 elif [ -d "$abs" ] && [ -z "$(ls -A -- "$abs" 2>/dev/null)" ]; then
141 empty+=("$path <- $required_by ($class, generator: $prov)")
142 fi
143done <"$MANIFEST"
144
145if ((${#missing[@]})) && [ "$root_present" -eq 1 ]; then
146 if [ "$REQUIRE" != 0 ]; then
147 echo "FAIL [mode ii]: ${#missing[@]} referenced fixture path(s) do not resolve," >&2
148 echo " inside a tree that HAS a fixture root -- the generator or the pin is" >&2
149 echo " genuinely missing:" >&2
150 printf ' %s\n' "${missing[@]}" >&2
151 fail=1
152 else
153 echo "SKIP: ${#missing[@]} referenced fixture path(s) do not resolve" >&2
154 echo " (EC_REQUIRE_FIXTURES unset, so this is reported, not failed):" >&2
155 printf ' %s\n' "${missing[@]}" >&2
156 fi
157fi
158if ((${#empty[@]})); then
159 if [ "$REQUIRE" != 0 ]; then
160 echo "FAIL [mode ii]: ${#empty[@]} referenced fixture DIRECTORY(ies) exist but are empty:" >&2
161 printf ' %s\n' "${empty[@]}" >&2
162 fail=1
163 else
164 echo "SKIP: ${#empty[@]} referenced fixture DIRECTORY(ies) exist but are empty:" >&2
165 printf ' %s\n' "${empty[@]}" >&2
166 fi
167fi
168note " resolve: ${#missing[@]} missing, ${#empty[@]} empty"
169
170# --- FINDINGS (not failures, but stated) ---------------------------------
171no_prov=$(awk -F'\t' '!/^#/ && ($3 == "captured" || $3 == "recovered-original") {print $1}' "$MANIFEST" | sort -u)
172absent=$(awk -F'\t' '!/^#/ && $3 == "absent-pin" {print $1}' "$MANIFEST" | sort -u)
173if [ -n "$no_prov" ]; then
174 n=$(printf '%s\n' "$no_prov" | wc -l)
175 echo "FINDING: $n pinned fixture(s) have NO generator -- provenance is prose in a" >&2
176 echo " gate comment only. A pin claim must cite the originating encoder" >&2
177 echo " program and the artefact sha256 (the sha256 IS recorded in column 5):" >&2
178 printf ' %s\n' $no_prov >&2
179fi
180if [ -n "$absent" ]; then
181 echo "FINDING: $(printf '%s\n' "$absent" | wc -l) KNOWN-ABSENT pin(s), kept as rows so the gap stays visible:" >&2
182 printf ' %s\n' "$absent" >&2
183fi
184
185# --- HARD INVARIANT 1: the forbidden root-fixture shape ---------------------
186# `concat!(env!("CARGO_MANIFEST_DIR"), "/../../fixtures/<file>")` names a
187# ROOT-level committed pin through the gitignored `fixtures/`. No committed pin
188# can satisfy it, so on any clean checkout or runner the gate silently skips --
189# the worst shape in the class (the film-grain instance combined it with
190# `.unwrap()`, so a clean checkout PANICKED instead). A root SUBDIRECTORY
191# (`fixtures/audio`, `fixtures/vectors/...`) is a different thing: those are
192# produced by a generator named in the manifest, so they are not forbidden here.
193# Comments are stripped first: a doc comment that REPRODUCES the forbidden
194# literal to explain what was fixed is prose, not code, and a grep cannot tell
195# the difference. One such comment in crates/ec-av1 read as a live violation for
196# a whole round (found by the lane that fixed the real ones).
197forbidden=$(python3 - "$ROOT" <<'PYEOF'
198import os, re, sys
199root = sys.argv[1]
200pat = re.compile(r'concat!\(\s*env!\("CARGO_MANIFEST_DIR"\)\s*,\s*"/\.\./\.\./fixtures/[^/"]*\.')
201for crate in sorted(os.listdir(os.path.join(root, "crates"))):
202 for sub in ("src", "tests"):
203 d = os.path.join(root, "crates", crate, sub)
204 if not os.path.isdir(d):
205 continue
206 for dirpath, _dirs, files in os.walk(d):
207 for name in sorted(files):
208 if not name.endswith(".rs"):
209 continue
210 p = os.path.join(dirpath, name)
211 try:
212 text = open(p, encoding="utf-8", errors="replace").read()
213 except OSError:
214 continue
215 text = re.sub(r"/\*.*?\*/", "", text, flags=re.S)
216 for i, line in enumerate(text.splitlines(), 1):
217 code = line.split("//", 1)[0]
218 if pat.search(code):
219 print("{}:{}:{}".format(os.path.relpath(p, root), i, line.strip()))
220PYEOF
221)
222# POSITIVE CONTROL. A comment-stripping bug makes this scan match NOTHING, and
223# "no violations" would then be indistinguishable from a scanner that is blind.
224# So before trusting the result, plant a known forbidden literal in a scratch
225# file and require the scanner to catch it. A scanner that cannot find a literal
226# it is looking at is broken, not clean.
227control=$(mktemp --suffix=.rs)
228printf 'fn probe() { let _ = concat!(env!("CARGO_MANIFEST_DIR"), "/../../fixtures/control.obu"); }\n' >"$control"
229control_hit=$(python3 - "$ROOT" "$control" <<'PYEOF'
230import re, sys
231pat = re.compile(r'concat!\(\s*env!\("CARGO_MANIFEST_DIR"\)\s*,\s*"/\.\./\.\./fixtures/[^/"]*\.')
232text = open(sys.argv[2], encoding="utf-8", errors="replace").read()
233text = re.sub(r"/\*.*?\*/", "", text, flags=re.S)
234print("1" if any(pat.search(l.split("//", 1)[0]) for l in text.splitlines()) else "0")
235PYEOF
236)
237rm -f "$control"
238if [ "$control_hit" != 1 ]; then
239 echo "FAIL [invariant 1]: the scanner's own positive control did not fire -- the" >&2
240 echo " comment-stripping pass is broken, so 'no violations' would be a" >&2
241 echo " silent all-clear. Fix the scanner before trusting its verdict." >&2
242 shape_fail=1
243 fail=1
244else
245 note " invariant 1: positive control fired (the scanner can still see a literal)"
246fi
247
248if [ -n "$forbidden" ]; then
249 if [ "$SHAPE" != 0 ]; then
250 echo "FAIL [invariant 1]: a committed pin is reached through the gitignored root" >&2
251 echo " fixtures/ (silent SKIP on every clean checkout and runner):" >&2
252 echo "$forbidden" | sed 's/^/ /' >&2
253 echo " fix: commit the pin under crates/<crate>/fixtures/ and read it with" >&2
254 echo " that crate's pin helper (crate_pin / pin_dir), never /../../fixtures/." >&2
255 shape_fail=1
256 else
257 echo "SKIP [invariant 1]: $(printf '%s\n' "$forbidden" | wc -l) site(s) reach a root" >&2
258 echo " pin through the gitignored fixtures/ (reported, not failed):" >&2
259 echo "$forbidden" | sed 's/^/ /' >&2
260 fi
261else
262 note " invariant 1: no root-fixture pin path"
263fi
264
265# --- HARD INVARIANT 2: every committed pin is present AND tracked -----------
266# A pin on disk but untracked is lost when the machine's scratchpad is reaped,
267# and its gate then skips GREEN. `tracked` is computed at generation time in a
268# git tree; a runner host has no .git, so it asserts the committed value.
269untracked=$(awk -F'\t' '!/^#/ && ($3 == "captured" || $3 == "recovered-original") && $6 != "yes" {print $1"\t"$6}' "$MANIFEST")
270if [ -n "$untracked" ]; then
271 if [ "$SHAPE" != 0 ]; then
272 echo "FAIL [invariant 2]: committed pin(s) present but NOT tracked by git:" >&2
273 echo "$untracked" | sed 's/^/ /' >&2
274 echo " fix: git add crates/<crate>/fixtures/<pin> -- the .gitignore negation" >&2
275 echo " (!crates/*/fixtures/**) must let a plain add work; if it does not, the" >&2
276 echo " negation is broken and invariant 3 below will say so." >&2
277 shape_fail=1
278 else
279 echo "SKIP [invariant 2]: untracked committed pin(s) (reported, not failed):" >&2
280 echo "$untracked" | sed 's/^/ /' >&2
281 fi
282else
283 note " invariant 2: every committed pin is tracked"
284fi
285
286# --- HARD INVARIANT 3: the .gitignore negation is intact --------------------
287if ! grep -q '^!crates/\*/fixtures/\*\*$' "$ROOT/.gitignore" 2>/dev/null; then
288 echo "FAIL [invariant 3]: .gitignore has no '!crates/*/fixtures/**' negation, so a" >&2
289 echo " new pin cannot be added and every recovered pin is untrackable." >&2
290 shape_fail=1
291else
292 note " invariant 3: .gitignore negation present"
293 if [ -e "$ROOT/.git" ]; then
294 shadowed=$(awk -F'\t' '!/^#/ && $6 == "yes" {print $1}' "$MANIFEST" |
295 while IFS= read -r p; do
296 git -C "$ROOT" check-ignore -q -- "$p" && echo "$p"
297 done)
298 if [ -n "$shadowed" ]; then
299 echo "FAIL [invariant 3]: git still ignores these tracked pins:" >&2
300 echo "$shadowed" | sed 's/^/ /' >&2
301 shape_fail=1
302 else
303 note " invariant 3: no tracked pin is shadowed by .gitignore"
304 fi
305 else
306 note " invariant 3: no .git here, check-ignore skipped (hosts assert the committed value)"
307 fi
308fi
309
310# --- HARD INVARIANT 4: the pin-reading GATE census -------------------------
311# The per-pin invariant is blind to a gate that reads N pins through a root
312# literal plus a runtime name list, and to a gate that only asserts inside a
313# helper. scripts/pin-gate-audit.py resolves the root literal, enumerates the
314# runtime names, checks each against a tracked committed copy, and classifies
315# assertions through the helper CALL GRAPH. Counts are printed, not summarised.
316if ! command -v python3 >/dev/null; then
317 echo "FAIL [invariant 4]: python3 is required for the pin-gate audit and is absent" >&2
318 fail=1
319else
320 selftest_out=$(mktemp)
321 audit=$("$ROOT/scripts/pin-gate-audit.py" 2>&1)
322 if [ $? -ne 0 ] && [ -z "$audit" ]; then
323 echo "FAIL [invariant 4]: scripts/pin-gate-audit.py did not run" >&2
324 fail=1
325 fi
326 echo "$audit" | awk -F'\t' '/^COUNT/{print " pin gates: "$2" "$3" "$4" "$5" "$6}' >&2
327 # The census's own POSITIVE CONTROL. Losing a gate to a doc comment is
328 # SILENT -- the count drops and nothing goes red -- so a control that only
329 # proved "the scanner finds a bad literal" would not catch it. This one
330 # plants the exact shape: a comment reproducing the forbidden literal
331 # inside a gate that reads crate_pin.
332 if ! "$ROOT/scripts/pin-gate-audit.py" --self-test >"$selftest_out" 2>&1; then
333 echo "FAIL [invariant 4]: the census self-test did not pass -- a doc comment" >&2
334 echo " can reclassify a pin-reading gate into a branch that counts" >&2
335 echo " nothing, which loses the gate SILENTLY. Fix the scanner first." >&2
336 sed 's/^/ /' "$selftest_out" >&2
337 fail=1
338 else
339 note " invariant 4: census self-test passed (a comment cannot steal a gate)"
340 fi
341 badrows=$(echo "$audit" | awk -F'\t' '/^BADROW/{print " "$2":"$3" "$4" "$5}')
342 bardir=$(echo "$audit" | awk -F'\t' '/^BARDIR/{print " "$2":"$3" "$4" "$5}')
343 absent=$(echo "$audit" | awk -F'\t' '/^NAME/ && $4=="absent"{print " "$2":"$3" "$4}')
344 if [ -n "$badrows" ] || [ -n "$bardir" ]; then
345 if [ "$SHAPE" != 0 ]; then
346 echo "FAIL [invariant 4]: pin-reading gates whose pins are not committed" >&2
347 echo " (a runtime name list over the gitignored root can never be" >&2
348 echo " satisfied by a committed tree, and a bare directory literal" >&2
349 echo " feeding one always fails):" >&2
350 printf '%s\n' "$badrows" "$bardir" >&2
351 echo " fix: commit each pin under crates/<crate>/fixtures/ and read it" >&2
352 echo " through that crate's pin helper, not /../../fixtures/." >&2
353 shape_fail=1
354 else
355 echo "SKIP [invariant 4]: pin-reading gates with uncommitted pins (reported," >&2
356 echo " not failed, because EC_REQUIRE_FIXTURES is unset):" >&2
357 printf '%s\n' "$badrows" "$bardir" >&2
358 fi
359 else
360 note " invariant 4: every pin-reading gate resolves through committed copies"
361 fi
362 # assertless gates are printed, never failed: a #[ignore]d gate that asserts
363 # nothing is a finding for its owner, not a preflight failure.
364 echo "$audit" | awk -F'\t' '/^GATE/ && $5=="no"{print " FINDING: "$3" reads a pin and asserts nothing in its body or helpers"}' >&2
365fi
366
367# --- RECOVERED-PIN SELF-VALIDATION -----------------------------------------
368# A recovered witness is the historical bytes; a re-encode is a DIFFERENT stream.
369# Hashing what is on disk against the recorded sha256 is the half a shell
370# preflight can decide. The other half is behavioural and needs the gate:
371# `pinned_golden7` records non_last_ref_hits 0->2 in its own doc, and the
372# recovered pin reproduces exactly that; only running the gate proves it.
373badsum=0
374while IFS=$'\t' read -r path required_by class prov status tracked sum; do
375 case $path in
376 \#* | '') continue ;;
377 esac
378 [ "$class" = recovered-original ] || continue
379 abs=$ROOT/$path
380 if [ ! -f "$abs" ]; then
381 echo "FAIL [recovered]: $path is absent" >&2
382 fail=1
383 continue
384 fi
385 have=$(sha256sum -- "$abs" | cut -d' ' -f1)
386 if [ "$have" != "$sum" ]; then
387 echo "FAIL [recovered]: $path hashes $have, the manifest records $sum -- this is" >&2
388 echo " a DIFFERENT stream (a re-encode), not the recovered original." >&2
389 fail=1
390 badsum=$((badsum + 1))
391 fi
392done <"$MANIFEST"
393[ "$badsum" -eq 0 ] && note " recovered pins: every recovered-original hash matches"
394echo " recovered pins: the behavioural half needs the gate, not this script --" >&2
395echo " run 'cargo test -p ec-av1 pinned_golden7'; it prints non_last_ref_hits" >&2
396echo " and its doc records the 0->2 delta only the recovered pin reproduces." >&2
397
398# --- VECTORS -------------------------------------------------------------
399vec_rows=$(awk -F'\t' '!/^#/ && $1 ~ /^fixtures\/vectors\//' "$MANIFEST" | wc -l)
400vec_missing=$(awk -F'\t' '!/^#/ && $1 ~ /^fixtures\/vectors\// && $5 != "ok"' "$MANIFEST" | wc -l)
401echo " vectors: $vec_rows referenced rows, $vec_missing not ok" >&2
402echo " vectors: nothing in crates/ reads a .tar.gz; the fleet hosts carry the" >&2
403echo " EXTRACTED sets, so the blobs are not required at test time" >&2
404
405# --- DRIFT ----------------------------------------------------------------
406regen=$(mktemp)
407patch=$(mktemp)
408trap 'rm -f "$regen" "$patch" ${selftest_out:-} ' EXIT
409if ! "$ROOT/scripts/gen-fixture-library.sh" "$regen" >/dev/null 2>&1; then
410 echo "FAIL: scripts/gen-fixture-library.sh did not run" >&2
411 exit 1
412fi
413# The `tracked` column is COMMITTED provenance: it is computed in a git tree.
414# A runner host has no .git, so a regeneration there cannot recompute it and
415# would emit 'no-git' for every committed pin -- a drift on all 37 pin rows that
416# says nothing about the host's library. Off-git the column is normalised on both
417# sides, and the tracked invariant falls back to the committed value (as its own
418# message already says).
419drift_norm() { grep -v '^#' "$1" | awk -F'\t' -v OFS='\t' 'BEGIN{off=1} $1 ~ /^crates\/.*\/fixtures\//{if(off && $6!="-") $6="-"} {print}'; }
420OFFGIT=0
421[ -e "$ROOT/.git" ] || OFFGIT=1
422if ! diff -u <(drift_norm "$MANIFEST") <(drift_norm "$regen") >"$patch" 2>&1; then
423 if [ "$REQUIRE" != 0 ]; then
424 echo "FAIL: this tree's library does not match what the code reaches" >&2
425 echo " (DRIFT: the committed manifest's rows differ from a regeneration" >&2
426 echo " here). The first difference is the row to act on; '- only here'" >&2
427 echo " is a path this host reaches and the committed manifest does not," >&2
428 echo " '+ only committed' is a row this host cannot satisfy. Fetch the" >&2
429 echo " library, or commit the regenerated manifest. (patch follows)" >&2
430 sed -n '1,40p' "$patch" >&2
431 fail=1
432 else
433 echo "SKIP: the library does not match what the code reaches (DRIFT;" >&2
434 echo " EC_REQUIRE_FIXTURES unset, so this is reported, not failed):" >&2
435 sed -n '1,20p' "$patch" >&2
436 fi
437else
438 note " drift: manifest rows match the code on this host"
439fi
440
441if [ "$fail" -ne 0 ]; then
442 echo "verify-fixture-library: RED (library verdict: mode i, mode ii or drift)" >&2
443 exit 1
444fi
445if [ "$SHAPE" != 0 ] && [ "$shape_fail" -ne 0 ]; then
446 echo "verify-fixture-library: RED (code-shape violations, EC_FIXTURE_SHAPE_STRICT=1)" >&2
447 exit 1
448fi
449# The shape tally is always printed, fatal only under EC_FIXTURE_SHAPE_STRICT.
450for s in $(echo "$audit" | awk -F'\t' '/^BADROW/{c++} END{print c+0}'); do :; done
451echo " code-shape violations: $(echo "$audit" | awk -F'\t' '/^BADROW/{c++} END{print c+0}')" >&2
452echo "$forbidden" | grep -q . && shape_violations=$((shape_violations + $(echo "$forbidden" | grep -c .)))
453# lane-av1clipprobe: the last word of this script used to be a bare `GREEN`
454# even when mode (i) had just been reported a few lines above -- so a reader
455# who read only the verdict read GREEN over a tree whose fixture root does not
456# exist, which is the same false green as a gate that skipped. The verdict now
457# says which it is: findings reported (not failed, because
458# EC_REQUIRE_FIXTURES is unset) versus a clean pass. `EC_REQUIRE_FIXTURES=1`
459# turns the first into the RED above.
460if [ "$root_present" -eq 0 ]; then
461 echo "verify-fixture-library: GREEN-WITH-FINDINGS ($rows rows; the absent root above is" >&2
462 echo " REPORTED, not failed -- set EC_REQUIRE_FIXTURES=1 on a tree that is" >&2
463 echo " meant to have the library, or provision it and re-run)" >&2
464else
465 echo "verify-fixture-library: GREEN ($rows rows)"
466fi