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
aien-sovereign-core-mv / docs / campaigns / cand4-qualification / inputs.sh
| 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 | # CAND-4 qualification: shared input handling, sourced by run-cand4.sh and hygiene.sh. |
| 17 | # Reads the ">>> CAND-4 frozen inputs >>>" block of ACCEPTANCE-CAND4.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. |
| 22 | load_inputs() { |
| 23 | INPUTS_FILE=$(cd "$(dirname "$1")" && pwd)/$(basename "$1") |
| 24 | INPUTS_BLOCK=$(sed -n '/^>>> CAND-4 frozen inputs >>>$/,/^<<< end of CAND-4 frozen inputs <<<$/p' "$INPUTS_FILE") |
| 25 | [ -n "$INPUTS_BLOCK" ] || { echo "inputs: no CAND-4 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"). |
| 38 | inp() { 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. |
| 41 | out_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 | |
| 52 | DIGESTS='[]' |
| 53 | # dg NAME PATH WANT: one pinned file; records the result; returns 1 on a mismatch. |
| 54 | dg() { |
| 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). |
| 63 | verify_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 | dg model.safetensors "$(readlink -f "$md/model.safetensors")" "$(inp model_safetensors)" || bad=1 |
| 76 | dg config.json "$(readlink -f "$md/config.json")" "$(inp model_config)" || bad=1 |
| 77 | dg generation_config.json "$(readlink -f "$md/generation_config.json")" "$(inp model_generation_config)" || bad=1 |
| 78 | dg tokenizer.json "$(readlink -f "$md/tokenizer.json")" "$(inp model_tokenizer)" || bad=1 |
| 79 | dg tokenizer_config.json "$(readlink -f "$md/tokenizer_config.json")" "$(inp model_tokenizer_config)" || bad=1 |
| 80 | dg special_tokens_map.json "$(readlink -f "$md/special_tokens_map.json")" "$(inp model_special_tokens)" || bad=1 |
| 81 | dg chat_template.jinja "$(readlink -f "$md/chat_template.jinja")" "$(inp model_chat_template)" || bad=1 |
| 82 | # the snapshot holds exactly these seven files (nothing else the loader could read) |
| 83 | [ "$(ls -A "$md" | LC_ALL=C sort | paste -sd,)" = "chat_template.jinja,config.json,generation_config.json,model.safetensors,special_tokens_map.json,tokenizer.json,tokenizer_config.json" ] \ |
| 84 | || { echo "model_dir holds other files: $(ls -A "$md" | paste -sd' ')" >&2; bad=1; } |
| 85 | # source constants at sc_commit (ACCEPTANCE-CAND4 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). |
| 99 | wait_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 | } |