omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / tests / r15_g15_diag_test.sh
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # G15 diagnostic in the reducer (tools/r15_reduce.c, m10_gpu_residency.worst_process_diagnostic). |
| 18 | # Uses the real CAND-1 window-2 trial-SEQ-06 raw file (16348 of 19253 samples live), |
| 19 | # plus copies whose residency record is extended with sampler diag fields. |
| 20 | # Checks: the verdict is untouched (G15 FAIL, value 0.849114424) in every case; old |
| 21 | # evidence says UNMEASURED and infers nothing; a long not-live run is reported as |
| 22 | # seat_stopped_long_run; scattered losses with a late sampler are reported as such. |
| 23 | # Needs build/r15_reduce (make build/r15_reduce). |
| 24 | cd "$(dirname "$0")/.." || exit 1 |
| 25 | RED=${R15_REDUCE:-build/r15_reduce}; SRC=evidence/CAND1-WINDOW2-20261005T1259Z/R15-silicon/raw/trial-SEQ-06.jsonl |
| 26 | [ -x "$RED" ] && [ -f "$SRC" ] || { echo "need $RED and $SRC"; exit 2; } |
| 27 | W=$(mktemp -d) || exit 1; trap 'rm -rf "$W"' EXIT; fail=0 |
| 28 | run() { # name diag-json-or-empty expected-class-text expected-extra-text |
| 29 | mkdir "$W/$1" |
| 30 | if [ -n "$2" ]; then sed "s|\"claims_max\":1}}|\"claims_max\":1,\"diag\":$2}}|" "$SRC" > "$W/$1/trial-SEQ-06.jsonl" |
| 31 | else cp "$SRC" "$W/$1/trial-SEQ-06.jsonl"; fi |
| 32 | ( cd "$W/$1" && sha256sum trial-SEQ-06.jsonl > SHA256SUMS ) |
| 33 | "$RED" "$W/$1" "$W/$1/s.json" >/dev/null 2>&1 |
| 34 | s=$(tr -d '\n' < "$W/$1/s.json") |
| 35 | if printf '%s' "$s" | grep -Fq "$3" && printf '%s' "$s" | grep -Fq "$4" \ |
| 36 | && printf '%s' "$s" | grep -Fq '"id":"G15","criterion":"GPU residency","threshold":">= 99% of samples live","value":0.849114424,"outcome":"FAIL"'; then |
| 37 | echo "[+] $1" |
| 38 | else echo "[-] $1: $(printf '%s' "$s" | grep -o '"worst_process_diagnostic":{[^}]*}')"; fail=$((fail + 1)); fi |
| 39 | } |
| 40 | run old_evidence "" '"class":"UNMEASURED"' '"lost_samples":2905' |
| 41 | run seat_stopped '{"late_2ms":0,"late_10ms":0,"max_gap_ns":1100000,"dead_runs":1,"dead_longest":2905,"dead_at_end":2905,"t_first":1000,"t_last":20000000000,"first_dead_t":17000001000,"last_live_t":16999000000,"stale_max_ns":3000000000}' \ |
| 42 | '"class":"seat_stopped_long_run"' '"sampler_late_observed":false' |
| 43 | run scattered_late_sampler '{"late_2ms":400,"late_10ms":60,"max_gap_ns":80000000,"dead_runs":2905,"dead_longest":1,"dead_at_end":0,"t_first":1000,"t_last":20000000000,"first_dead_t":5000000,"last_live_t":19999000000,"stale_max_ns":2000000}' \ |
| 44 | '"class":"scattered_not_live"' '"sampler_late_observed":true' |
| 45 | # xid-scan: a GPU fault must be reported, none must read as none, and an unreadable |
| 46 | # log must never read as none (window 2's dmesg-based count did exactly that). |
| 47 | T=tools/r15_machine_state.sh |
| 48 | xcheck() { # name expected-exit expected-text |
| 49 | out=$(R15_KLOG_FILE="$W/$1" "$T" xid-scan 0 1 2>&1); rc=$? |
| 50 | if [ "$rc" = "$2" ] && printf '%s\n' "$out" | grep -Fq -- "$3"; then echo "[+] xid-scan $1" |
| 51 | else echo "[-] xid-scan $1: exit $rc: $out"; fail=$((fail + 1)); fi |
| 52 | } |
| 53 | printf '%s\n' '2026-10-05T08:08:16-05:00 spark kernel: NVRM: Xid (PCI:000f:01:00): 109, pid=2050644, name=rx_r15_perf_sil, channel 0x0000000a, errorString CTX SWITCH TIMEOUT, Info 0x3c002' \ |
| 54 | '2026-10-05T08:08:17-05:00 spark kernel: audit: unrelated' > "$W/with_xid" |
| 55 | : > "$W/none" |
| 56 | xcheck with_xid 0 "xid lines: 1" |
| 57 | xcheck none 0 "xid lines: 0" |
| 58 | xcheck missing_file 4 "XID_LOG_UNREADABLE" |
| 59 | # No journal access: journalctl prints "-- No entries --" and exits 0. The empty |
| 60 | # boot-log probe must turn that into UNREADABLE, while a readable boot log with an |
| 61 | # empty window still reads as none. |
| 62 | printf '%s\n' '-- No entries --' > "$W/no_entries" |
| 63 | printf '%s\n' 'Linux version 7.0.0' > "$W/probe_ok" |
| 64 | : > "$W/probe_empty" |
| 65 | pcheck() { # name probe expected-exit expected-text |
| 66 | out=$(R15_KLOG_FILE="$W/$1" R15_KLOG_PROBE_FILE="$W/$2" "$T" xid-scan 0 1 2>&1); rc=$? |
| 67 | if [ "$rc" = "$3" ] && printf '%s\n' "$out" | grep -Fq -- "$4"; then echo "[+] xid-scan $1 probe=$2" |
| 68 | else echo "[-] xid-scan $1 probe=$2: exit $rc: $out"; fail=$((fail + 1)); fi |
| 69 | } |
| 70 | pcheck no_entries probe_empty 4 "XID_LOG_UNREADABLE" |
| 71 | pcheck no_entries probe_missing 4 "XID_LOG_UNREADABLE" |
| 72 | pcheck no_entries probe_ok 0 "xid lines: 0" |
| 73 | pcheck with_xid probe_ok 0 "xid lines: 1" |
| 74 | echo "failures $fail"; [ "$fail" = 0 ] |