Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/physics-mv/blob/main/tests/run_forge_form_gates.sh # physics-mv FORGE: request-bound machine realization, providers and verification for AienOS. Host, simulated and GB10 hardware paths have separate evidence. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `physics-mv / tests / run_forge_form_gates.sh` 122 lines ยท 5925 bytes Raw Blame History 1 #!/bin/bash 2 # tests/run_forge_form_gates.sh -- FORM0 gates: FORGE REALIZATION FORM V1 3 # (substrate-neutral physical-form realization IR, ADR 0034 PROPOSED; extends 4 # ARCH-0018 / ARCH-0019). Host-only: no hardware, no driver, no GPU lock. 5 # Every result is SIMULATED_DEVELOPMENT. 6 # 7 # tests/run_forge_form_gates.sh build, run every check, verify the 8 # committed receipt is reproduced byte for byte 9 # tests/run_forge_form_gates.sh --regen also (re)write evidence/FORM0/.json 10 # 11 # Exit code 0 only when every gate passes. 12 set -uo pipefail 13 14 SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P) 15 REPO_ROOT=$(cd "$SCRIPT_DIR/.." && pwd -P) 16 cd "$REPO_ROOT" || exit 1 17 18 BUILD_DIR="$REPO_ROOT/build" 19 BIN="$BUILD_DIR/test_forge_form" 20 RECEIPT_DIR="evidence/FORM0" 21 SRC_C="forge/form/forge_form.c" 22 SRC_H="forge/form/forge_form.h" 23 TEST_C="tests/test_forge_form.c" 24 SRCS="forge/v2/forge_substrate_v2.c forge/analog-sim/forge_analog_sim.c $SRC_C sha256_clean.c" 25 INC="-I./forge/v2 -I./forge/analog-sim -I./forge/form" 26 FAILS=0 27 PASSES=0 28 29 gate() { # name, status(0 = pass) 30 if [ "$2" -eq 0 ]; then echo "PASS $1"; PASSES=$((PASSES + 1)); 31 else echo "FAIL $1"; FAILS=$((FAILS + 1)); fi 32 } 33 34 echo "=== FORM0 realization-form gates (host-only, SIMULATED_DEVELOPMENT) ===" 35 mkdir -p "$BUILD_DIR" 36 37 # shellcheck disable=SC2086 38 gcc -O2 -Wall -Wextra -Werror -std=c11 $INC $SRCS "$TEST_C" -o "$BIN" 39 gate "build_gcc_O2_Wall_Wextra_Werror_std_c11" $? 40 if [ ! -x "$BIN" ]; then 41 echo "RESULT gates: $PASSES passed, $FAILS failed (build failed)" 42 exit 1 43 fi 44 45 "$BIN" | grep -E '^(FAIL|INFO|RESULT)' 46 "$BIN" > /dev/null 47 gate "form0_checks_all_pass" $? 48 49 # Same checks under the undefined-behaviour sanitizer (any UB aborts the run). 50 # shellcheck disable=SC2086 51 gcc -O1 -g -Wall -Wextra -Werror -std=c11 -fsanitize=undefined -fno-sanitize-recover=all \ 52 $INC $SRCS "$TEST_C" -o "$BIN-ubsan" \ 53 && "$BIN-ubsan" > /dev/null 54 gate "form0_checks_pass_under_ubsan" $? 55 56 # Deterministic receipt, named by the SHA-256 of its bytes. 57 "$BIN" --receipt > "$BUILD_DIR/form0-receipt.json" 58 gate "receipt_emitted_by_code" $? 59 SUM=$(sha256sum "$BUILD_DIR/form0-receipt.json" | cut -d' ' -f1) 60 if [ "${1:-}" = "--regen" ]; then 61 mkdir -p "$RECEIPT_DIR" 62 rm -f "$RECEIPT_DIR"/*.json 63 cp "$BUILD_DIR/form0-receipt.json" "$RECEIPT_DIR/$SUM.json" 64 gate "receipt_regenerated" $? 65 fi 66 "$BIN" --receipt | cmp -s - "$BUILD_DIR/form0-receipt.json" 67 gate "receipt_deterministic_across_runs" $? 68 COMMITTED=$(ls "$RECEIPT_DIR"/*.json 2>/dev/null | wc -l) 69 [ "$COMMITTED" -eq 1 ] && [ -f "$RECEIPT_DIR/$SUM.json" ] && cmp -s "$RECEIPT_DIR/$SUM.json" "$BUILD_DIR/form0-receipt.json" 70 gate "committed_receipt_reproduced_digest_named" $? 71 72 # Provenance: the receipt says SIMULATED_DEVELOPMENT and never claims a physical result. 73 grep -q '"provenance_class": "SIMULATED_DEVELOPMENT"' "$BUILD_DIR/form0-receipt.json" \ 74 && grep -q '"status": "PASS"' "$BUILD_DIR/form0-receipt.json" \ 75 && ! grep -qiE 'physical_result|measured_on_device|PROVENANCE_PHYSICAL' "$BUILD_DIR/form0-receipt.json" 76 gate "receipt_simulated_development_no_physical_claim" $? 77 CASES=$(grep -c '"name": ' "$BUILD_DIR/form0-receipt.json") 78 SIMCASES=$(grep -c '"provenance_class": "SIMULATED_DEVELOPMENT"}' "$BUILD_DIR/form0-receipt.json") 79 [ "$CASES" -gt 0 ] && [ "$CASES" -eq "$SIMCASES" ] 80 gate "every_receipt_case_simulated_development" $? 81 82 # The success criterion is in the receipt: one contract, two realizations, 83 # same contract digest, different realization identities. 84 grep -q '"proof_two_realizations_same_contract": "PASS"' "$BUILD_DIR/form0-receipt.json" 85 gate "receipt_proof_two_realizations_same_contract" $? 86 87 # The provider source never names the PHYSICAL provenance (except to refuse it). 88 [ "$(grep -c 'PROVENANCE_PHYSICAL' "$SRC_C" "$SRC_H" | awk -F: '{s+=$2} END {print s}')" -eq 0 ] 89 gate "provider_source_cannot_emit_physical" $? 90 91 # The form object itself carries no substrate, vendor, device or calibration coordinate. 92 ! awk '/^typedef struct \{/{b=1; buf=""} b{buf=buf $0 "\n"} /\} ForgeRealizationForm;/{print buf; b=0}' "$SRC_H" \ 93 | grep -qiE 'substrate|vendor|device|calibrat|clock|temperature|address|bus|machine' 94 gate "form_struct_has_no_realization_coordinates" $? 95 96 # Vendor-neutral: no vendor or product word in any identifier of the new files. 97 ! grep -nE '\b[A-Za-z_]*(NVIDIA|Nvidia|nvidia|GB10|gb10|BLACKWELL|Blackwell|blackwell|CUDA|cuda|NVRM|nvrm)[A-Za-z_0-9]*\b' \ 98 "$SRC_C" "$SRC_H" "$TEST_C" | grep -vE '^\S+:[0-9]+:\s*(/\*|\*)' > /dev/null 99 gate "no_vendor_names_in_identifiers" $? 100 101 # No quantum vocabulary in classical semantics. 102 ! grep -niE 'quantum|superposition|wavefunction|collapse|entangle' "$SRC_C" "$SRC_H" > /dev/null 103 gate "no_quantum_metaphors_in_provider" $? 104 105 # No hardware, driver, heap or I/O in the provider. 106 ! grep -nE '#include\s*[<"](nvrm|nv|cuda|sys/ioctl|sys/mman|fcntl|stdio)' "$SRC_C" "$SRC_H" > /dev/null \ 107 && ! grep -nE '\b(malloc|calloc|realloc|free|ioctl|mmap|open|printf|fopen)\s*\(' "$SRC_C" > /dev/null 108 gate "no_hardware_access_no_heap_no_io_in_provider" $? 109 110 # R16 loop-inventory heuristics (same patterns as the V2 / AR2 gates). 111 ! grep -nE 'while\s*\(\s*(1|true)\s*\)|for\s*\(\s*;\s*;\s*\)' "$SRC_C" "$TEST_C" > /dev/null \ 112 && ! grep -niE '(^|[^a-z])(u?sleep|nanosleep|msleep|poll|recv|heartbeat|tick|dispatch|schedule|scheduler|orchestrate|orchestrator|turns?|pulse|yield|epoll|run_until_complete|max_steps|max_turns)([^a-z]|$)' \ 113 "$SRC_C" "$SRC_H" "$TEST_C" > /dev/null 114 gate "r16_loop_inventory_heuristics_clean" $? 115 116 # FORGE V2 and AR2 files are untouched by this gate: their committed receipts 117 # and golden vectors must still reproduce (AR2 script also runs the AR1 gates). 118 bash tests/run_forge_analog_sim_gates.sh > "$BUILD_DIR/ar2-gates-from-form0.log" 2>&1 119 gate "ar1_ar2_gates_still_pass" $? 120 121 echo "RESULT gates: $PASSES passed, $FAILS failed" 122 [ "$FAILS" -eq 0 ]