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 / scripts / test-omega-checkout.sh
| 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 | # Pinned-checkout checks in the aien-omega-gpu build script (build::require_pinned_checkout). |
| 18 | # Needs the pinned omega checkout (AIEN_OMEGA_DIR, from scripts/pins.sh --gpu). Each case runs |
| 19 | # against a scratch clone of it, so the pinned checkout is never modified: |
| 20 | # - a clean clone at omega.lock builds |
| 21 | # - untracked and ignored files in the clone are allowed (they are not the source) |
| 22 | # - a modified tracked file (seed/out/omc) is refused |
| 23 | # - the same edit hidden with git update-index --assume-unchanged is refused |
| 24 | # - the same edit hidden with git update-index --skip-worktree is refused |
| 25 | # - a checkout at another commit is refused |
| 26 | # - a prebuilt archive with a wrong sha256 is refused |
| 27 | # Exit 0 when every case behaves, 1 otherwise, 2 when the pinned checkout is missing. |
| 28 | set -euo pipefail |
| 29 | ROOT=$(cd "$(dirname "$0")/.." && pwd) |
| 30 | PINNED=${AIEN_OMEGA_DIR:-} |
| 31 | if [ -z "$PINNED" ] || ! git -C "$PINNED" rev-parse -q --verify HEAD >/dev/null; then |
| 32 | echo "omega checkout: AIEN_OMEGA_DIR is not a git checkout (run scripts/pins.sh --gpu and source target/pins/env.sh)" |
| 33 | exit 2 |
| 34 | fi |
| 35 | PHYSICS=${AIEN_PHYSICS_DIR:-$PINNED/../physics} |
| 36 | WORK=$(mktemp -d) |
| 37 | trap 'rm -rf "$WORK"' EXIT |
| 38 | export CARGO_TARGET_DIR="${AIEN_CHECKOUT_TARGET_DIR:-$ROOT/target/omega-checkout}" |
| 39 | for v in $(env | sed -n 's/^\(AIEN_[A-Z0-9_]*\)=.*/\1/p'); do unset "$v"; done |
| 40 | export AIEN_PHYSICS_DIR="$PHYSICS" |
| 41 | |
| 42 | fails=0 |
| 43 | pass() { echo "ok $1"; } |
| 44 | fail() { echo "FAIL $1"; fails=$((fails + 1)); } |
| 45 | |
| 46 | # expect_built <case> [VAR=value ...] |
| 47 | expect_built() { |
| 48 | local name=$1 |
| 49 | shift |
| 50 | if env "$@" cargo check -q -p aien-omega-gpu >"$WORK/log" 2>&1; then |
| 51 | pass "$name" |
| 52 | else |
| 53 | fail "$name (refused, rc $?)" |
| 54 | tail -5 "$WORK/log" |
| 55 | fi |
| 56 | } |
| 57 | |
| 58 | # expect_refused <case> <pattern> [VAR=value ...]: cargo must exit 101 and print the pattern |
| 59 | expect_refused() { |
| 60 | local name=$1 pat=$2 rc=0 |
| 61 | shift 2 |
| 62 | env "$@" cargo check -q -p aien-omega-gpu >"$WORK/log" 2>&1 || rc=$? |
| 63 | if [ "$rc" -ne 101 ]; then |
| 64 | fail "$name (rc $rc, expected 101)" |
| 65 | tail -5 "$WORK/log" |
| 66 | elif grep -qF -- "$pat" "$WORK/log"; then |
| 67 | pass "$name" |
| 68 | else |
| 69 | fail "$name (refused, but not with '$pat')" |
| 70 | tail -5 "$WORK/log" |
| 71 | fi |
| 72 | } |
| 73 | |
| 74 | # fresh <dir>: a scratch clone of the pinned checkout, at the same commit |
| 75 | fresh() { |
| 76 | rm -rf "$1" |
| 77 | git clone -q --no-checkout "$PINNED" "$1" |
| 78 | git -C "$1" checkout -q --detach "$(git -C "$PINNED" rev-parse HEAD)" |
| 79 | } |
| 80 | |
| 81 | OMC=seed/out/omc |
| 82 | C="$WORK/omega" |
| 83 | cd "$ROOT" |
| 84 | |
| 85 | fresh "$C" |
| 86 | expect_built "clean checkout at omega.lock builds" AIEN_OMEGA_DIR="$C" |
| 87 | |
| 88 | touch "$C/untracked-probe" |
| 89 | echo probe >"$C/seed/out/ignored-probe.o" |
| 90 | if git -C "$C" check-ignore -q seed/out/ignored-probe.o; then |
| 91 | expect_built "untracked and ignored files are allowed" AIEN_OMEGA_DIR="$C" |
| 92 | else |
| 93 | fail "untracked and ignored files are allowed (seed/out/ignored-probe.o is not ignored in omega)" |
| 94 | fi |
| 95 | |
| 96 | fresh "$C" |
| 97 | printf x >>"$C/$OMC" |
| 98 | expect_refused "modified tracked file is refused" "has uncommitted changes to tracked files" \ |
| 99 | AIEN_OMEGA_DIR="$C" |
| 100 | |
| 101 | fresh "$C" |
| 102 | git -C "$C" update-index --assume-unchanged "$OMC" |
| 103 | printf x >>"$C/$OMC" |
| 104 | expect_refused "edit hidden by assume-unchanged is refused" "assume-unchanged or skip-worktree" \ |
| 105 | AIEN_OMEGA_DIR="$C" |
| 106 | |
| 107 | fresh "$C" |
| 108 | git -C "$C" update-index --skip-worktree "$OMC" |
| 109 | printf x >>"$C/$OMC" |
| 110 | expect_refused "edit hidden by skip-worktree is refused" "assume-unchanged or skip-worktree" \ |
| 111 | AIEN_OMEGA_DIR="$C" |
| 112 | |
| 113 | STALE="$WORK/stale" |
| 114 | git init -q "$STALE" |
| 115 | git -C "$STALE" -c user.name=t -c user.email=t@t commit -q --allow-empty -m stale |
| 116 | expect_refused "checkout at another commit is refused" "is at '" AIEN_OMEGA_DIR="$STALE" |
| 117 | |
| 118 | ARCHIVE=$(find "$CARGO_TARGET_DIR/debug/build" -path '*aien-omega-gpu-*/out/omega-build/libomega_gpu.a' | head -1) |
| 119 | if [ -n "$ARCHIVE" ]; then |
| 120 | expect_refused "prebuilt archive with a wrong sha256 is refused" "expects" \ |
| 121 | AIEN_OMEGA_GPU_LIB="$ARCHIVE" AIEN_OMEGA_GPU_LIB_SHA256="$(printf '0%.0s' {1..64})" |
| 122 | else |
| 123 | fail "prebuilt archive with a wrong sha256 is refused (the clean build left no archive)" |
| 124 | fi |
| 125 | |
| 126 | if [ "$fails" -ne 0 ]; then |
| 127 | echo "omega checkout: $fails case(s) failed" |
| 128 | exit 1 |
| 129 | fi |
| 130 | echo "omega checkout: all cases behave" |