Files
ersatztv/scripts/check-kickoff-guard.sh
T

45 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# ersatztv#520 — block re-treating the CLOSED arc tracker #237 as live queue state / source of truth.
# Scans active startup docs for forbidden phrasings. A hit is exempt when the line itself contains
# "archiv" OR the line is inside an archival section (a heading whose text contains "archiv", up to
# the next heading of the same or higher level). The "archiv" escape is an anti-footgun convenience,
# not an anti-adversary control.
set -euo pipefail
FILES=(
"docs/handoffs/chicorytv-issue-queue.md"
"docs/README.md"
"CLAUDE.md"
"scripts/select-queue.sh"
)
# Case-insensitive patterns that assert #237 is live/authoritative.
PATTERNS='read #237|#237.?s (body|arc|comments)|tracker #237|queue state lives in|read that, not this file'
rc=0
for f in "${FILES[@]}"; do
[ -f "$f" ] || continue
archive_level=0 # 0 = not in an archival section; else the heading level that opened it
lineno=0
while IFS= read -r line; do
lineno=$((lineno + 1))
# Track archival-section state via Markdown ATX headings.
if [[ "$line" =~ ^(#{1,6})[[:space:]] ]]; then
level=${#BASH_REMATCH[1]}
if printf '%s' "$line" | grep -qi 'archiv'; then
archive_level=$level
elif [ "$archive_level" -ne 0 ] && [ "$level" -le "$archive_level" ]; then
archive_level=0 # a same-or-higher heading closes the archival section
fi
continue
fi
[ "$archive_level" -ne 0 ] && continue # inside archival section → exempt
printf '%s' "$line" | grep -qi 'archiv' && continue # per-line escape
if printf '%s' "$line" | grep -qiE "$PATTERNS"; then
echo "kickoff-guard: $f:$lineno reintroduces #237-as-live-state: ${line}" >&2
rc=1
fi
done < "$f"
done
[ "$rc" -eq 0 ] && echo "kickoff-guard: OK"
exit "$rc"