aien-architecture-mv
Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.
Brought by drakestapleton
aien-architecture-mv / bootstrap / formal-oracles / lean / run-cap-formal.sh
| 1 | #!/bin/sh |
| 2 | # FORMAL-2/3: capability formal bootstrap runner (DEVELOPMENT_ORACLE, not permanent lineage). |
| 3 | # Builds the real model (must PASS) and each deliberate mutant claim (must FAIL). |
| 4 | # Last stdout line: CAP_FORMAL_BOOTSTRAP: PASS | FAIL | NOT_RUN |
| 5 | # No network needed after the toolchain is installed (core Lean only, no dependencies). |
| 6 | set -u |
| 7 | here=$(cd "$(dirname "$0")" && pwd) |
| 8 | cd "$here" || exit 2 |
| 9 | PATH="$HOME/.elan/bin:$PATH"; export PATH |
| 10 | |
| 11 | quiet="${AIEN_SPARK_QUIET_FLAG:-$HOME/workspace/.spark-quiet}" |
| 12 | if [ -e "$quiet" ]; then |
| 13 | echo "quiet flag present ($quiet): not building" |
| 14 | echo "CAP_FORMAL_BOOTSTRAP: NOT_RUN" |
| 15 | exit 3 |
| 16 | fi |
| 17 | command -v lake >/dev/null 2>&1 || { echo "lake not found (install elan)"; echo "CAP_FORMAL_BOOTSTRAP: NOT_RUN"; exit 3; } |
| 18 | |
| 19 | log=$(mktemp); trap 'rm -f "$log"' EXIT |
| 20 | echo "toolchain: $(cat lean-toolchain) / $(lean --version)" |
| 21 | fail=0 |
| 22 | |
| 23 | lake build AienCap >"$log" 2>&1; rc=$? |
| 24 | if [ $rc -eq 0 ] && ! grep -qi "sorry" "$log"; then |
| 25 | echo "real_model: PASS" |
| 26 | else |
| 27 | echo "real_model: FAIL (rc=$rc)"; tail -20 "$log"; fail=1 |
| 28 | fi |
| 29 | |
| 30 | lake build MutantModels >"$log" 2>&1; rc=$? |
| 31 | if [ $rc -eq 0 ] && ! grep -qi "sorry" "$log"; then |
| 32 | echo "mutant_models_compile: PASS" |
| 33 | else |
| 34 | echo "mutant_models_compile: FAIL (rc=$rc)"; tail -20 "$log"; fail=1 |
| 35 | fi |
| 36 | |
| 37 | for m in MutantScopeClaim MutantExpiryClaim MutantDepthClaim; do |
| 38 | lake build "$m" >"$log" 2>&1; rc=$? |
| 39 | if [ $rc -ne 0 ] && grep -q "^error: $m.lean:" "$log" && ! grep -q "^error: MutantModels.lean" "$log"; then |
| 40 | echo "$m: FAIL_AS_EXPECTED (mutant killed)" |
| 41 | else |
| 42 | echo "$m: UNEXPECTED_BUILD_SUCCESS_OR_NO_ERROR (rc=$rc), mutant survived"; fail=1 |
| 43 | fi |
| 44 | done |
| 45 | |
| 46 | if [ $fail -eq 0 ]; then echo "CAP_FORMAL_BOOTSTRAP: PASS"; else echo "CAP_FORMAL_BOOTSTRAP: FAIL"; fi |
| 47 | exit $fail |