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 / at1 / oracle / isolation.sh

79 lines · 4445 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-1 oracle compute crate (src/at1/), 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# Portable to macOS (BSD nm prefixes C symbols with an underscore, so anchored names allow
30# an optional leading underscore; Mach-O mangled std paths keep the 3std4time substring).
31# Exit 0 PASS, 1 FAIL. Prints every offending line.
32set -u
33cd "$(dirname "$0")"
34FLAGS="--edition 2021 -C opt-level=2 -C codegen-units=1 -C debuginfo=0 -C panic=abort"
35fail=0
36
37echo "== source rule (src/at1/)"
38if grep -n -E 'std::(time|fs|process|thread|net|env|io::std(in|out|err))|SystemTime|Instant::|getrandom|rand::|libc::|extern "C"' src/at1/*.rs; then
39 echo "FAIL: forbidden facility named in compute code"; fail=1
40else
41 echo "ok: no clock, file, process, thread, network, environment or random facility named"
42fi
43
44echo "== object rule (nm -u on the compute rlib)"
45./build.sh lib >/dev/null || { echo "FAIL: compute crate did not build alone"; exit 1; }
46rm -rf target/iso && mkdir -p target/iso && (cd target/iso && ar x ../libat1.rlib) || { echo "FAIL: cannot unpack rlib"; exit 1; }
47objs=$(ls target/iso/*.o 2>/dev/null)
48[ -n "$objs" ] || { echo "FAIL: no objects in rlib"; exit 1; }
49libc_names='clock_gettime|gettimeofday|^_?time$|nanosleep|getrandom|/dev/urandom|pthread_create|socket|connect|fopen|open64|openat|^_?read$|^_?write$|pread64|pwrite64|fork|execve|system|getenv|mach_absolute_time|arc4random'
50std_paths='3std4time|3std2fs|3std7process|3std6thread|3std3net|3std3env|3std2io5stdio|6random'
51banned="$libc_names|$std_paths"
52object_rule() {
53 nm -u "$@" 2>/dev/null | awk '{print $NF}' | sort -u | grep -E "$banned"
54}
55if object_rule $objs; then
56 echo "FAIL: banned undefined symbol in compute objects"; fail=1
57else
58 echo "ok: no clock, random, thread, socket, file, process or environment symbol referenced (libc names and mangled std paths)"
59fi
60
61echo "== negative control: a copy that reads the clock must be caught"
62rm -rf target/mutant && mkdir -p target/mutant && cp -r src/at1 target/mutant/at1
63printf '\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/at1/mod.rs
64if grep -q -E 'std::(time|fs|process|thread|net|env)' target/mutant/at1/*.rs; then
65 echo "ok: mutant caught by the source rule"
66else
67 echo "FAIL: mutant not caught by the source rule"; fail=1
68fi
69# Agent 5 finding D5: the object rule must catch the std::time mutant on its own.
70if rustc $FLAGS --crate-type lib --crate-name at1_mutant target/mutant/at1/mod.rs -o target/mutant/libat1_mutant.rlib 2>/dev/null \
71 && rm -rf target/mutant/iso && mkdir -p target/mutant/iso && (cd target/mutant/iso && ar x ../libat1_mutant.rlib) \
72 && object_rule target/mutant/iso/*.o >/dev/null; then
73 echo "ok: mutant caught by the object rule (nm -u, mangled std path)"
74else
75 echo "FAIL: mutant not caught by the object rule"; fail=1
76fi
77
78[ $fail -eq 0 ] && echo "ISOLATION PASS" || echo "ISOLATION FAIL"
79exit $fail