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 / health.sh
| 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 | # health.sh: one-screen health of the sovereign local pipeline host pieces (lane INFRA). Read-only. |
| 18 | set -uo pipefail |
| 19 | RUN_HOME=/var/lib/aien-run |
| 20 | OP_HOME=${AIEN_OPERATOR_HOME:-$HOME} |
| 21 | FORGEJO_DATA=$OP_HOME/atlas-forgejo/data |
| 22 | FORGEJO_PORT=$(grep -E '^HTTP_PORT' "$FORGEJO_DATA/custom/conf/app.ini" 2>/dev/null | awk -F= '{gsub(/ /,"",$2); print $2}') |
| 23 | FORGEJO_PORT=${FORGEJO_PORT:-3443} |
| 24 | STATE=$OP_HOME/.local/state/aien-local-ci |
| 25 | GPU_LOCK=/tmp/aien-gb10.lock |
| 26 | SLOTS=$OP_HOME/.local/state/aien-proof/slots |
| 27 | |
| 28 | row() { printf '%-22s %s\n' "$1" "$2"; } |
| 29 | |
| 30 | if mountpoint -q "$FORGEJO_DATA"; then row "forgejo storage" "mounted ($FORGEJO_DATA)"; else row "forgejo storage" "NOT MOUNTED"; fi |
| 31 | code=$(curl -sk -m 3 -o /dev/null -w '%{http_code}' "https://127.0.0.1:$FORGEJO_PORT/" 2>/dev/null) |
| 32 | if [[ $code == 200 ]]; then row "forgejo web" "up (https://127.0.0.1:$FORGEJO_PORT, $(systemctl is-active atlas-forgejo.service 2>/dev/null))"; else row "forgejo web" "DOWN (http $code, unit $(systemctl is-active atlas-forgejo.service 2>/dev/null))"; fi |
| 33 | if (exec 3<>/dev/tcp/127.0.0.1/2222) 2>/dev/null; then row "forgejo ssh" "listening 127.0.0.1:2222"; else row "forgejo ssh" "NOT listening on 2222"; fi |
| 34 | row "forgejo-runner" "$(systemctl --user is-active forgejo-runner.service 2>/dev/null) (enabled: $(systemctl --user is-enabled forgejo-runner.service 2>/dev/null)); must stay off" |
| 35 | |
| 36 | if u=$(getent passwd aien-run); then |
| 37 | row "aien-run user" "ok uid=$(cut -d: -f3 <<<"$u") groups=$(id -nG aien-run | tr ' ' ',') shell=$(cut -d: -f7 <<<"$u")" |
| 38 | else |
| 39 | row "aien-run user" "MISSING" |
| 40 | fi |
| 41 | [[ -x /usr/local/sbin/aien-run-exec ]] && row "aien-run-exec" "$(stat -c '%U %a' /usr/local/sbin/aien-run-exec) $(sudo -n -l /usr/local/sbin/aien-run-exec >/dev/null 2>&1 && echo 'sudo ok' || echo 'SUDO RULE MISSING')" || row "aien-run-exec" "MISSING" |
| 42 | if [[ -x /usr/local/bin/crumb ]]; then |
| 43 | want=$(sed -n 's/^CRUMB_COMMIT=//p' "$(dirname "$0")/install.sh" 2>/dev/null | cut -c1-7) |
| 44 | row "crumb (sandbox)" "/usr/local/bin/crumb $(stat -c '%U %a' /usr/local/bin/crumb) sha256 $(sha256sum < /usr/local/bin/crumb | cut -c1-12) (install.sh pins aien-architecture ${want:-?})" |
| 45 | else |
| 46 | row "crumb (sandbox)" "MISSING (run install.sh)" |
| 47 | fi |
| 48 | hl=$(stat -c '%U:%G %a' "$RUN_HOME" "$RUN_HOME/cargo" "$RUN_HOME/target" 2>/dev/null | tr '\n' ' ') |
| 49 | [[ $hl == "root:aien-run 750 root:root 755 root:root 755 " ]] && row "sandbox home layout" "root-owned (home, cargo, target)" || row "sandbox home layout" "UNSAFE: $hl(re-run install.sh)" |
| 50 | |
| 51 | for c in cargo/registry cargo/git rustup/toolchains; do |
| 52 | if [[ -d $RUN_HOME/$c ]]; then row "cache $c" "$(sudo -n du -sh "$RUN_HOME/$c" 2>/dev/null | cut -f1) $(stat -c '%U %a' "$RUN_HOME/$c")"; else row "cache $c" "MISSING"; fi |
| 53 | done |
| 54 | for t in "$RUN_HOME"/target/*/*/; do [[ -d $t ]] && row "target ${t#"$RUN_HOME"/target/}" "$(sudo -n du -sh "$t" 2>/dev/null | cut -f1)"; done |
| 55 | n=0; for w in "$RUN_HOME"/wt/*/*/; do [[ -d $w ]] && n=$((n+1)); done |
| 56 | row "worktrees" "$n under $RUN_HOME/wt" |
| 57 | row "mirrors" "$(ls "$RUN_HOME/mirror" 2>/dev/null | tr '\n' ' ')" |
| 58 | row "scopes running" "$(systemctl list-units --no-legend --plain 'aien-run-exec-*.scope' 2>/dev/null | wc -l)" |
| 59 | row "disk free /" "$(df -h / | awk 'NR==2{print $4" of "$2" ("$5" used)"}')" |
| 60 | row "triggers pending" "$(ls "$STATE/trigger" 2>/dev/null | wc -l)" |
| 61 | |
| 62 | if [[ -e $GPU_LOCK ]]; then |
| 63 | holder=$(cat "$GPU_LOCK" 2>/dev/null | head -c 120) |
| 64 | if command -v fuser >/dev/null && fuser "$GPU_LOCK" >/dev/null 2>&1; then |
| 65 | row "gpu lock" "HELD by pid(s) $(fuser "$GPU_LOCK" 2>/dev/null | tr -s ' ') ${holder:+[$holder]}" |
| 66 | else |
| 67 | row "gpu lock" "file present, no live holder (flock free) ${holder:+[$holder]}" |
| 68 | fi |
| 69 | else |
| 70 | row "gpu lock" "absent" |
| 71 | fi |
| 72 | for s in "$SLOTS"/*.lock; do |
| 73 | [[ -e $s ]] || continue |
| 74 | if fuser "$s" >/dev/null 2>&1; then row "slot $(basename "$s")" "HELD by pid $(fuser "$s" 2>/dev/null | tr -s ' ')"; else row "slot $(basename "$s")" "free"; fi |
| 75 | done |
| 76 | if command -v quietlock >/dev/null; then |
| 77 | q=$(quietlock check 2>&1 | head -1) |
| 78 | if quietlock check >/dev/null 2>&1; then row "quiet flag" "clear${q:+ ($q)}"; else row "quiet flag" "RAISED${q:+ ($q)}"; fi |
| 79 | else |
| 80 | row "quiet flag" "quietlock not installed" |
| 81 | fi |