Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/scripts/test-native-identity.sh # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / scripts / test-native-identity.sh` 111 lines ยท 4766 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 # Native identity checks in the build scripts of aien-omega-compose and aien-omega-gpu. 18 # Runs without omega: every case below must be decided by build.rs before any make. 19 # - a stub together with AIEN_REQUIRE_NATIVE_LIBS=1 is refused 20 # - AIEN_REQUIRE_NATIVE_LIBS=1 with no library source is refused 21 # - a prebuilt archive with no expected sha256, a wrong one, or a truncated archive is refused 22 # - a prebuilt archive that misses one ABI function is refused 23 # - an omega checkout at a commit other than omega.lock is refused 24 # - a correct prebuilt archive builds, and its identity says "prebuilt" (never qualifies) 25 # Exit 0 when every case behaves, 1 otherwise. 26 set -euo pipefail 27 ROOT=$(cd "$(dirname "$0")/.." && pwd) 28 WORK=$(mktemp -d) 29 trap 'rm -rf "$WORK"' EXIT 30 export CARGO_TARGET_DIR="${AIEN_IDENTITY_TARGET_DIR:-$ROOT/target/native-identity}" 31 for v in $(env | sed -n 's/^\(AIEN_[A-Z0-9_]*\)=.*/\1/p'); do unset "$v"; done 32 33 fails=0 34 pass() { echo "ok $1"; } 35 fail() { echo "FAIL $1"; fails=$((fails + 1)); } 36 37 # expect_refused [VAR=value ...] 38 expect_refused() { 39 local crate=$1 name=$2 pat=$3 40 shift 3 41 local log="$WORK/log" 42 if env "$@" cargo check -q -p "$crate" >"$log" 2>&1; then 43 fail "$crate: $name (build was accepted)" 44 elif grep -qF -- "$pat" "$log"; then 45 pass "$crate: $name" 46 else 47 fail "$crate: $name (refused, but not with '$pat')" 48 tail -5 "$log" 49 fi 50 } 51 52 # fake_archive [function to leave out] 53 fake_archive() { 54 local src="$WORK/fake-$$-$RANDOM.c" 55 sed -n 's/^fn \([A-Za-z0-9_]*\) .*/\1/p' "$1" | { grep -vx "${3:-}" || true; } | 56 sed 's/.*/int &(void) { return 0; }/' >"$src" 57 cc -c -o "$src.o" "$src" 58 rm -f "$2" 59 ar rcs "$2" "$src.o" 60 } 61 62 # A git checkout at a commit that is not omega.lock. 63 WRONG="$WORK/wrong-omega" 64 git init -q "$WRONG" 65 git -C "$WRONG" -c user.name=t -c user.email=t@t commit -q --allow-empty -m wrong 66 67 check_crate() { 68 local crate=$1 manifest=$2 libvar=$3 dirvar=$4 drop=$5 69 local good="$WORK/$crate-good.a" short="$WORK/$crate-short.a" miss="$WORK/$crate-miss.a" 70 fake_archive "$manifest" "$good" 71 fake_archive "$manifest" "$miss" "$drop" 72 local sha miss_sha 73 sha=$(sha256sum "$good" | cut -d' ' -f1) 74 miss_sha=$(sha256sum "$miss" | cut -d' ' -f1) 75 head -c 100 "$good" >"$short" 76 77 expect_refused "$crate" "stub with required native" "contradict each other" \ 78 AIEN_FORCE_CPU_STUB=1 AIEN_REQUIRE_NATIVE_LIBS=1 79 expect_refused "$crate" "required native with no library" "AIEN_REQUIRE_NATIVE_LIBS=1 but" \ 80 AIEN_REQUIRE_NATIVE_LIBS=1 81 expect_refused "$crate" "prebuilt with no sha256" "no expected digest" \ 82 "$libvar=$good" 83 expect_refused "$crate" "prebuilt with a wrong sha256" "expects" \ 84 "$libvar=$good" "${libvar}_SHA256=$(printf '0%.0s' {1..64})" 85 expect_refused "$crate" "truncated prebuilt" "truncated or corrupted" \ 86 "$libvar=$short" "${libvar}_SHA256=$sha" 87 expect_refused "$crate" "prebuilt missing $drop" "does not define" \ 88 "$libvar=$miss" "${libvar}_SHA256=$miss_sha" 89 expect_refused "$crate" "omega checkout at the wrong commit" "is at '" \ 90 "$dirvar=$WRONG" 91 92 if env "$libvar=$good" "${libvar}_SHA256=$sha" cargo check -q -p "$crate" >"$WORK/log" 2>&1 && 93 grep -qsx "cargo:rustc-env=${6}_LINK=prebuilt" "$(ls -t "$CARGO_TARGET_DIR"/debug/build/"$crate"-*/output | head -1)"; then 94 pass "$crate: matching prebuilt builds and says prebuilt" 95 else 96 fail "$crate: matching prebuilt builds and says prebuilt" 97 tail -5 "$WORK/log" 98 fi 99 } 100 101 cd "$ROOT" 102 check_crate aien-omega-compose crates/aien-omega-compose/abi/rxc_host_abi.manifest \ 103 AIEN_OMEGA_COMPOSE_LIB AIEN_OMEGA_COMPOSE_DIR rxc_host_recover AIEN_OMEGA_COMPOSE 104 check_crate aien-omega-gpu crates/aien-omega-gpu/abi/omega_gpu.manifest \ 105 AIEN_OMEGA_GPU_LIB AIEN_OMEGA_DIR omega_gpu_matmul_f32 AIEN_OMEGA_GPU 106 107 if [ "$fails" -ne 0 ]; then 108 echo "native identity: $fails case(s) failed" 109 exit 1 110 fi 111 echo "native identity: all cases behave"