#!/bin/bash # CHECK-env-verifiers: grade the lane's two environment verifiers. # # Q109. The lane's own CHECK grades artifacts under an absolute home path and # runs none of the lane's test_*.py (that blindness is a separate item), so this # file gives these two verifiers a gate of their own. The cell # (test_env_verifiers.py) invokes both verifiers as subprocesses with stub # modules on PYTHONPATH and synthetic Hermes trees, so it grades the tree it # sits in -- the paths are resolved from the cell's own location. # # 2026-10-29 repair. The lone-copy cell asserted the path it had built # (self.tmp/lone/snippet.py) while verify_hermes_setup.sh reports the path it # resolved with `readlink -f`. On any host whose TMPDIR is reached through a # symlink those two strings differ, and a correct pair read a false MISSING -- # the gate went rc 1 on green work. The suite now canonicalises its fixture root # with os.path.realpath and pins the alias case with two cells of its own; this # gate runs the suite TWICE, under the ambient TMPDIR and under a directory # alias it builds, so the host shape that produced the flake is graded on every # run instead of remembered. # # Exit codes follow the repo's tools/ contract: # 0 = both verifiers measure what they claim, on both TMPDIR shapes # 1 = a verifier regression (a cell failed) # 2 = could not grade (no python3, no fixture, or the cell will not collect) set -u cd "$(dirname "$(readlink -f "$0")")" || { echo "CHECK: cannot cd to the cell's own directory -- cannot grade." >&2 exit 2 } if ! command -v python3 >/dev/null 2>&1; then echo "CHECK: python3 not on PATH -- cannot grade." >&2 exit 2 fi tmpbase=${TMPDIR:-/tmp} real_root=$(mktemp -d "$tmpbase/q109-alias-XXXXXX") || { echo "CHECK: mktemp failed -- cannot build the alias leg." >&2 exit 2 } alias_root="$real_root.alias" if ! ln -s "$real_root" "$alias_root"; then rmdir "$real_root" 2>/dev/null || true echo "CHECK: could not build the alias leg." >&2 exit 2 fi out=$(mktemp "$tmpbase/q109-out-XXXXXX") || { rm -f "$alias_root" rmdir "$real_root" 2>/dev/null || true echo "CHECK: mktemp failed -- cannot capture the cell's output." >&2 exit 2 } fault=0 ungradable=0 for leg_tmp in "$tmpbase" "$alias_root"; do TMPDIR=$leg_tmp python3 -m unittest -q test_env_verifiers >"$out" 2>&1 leg_rc=$? case $leg_rc in 0) echo "leg TMPDIR=$leg_tmp -> rc 0" ;; 1) fault=1; echo "leg TMPDIR=$leg_tmp -> rc 1" >&2; tail -n 12 "$out" >&2 ;; *) ungradable=1; echo "leg TMPDIR=$leg_tmp -> rc $leg_rc" >&2; tail -n 12 "$out" >&2 ;; esac done rm -f "$alias_root" "$out" rmdir "$real_root" 2>/dev/null || true if [ "$ungradable" -ne 0 ]; then echo "CHECK: unittest exited non-zero and non-one -- collection error, could not grade." >&2 exit 2 fi if [ "$fault" -ne 0 ]; then echo "CHECK: verifier contract broken -- a cell failed." >&2 exit 1 fi echo "CHECK: both environment verifiers measure what they claim (plain and symlinked TMPDIR)." exit 0