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 / sibling_map_check_test.sh

80 lines · 6031 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# sibling_map_check_test.sh <sibling-map-check>: the tick's sibling map guard (the part of crumb-doctor that the
18# 2026-11-08 crumb retirement kept) goes RED on a stale trusted clone (the 2026-10-11..18 synapse "../aien-architecture
19# is missing" cause), heals it, refuses to move a dirty clone, sees a gate need the map lacks, and raises/clears its
20# aien-watch alert (also the legacy CRUMB-DRIFT line) while other alerts survive.
21# The tool also reads the --siblings file of every running `aien-test worker` (/proc). A worker started with
22# --siblings and an incomplete map makes the RED checks below still RED and the GREEN ones RED: that is the tool
23# doing its job on this host, not a test defect; the output then names "--siblings of pid".
24set -u
25SMC=$(readlink -f "${1:?usage: sibling_map_check_test.sh <sibling-map-check>}")
26T=$(mktemp -d); trap 'rm -rf "$T"' EXIT
27pass=0; fail=0
28ok() { pass=$((pass+1)); echo "ok $1"; }
29bad() { fail=$((fail+1)); echo "FAIL $1: $2"; }
30g() { git -c user.name=t -c user.email=t@t -c commit.gpgsign=false "$@"; }
31export AIEN_CLONES=$T/clones AIEN_WATCH_STATE=$T/watch
32mkdir -p "$T/clones" "$T/watch"
33printf '%s\n' "OTHER: unrelated alert (must survive)" "CRUMB-DRIFT: legacy line from the retired crumb-doctor" > "$T/watch/ALERT"
34
35o=$("$SMC" --bogus 2>&1); rc=$?
36(( rc == 2 )) && [[ $o == *"usage: sibling-map-check"* ]] && ok "unknown flag: usage, exit 2" || bad "usage" "rc=$rc $o"
37
38# upstream sc: commit 1 without the synapse sibling line, commit 2 with it
39mkdir -p "$T/up/sc/tools/aien-local-ci"; cd "$T/up/sc"; g init -q -b main
40echo "omega aien-architecture aien-architecture main" > tools/aien-local-ci/siblings; g add -A; g commit -qm one
41c1=$(git rev-parse HEAD)
42echo "synapse aien-architecture aien-architecture main" >> tools/aien-local-ci/siblings; g commit -qam two
43# upstream synapse: its gate asks for ../aien-architecture
44mkdir -p "$T/up/synapse/tests/gates"; cd "$T/up/synapse"; g init -q -b main
45printf 'case $1 in\n verify)\n need_sibling aien-architecture\n ;;\nesac\n' > tests/gates/run.sh; g add -A; g commit -qm s
46# trusted clones; sc work tree left on the OLD commit (what the Spark had)
47git clone -q "$T/up/sc" "$T/clones/aien-sovereign-core"; git -C "$T/clones/aien-sovereign-core" -c advice.detachedHead=false checkout -q --detach "$c1"
48git clone -q "$T/up/synapse" "$T/clones/synapse"
49
50o=$("$SMC" --repos synapse --alert 2>&1); rc=$?
51(( rc == 1 )) && [[ $o == *"FAIL SIBMAP"*"missing synapse ../aien-architecture"* ]] && ok "stale trusted clone is RED (exit 1, names the missing sibling)" || bad "red" "rc=$rc $o"
52grep -q '^SIBLING-MAP: ' "$T/watch/ALERT" && grep -q '^OTHER: ' "$T/watch/ALERT" && ! grep -q '^CRUMB-DRIFT: ' "$T/watch/ALERT" \
53 && grep -q ' SIBLING-MAP ' "$T/watch/alerts.log" && ok "alert raised and logged, legacy CRUMB-DRIFT line dropped, other alerts kept" || bad "alert" "$(cat "$T/watch/ALERT")"
54
55o=$("$SMC" --heal-only 2>&1); rc=$?
56h=$(git -C "$T/clones/aien-sovereign-core" rev-parse HEAD); m=$(git -C "$T/clones/aien-sovereign-core" rev-parse origin/main)
57(( rc == 0 )) && [ "$h" = "$m" ] && ok "--heal-only moves the work tree to origin/main" || bad "heal" "rc=$rc head=$h main=$m $o"
58o=$("$SMC" --heal-only 2>&1); rc=$?
59(( rc == 0 )) && [ -z "$o" ] && ok "--heal-only on a current clone: silent, exit 0" || bad "heal noop" "rc=$rc $o"
60
61o=$("$SMC" --repos synapse --alert 2>&1); rc=$?
62(( rc == 0 )) && [[ $o == *"PASS SIBMAP"* ]] && [[ $o == *"1 pass, 0 FAIL"* ]] && ok "after heal: GREEN" || bad "green" "rc=$rc $o"
63! grep -q '^SIBLING-MAP: ' "$T/watch/ALERT" && grep -q '^OTHER: ' "$T/watch/ALERT" && ok "alert cleared when green, other alerts kept" || bad "clear" "$(cat "$T/watch/ALERT")"
64
65# a dirty trusted clone is never moved (someone is using it): reported, not clobbered
66git -C "$T/clones/aien-sovereign-core" -c advice.detachedHead=false checkout -q --detach "$c1"
67echo "local edit" >> "$T/clones/aien-sovereign-core/tools/aien-local-ci/siblings"
68o=$("$SMC" --heal-only 2>&1); rc=$?
69(( rc == 1 )) && [[ $o == *"local changes"* ]] && grep -q "local edit" "$T/clones/aien-sovereign-core/tools/aien-local-ci/siblings" \
70 && [ "$(git -C "$T/clones/aien-sovereign-core" rev-parse HEAD)" = "$c1" ] && ok "dirty work tree: refused, edit kept" || bad "dirty" "rc=$rc $o"
71
72# map on main missing a sibling a gate needs (need_sibling or a pin line): RED even when the work tree is current
73git -C "$T/clones/aien-sovereign-core" checkout -q -- . ; git -C "$T/clones/aien-sovereign-core" -c advice.detachedHead=false checkout -q --detach origin/main
74cd "$T/up/synapse"; sed -i 's/need_sibling aien-architecture/need_sibling aien-architecture\n need_sibling omega/' tests/gates/run.sh; g commit -qam needs-omega; git -C "$T/clones/synapse" fetch -q
75o=$("$SMC" --repos synapse 2>&1); rc=$?
76(( rc == 1 )) && [[ $o == *"synapse needs ../omega"* ]] && ok "gate needs a sibling the map lacks: RED" || bad "coverage" "rc=$rc $o"
77cd "$T/up/synapse"; sed -i '/need_sibling omega/d' tests/gates/run.sh; printf ' pin physics-src physics "$sha"\n' >> tests/gates/run.sh; g commit -qam pin-physics; git -C "$T/clones/synapse" fetch -q
78o=$("$SMC" --repos synapse 2>&1); rc=$?
79(( rc == 1 )) && [[ $o == *"synapse needs ../physics"* ]] && ok "pin line the map lacks: RED" || bad "pin coverage" "rc=$rc $o"
80echo "sibling-map-check tests: $pass passed, $fail failed"; (( fail == 0 ))