#!/usr/bin/env bash # det-gate — the deterministic gate (phase 5). Runs the cheap, ungameable checks # (lint, format, typecheck, tests) BEFORE any LLM reviewer is spawned, because # they catch the bulk of issues for free. # # Auto-detects the stack. Runs every check that applies, collects failures, and # exits non-zero if ANY failed. Customize per-project by creating an executable # `.skepticism/det-gate.sh` at the repo root — if present, it is run instead. # # One check is NOT overridable: leak-check runs first, before the project hook, # because Iron Rule 6 (leave no trace) must not be switchable off by a config # file the user forgot they wrote. # # Usage: det-gate [base-ref] (run from the project repo root) # base-ref, when given, is forwarded to leak-check so it can also scan the # commit messages in base..HEAD. set -uo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" LEAK_CHECK="${SCRIPT_DIR}/leak-check" base="${1:-}" # Transparency gate (not overridable) ---------------------------------------- if [[ -x "$LEAK_CHECK" ]]; then if ! "$LEAK_CHECK" ${base:+"$base"}; then echo echo "════════════════════════════════════════════" echo "det-gate: FAILED → leak-check" exit 1 fi echo fi # Project override hook ------------------------------------------------------ if [[ -x ".skepticism/det-gate.sh" ]]; then exec ./.skepticism/det-gate.sh fi failures=() ran_any=0 run() { local label="$1"; shift ran_any=1 echo "──► ${label}: $*" if "$@"; then echo " ✓ ${label} passed" else echo " ✗ ${label} FAILED" failures+=("$label") fi echo } have() { command -v "$1" >/dev/null 2>&1; } # Pick the JS package manager if this is a Node project. js_pm() { if [[ -f pnpm-lock.yaml ]] && have pnpm; then echo pnpm elif [[ -f yarn.lock ]] && have yarn; then echo yarn elif have npm; then echo npm fi } # Run an npm script only if it is defined in package.json. js_script() { #