interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core-mv / docs / campaigns / cand4-qualification / hygiene.sh

106 lines · 7087 bytes Raw Blame History
1#!/usr/bin/env bash
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# CAND-4 production hygiene (ACCEPTANCE-CAND4.md section 3, rows H1..H6). Shell + jq only.
18# No GPU use: the omega host program's ARGUS probe never starts the graphics processor
19# (omega tools/r16_prod_hygiene.sh step 4); the silicon programs are checked statically.
20# Usage: hygiene.sh INPUTS OUT_DIR
21# INPUTS ACCEPTANCE-CAND4.md (qualification) or a TRIAL inputs file with the same block
22# Writes OUT_DIR/hygiene-<sha256>.json (named by its content) and prints it. Exit 0 iff PASS.
23set -u
24HERE=$(cd "$(dirname "$0")" && pwd)
25INPUTS=${1:?INPUTS} OUT=${2:?OUT_DIR}
26. "$HERE/inputs.sh"
27load_inputs "$INPUTS" || exit 3
28mkdir -p "$OUT"; OUT=$(cd "$OUT" && pwd)
29W=$(mktemp -d "${TMPDIR:-/tmp}/cand4-hygiene.XXXXXX"); trap 'rm -rf "$W"' EXIT
30CLI=$(inp aien_cli_path) CPU=$(inp cpu_fault_path) EVD=$(inp build_evidence) OB=$(inp omega_build_dir)
31verify_digests || exit 3
32ROWS='[]'
33row() { ROWS=$(jq -c --arg r "$1" --arg c "$2" --arg v "$3" --argjson e "$4" '. + [{row:$r, check:$c, verdict:$v, evidence:$e}]' <<<"$ROWS"); }
34pv() { if [ "$1" = 1 ]; then echo PASS; else echo FAIL; fi; }
35
36# H1 / H1c: fault hook strings (the patterns of NEXT-PHASE-2 link_proof, plus the hook names)
37PAT='AIEN_FAULT_HOLD|fault hold|reconcile_panic|reconcile_error|forced start-up reconcile'
38strings -a "$CLI" >"$W/cli.str"; strings -a "$CPU" >"$W/cpu.str"
39n1=$(grep -Ec "$PAT" "$W/cli.str"); n1c=$(grep -Ec "$PAT" "$W/cpu.str")
40row H1 "production aien-cli: 0 lines matching /$PAT/" "$(pv $([ "$n1" = 0 ] && echo 1))" \
41 "$(jq -nc --argjson n "$n1" --arg s "$(grep -E "$PAT" "$W/cli.str" | head -3)" '{matching_lines:$n, first:$s}')"
42row H1c "positive control: cpu-fault binary carries the same patterns" "$(pv $([ "$n1c" -gt 0 ] && echo 1))" \
43 "$(jq -nc --argjson n "$n1c" '{matching_lines:$n}')"
44
45# H2 / H2c: no test feature on any rustc line of the production -vv release log
46L=$EVD/sc-rel-2.log
47if [ -f "$L" ]; then
48 f1=$(grep -c 'feature=\\\?"fault-hold\\\?"' "$L"); f2=$(grep -c 'feature=\\\?"dev-fallback\\\?"' "$L")
49 row H2 "production -vv build log: no feature fault-hold or dev-fallback" "$(pv $([ "$f1" = 0 ] && [ "$f2" = 0 ] && echo 1))" \
50 "$(jq -nc --arg l "$L" --arg sha "$(sha256sum "$L" | cut -d' ' -f1)" --argjson a "$f1" --argjson b "$f2" '{log:$l, sha256:$sha, fault_hold_lines:$a, dev_fallback_lines:$b}')"
51else
52 row H2 "production -vv build log present" FAIL "$(jq -nc --arg l "$L" '{missing:$l}')"
53fi
54CL=$(dirname "$CPU")/build.log
55if [ -f "$CL" ]; then
56 c1=$(grep -c 'feature=\\\?"fault-hold\\\?"' "$CL")
57 row H2c "positive control: the cpu-fault -vv log shows feature fault-hold" "$(pv $([ "$c1" -gt 0 ] && echo 1))" "$(jq -nc --argjson a "$c1" '{fault_hold_lines:$a}')"
58else
59 row H2c "positive control: cpu-fault build log present" FAIL "$(jq -nc --arg l "$CL" '{missing:$l}')"
60fi
61
62# H3: no omega test-build piece in aien-cli (stripped: strings) nor in librx_compose.a (nm)
63t1=$(grep -c 'AIEN_TEST_BUILD piece:' "$W/cli.str")
64LIB=$OB/librx_compose.a
65if [ -f "$LIB" ]; then
66 t2=$(nm "$LIB" 2>/dev/null | awk '{print $NF}' | grep -c '^aien_test_build_')
67 t3=$(strings -a "$LIB" | grep -c 'AIEN_TEST_BUILD piece:')
68 row H3 "no AIEN_TEST_BUILD piece in aien-cli or librx_compose.a" "$(pv $([ "$t1" = 0 ] && [ "$t2" = 0 ] && [ "$t3" = 0 ] && echo 1))" \
69 "$(jq -nc --argjson a "$t1" --argjson b "$t2" --argjson c "$t3" --arg s "$(sha256sum "$LIB" | cut -d' ' -f1)" '{aien_cli_marker_strings:$a, lib_test_symbols:$b, lib_marker_strings:$c, lib_sha256:$s}')"
70else
71 row H3 "librx_compose.a present in omega_build_dir" FAIL "$(jq -nc --arg l "$LIB" '{missing:$l}')"
72fi
73
74# H4 / H4c / H5: omega's own tools at the frozen omega commit, from a scratch copy
75OSRC=$(inp omega_src_dir); OC=$(inp omega_commit); AO=$(inp aienos_repo); PH=$(inp physics_dir)
76mkdir -p "$W/omega"
77git -C "$OSRC" archive "$OC" | tar -x -C "$W/omega" || { row H4 "omega source at omega_commit" FAIL '{"error":"git archive failed"}'; }
78if [ -f "$W/omega/tools/r16_prod_hygiene.sh" ]; then
79 (cd "$W/omega" && sh tools/r16_prod_hygiene.sh host "$OB/rx_r13_living_host") >"$W/h4a.out" 2>&1; a=$?
80 (cd "$W/omega" && R16_PROD_NO_RUN=1 sh tools/r16_prod_hygiene.sh silicon "$OB/rx_r13_living_silicon") >"$W/h4b.out" 2>&1; b=$?
81 row H4 "omega production programs: host (full, ARGUS probe) and silicon (static)" "$(pv $([ $a = 0 ] && [ $b = 0 ] && echo 1))" \
82 "$(jq -nc --argjson a $a --argjson b $b --arg x "$(tail -2 "$W/h4a.out")" --arg y "$(tail -2 "$W/h4b.out")" '{host_rc:$a, host:$x, silicon_rc:$b, silicon:$y}')"
83 (cd "$W/omega" && R16_PROD_NO_RUN=1 sh tools/r16_prod_hygiene.sh silicon "$OB/rx_r13_living_testbuild_silicon") >"$W/h4c.out" 2>&1; c=$?
84 row H4c "negative control: the test-build silicon program fails the same check" "$(pv $([ $c != 0 ] && grep -q 'PROD_HYGIENE=FAIL' "$W/h4c.out" && echo 1))" \
85 "$(jq -nc --argjson c $c --arg x "$(head -1 "$W/h4c.out")" '{rc:$c, first_line:$x}')"
86 wait_quiet "omega make (H5)"
87 ARGUS_REPO=$AO make -C "$W/omega" OUT_DIR="$W/out" PHYSICS_DIR="$PH" ARGUS_REPO="$AO" AIENOS_LOCK_REPO="$AO" \
88 test-prod-refuses-test-pieces >"$W/h5.out" 2>&1; d=$?
89 row H5 "make test-prod-refuses-test-pieces at omega_commit (scratch copy)" "$(pv $([ $d = 0 ] && echo 1))" \
90 "$(jq -nc --argjson d $d --arg x "$(grep -E 'R16 refuse' "$W/h5.out" | tail -12)" '{rc:$d, lines:$x}')"
91fi
92
93# H6: report only
94names=$(grep -Eo 'AIEN_[A-Z0-9_]*(TEST|STUB|FAULT|FALLBACK|DEV)[A-Z0-9_]*' "$W/cli.str" | sort -u | jq -R . | jq -sc .)
95row H6 "report only: AIEN_* names with TEST, STUB, FAULT, FALLBACK or DEV in aien-cli" REPORTED "$(jq -nc --argjson n "$names" '{names:$n}')"
96
97tmp=$(mktemp "$OUT/.hygiene.XXXXXX")
98jq -n --argjson rows "$ROWS" --arg kind "$(inp kind)" --arg cand "$(inp candidate_id)" --arg sc "$(inp sc_commit)" \
99 --arg oc "$OC" --arg cli "$(inp aien_cli_sha256)" --arg cpu "$(inp cpu_fault_sha256)" \
100 '{gate:"CAND4_HYGIENE", kind:$kind, candidate:$cand, sc_commit:$sc, omega_commit:$oc,
101 aien_cli_sha256:$cli, cpu_fault_sha256:$cpu, acceptance_spec:"ACCEPTANCE-CAND4.md section 3",
102 verdict:(if ($rows | map(select(.verdict != "PASS" and .verdict != "REPORTED")) | length) == 0 then "PASS" else "FAIL" end),
103 rows:$rows}' >"$tmp"
104h=$(sha256sum "$tmp" | cut -d' ' -f1); mv "$tmp" "$OUT/hygiene-$h.json"
105jq -r '"hygiene-'"$h"'.json verdict \(.verdict)", (.rows[] | " \(.verdict) \(.row) \(.check)")' "$OUT/hygiene-$h.json"
106[ "$(jq -r .verdict "$OUT/hygiene-$h.json")" = PASS ]