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 / tools / aien-local-ci / sibling-map-check
| 1 | #!/usr/bin/env bash |
| 2 | # sibling-map-check: the part of the retired crumb-doctor that worked (Drake 2026-11-08: "get rid of crumbs", |
| 3 | # "keep the parts that worked"). Code taken unchanged from crumb-doctor's heal and SIBMAP checks. |
| 4 | # |
| 5 | # The test workers read the sibling map (tools/aien-local-ci/siblings: which repos need which neighbour repos beside |
| 6 | # them to run their tests) from the WORK TREE of the trusted aien-sovereign-core clone. This tool: |
| 7 | # HEAL moves that work tree to origin/main when it is clean (--heal-only does only this; cheap, every tick) |
| 8 | # SIBMAP every map a running worker reads equals origin/main's, and covers every need_sibling / pin that a |
| 9 | # repo's tests/gates/run.sh asks for |
| 10 | # --alert writes a SIBLING-MAP line into the aien-watch ALERT (removed when green). Exit 0 all PASS, 1 any FAIL. |
| 11 | set -u |
| 12 | CLONES=${AIEN_CLONES:-$HOME/workspace/pipeline/clones} |
| 13 | WATCH=${AIEN_WATCH_STATE:-$HOME/.local/state/aienos/watch} |
| 14 | TRUSTED=$CLONES/aien-sovereign-core |
| 15 | REPOS="aien-sovereign-core omega aienux physics aien-protocols aegis-runtime spark-rsi aien-architecture benchmarks synapse interplane" |
| 16 | HEAL=0 HEAL_ONLY=0 ALERT=0 |
| 17 | while [ $# -gt 0 ]; do |
| 18 | case $1 in |
| 19 | --heal) HEAL=1 ;; --heal-only) HEAL=1; HEAL_ONLY=1 ;; --alert) ALERT=1 ;; |
| 20 | --repos) REPOS=${2//,/ }; shift ;; |
| 21 | *) echo "usage: sibling-map-check [--heal|--heal-only] [--alert] [--repos a,b]" >&2; exit 2 ;; |
| 22 | esac; shift |
| 23 | done |
| 24 | npass=0; FAILS=() |
| 25 | record() { printf '%-4s %-6s %-40s %s\n' "$1" "$2" "$3" "$4"; case $1 in PASS) npass=$((npass+1)) ;; FAIL) FAILS+=("$2 $3") ;; esac; } |
| 26 | g() { git -c advice.detachedHead=false "$@"; } |
| 27 | heal_trusted() { |
| 28 | local head main |
| 29 | head=$(git -C "$TRUSTED" rev-parse HEAD 2>/dev/null); main=$(git -C "$TRUSTED" rev-parse origin/main 2>/dev/null) |
| 30 | [ "$HEAL" = 1 ] && [ -n "$main" ] && [ "$head" != "$main" ] || return 0 |
| 31 | if [ -n "$(git -C "$TRUSTED" status --porcelain --untracked-files=no)" ]; then |
| 32 | record FAIL HEAL "trusted clone" "work tree has local changes; not moved off ${head:0:8}" |
| 33 | else |
| 34 | g -C "$TRUSTED" checkout -q --detach origin/main && record INFO HEAL "trusted clone" "work tree moved ${head:0:8} -> origin/main ${main:0:8}" |
| 35 | fi |
| 36 | } |
| 37 | if [ "$HEAL_ONLY" = 1 ]; then heal_trusted; [ ${#FAILS[@]} = 0 ]; exit $?; fi |
| 38 | |
| 39 | SIBFILES=() |
| 40 | for p in /proc/[0-9]*; do |
| 41 | cmd=$( { tr '\0' ' ' < "$p/cmdline"; } 2>/dev/null) || continue |
| 42 | [[ $cmd == *aien-test\ worker* ]] || continue |
| 43 | [[ $cmd =~ --siblings\ ([^ ]+) ]] && SIBFILES+=("${BASH_REMATCH[1]}|--siblings of pid ${p#/proc/}") |
| 44 | done |
| 45 | echo "sibling-map-check $(date -u +%FT%TZ)" |
| 46 | map_rows() { sed 's/#.*//' "$@" 2>/dev/null | awk 'NF==4 {print $1" "$2}' | sort -u; } |
| 47 | heal_trusted |
| 48 | main=$(git -C "$TRUSTED" rev-parse origin/main 2>/dev/null) |
| 49 | want=$(git -C "$TRUSTED" show origin/main:tools/aien-local-ci/siblings 2>/dev/null | sed 's/#.*//' | awk 'NF==4 {print $1" "$2}' | sort -u) |
| 50 | for entry in "$TRUSTED/tools/aien-local-ci/siblings|default (poll workers)" "${SIBFILES[@]}"; do |
| 51 | f=${entry%%|*}; who=${entry#*|} |
| 52 | missing=$(comm -23 <(printf '%s\n' "$want") <(map_rows "$f") | grep . | sed 's/ / ..\//' | paste -sd, -) |
| 53 | if [ -n "$missing" ]; then record FAIL SIBMAP "$f" "$who: missing $missing (origin/main ${main:0:8} has them)" |
| 54 | else record PASS SIBMAP "$f" "$who: matches origin/main ${main:0:8}"; fi |
| 55 | done |
| 56 | for repo in $REPOS; do |
| 57 | runsh=$(git -C "$CLONES/$repo" show origin/main:tests/gates/run.sh 2>/dev/null) |
| 58 | need=$( { printf '%s\n' "$runsh" | grep -oE 'need_sibling[[:blank:]]+[A-Za-z0-9._-]+' | awk '{print $2}' |
| 59 | printf '%s\n' "$runsh" | grep -E '^[[:blank:]]*pin[[:blank:]]+[^[:blank:]]+[[:blank:]]+[^[:blank:]]+[[:blank:]]+[^[:blank:]]+' | awk '{print $3}'; } | sort -u) |
| 60 | for d in $need; do |
| 61 | grep -qx "$repo $d" <<<"$want" || record FAIL SIBMAP "$repo needs ../$d" "origin/main sibling map has no line for it" |
| 62 | done |
| 63 | done |
| 64 | echo "sibling-map-check: $npass pass, ${#FAILS[@]} FAIL" |
| 65 | if [ "$ALERT" = 1 ]; then |
| 66 | mkdir -p "$WATCH"; stamp=$(date -u +%FT%TZ) |
| 67 | keep=$(grep -v -e '^SIBLING-MAP:' -e '^CRUMB-DRIFT:' "$WATCH/ALERT" 2>/dev/null) |
| 68 | if [ ${#FAILS[@]} -gt 0 ]; then |
| 69 | text=$(printf '%s; ' "${FAILS[@]}" | cut -c1-600) |
| 70 | printf '%s SIBLING-MAP %s\n' "$stamp" "$text" >> "$WATCH/alerts.log" |
| 71 | keep=$(printf '%s\n%s' "$keep" "SIBLING-MAP: a test worker's list of neighbour repos is incomplete: $text(run: sibling-map-check; since $stamp)" | grep .) |
| 72 | fi |
| 73 | if [ -n "$keep" ]; then printf '%s\n' "$keep" > "$WATCH/ALERT.tmp" && mv -f "$WATCH/ALERT.tmp" "$WATCH/ALERT"; else rm -f "$WATCH/ALERT"; fi |
| 74 | fi |
| 75 | [ ${#FAILS[@]} = 0 ] |