forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB0cea07aTahinli2 months ago3647 commits

verify-fixture-library.sh475 lines, 23.7 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 importlib.util, os, re, sys
199root = sys.argv[1]
200# SINGLE-SOURCE the rule: this scan (invariant 1) and the census (invariant 4,
201# scripts/pin-gate-audit.py) must not disagree about what counts as a gate, or
202# fixing one leaves the other red. Both strip comments AND mask line-spanning
203# string literals -- prose reproducing a shape and SOURCE reproducing a shape
204# are both data, not a gate.
205spec = importlib.util.spec_from_file_location(
206 "pin_gate_audit", os.path.join(root, "scripts", "pin-gate-audit.py"))
207audit = importlib.util.module_from_spec(spec)
208spec.loader.exec_module(audit)
209pat = re.compile(r'concat!\(\s*env!\("CARGO_MANIFEST_DIR"\)\s*,\s*"/\.\./\.\./fixtures/[^/"]*\.')
210for crate in sorted(os.listdir(os.path.join(root, "crates"))):
211 for sub in ("src", "tests"):
212 d = os.path.join(root, "crates", crate, sub)
213 if not os.path.isdir(d):
214 continue
215 for dirpath, _dirs, files in os.walk(d):
216 for name in sorted(files):
217 if not name.endswith(".rs"):
218 continue
219 p = os.path.join(dirpath, name)
220 try:
221 text = open(p, encoding="utf-8", errors="replace").read()
222 except OSError:
223 continue
224 text = re.sub(r"/\*.*?\*/", "", text, flags=re.S)
225 for i, line in enumerate(audit.mask_embedded_source(text).splitlines(), 1):
226 code = line.split("//", 1)[0]
227 if pat.search(code):
228 print("{}:{}:{}".format(os.path.relpath(p, root), i, line.strip()))
229PYEOF
230)
231# POSITIVE CONTROL. A comment-stripping bug makes this scan match NOTHING, and
232# "no violations" would then be indistinguishable from a scanner that is blind.
233# So before trusting the result, plant a known forbidden literal in a scratch
234# file and require the scanner to catch it. A scanner that cannot find a literal
235# it is looking at is broken, not clean.
236control=$(mktemp --suffix=.rs)
237printf 'fn probe() { let _ = concat!(env!("CARGO_MANIFEST_DIR"), "/../../fixtures/control.obu"); }\n' >"$control"
238control_hit=$(python3 - "$ROOT" "$control" <<'PYEOF'
239import re, sys
240pat = re.compile(r'concat!\(\s*env!\("CARGO_MANIFEST_DIR"\)\s*,\s*"/\.\./\.\./fixtures/[^/"]*\.')
241text = open(sys.argv[2], encoding="utf-8", errors="replace").read()
242text = re.sub(r"/\*.*?\*/", "", text, flags=re.S)
243print("1" if any(pat.search(l.split("//", 1)[0]) for l in text.splitlines()) else "0")
244PYEOF
245)
246rm -f "$control"
247if [ "$control_hit" != 1 ]; then
248 echo "FAIL [invariant 1]: the scanner's own positive control did not fire -- the" >&2
249 echo " comment-stripping pass is broken, so 'no violations' would be a" >&2
250 echo " silent all-clear. Fix the scanner before trusting its verdict." >&2
251 shape_fail=1
252 fail=1
253else
254 note " invariant 1: positive control fired (the scanner can still see a literal)"
255fi
256
257if [ -n "$forbidden" ]; then
258 if [ "$SHAPE" != 0 ]; then
259 echo "FAIL [invariant 1]: a committed pin is reached through the gitignored root" >&2
260 echo " fixtures/ (silent SKIP on every clean checkout and runner):" >&2
261 echo "$forbidden" | sed 's/^/ /' >&2
262 echo " fix: commit the pin under crates/<crate>/fixtures/ and read it with" >&2
263 echo " that crate's pin helper (crate_pin / pin_dir), never /../../fixtures/." >&2
264 shape_fail=1
265 else
266 echo "SKIP [invariant 1]: $(printf '%s\n' "$forbidden" | wc -l) site(s) reach a root" >&2
267 echo " pin through the gitignored fixtures/ (reported, not failed):" >&2
268 echo "$forbidden" | sed 's/^/ /' >&2
269 fi
270else
271 note " invariant 1: no root-fixture pin path"
272fi
273
274# --- HARD INVARIANT 2: every committed pin is present AND tracked -----------
275# A pin on disk but untracked is lost when the machine's scratchpad is reaped,
276# and its gate then skips GREEN. `tracked` is computed at generation time in a
277# git tree; a runner host has no .git, so it asserts the committed value.
278untracked=$(awk -F'\t' '!/^#/ && ($3 == "captured" || $3 == "recovered-original") && $6 != "yes" {print $1"\t"$6}' "$MANIFEST")
279if [ -n "$untracked" ]; then
280 if [ "$SHAPE" != 0 ]; then
281 echo "FAIL [invariant 2]: committed pin(s) present but NOT tracked by git:" >&2
282 echo "$untracked" | sed 's/^/ /' >&2
283 echo " fix: git add crates/<crate>/fixtures/<pin> -- the .gitignore negation" >&2
284 echo " (!crates/*/fixtures/**) must let a plain add work; if it does not, the" >&2
285 echo " negation is broken and invariant 3 below will say so." >&2
286 shape_fail=1
287 else
288 echo "SKIP [invariant 2]: untracked committed pin(s) (reported, not failed):" >&2
289 echo "$untracked" | sed 's/^/ /' >&2
290 fi
291else
292 note " invariant 2: every committed pin is tracked"
293fi
294
295# --- HARD INVARIANT 3: the .gitignore negation is intact --------------------
296if ! grep -q '^!crates/\*/fixtures/\*\*$' "$ROOT/.gitignore" 2>/dev/null; then
297 echo "FAIL [invariant 3]: .gitignore has no '!crates/*/fixtures/**' negation, so a" >&2
298 echo " new pin cannot be added and every recovered pin is untrackable." >&2
299 shape_fail=1
300else
301 note " invariant 3: .gitignore negation present"
302 if [ -e "$ROOT/.git" ]; then
303 shadowed=$(awk -F'\t' '!/^#/ && $6 == "yes" {print $1}' "$MANIFEST" |
304 while IFS= read -r p; do
305 git -C "$ROOT" check-ignore -q -- "$p" && echo "$p"
306 done)
307 if [ -n "$shadowed" ]; then
308 echo "FAIL [invariant 3]: git still ignores these tracked pins:" >&2
309 echo "$shadowed" | sed 's/^/ /' >&2
310 shape_fail=1
311 else
312 note " invariant 3: no tracked pin is shadowed by .gitignore"
313 fi
314 else
315 note " invariant 3: no .git here, check-ignore skipped (hosts assert the committed value)"
316 fi
317fi
318
319# --- HARD INVARIANT 4: the pin-reading GATE census -------------------------
320# The per-pin invariant is blind to a gate that reads N pins through a root
321# literal plus a runtime name list, and to a gate that only asserts inside a
322# helper. scripts/pin-gate-audit.py resolves the root literal, enumerates the
323# runtime names, checks each against a tracked committed copy, and classifies
324# assertions through the helper CALL GRAPH. Counts are printed, not summarised.
325if ! command -v python3 >/dev/null; then
326 echo "FAIL [invariant 4]: python3 is required for the pin-gate audit and is absent" >&2
327 fail=1
328else
329 selftest_out=$(mktemp)
330 audit=$("$ROOT/scripts/pin-gate-audit.py" 2>&1)
331 if [ $? -ne 0 ] && [ -z "$audit" ]; then
332 echo "FAIL [invariant 4]: scripts/pin-gate-audit.py did not run" >&2
333 fail=1
334 fi
335 echo "$audit" | awk -F'\t' '/^COUNT/{print " pin gates: "$2" "$3" "$4" "$5" "$6}' >&2
336 # The census's own POSITIVE CONTROL. Losing a gate to a doc comment is
337 # SILENT -- the count drops and nothing goes red -- so a control that only
338 # proved "the scanner finds a bad literal" would not catch it. This one
339 # plants the exact shape: a comment reproducing the forbidden literal
340 # inside a gate that reads crate_pin.
341 if ! "$ROOT/scripts/pin-gate-audit.py" --self-test >"$selftest_out" 2>&1; then
342 echo "FAIL [invariant 4]: the census self-test did not pass -- a doc comment" >&2
343 echo " can reclassify a pin-reading gate into a branch that counts" >&2
344 echo " nothing, which loses the gate SILENTLY. Fix the scanner first." >&2
345 sed 's/^/ /' "$selftest_out" >&2
346 fail=1
347 else
348 note " invariant 4: census self-test passed (a comment cannot steal a gate)"
349 fi
350 badrows=$(echo "$audit" | awk -F'\t' '/^BADROW/{print " "$2":"$3" "$4" "$5}')
351 bardir=$(echo "$audit" | awk -F'\t' '/^BARDIR/{print " "$2":"$3" "$4" "$5}')
352 absent=$(echo "$audit" | awk -F'\t' '/^NAME/ && $4=="absent"{print " "$2":"$3" "$4}')
353 if [ -n "$badrows" ] || [ -n "$bardir" ]; then
354 if [ "$SHAPE" != 0 ]; then
355 echo "FAIL [invariant 4]: pin-reading gates whose pins are not committed" >&2
356 echo " (a runtime name list over the gitignored root can never be" >&2
357 echo " satisfied by a committed tree, and a bare directory literal" >&2
358 echo " feeding one always fails):" >&2
359 printf '%s\n' "$badrows" "$bardir" >&2
360 echo " fix: commit each pin under crates/<crate>/fixtures/ and read it" >&2
361 echo " through that crate's pin helper, not /../../fixtures/." >&2
362 shape_fail=1
363 else
364 echo "SKIP [invariant 4]: pin-reading gates with uncommitted pins (reported," >&2
365 echo " not failed, because EC_REQUIRE_FIXTURES is unset):" >&2
366 printf '%s\n' "$badrows" "$bardir" >&2
367 fi
368 else
369 note " invariant 4: every pin-reading gate resolves through committed copies"
370 fi
371 # assertless gates are printed, never failed: a #[ignore]d gate that asserts
372 # nothing is a finding for its owner, not a preflight failure.
373 echo "$audit" | awk -F'\t' '/^GATE/ && $5=="no"{print " FINDING: "$3" reads a pin and asserts nothing in its body or helpers"}' >&2
374fi
375
376# --- RECOVERED-PIN SELF-VALIDATION -----------------------------------------
377# A recovered witness is the historical bytes; a re-encode is a DIFFERENT stream.
378# Hashing what is on disk against the recorded sha256 is the half a shell
379# preflight can decide. The other half is behavioural and needs the gate:
380# `pinned_golden7` records non_last_ref_hits 0->2 in its own doc, and the
381# recovered pin reproduces exactly that; only running the gate proves it.
382badsum=0
383while IFS=$'\t' read -r path required_by class prov status tracked sum; do
384 case $path in
385 \#* | '') continue ;;
386 esac
387 [ "$class" = recovered-original ] || continue
388 abs=$ROOT/$path
389 if [ ! -f "$abs" ]; then
390 echo "FAIL [recovered]: $path is absent" >&2
391 fail=1
392 continue
393 fi
394 have=$(sha256sum -- "$abs" | cut -d' ' -f1)
395 if [ "$have" != "$sum" ]; then
396 echo "FAIL [recovered]: $path hashes $have, the manifest records $sum -- this is" >&2
397 echo " a DIFFERENT stream (a re-encode), not the recovered original." >&2
398 fail=1
399 badsum=$((badsum + 1))
400 fi
401done <"$MANIFEST"
402[ "$badsum" -eq 0 ] && note " recovered pins: every recovered-original hash matches"
403echo " recovered pins: the behavioural half needs the gate, not this script --" >&2
404echo " run 'cargo test -p ec-av1 pinned_golden7'; it prints non_last_ref_hits" >&2
405echo " and its doc records the 0->2 delta only the recovered pin reproduces." >&2
406
407# --- VECTORS -------------------------------------------------------------
408vec_rows=$(awk -F'\t' '!/^#/ && $1 ~ /^fixtures\/vectors\//' "$MANIFEST" | wc -l)
409vec_missing=$(awk -F'\t' '!/^#/ && $1 ~ /^fixtures\/vectors\// && $5 != "ok"' "$MANIFEST" | wc -l)
410echo " vectors: $vec_rows referenced rows, $vec_missing not ok" >&2
411echo " vectors: nothing in crates/ reads a .tar.gz; the fleet hosts carry the" >&2
412echo " EXTRACTED sets, so the blobs are not required at test time" >&2
413
414# --- DRIFT ----------------------------------------------------------------
415regen=$(mktemp)
416patch=$(mktemp)
417trap 'rm -f "$regen" "$patch" ${selftest_out:-} ' EXIT
418if ! "$ROOT/scripts/gen-fixture-library.sh" "$regen" >/dev/null 2>&1; then
419 echo "FAIL: scripts/gen-fixture-library.sh did not run" >&2
420 exit 1
421fi
422# The `tracked` column is COMMITTED provenance: it is computed in a git tree.
423# A runner host has no .git, so a regeneration there cannot recompute it and
424# would emit 'no-git' for every committed pin -- a drift on all 37 pin rows that
425# says nothing about the host's library. Off-git the column is normalised on both
426# sides, and the tracked invariant falls back to the committed value (as its own
427# message already says).
428drift_norm() { grep -v '^#' "$1" | awk -F'\t' -v OFS='\t' 'BEGIN{off=1} $1 ~ /^crates\/.*\/fixtures\//{if(off && $6!="-") $6="-"} {print}'; }
429OFFGIT=0
430[ -e "$ROOT/.git" ] || OFFGIT=1
431if ! diff -u <(drift_norm "$MANIFEST") <(drift_norm "$regen") >"$patch" 2>&1; then
432 if [ "$REQUIRE" != 0 ]; then
433 echo "FAIL: this tree's library does not match what the code reaches" >&2
434 echo " (DRIFT: the committed manifest's rows differ from a regeneration" >&2
435 echo " here). The first difference is the row to act on; '- only here'" >&2
436 echo " is a path this host reaches and the committed manifest does not," >&2
437 echo " '+ only committed' is a row this host cannot satisfy. Fetch the" >&2
438 echo " library, or commit the regenerated manifest. (patch follows)" >&2
439 sed -n '1,40p' "$patch" >&2
440 fail=1
441 else
442 echo "SKIP: the library does not match what the code reaches (DRIFT;" >&2
443 echo " EC_REQUIRE_FIXTURES unset, so this is reported, not failed):" >&2
444 sed -n '1,20p' "$patch" >&2
445 fi
446else
447 note " drift: manifest rows match the code on this host"
448fi
449
450if [ "$fail" -ne 0 ]; then
451 echo "verify-fixture-library: RED (library verdict: mode i, mode ii or drift)" >&2
452 exit 1
453fi
454if [ "$SHAPE" != 0 ] && [ "$shape_fail" -ne 0 ]; then
455 echo "verify-fixture-library: RED (code-shape violations, EC_FIXTURE_SHAPE_STRICT=1)" >&2
456 exit 1
457fi
458# The shape tally is always printed, fatal only under EC_FIXTURE_SHAPE_STRICT.
459for s in $(echo "$audit" | awk -F'\t' '/^BADROW/{c++} END{print c+0}'); do :; done
460echo " code-shape violations: $(echo "$audit" | awk -F'\t' '/^BADROW/{c++} END{print c+0}')" >&2
461echo "$forbidden" | grep -q . && shape_violations=$((shape_violations + $(echo "$forbidden" | grep -c .)))
462# lane-av1clipprobe: the last word of this script used to be a bare `GREEN`
463# even when mode (i) had just been reported a few lines above -- so a reader
464# who read only the verdict read GREEN over a tree whose fixture root does not
465# exist, which is the same false green as a gate that skipped. The verdict now
466# says which it is: findings reported (not failed, because
467# EC_REQUIRE_FIXTURES is unset) versus a clean pass. `EC_REQUIRE_FIXTURES=1`
468# turns the first into the RED above.
469if [ "$root_present" -eq 0 ]; then
470 echo "verify-fixture-library: GREEN-WITH-FINDINGS ($rows rows; the absent root above is" >&2
471 echo " REPORTED, not failed -- set EC_REQUIRE_FIXTURES=1 on a tree that is" >&2
472 echo " meant to have the library, or provision it and re-run)" >&2
473else
474 echo "verify-fixture-library: GREEN ($rows rows)"
475fi