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 / tools / r16_prod_hygiene.sh

85 lines · 4458 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# Lane 32: production program hygiene (docs/r16-production-entry-point.md).
18#
19# Usage: tools/r16_prod_hygiene.sh host|silicon <production-r13-binary>
20# R16_PROD_NO_RUN=1: static checks only (link map and strings); the ARGUS
21# probe is not run (used by tools/r16_authpath.sh check 2b).
22#
23# Checks, stopping at the first failure:
24# 1. link map: no test-build piece. No aien_test_build_* marker (Fabric
25# loopback transport, HMAC stand-in, in-process dispatcher, Fabric living
26# phase, rx_compose test hooks), no Fabric symbol (fab_*), no Fabric
27# living phase (fl_*) and no composition test fixture (fx_*).
28# 2. strings: no fixed test key (fl-key-*) and no test-build marker text.
29# 3. ARGUS linked: the runtime producer (rx_argus_*), the authority observer
30# wrap (__wrap_aienos_cap_start) and the pinned argus_core/argus_detect.
31# 4. host run (unless R16_PROD_NO_RUN=1): `<binary> --argus-probe` starts one
32# authority through the wrapped aienos_cap_start and must report
33# ARGUS_OBSERVING=PASS; with RX_ARGUS_AUTO=0 (ARGUS not started) the same
34# binary must refuse to run (fail closed). The probe runs no living
35# episode and never starts the graphics processor.
36set -u
37mode=${1:-}; bin=${2:-}
38if [ $# -ne 2 ] || { [ "$mode" != host ] && [ "$mode" != silicon ]; }; then
39 echo "usage: $0 host|silicon <production-r13-binary>" >&2
40 exit 2
41fi
42fail() { echo "R16 prod FAIL: $*"; echo "R16 prod: PROD_HYGIENE=FAIL mode=$mode"; exit 1; }
43[ -x "$bin" ] || fail "binary missing: $bin"
44n=$(basename "$bin")
45tmp=$(mktemp -d) || exit 2
46trap 'rm -rf "$tmp"' EXIT
47
48# 1. link map ------------------------------------------------------------------
49nm "$bin" > "$tmp/nm" 2>&1 || fail "nm failed on $bin"
50awk '{print $NF}' "$tmp/nm" > "$tmp/syms"
51grep -qx 'main' "$tmp/syms" || fail "$n has no symbol table (stripped?); cannot check its link map"
52# fab_om_* are pure-OM-2 unit helpers compiled into src/omega_om_units.c (not src/fabric/ test-build pieces).
53if grep -E '^(aien_test_build_|fab_|fl_|fx_)' "$tmp/syms" | grep -vE '^fab_om_' > "$tmp/bad-syms"; then
54 fail "$n links test-build pieces: $(head -5 "$tmp/bad-syms" | tr '\n' ' ')"
55fi
56
57# 2. strings -------------------------------------------------------------------
58if strings -a "$bin" | grep -E 'fl-key-|AIEN_TEST_BUILD piece:' > "$tmp/bad-strings"; then
59 fail "$n embeds test keys or test-build pieces: $(head -3 "$tmp/bad-strings" | tr '\n' ' ')"
60fi
61
62# 3. ARGUS linked ----------------------------------------------------------------
63for s in rx_argus_active rx_argus_shutdown rx_argus_stats __wrap_aienos_cap_start \
64 argus_core_init argus_core_ingest argus_detect_run; do
65 grep -qx "$s" "$tmp/syms" || fail "$n does not link ARGUS ($s missing)"
66done
67printf 'link map clean, ARGUS linked (rx_argus, authority observer wrap, argus_core, argus_detect)' > "$tmp/summary"
68
69# 4. host run of the ARGUS probe ---------------------------------------------------
70if [ "${R16_PROD_NO_RUN:-0}" != 1 ]; then
71 env -u RX_ARGUS_AUTO -u RX_ARGUS_CONSUMER -u RX_ARGUS_STREAM -u RX_ARGUS_SUMMARY \
72 "$bin" --argus-probe > "$tmp/probe.out" 2>&1
73 rc=$?
74 sed 's/^/R16 prod /' "$tmp/probe.out"
75 [ $rc -eq 0 ] && grep -q '^R13 ARGUS probe: ARGUS_OBSERVING=PASS$' "$tmp/probe.out" \
76 || fail "ARGUS probe did not observe (exit $rc)"
77 RX_ARGUS_AUTO=0 "$bin" --argus-probe > "$tmp/probe-off.out" 2>&1
78 rc=$?
79 if [ $rc -eq 0 ] || grep -q 'ARGUS_OBSERVING=PASS' "$tmp/probe-off.out"; then
80 fail "with ARGUS not started the program still ran (exit $rc): it must refuse to run unobserved"
81 fi
82 printf '; ARGUS probe observing; refuses to run unobserved' >> "$tmp/summary"
83fi
84echo "R16 prod: $(cat "$tmp/summary")"
85echo "R16 prod: PROD_HYGIENE=PASS mode=$mode binary=$n"