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 / scripts / pins.sh

98 lines · 5306 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# pins.sh: materialize the three pinned checkouts a native (no CUDA) build needs,
18# exactly as CI does (ci.yml "Linked composition tests"), so a clean clone plus one
19# command yields the real omega libraries instead of the CPU stubs (sovereign-core #92).
20#
21# omega at omega.lock (this repository)
22# physics at omega's physics.lock
23# aienos at omega's aienos.lock (authority source for the composition library)
24#
25# Usage: scripts/pins.sh [--gpu] [--check] [DIR]
26# DIR where the checkouts live (default target/pins). Existing clones are reused;
27# the network is touched only when a clone is missing or not at its pin.
28# --gpu env.sh also sets AIEN_OMEGA_DIR, which links the GB10 engine (aien-omega-gpu).
29# Without it only the composition library (CPU) is linked, as the CI gate does.
30# --check verify only: every clone present and at its pin, no network, no writes.
31# Writes DIR/env.sh. Then: . target/pins/env.sh && cargo build --release
32# Env: AIEN_PINS_REMOTE_BASE (default https://github.com/aien-dev; a local mirror directory
33# works too), AIEN_PINS_REMOTE_SUFFIX (appended to each repository name; default "-mv"
34# for the default GitHub base, where the repositories are omega-mv, physics-mv and
35# aienos-mv, and "" when AIEN_PINS_REMOTE_BASE is set), AIEN_PINS_ROOT (repository root
36# override, used by scripts/test-pins.sh).
37# Exit: 0 ok, 2 usage, 3 a checkout is not at its pin (or missing under --check), 4 git failed.
38set -euo pipefail
39ROOT="${AIEN_PINS_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
40if [ -n "${AIEN_PINS_REMOTE_BASE:-}" ]; then
41 BASE="$AIEN_PINS_REMOTE_BASE"; SUFFIX="${AIEN_PINS_REMOTE_SUFFIX:-}"
42else
43 BASE="https://github.com/aien-dev"; SUFFIX="${AIEN_PINS_REMOTE_SUFFIX--mv}"
44fi
45GPU=0; CHECK=0; DIR=""
46for a in "$@"; do
47 case "$a" in
48 --gpu) GPU=1 ;;
49 --check) CHECK=1 ;;
50 -h|--help) sed -n '2,22p' "$0"; exit 0 ;;
51 -*) echo "pins.sh: unknown flag $a" >&2; exit 2 ;;
52 *) [ -z "$DIR" ] || { echo "pins.sh: one DIR only" >&2; exit 2; }; DIR="$a" ;;
53 esac
54done
55DIR="${DIR:-$ROOT/target/pins}"
56mkdir -p "$DIR" 2>/dev/null || true; DIR="$(cd "$DIR" 2>/dev/null && pwd || echo "$DIR")"
57die() { echo "pins.sh: $*" >&2; exit 3; }
58sha_of() { tr -d '[:space:]' < "$1"; }
59is_sha() { [[ "$1" =~ ^[0-9a-f]{40}$ ]]; }
60head_of() { git -C "$1" rev-parse HEAD 2>/dev/null || true; }
61# place NAME SHA: make DIR/NAME a clone at SHA (detached), fetching only when needed.
62place() {
63 local name="$1" sha="$2"
64 local d="$DIR/$name"
65 is_sha "$sha" || die "$name pin is not a full 40-hex sha: '$sha'"
66 if [ "$(head_of "$d")" = "$sha" ]; then echo "pins: $name at $sha (present)"; return 0; fi
67 [ "$CHECK" -eq 0 ] || die "$name is not at $sha under --check (have '$(head_of "$d")', dir $d)"
68 mkdir -p "$DIR"
69 if [ ! -d "$d/.git" ]; then
70 echo "pins: cloning $name from $BASE/$name$SUFFIX"
71 git clone -q "$BASE/$name$SUFFIX" "$d" || { echo "pins.sh: clone of $name ($BASE/$name$SUFFIX) failed" >&2; exit 4; }
72 fi
73 if ! git -C "$d" cat-file -e "$sha^{commit}" 2>/dev/null; then
74 git -C "$d" fetch -q origin "$sha" || git -C "$d" fetch -q origin || { echo "pins.sh: fetch of $name failed" >&2; exit 4; }
75 fi
76 git -C "$d" checkout -q --detach "$sha" || { echo "pins.sh: checkout of $name@$sha failed" >&2; exit 4; }
77 [ "$(head_of "$d")" = "$sha" ] || die "$name HEAD is not $sha after checkout"
78 echo "pins: $name at $sha"
79}
80[ -f "$ROOT/omega.lock" ] || die "no omega.lock under $ROOT"
81place omega "$(sha_of "$ROOT/omega.lock")"
82[ -f "$DIR/omega/physics.lock" ] || die "omega checkout has no physics.lock"
83[ -f "$DIR/omega/aienos.lock" ] || die "omega checkout has no aienos.lock"
84place physics "$(sha_of "$DIR/omega/physics.lock")"
85place aienos "$(sha_of "$DIR/omega/aienos.lock")"
86if [ "$CHECK" -eq 0 ]; then
87 {
88 echo "# written by scripts/pins.sh; source it before cargo build/test"
89 echo "export AIEN_OMEGA_COMPOSE_DIR='$DIR/omega'"
90 echo "export AIEN_PHYSICS_DIR='$DIR/physics'"
91 echo "export AIEN_AIENOS_LOCK_REPO='$DIR/aienos'"
92 if [ "$GPU" -eq 1 ]; then echo "export AIEN_OMEGA_DIR='$DIR/omega'"; else echo "unset AIEN_OMEGA_DIR"; fi
93 echo "unset AIEN_OMEGA_GPU_LIB AIEN_OMEGA_COMPOSE_LIB AIEN_OMEGA_COMPOSE_SHA AIEN_FORCE_CPU_STUB AIEN_DEV_FALLBACK"
94 echo "export AIEN_REQUIRE_NATIVE_LIBS=1"
95 } > "$DIR/env.sh"
96 echo "pins: wrote $DIR/env.sh ($([ "$GPU" -eq 1 ] && echo 'GPU engine + composition' || echo 'composition only, CPU'))"
97 echo "next: . '$DIR/env.sh' && cargo build --release"
98fi