interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / research / atemporal / at0 / oracle / isolation.sh

77 lines · 4228 bytes Raw Blame History
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# Symbol-isolation gate for the AT-0 oracle compute crate (src/at0/), Rust adaptation of the
18# charter's nm gate.
19# 1. Source rule: no compute file names a std::time, std::fs, std::process, std::thread,
20# std::net, std::env, random or clock facility.
21# 2. Object rule: the compute crate compiled alone (rlib) has no undefined reference to a
22# clock, file, process, thread, network, environment or random symbol (nm -u over its
23# objects). Two symbol families are banned: libc entry points (the extern "C" route) and
24# mangled Rust std paths (the std route: a std::time call leaves no libc symbol in the
25# rlib, only a mangled std path; both the v0 form _RNv..NtCs<hash>_3std4time.. and the
26# legacy form _ZN3std4time.. contain the substring 3std4time).
27# 3. Negative control: a copy of the crate with a hidden std::time read must be caught by the
28# source rule AND by the object rule on its own.
29# Exit 0 PASS, 1 FAIL. Prints every offending line.
30set -u
31cd "$(dirname "$0")"
32FLAGS="--edition 2021 -C opt-level=2 -C codegen-units=1 -C debuginfo=0 -C panic=abort"
33fail=0
34
35echo "== source rule (src/at0/)"
36if grep -n -E 'std::(time|fs|process|thread|net|env|io::std(in|out|err))|SystemTime|Instant::|getrandom|rand::|libc::|extern "C"' src/at0/*.rs; then
37 echo "FAIL: forbidden facility named in compute code"; fail=1
38else
39 echo "ok: no clock, file, process, thread, network, environment or random facility named"
40fi
41
42echo "== object rule (nm -u on the compute rlib)"
43./build.sh lib >/dev/null || { echo "FAIL: compute crate did not build alone"; exit 1; }
44rm -rf target/iso && mkdir -p target/iso && (cd target/iso && ar x ../libat0.rlib) || { echo "FAIL: cannot unpack rlib"; exit 1; }
45objs=$(ls target/iso/*.o 2>/dev/null)
46[ -n "$objs" ] || { echo "FAIL: no objects in rlib"; exit 1; }
47libc_names='clock_gettime|gettimeofday|^time$|nanosleep|getrandom|/dev/urandom|pthread_create|socket|connect|fopen|open64|openat|^read$|^write$|pread64|pwrite64|fork|execve|system|getenv'
48std_paths='3std4time|3std2fs|3std7process|3std6thread|3std3net|3std3env|3std2io5stdio|6random'
49banned="$libc_names|$std_paths"
50object_rule() {
51 nm -u "$@" 2>/dev/null | awk '{print $NF}' | sort -u | grep -E "$banned"
52}
53if object_rule $objs; then
54 echo "FAIL: banned undefined symbol in compute objects"; fail=1
55else
56 echo "ok: no clock, random, thread, socket, file, process or environment symbol referenced (libc names and mangled std paths)"
57fi
58
59echo "== negative control: a copy that reads the clock must be caught"
60rm -rf target/mutant && mkdir -p target/mutant && cp -r src/at0 target/mutant/at0
61printf '\npub fn hidden_clock() -> u64 { std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_secs()).unwrap_or(0) }\n' >> target/mutant/at0/mod.rs
62if grep -q -E 'std::(time|fs|process|thread|net|env)' target/mutant/at0/*.rs; then
63 echo "ok: mutant caught by the source rule"
64else
65 echo "FAIL: mutant not caught by the source rule"; fail=1
66fi
67# Agent 5 finding D5: the object rule must catch the std::time mutant on its own.
68if rustc $FLAGS --crate-type lib --crate-name at0_mutant target/mutant/at0/mod.rs -o target/mutant/libat0_mutant.rlib 2>/dev/null \
69 && rm -rf target/mutant/iso && mkdir -p target/mutant/iso && (cd target/mutant/iso && ar x ../libat0_mutant.rlib) \
70 && object_rule target/mutant/iso/*.o >/dev/null; then
71 echo "ok: mutant caught by the object rule (nm -u, mangled std path)"
72else
73 echo "FAIL: mutant not caught by the object rule"; fail=1
74fi
75
76[ $fail -eq 0 ] && echo "ISOLATION PASS" || echo "ISOLATION FAIL"
77exit $fail