#!/usr/bin/env bash # G.U.I.D.E. pre-commit gate — runs the sanity suite (SPEC.md §3-4). # No code may be committed while these fail. Bypass only with --no-verify. set -euo pipefail ROOT="$(git rev-parse --show-toplevel)" cd "$ROOT" if [ -x ".venv/bin/python" ]; then PY=".venv/bin/python" else PY="python3" fi echo "[pre-commit] Running G.U.I.D.E. sanity tests ($PY)…" if ! "$PY" -m pytest tests/test_sanity.py -q; then echo "" echo "[pre-commit] ❌ Sanity tests failed — commit aborted (see SPEC.md)." echo "[pre-commit] Fix the failures, or bypass with 'git commit --no-verify'" echo "[pre-commit] (only in a genuine emergency; the change is then not Done)." exit 1 fi echo "[pre-commit] ✅ Sanity tests passed."