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 / research / atemporal / at0 / evaluator / gates / isolation.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 | # AT-0 evaluator isolation gate (charter section 3, gate AT0-G2 method; adapted |
| 18 | # from omega tests/physics0/isolation.sh). Compute objects of the candidate |
| 19 | # (engine, oracle) must reference no clock, randomness, environment, file, |
| 20 | # process, socket or thread symbol. Works on .o files and on linked executables |
| 21 | # (C or Rust) via nm static and dynamic tables; undefined and defined references both count. |
| 22 | # Limits: inline syscalls, raw timer reads (CNTVCT_EL0 / rdtsc) and symbols resolved at run time |
| 23 | # through dlsym-free tricks are NOT visible to a symbol scan (see ISOLATION_REPORT.md). |
| 24 | # sh gates/isolation.sh <object-or-binary>... |
| 25 | # Prints AT0_ISOLATION: PASS|FAIL and one line per hit. Exit 0 on PASS. |
| 26 | fail=0 |
| 27 | FORBIDDEN="clock_gettime clock_getres clock_nanosleep clock gettimeofday time timegm timelocal localtime localtime_r gmtime gmtime_r mktime strftime nanosleep sleep usleep rand rand_r srand random srandom drand48 lrand48 arc4random getrandom getentropy getenv secure_getenv setenv putenv fopen fopen64 freopen open open64 openat openat64 creat socket connect accept bind listen send recv sendto recvfrom getaddrinfo gethostbyname dlopen dlsym system popen fork vfork posix_spawn execv execve execvp execl pthread_create thrd_create clone syscall read write pread pwrite pread64 pwrite64 readv writev fread fwrite fgets fgetc getc getchar getline getdelim fscanf scanf mmap mmap64 ioctl" |
| 28 | for o in "$@"; do |
| 29 | [ -f "$o" ] || { echo "missing $o"; fail=1; continue; } |
| 30 | # static (-p) and dynamic (-D) tables; a stripped executable keeps only its dynamic imports |
| 31 | if ! nm -p "$o" >"$o.nm" 2>/dev/null && ! nm -D "$o" >"$o.nm" 2>/dev/null; then echo "FAIL: $o: nm cannot read symbols (not an ELF object?)"; fail=1; rm -f "$o.nm"; continue; fi |
| 32 | { nm -p "$o" 2>/dev/null; nm -D "$o" 2>/dev/null; } > "$o.nm" |
| 33 | # strip the version suffix, then normalise hardened-libc aliases so a fortified build cannot hide a call: |
| 34 | # __fread_chk -> fread, __open_2 -> open, __openat64_2 -> openat64 (Agent 5 finding, omega#358) |
| 35 | syms=$(awk 'NF>=2 {print $NF}' "$o.nm" | sed -E 's/@.*$//; s/^__([a-z0-9_]+)_chk$/\1/; s/^__([a-z0-9_]+)_2$/\1/') |
| 36 | for bad in $FORBIDDEN; do |
| 37 | if echo "$syms" | grep -qx "_\{0,1\}${bad}" ; then echo "FAIL: $o references $bad"; fail=1; fi |
| 38 | done |
| 39 | # Rust std time/random/env/fs/net/process/thread paths: legacy (_ZN3std4time..) and v0 (_RNv..3std4time..) mangling, |
| 40 | # plus the demangled spelling (nm -C), so a toolchain change in mangling cannot blind the gate |
| 41 | { nm -C -p "$o" 2>/dev/null; nm -C -D "$o" 2>/dev/null; } >> "$o.nm" |
| 42 | if grep -qE '3std4time|3std3env|3std2fs|3std3net|3std7process|3std6thread|3std2io5stdio|10SystemTime|7Instant|4rand[0-9A-Za-z_]*|getrandom|std::(time|env|fs|net|process|thread|io::stdio)|SystemTime|Instant::|rand::' "$o.nm"; then |
| 43 | echo "FAIL: $o references a Rust std time/env/fs/net/process/thread or rand path"; fail=1 |
| 44 | fi |
| 45 | rm -f "$o.nm" |
| 46 | done |
| 47 | if [ $fail = 0 ]; then echo "AT0_ISOLATION: PASS ($# objects clean)"; else echo "AT0_ISOLATION: FAIL"; fi |
| 48 | exit $fail |