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 / tools / aien-local-ci / tests / per_head_target_test.sh

60 lines · 3261 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# tests/per_head_target_test.sh: why every head gets its own CARGO_TARGET_DIR (sc #605 flakes, #452 signature).
18#
19# Cargo calls a workspace crate fresh when its outputs are newer than its sources. It compares file times and a
20# path RELATIVE to the workspace, never the absolute checkout path. Two heads that share one target dir therefore
21# share binaries: when head A builds after head B was checked out, head B's gate links and runs head A's build,
22# with head A's CARGO_MANIFEST_DIR baked in. Seen on the Spark as SC-VERIFY-CLOSURE "…/wt/aien-sovereign-core/
23# 2692c1e8…/tests/fixtures/c-cycle: No such file" while judging 9b8e09eb, and as PREFILL-E2E-2 running a mutant.
24#
25# Leg 1 (shared dir, the old layout): must show head B running head A's binary. If it does not, this cargo no
26# longer has the hazard and the test says so (exit 1) instead of passing silently.
27# Leg 2 (one dir per head, the new layout): head B must run its own build.
28# Needs only cargo; no sandbox, no network.
29set -uo pipefail
30R=$(mktemp -d); trap 'rm -rf "$R"' EXIT
31pass=0; fail=0
32ok() { pass=$((pass+1)); printf 'PASS %s\n' "$1"; }
33bad() { fail=$((fail+1)); printf 'FAIL %s: %s\n' "$1" "$2"; }
34mk() { # mk <dir>: one probe crate whose test prints and checks the checkout path baked in at build time
35 mkdir -p "$1/src"
36 printf '[package]\nname = "probe"\nversion = "0.1.0"\nedition = "2021"\n\n[workspace]\n' > "$1/Cargo.toml"
37 cat > "$1/src/lib.rs" <<'EOF'
38pub fn dir() -> &'static str { env!("CARGO_MANIFEST_DIR") }
39#[test]
40fn where_am_i() {
41 println!("BUILT_IN={}", dir());
42 assert!(std::path::Path::new(dir()).exists(), "baked path gone: {}", dir());
43}
44EOF
45}
46leg() { # leg <name> <target-of-A> <target-of-B>: B checked out first, A built after it, A's checkout removed
47 local n=$1 ta=$2 tb=$3
48 mk "$R/$n/headB"; sleep 1.1; mk "$R/$n/headA"
49 (cd "$R/$n/headA" && CARGO_TARGET_DIR=$ta cargo test -q --offline -- --nocapture >/dev/null 2>&1) || { bad "$n" "head A build failed"; return; }
50 rm -rf "$R/$n/headA"
51 (cd "$R/$n/headB" && CARGO_TARGET_DIR=$tb cargo test -q --offline -- --nocapture 2>&1) | grep -o 'BUILT_IN=[^ ]*' | head -1
52}
53got=$(leg shared "$R/shared/t" "$R/shared/t")
54[[ $got == "BUILT_IN=$R/shared/headA" ]] && ok "shared target dir: head B ran head A's binary (the hazard is real)" \
55 || bad "shared hazard not reproduced" "$got"
56got=$(leg perhead "$R/perhead/t-A" "$R/perhead/t-B")
57[[ $got == "BUILT_IN=$R/perhead/headB" ]] && ok "one target dir per head: head B ran its own build" \
58 || bad "per-head" "$got"
59printf '%d passed, %d failed\n' "$pass" "$fail"
60(( fail == 0 ))