#!/usr/bin/env bash # Pre-commit hook: FAST (~2s). High-signal, low-cost. # # Runs ruff bug-classes on staged source + a curated fast-test gate that # rebuilds the kernel, guards against a stale binary, and proves the # load-bearing claims end-to-end (3 4 + . -> 7), the dragon trapnet, the # cave size budget, the print path, and branch logic. # # The comprehensive gate (full suite) lives in pre-push — commit is for fast # feedback, push is for the full net. Phantom state thrives in hidden output; # each phase announces itself before it runs. set -euo pipefail cd "$(git rev-parse --show-toplevel)" # Only relevant if Python/build config changed. A docs-only commit skips. if ! git diff --cached --name-only | grep -qE '\.(py|toml)$|Makefile|^hooks/'; then echo "── pre-commit: no .py/.toml/Makefile changes — skipping ──" exit 0 fi echo "── pre-commit: ruff bug-classes (src + test) ──" ruff check src/ test/ --select F821,F811,E722,W605 echo "── pre-commit: fast gate (build + staleness + integration + trapnet + size) ──" uv run python -m src.build_kernel >/dev/null uv run pytest -q \ test/test_precompiled_kernel.py::TestStalenessGuard \ test/test_kernel_integration.py \ test/test_trapnet.py \ test/test_size_budget.py \ test/test_dot_hunt.py \ test/test_conditionals.py echo "── pre-commit: done ──"