#!/usr/bin/env sh
# git pre-commit hook — gate a commit that breaks a bound ev decision (the deterministic rung).
#
# Install: copy to .git/hooks/pre-commit and chmod +x, in a repo with a co-located .evolving/ ledger
# (see ../scaffold/ev-colocate.sh — ev reads git state from here, so the ledger must sit with the code).
#
# `--run` re-executes each bound check at commit time so a commit that breaks a premise goes red; drop
# it for a faster receipt-only gate (checks the last recorded run, runs nothing). `--exit-on-red`
# returns non-zero on any not-green bound decision, which aborts the commit.
set -eu
command -v ev >/dev/null 2>&1 || exit 0
[ -d .evolving ] || exit 0
exec ev check --run --exit-on-red
