|
| 1 | +#!/usr/bin/env bash |
| 2 | +# SPDX-License-Identifier: MPL-2.0 |
| 3 | +# Acceptance checks for the documentation added by PR #188. No prover runs. |
| 4 | +# Usage: bash tests/check-policy-records.sh (bash/awk only; finishes in seconds). |
| 5 | +# These check references and factual claims, not prose or proof correctness. |
| 6 | +set -euo pipefail |
| 7 | +repo_root="$(cd "$(dirname "$0")/.." && pwd)" |
| 8 | +cd "$repo_root" |
| 9 | +export LC_ALL=C |
| 10 | +failures=0 |
| 11 | +cases=0 |
| 12 | + |
| 13 | +expect() { |
| 14 | + local label=$1 |
| 15 | + shift |
| 16 | + cases=$((cases + 1)) |
| 17 | + if "$@"; then |
| 18 | + printf 'PASS: %s\n' "$label" |
| 19 | + else |
| 20 | + printf 'FAIL: %s\n' "$label" >&2 |
| 21 | + failures=$((failures + 1)) |
| 22 | + fi |
| 23 | +} |
| 24 | + |
| 25 | +exception=docs/EXCEPTION-T1-2026-10-12.adoc |
| 26 | +decision=docs/DECISION-T7-2026-10-12.adoc |
| 27 | +for document in README.adoc "$exception" "$decision"; do |
| 28 | + # Missing input must fail before extraction, never yield an empty passing loop. |
| 29 | + if [[ ! -s "$document" ]]; then |
| 30 | + printf 'FAIL: missing or empty document: %s\n' "$document" >&2 |
| 31 | + exit 1 |
| 32 | + fi |
| 33 | +done |
| 34 | + |
| 35 | +# Resolve the actual link in the new README note, relative to the README. |
| 36 | +mapfile -t links < <(awk ' |
| 37 | + { |
| 38 | + while (match($0, /link:[^[:space:][]*EXCEPTION-T1[^[:space:][]*\[/)) { |
| 39 | + print substr($0, RSTART + 5, RLENGTH - 6) |
| 40 | + $0 = substr($0, RSTART + RLENGTH) |
| 41 | + } |
| 42 | + } |
| 43 | +' README.adoc) |
| 44 | +expect 'README has one T1 exception link' test "${#links[@]}" -eq 1 |
| 45 | +for target in "${links[@]}"; do |
| 46 | + expect "README exception link resolves: $target" test -s "$target" |
| 47 | +done |
| 48 | + |
| 49 | +# Extract the named modules rather than duplicating the exception's inventory. |
| 50 | +mapfile -t modules < <(awk ' |
| 51 | + { |
| 52 | + while (match($0, /[[:alnum:]_]+[.]agda/)) { |
| 53 | + print substr($0, RSTART, RLENGTH) |
| 54 | + $0 = substr($0, RSTART + RLENGTH) |
| 55 | + } |
| 56 | + } |
| 57 | +' "$exception") |
| 58 | +expect 'T1 names at least one proof module' test "${#modules[@]}" -gt 0 |
| 59 | +for module in "${modules[@]}"; do |
| 60 | + expect "T1 module exists: $module" test -s "proofs/agda/$module" |
| 61 | + for flag in --safe --without-K; do |
| 62 | + expect "$module declares the T1 safety condition $flag" awk -v flag="$flag" ' |
| 63 | + /^[[:space:]]*\{-# OPTIONS / { |
| 64 | + for (i = 3; i <= NF; i++) if ($i == flag) found = 1 |
| 65 | + } |
| 66 | + END { exit !found } |
| 67 | + ' "proofs/agda/$module" |
| 68 | + done |
| 69 | +done |
| 70 | + |
| 71 | +# The archive claim must not silently point readers back to an active tree. |
| 72 | +for prover in coq lean4 isabelle mizar; do |
| 73 | + expect "archived $prover tree exists" test -d "archive/proofs/$prover" |
| 74 | + expect "$prover has no active proof tree" test ! -e "proofs/$prover" |
| 75 | +done |
| 76 | +expect 'T7 proof-contract destination exists' test -d proofs/agda |
| 77 | +expect 'T1 ABI package exists' test -s absolute-zero-abi.ipkg |
| 78 | +expect 'T1 ABI directory matches the package source directory' awk ' |
| 79 | + /^[[:space:]]*sourcedir[[:space:]]*=[[:space:]]*"src\/abi"[[:space:]]*$/ { found = 1 } |
| 80 | + END { exit !found } |
| 81 | +' absolute-zero-abi.ipkg |
| 82 | +expect 'T1 ABI source directory exists' test -d src/abi |
| 83 | + |
| 84 | +# Negative/regression case: documentation and line comments are not live |
| 85 | +# escape hatches. Follow scripts/check-proof-patterns.sh counting semantics; |
| 86 | +# count occurrences (including multiple on one line), not matching lines. |
| 87 | +documented_count=$(awk ' |
| 88 | + match($0, /[0-9]+[[:space:]]+`believe_me`/) { |
| 89 | + print substr($0, RSTART, RLENGTH) + 0 |
| 90 | + } |
| 91 | +' "$decision") |
| 92 | +shopt -s globstar nullglob |
| 93 | +abi_sources=(src/abi/**/*.idr) |
| 94 | +expect 'ABI census has source inputs' test "${#abi_sources[@]}" -gt 0 |
| 95 | +if ((${#abi_sources[@]} > 0)); then |
| 96 | + live_count=$(awk ' |
| 97 | + /^[[:space:]]*\|\|\|/ { next } |
| 98 | + { |
| 99 | + sub(/--.*/, "") |
| 100 | + while (match($0, /believe_me/)) { |
| 101 | + count++ |
| 102 | + $0 = substr($0, RSTART + RLENGTH) |
| 103 | + } |
| 104 | + } |
| 105 | + END { print count + 0 } |
| 106 | + ' "${abi_sources[@]}") |
| 107 | + expect "T7 live believe_me count: documented=$documented_count, actual=$live_count" \ |
| 108 | + test "$documented_count" = "$live_count" |
| 109 | +fi |
| 110 | + |
| 111 | +printf 'POLICY-RECORDS: %s checks, %s failures\n' "$cases" "$failures" |
| 112 | +test "$failures" -eq 0 |
0 commit comments