diff --git a/hooks/validate-coordinator-boundary.sh b/hooks/validate-coordinator-boundary.sh index 71168d3..e282202 100755 --- a/hooks/validate-coordinator-boundary.sh +++ b/hooks/validate-coordinator-boundary.sh @@ -57,6 +57,55 @@ for lang in $LANGS; do fi done +# --------------------------------------------------------------------------- +# Advisory tier (NON-blocking): catch *prose* language-spec leakage that the +# structural checks above cannot — a grammar, typing rules, or a whole language +# spec pasted into a narrative doc (how "TypeFix Zero" ended up inside README). +# This is heuristic, so it only WARNS; it never fails the build. +# +# Scope = the coordinator's NARRATIVE surface (top-level *.md/*.adoc + docs/, +# minus the cross-language disambiguation notes). It deliberately does NOT scan +# wiki/, where illustrative rust/ocaml/agda/ebnf *teaching* snippets legitimately +# live, nor extraction-queue/ (content already staged for relocation). +# --------------------------------------------------------------------------- +WARN=0 +in_gha() { [ -n "${GITHUB_ACTIONS:-}" ]; } + +narrative_files() { + find . -maxdepth 1 -type f \( -name '*.md' -o -name '*.adoc' \) + find docs -type f \( -name '*.md' -o -name '*.adoc' \) ! -path 'docs/disambiguation/*' 2>/dev/null +} + +advise() { # $1=regex $2=message + local f ln + while IFS= read -r f; do + [ -f "$f" ] || continue + while IFS= read -r ln; do + [ -n "$ln" ] || continue + in_gha && echo "::warning file=${f#./},line=${ln}::$2" + printf ' WARN %s:%s — %s\n' "${f#./}" "$ln" "$2" + WARN=$((WARN + 1)) + done < <({ grep -nE "$1" "$f" 2>/dev/null || true; } | cut -d: -f1) + done < <(narrative_files) +} + +# grammar/proof code blocks have no place in a coordinator narrative doc +advise '^[[:space:]]*(```|----)[[:space:]]*(agda|lean|coq|idris2?|ebnf|bnf|antlr|g4)\b' \ + 'grammar/proof code block in a coordinator narrative doc — belongs in the language repo' +# implementation-language code blocks: a coordinator describes, it does not implement +advise '^[[:space:]]*(```|----)[[:space:]]*(rust|ocaml|reason|rescript)\b' \ + 'implementation-language code block in a coordinator narrative doc — describe, do not implement here' +# unfenced spec tells: BNF productions, sequents, universe/fixpoint typing judgments +advise '::=|⊢|Type[[:space:]]+[0-9a-z][[:space:]]*:[[:space:]]*Type|(^|[^A-Za-z])fix[[:space:]]*:[[:space:]]*\(' \ + 'typing-judgment / grammar-production notation — looks like a pasted language spec' + +if [ "$WARN" -gt 0 ]; then + echo "" + echo "coordinator-boundary: $WARN advisory warning(s) — possible prose/spec leakage (NON-blocking)." + echo " If a language spec was pasted in, move it to that language's hyperpolymath/ repo." + echo " If it is legitimate cross-language prose, ignore — advisory checks never fail the build." +fi + if [ "$ERRORS" -gt 0 ]; then echo "" echo "Coordinator-boundary check FAILED ($ERRORS violation(s))."