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 / smollm2-qualification / inputs.sh

103 lines · 5666 bytes Raw Blame History
1# SPDX-License-Identifier: Apache-2.0
2# Copyright 2026 Drake Stapleton (AIEN / aien-dev)
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16# SMOLLM2-Q qualification (copied from cand4-qualification): shared input handling, sourced by run-smol2q.sh and hygiene.sh.
17# Reads the ">>> SMOLLM2-Q frozen inputs >>>" block of ACCEPTANCE-SMOLLM2-Q.md (or of a TRIAL
18# inputs file with the same block) and checks every pinned digest. Shell only.
19
20# load_inputs FILE: keep FILE; refuse a QUALIFICATION block with an UNFROZEN value,
21# and a block whose kind is neither QUALIFICATION nor TRIAL.
22load_inputs() {
23 INPUTS_FILE=$(cd "$(dirname "$1")" && pwd)/$(basename "$1")
24 INPUTS_BLOCK=$(sed -n '/^>>> SMOLLM2-Q frozen inputs >>>$/,/^<<< end of SMOLLM2-Q frozen inputs <<<$/p' "$INPUTS_FILE")
25 [ -n "$INPUTS_BLOCK" ] || { echo "inputs: no SMOLLM2-Q frozen inputs block in $1" >&2; return 1; }
26 case $(inp kind) in
27 QUALIFICATION)
28 if grep -q '= *UNFROZEN *$' <<<"$INPUTS_BLOCK"; then
29 echo "inputs: REFUSED, UNFROZEN values in a QUALIFICATION block: $(grep '= *UNFROZEN' <<<"$INPUTS_BLOCK" | cut -d' ' -f1 | paste -sd' ')" >&2
30 return 1
31 fi;;
32 TRIAL) ;;
33 *) echo "inputs: kind must be QUALIFICATION or TRIAL" >&2; return 1;;
34 esac
35}
36
37# inp KEY: the value of KEY (exact key; "a" does not match "a_b").
38inp() { sed -n "s/^$1 *= *//p" <<<"$INPUTS_BLOCK" | head -1 | sed 's/ *$//'; }
39
40# out_ok DIR: TRIAL output must say TRIAL and stay out of the evidence dir and the repo.
41out_ok() {
42 [ "$(inp kind)" = TRIAL ] || return 0
43 case $1 in
44 *TRIAL*) ;;
45 *) echo "inputs: TRIAL output dir must contain TRIAL in its path: $1" >&2; return 1;;
46 esac
47 case $1 in
48 "$HOME"/workspace/evidence-out*|*/docs/campaigns/*) echo "inputs: TRIAL output not allowed in $1" >&2; return 1;;
49 esac
50}
51
52DIGESTS='[]'
53# dg NAME PATH WANT: one pinned file; records the result; returns 1 on a mismatch.
54dg() {
55 local got=absent
56 [ -f "$2" ] && got=$(sha256sum "$2" | cut -d' ' -f1)
57 DIGESTS=$(jq -c --arg n "$1" --arg p "$2" --arg w "$3" --arg g "$got" '. + [{name:$n, path:$p, want:$w, got:$g, ok:($w == $g)}]' <<<"$DIGESTS")
58 [ "$got" = "$3" ] || { echo "digest MISMATCH $1: $2 is $got, frozen $3" >&2; return 1; }
59}
60
61# verify_digests: every pinned file and the source constants at sc_commit. Returns 1 on
62# any difference (the caller refuses to run).
63verify_digests() {
64 local bad=0 md ob src
65 DIGESTS='[]'
66 dg aien_cli "$(inp aien_cli_path)" "$(inp aien_cli_sha256)" || bad=1
67 dg cpu_fault "$(inp cpu_fault_path)" "$(inp cpu_fault_sha256)" || bad=1
68 ob=$(inp omega_build_dir)
69 dg librx_compose "$ob/librx_compose.a" "$(inp librx_compose_sha256)" || bad=1
70 dg libomega_gpu "$ob/libomega_gpu.a" "$(inp libomega_gpu_sha256)" || bad=1
71 dg rx_r13_living_host "$ob/rx_r13_living_host" "$(inp rx_r13_host_sha256)" || bad=1
72 dg rx_r13_living_silicon "$ob/rx_r13_living_silicon" "$(inp rx_r13_silicon_sha256)" || bad=1
73 dg rx_r13_living_testbuild_silicon "$ob/rx_r13_living_testbuild_silicon" "$(inp rx_r13_testbuild_sha256)" || bad=1
74 md=$(inp model_dir)
75 # every regular file of the snapshot is pinned by a "model_file = NAME SHA256" line, and the
76 # directory holds exactly the declared entries (model_dir_listing): nothing else the loader could read
77 local nmf=0 mf want
78 while read -r mf want; do
79 [ -n "$mf" ] || continue; nmf=$((nmf + 1))
80 dg "model/$mf" "$(readlink -f "$md/$mf")" "$want" || bad=1
81 done < <(sed -n 's/^model_file *= *//p' <<<"$INPUTS_BLOCK")
82 [ "$nmf" -ge 1 ] || { echo "inputs: no model_file lines" >&2; bad=1; }
83 [ "$(ls -A "$md" | LC_ALL=C sort | paste -sd,)" = "$(inp model_dir_listing)" ] \
84 || { echo "model_dir holds other entries than model_dir_listing: $(ls -A "$md" | paste -sd' ')" >&2; bad=1; }
85 # source constants at sc_commit (ACCEPTANCE-SMOLLM2-Q section 2): the frozen values are read from code
86 src=$(git -C "$(dirname "${BASH_SOURCE[0]}")" show "$(inp sc_commit):crates/aien-runtime/src/spine.rs" 2>/dev/null)
87 grep -q "COMPOSE_ATTEMPT_BUDGET: std::time::Duration = std::time::Duration::from_millis($(inp attempt_budget_ms | sed 's/\(...\)$/_\1/'));" <<<"$src" \
88 || { echo "source: COMPOSE_ATTEMPT_BUDGET at sc_commit is not $(inp attempt_budget_ms) ms" >&2; bad=1; }
89 grep -q "COMPOSE_SKILL_BUDGET: std::time::Duration = std::time::Duration::from_secs($(( $(inp skill_budget_ms) / 1000 )));" <<<"$src" \
90 || { echo "source: COMPOSE_SKILL_BUDGET at sc_commit is not $(inp skill_budget_ms) ms" >&2; bad=1; }
91 grep -q "COMPOSE_MAX_ATTEMPTS: u32 = $(inp max_attempts);" <<<"$src" \
92 || { echo "source: COMPOSE_MAX_ATTEMPTS at sc_commit is not $(inp max_attempts)" >&2; bad=1; }
93 [ "$(git -C "$(dirname "${BASH_SOURCE[0]}")" show "$(inp sc_commit):omega.lock" 2>/dev/null | tr -d '[:space:]')" = "$(inp omega_commit)" ] \
94 || { echo "source: omega.lock at sc_commit is not omega_commit" >&2; bad=1; }
95 return $bad
96}
97
98# wait_quiet WHAT: wait while another lane holds the Spark quiet flag (never interrupt it).
99wait_quiet() {
100 while [ -e "$HOME/workspace/.spark-quiet" ]; do
101 echo "waiting for the Spark quiet flag to clear before $1 ($(date -u +%T))" >&2; sleep 30
102 done
103}