#!/usr/bin/env bash
# Lodlina pre-push gate: never push red.
#
# CI runs AFTER a push lands on main (trunk-based, no PRs), so this hook is the
# actual gate. It runs the linter and the full offline suite; live tests are a
# separate, explicit step for big changes (pytest -m live — see CLAUDE.md).
#
# One-time setup per clone:  git config core.hooksPath .githooks
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"

PY=.venv/bin/python
RUFF=.venv/bin/ruff
if [[ ! -x "$PY" ]]; then
  echo "[pre-push] no .venv — run: uv sync --extra dev" >&2
  exit 1
fi

echo "[pre-push] ruff check src/ tests/"
"$RUFF" check src/ tests/

echo "[pre-push] pytest (offline suite)"
"$PY" -m pytest -q

echo "[pre-push] OK — pushing"
