#!/bin/sh
# Deterministic guard for the OMP-native CI dispatcher.
set -u
ROOT=$(CDPATH= cd "$(dirname "$0")/.." && pwd)
GATES="$ROOT/ci/run-gates.sh"
fail=0

sh -n "$GATES" && echo "ok   run-gates syntax" || { echo "FAIL run-gates syntax"; fail=1; }
for required in \
  'traceable-reqs check' \
  'tests/manifest-shortcut.sh' \
  'tests/native-launch-manifest.sh' \
  'ci/digest/build.sh' \
  'tests/release-acquire.sh' \
  'ci/manifest/check-manifest.sh' \
  'ci/publish/validate-release-binary.py' \
  'ci/release/check-version-consistency.py' \
  'tests/version-consistency.py' \
  'ci/docs/check-docs.sh' \
  'bun tests/omp-skills.mjs' \
  'tests/docs-gate.py' \
  'tests/release-evidence.py'; do
  grep -Fq "$required" "$GATES" \
    && echo "ok   gate: $required" \
    || { echo "FAIL missing gate: $required"; fail=1; }
done

for stale in 'validate-skeleton' 'idle-translate' 'hooks-dispatch' 'acceptance-harness'; do
  if grep -Fq "$stale" "$GATES"; then
    echo "FAIL stale gate remains: $stale"
    fail=1
  fi
done

[ "$fail" -eq 0 ] && { echo "CI-GATES OK"; exit 0; } || { echo "CI-GATES FAIL"; exit 1; }
