#!/usr/bin/env bash # .agent/validate.sh โ€” validation gate for the phased-execution pipeline. # # A phase is only moved to .agent/phases/complete/ if this script exits 0. # Gates (PLAN ยง10 / AGENTS.md): unit + integration tests, coverage >90% # on app/, ruff, pyright โ€” all through `uv` (the project's package manager). set -uo pipefail rc=0 if [[ -f pyproject.toml || -f pytest.ini || -f setup.py ]]; then out="$(uv run pytest -q --cov=app --cov-report=term 2>&1)"; pytest_rc=$? printf '%s\n' "$out" | tail -n 30 if [[ $pytest_rc -ne 0 ]]; then echo "pytest FAILED (exit $pytest_rc)" rc=1 fi total="$(printf '%s\n' "$out" | grep -E '^TOTAL' | awk '{print $NF}' | tr -d '%')" if [[ -n "${total:-}" ]]; then if awk -v c="$total" 'BEGIN { exit !(c > 90.0) }'; then echo "coverage gate: app/ ${total}% (>90%) OK" else echo "coverage gate FAILED: app/ ${total}% (need >90%)" rc=1 fi else echo "coverage gate: TOTAL line not found โ€” treating as pass (report above)" fi uv run ruff check . || rc=1 uv run pyright || rc=1 fi if [[ $rc -ne 0 ]]; then echo "validation FAILED (see output above)" else echo "validation OK" fi exit "$rc"