Files
ChatGPTScaffolding/scripts/audit.sh

80 lines
2.2 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
root_dir="$(cd "$(dirname "$0")/.." && pwd)"
failures=0
check() {
local msg="$1"; shift
if "$@"; then
echo "[ok] $msg"
else
echo "[fail] $msg" >&2
failures=$((failures+1))
fi
}
cd "$root_dir"
# Structure checks
for d in collab docs prompts templates scripts meta .gitea; do
check "dir exists: $d" test -d "$d"
done
# .gitignore housekeeping
if [ -f .gitignore ]; then
if grep -q '^runs/' .gitignore; then
echo "[ok] .gitignore includes runs/"
else
echo "[fail] .gitignore missing runs/" >&2; failures=$((failures+1))
fi
else
echo "[warn] no .gitignore at repo root"
fi
# CI presence
check "Gitea workflow exists" test -f .gitea/workflows/ci.yml
# Docker compose for local parity
check "docker/compose.yml exists" test -f docker/compose.yml
# Quiet shell policy (advisory): ensure no scripted chat streaming helpers exist
if command -v rg >/dev/null 2>&1; then
if rg -n "\b(cat|sed\s+-n)\b" scripts 2>/dev/null | grep -v audit.sh >/dev/null 2>&1; then
echo "[warn] scripts contain cat/sed -n; ensure these are not used to stream contents into chat" >&2
fi
fi
# Sequencing gates: for each plan, ensure corresponding proposal approved; for each proposal, ensure questions approved
status_warn=0
for plan in collab/plan/*.md; do
[ -f "$plan" ] || continue
base=$(basename "$plan")
prefix=${base%%.md}
proposal="collab/proposals/$prefix.md"
if [ ! -f "$proposal" ]; then
echo "[fail] Missing proposal for plan: $plan" >&2; failures=$((failures+1)); continue
fi
if ! grep -q "Approved for Plan" "$proposal"; then
echo "[warn] Proposal not yet approved for plan ($prefix). Plan should be pending." >&2
status_warn=1
fi
# check questions
qfile="collab/questions/$prefix.md"
if [ ! -f "$qfile" ]; then
echo "[fail] Missing questions for: $prefix" >&2; failures=$((failures+1))
else
if ! grep -q "Approved for Proposal" "$qfile"; then
echo "[warn] Questions not yet approved for proposal ($prefix)." >&2
status_warn=1
fi
fi
done
if [ "$status_warn" -eq 1 ]; then
echo "[note] Sequencing warnings present; ensure approvals before proceeding."
fi
echo "[summary] failures=$failures"
exit "$failures"