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 / repro-container-build.sh

95 lines · 4948 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# Path-independent build of the serving engine in a pinned container (DRA-43).
18#
19# scripts/repro-container-build.sh [--plain] WORK
20#
21# WORK is a new absolute directory. The script checks out core, omega and physics under WORK, starts the
22# release/repro/Dockerfile image with WORK mounted at the same path, builds libomega_gpu.a with omega's Makefile and
23# links it into the engine the way the shipped engine is linked (AIEN_OMEGA_GPU_LIB + AIEN_OMEGA_GPU_LIB_SHA256).
24# CARGO_HOME, CARGO_TARGET_DIR and HOME live under WORK, so two runs from two WORK paths differ only in their paths:
25# equal sha256 in WORK/out/BUILD-INFO.txt means the build does not depend on where it ran. --plain builds without
26# scripts/repro-build.sh (no path remap), the negative control. CPU only: no --gpus, no device mounts.
27#
28# Environment (40-hex commits; defaults in brackets):
29# CORE_REV core commit to build [HEAD of this checkout]
30# OMEGA_REV omega commit for libomega_gpu.a [omega.lock at CORE_REV]
31# PHYSICS_REV physics commit [physics.lock at OMEGA_REV]
32# EXPECT_LIB_SHA256, EXPECT_ENGINE_SHA256 fail unless the built file has this digest [unchecked]
33# PACKAGE cargo package [aien-serve-http]
34# CORE_URL OMEGA_URL PHYSICS_URL git remotes [github.com/aien-dev/{aien-sovereign-core,omega,physics}-mv]
35# REPRO_CPUS docker --cpuset-cpus [2-4] REPRO_JOBS build jobs [3]
36# REPRO_MEMORY docker --memory and --memory-swap, e.g. 16g [no limit]
37#
38# The SI alpha-20261029.1 engine (sovereign-intelligence installer/build.sh):
39# CORE_REV=59b05a71a33e4a2f1324db2f2b6407ee82b8c2c3 OMEGA_REV=6de999da86efc6edd9c2554a87ee31f7fa9215ac \
40# EXPECT_LIB_SHA256=110295ef23dc7561eea371636347c005835f37b82c22f92401aa8a887a3ca990 \
41# scripts/repro-container-build.sh /abs/new/dir
42set -euo pipefail
43
44usage() { echo "usage: $0 [--plain] WORK" >&2; exit 2; }
45mode=remap
46if [ "${1:-}" = --plain ]; then mode=plain; shift; fi
47[ $# -eq 1 ] || usage
48work=$1
49case "$work" in /*) ;; *) echo "$0: WORK must be an absolute path" >&2; exit 2 ;; esac
50if [ -e "$work" ] && [ -n "$(ls -A "$work")" ]; then echo "$0: $work exists and is not empty" >&2; exit 2; fi
51
52here=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
53pkg=${PACKAGE:-aien-serve-http}
54core_url=${CORE_URL:-https://github.com/aien-dev/aien-sovereign-core-mv.git}
55omega_url=${OMEGA_URL:-https://github.com/aien-dev/omega-mv.git}
56physics_url=${PHYSICS_URL:-https://github.com/aien-dev/physics-mv.git}
57core_rev=${CORE_REV:-$(git -C "$here" rev-parse HEAD)}
58
59is_sha() { [[ $1 =~ ^[0-9a-f]{40}$ ]]; }
60# fetch_rev DIR URL REV: a one-commit checkout of REV at DIR.
61fetch_rev() {
62 is_sha "$3" || { echo "$0: $3 is not a 40-hex commit" >&2; exit 2; }
63 git init -q "$1"
64 git -C "$1" -c uploadpack.allowAnySHA1InWant=true fetch -q --depth 1 "$2" "$3"
65 git -C "$1" checkout -q --detach FETCH_HEAD
66 [ "$(git -C "$1" rev-parse HEAD)" = "$3" ] || { echo "$0: $1 is not at $3" >&2; exit 1; }
67}
68
69mkdir -p "$work"
70fetch_rev "$work/core" "$core_url" "$core_rev"
71omega_rev=${OMEGA_REV:-$(tr -d '[:space:]' <"$work/core/omega.lock")}
72fetch_rev "$work/omega" "$omega_url" "$omega_rev"
73physics_rev=${PHYSICS_REV:-$(tr -d '[:space:]' <"$work/omega/physics.lock")}
74fetch_rev "$work/physics" "$physics_url" "$physics_rev"
75
76# The tag names every file the image is built from, so a changed package lock gives a new image.
77image=aien-repro-build:$(cd "$here/release/repro" && cat Dockerfile apt-install.sh apt-packages.lock dpkg-manifest.tsv | sha256sum | cut -c1-12)
78if ! docker image inspect "$image" >/dev/null 2>&1; then
79 docker build -q -t "$image" "$here/release/repro" >/dev/null
80fi
81
82mem=()
83[ -n "${REPRO_MEMORY:-}" ] && mem=(--memory "$REPRO_MEMORY" --memory-swap "$REPRO_MEMORY")
84docker run --rm --cpuset-cpus "${REPRO_CPUS:-2-4}" "${mem[@]}" --user "$(id -u):$(id -g)" \
85 -e CARGO_BUILD_JOBS="${REPRO_JOBS:-3}" \
86 -v "$work:$work" -v "$here/release/repro/inside.sh:/repro/inside.sh:ro" \
87 "$image" nice -n 19 ionice -c3 bash /repro/inside.sh "$work" "$mode" "$pkg"
88
89check() { # check FILE EXPECTED
90 [ -z "$2" ] && return 0
91 got=$(sha256sum "$1" | cut -d' ' -f1)
92 [ "$got" = "$2" ] || { echo "$0: $1 sha256 $got, expected $2" >&2; exit 1; }
93}
94check "$work/out/libomega_gpu.a" "${EXPECT_LIB_SHA256:-}"
95check "$work/out/$pkg" "${EXPECT_ENGINE_SHA256:-}"