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 / aien-local-ci

94 lines · 6432 bytes Raw Blame History
1#!/bin/bash
2# aien-local-ci: operator front door for the Spark's local verification pipeline (ADR 0033, 2026-10-11).
3# Wraps the release aien-test binary with the machine's standard locations. Plain subcommands:
4# aien-local-ci status what the worker is doing, pending triggers, newest bundles
5# aien-local-ci start [--github] [--lane L --repos a,b] start a worker loop detached (trigger files; --github adds
6# PR polling + status posting); lane main (default) = aienux, synapse, interplane
7# other lanes: worker-L.pid, worker-L.log, need --github --repos
8# aien-local-ci stop [--lane L] stop one worker loop (default lane main)
9# aien-local-ci trigger <repo> <sha> ask the worker to verify one head
10# aien-local-ci verify <repo> <sha> [--base REF] independent check of a bundle (exit 0 only on READY)
11# aien-local-ci once <repo> <sha> run one head in the foreground (sandbox user)
12# aien-local-ci plan [--base REF] which gates a change selects (run inside a checkout)
13# aien-local-ci health sandbox + Forgejo health (INFRA health.sh)
14# aien-local-ci log [N] last N journal lines (default 20)
15# Source: aien-sovereign-core tools/aien-local-ci/aien-local-ci, installed as ~/.local/bin/aien-local-ci.
16# Everything runs as the operator; untrusted code only ever runs through /usr/local/sbin/aien-run-exec as aien-run.
17set -euo pipefail
18BIN=${AIEN_TEST_BIN:-$HOME/workspace/pipeline/target-sc/release/aien-test}
19CLONES=${AIEN_CLONES:-$HOME/workspace/pipeline/clones}
20STATE=${AIEN_STATE:-$HOME/.local/state/aien-local-ci}
21# main lane repos: the ones no other lane covers (2026-10-18: overlapping lanes polled the same repos twice, about 59
22# GitHub requests a minute in all). pipeline.sh and rebase-train.sh keep their own full lists.
23REPOS=${AIEN_REPOS:-aienux,synapse,interplane}
24POLL=${AIEN_POLL:-60}
25mkdir -p "$STATE/trigger"
26cmd=${1:-status}; shift || true
27# Worker lanes. One aien-test worker is one serial queue: a 45 to 60 min aienux, sc or omega job starved every other
28# repo of bundles (2026-10-18). So the machine runs named lanes, each its own worker with its own repo list, pidfile and
29# log: main (worker.pid, worker.log, AIEN_REPOS) and any other NAME (worker-NAME.pid, worker-NAME.log, --repos LIST).
30# Keep the lists apart (core and big both hold sovereign-core on purpose; the per-target lock serialises a double run).
31lane=main github=0 lane_repos="" args=()
32while [[ $cmd == start || $cmd == stop ]] && [[ $# -gt 0 ]]; do
33 case "$1" in
34 --lane) lane=${2:?lane name}; shift 2 ;;
35 --repos) lane_repos=${2:?repo list}; shift 2 ;;
36 --github) github=1; shift ;;
37 *) args+=("$1"); shift ;;
38 esac
39done
40if [[ $cmd == start || $cmd == stop ]]; then
41 set -- ${args[@]+"${args[@]}"}
42fi
43[[ $lane =~ ^[a-z][a-z0-9-]{0,30}$ ]] || { echo "bad lane name '$lane'" >&2; exit 2; }
44[[ -z $lane_repos || $lane_repos =~ ^[A-Za-z0-9._-]+(,[A-Za-z0-9._-]+)*$ ]] || { echo "bad --repos '$lane_repos'" >&2; exit 2; }
45if [[ $lane == main ]]; then PIDFILE=$STATE/worker.pid LOG=$STATE/worker.log LANE_REPOS=${lane_repos:-$REPOS}
46else PIDFILE=$STATE/worker-$lane.pid LOG=$STATE/worker-$lane.log LANE_REPOS=$lane_repos; fi
47
48# lane_pid: the pid of this lane's running worker. The pidfile first; when its pid is gone, adopt a running
49# `aien-test worker` of this user whose --state-dir and --repos equal this lane's (exact argv match from
50# /proc/<pid>/cmdline, never a pattern), and rewrite the pidfile, so a lane started by hand is not started twice.
51lane_pid() {
52 local p a i sd rp w once
53 if [[ -f $PIDFILE ]]; then p=$(cat "$PIDFILE"); [[ $p =~ ^[0-9]+$ ]] && kill -0 "$p" 2>/dev/null && { echo "$p"; return 0; }; fi
54 [[ -n $LANE_REPOS && ( $github == 1 || $cmd == stop ) ]] || return 1
55 for p in $(pgrep -u "$(id -u)" -x aien-test || true); do
56 mapfile -d '' a < "/proc/$p/cmdline" 2>/dev/null || continue
57 sd="" rp="" w=0 once=0
58 for ((i = 0; i < ${#a[@]}; i++)); do
59 case "${a[i]}" in
60 worker) w=1 ;; --once) once=1 ;;
61 --state-dir) sd=${a[i+1]:-} ;; --repos) rp=${a[i+1]:-} ;;
62 esac
63 done
64 if [[ $w == 1 && $once == 0 && $sd == "$STATE" && $rp == "$LANE_REPOS" ]]; then
65 echo "$p" > "$PIDFILE"; echo "$p"; return 0
66 fi
67 done
68 return 1
69}
70case "$cmd" in
71 status) exec "$BIN" status --state-dir "$STATE" ;;
72 start)
73 if p=$(lane_pid); then echo "worker ($lane) already running (pid $p)"; exit 0; fi
74 [[ $lane == main || $github == 1 ]] || { echo "lane $lane needs --github" >&2; exit 2; }
75 [[ -n $LANE_REPOS ]] || { echo "lane $lane needs --repos LIST" >&2; exit 2; }
76 extra=(); [[ $github == 1 ]] && extra=(--github --repos "$LANE_REPOS")
77 setsid nohup "$BIN" worker --poll "$POLL" --state-dir "$STATE" --clones "$CLONES" --sandbox user "${extra[@]}" >>"$LOG" 2>&1 < /dev/null &
78 echo $! > "$PIDFILE"; echo "worker ($lane) started (pid $!, log $LOG, github=${extra[0]:-off})" ;;
79 stop)
80 if p=$(lane_pid); then kill "$p"; echo "worker ($lane) stopped (pid $p)"; else echo "worker ($lane) not running"; fi
81 rm -f "$PIDFILE" ;;
82 trigger)
83 repo=${1:?repo}; sha=$(git -C "$CLONES/${1}" rev-parse --verify "${2:?sha}^{commit}" 2>/dev/null || { echo "unknown commit $2 in $CLONES/$1 (run: git -C $CLONES/$1 fetch --all)"; exit 2; })
84 set -- "$repo" "$sha"
85 repo=${1:?repo}; sha=${2:?sha}
86 printf 'manual 0000000000000000000000000000000000000000 %s %s\n' "$sha" "$(date -u +%Y-%m-%dT%H:%M:%SZ)" > "$STATE/trigger/$repo.$sha"
87 echo "trigger written: $STATE/trigger/$repo.$sha" ;;
88 verify) repo=${1:?repo}; sha=$(git -C "$CLONES/$repo" rev-parse --verify "${2:?sha}^{commit}") || exit 2; shift 2; cd "$CLONES/$repo" && exec "$BIN" verify "$sha" --repo "github.com/aien-dev/$repo" --state-dir "$STATE" "$@" ;;
89 once) repo=${1:?repo}; sha=$(git -C "$CLONES/$repo" fetch -q --all 2>/dev/null; git -C "$CLONES/$repo" rev-parse --verify "${2:?sha}^{commit}") || exit 2; shift 2; exec "$BIN" worker --once "$repo" "$sha" --state-dir "$STATE" --clones "$CLONES" --sandbox user "$@" ;;
90 plan) exec "$BIN" plan "$@" ;;
91 health) exec bash "$CLONES/aien-sovereign-core/tools/aien-local-ci/health.sh" "$@" ;;
92 log) tail -n "${1:-20}" "$STATE/journal.jsonl" 2>/dev/null || echo "no journal yet" ;;
93 *) sed -n '2,15p' "$0"; exit 2 ;;
94esac