aien-protocols-mv
Canonical specifications, wire protocols, and schemas for the AIEN sovereign ecosystem
Brought by drakestapleton
aien-protocols-mv / tests / gates / run.sh
| 1 | #!/usr/bin/env bash |
| 2 | # tests/gates/run.sh: the one entry point for the local verification gates of |
| 3 | # aien-protocols. Every step runs the SAME command as the hosted job it mirrors |
| 4 | # (.github/workflows/ci.yml, job "Workspace Verification & Invariant Audit"). |
| 5 | # Manifests under tests/gates/ name this script plus one step word, so no |
| 6 | # manifest ever needs shell expansion (ADR 0028 P6). Observations are printed |
| 7 | # as "AIEN-OBS <name> <json>" lines (ADR 0028 Decision 5). |
| 8 | set -euo pipefail |
| 9 | ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" |
| 10 | cd "$ROOT" |
| 11 | step="${1:?usage: tests/gates/run.sh <step>}" |
| 12 | obs() { printf 'AIEN-OBS %s %s\n' "$1" "$2"; } |
| 13 | |
| 14 | case "$step" in |
| 15 | # crumb-verify (gate CRUMB-VERIFY) is retired (DRA-97, 2026-11-07): Crumbs are off the active |
| 16 | # workflow, so no gate checks crumb freshness. The .crumb files stay as history. |
| 17 | fmt) |
| 18 | cargo fmt --all -- --check |
| 19 | ;; |
| 20 | check) |
| 21 | cargo check --workspace --all-targets |
| 22 | ;; |
| 23 | clippy) |
| 24 | cargo clippy --workspace --all-targets -- -D warnings |
| 25 | ;; |
| 26 | test) |
| 27 | cargo test --workspace --verbose |
| 28 | ;; |
| 29 | zero-disk-secrets) |
| 30 | echo "Auditing repository for prohibited plaintext secret files..." |
| 31 | if find . -maxdepth 4 -name ".env*" -not -path "*/.git/*" -not -path "*/target/*" | grep -q .; then |
| 32 | echo "::error::Prohibited plaintext .env file found. Use an approved AIEN SecretProvider." |
| 33 | obs env_files_found true |
| 34 | exit 1 |
| 35 | fi |
| 36 | obs env_files_found false |
| 37 | echo "Zero plaintext .env files verified." |
| 38 | ;; |
| 39 | anti-slop) |
| 40 | echo "Auditing repository for em dashes, en dashes, and formulaic tropes..." |
| 41 | BAD_CHARS=$(grep -rnE --exclude-dir=target --exclude-dir=.git --exclude="*.rs" --exclude="*.json" --exclude="*.safetensors" "—|–" crates/ docs/ README.md ANTI_ENCLOSURE.md || true) |
| 42 | if [ -n "$BAD_CHARS" ]; then |
| 43 | echo "::error::Em dashes or en dashes detected:" |
| 44 | echo "$BAD_CHARS" |
| 45 | obs dash_hits "$(printf '%s\n' "$BAD_CHARS" | grep -c . )" |
| 46 | exit 1 |
| 47 | fi |
| 48 | obs dash_hits 0 |
| 49 | echo "Sovereign voice compliance verified." |
| 50 | ;; |
| 51 | c-vectors) |
| 52 | # Runs every spec checker that matches specs/*/tools/check-*.sh, each with |
| 53 | # bash (two of them use bash-only syntax). PASS only if every one passes; |
| 54 | # FAIL if any fails or if none is found. A new spec checker named |
| 55 | # check-*.sh is picked up with no change here. |
| 56 | shopt -s nullglob |
| 57 | checkers=(specs/*/tools/check-*.sh) |
| 58 | shopt -u nullglob |
| 59 | found=${#checkers[@]} |
| 60 | failed=0 |
| 61 | obs c_checkers_found "$found" |
| 62 | if [ "$found" -eq 0 ]; then |
| 63 | echo "::error::No spec checker matches specs/*/tools/check-*.sh" |
| 64 | obs c_checkers_failed 0 |
| 65 | exit 1 |
| 66 | fi |
| 67 | for c in "${checkers[@]}"; do |
| 68 | echo "== $c" |
| 69 | if bash "$c"; then |
| 70 | echo "CHECKER_PASS $c" |
| 71 | else |
| 72 | echo "::error::CHECKER_FAIL $c" |
| 73 | failed=$((failed + 1)) |
| 74 | fi |
| 75 | done |
| 76 | obs c_checkers_failed "$failed" |
| 77 | if [ "$failed" -ne 0 ]; then |
| 78 | echo "PROTO_C_VECTORS FAIL found=$found failed=$failed" |
| 79 | exit 1 |
| 80 | fi |
| 81 | echo "PROTO_C_VECTORS PASS found=$found failed=0" |
| 82 | ;; |
| 83 | *) |
| 84 | echo "run.sh: unknown step '$step'" >&2 |
| 85 | exit 2 |
| 86 | ;; |
| 87 | esac |