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 / tests / cron_tick_test.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 | # cron_tick_test.sh <cron-tick.sh>: runs the tick under a throwaway HOME whose ~/.local/bin and |
| 18 | # ~/.local/lib/aien-local-ci hold logging stubs (the tick puts $HOME/.local/bin first on PATH), and checks what it |
| 19 | # calls: the sibling map guard (every tick, and the background --heal --alert at most every 15 minutes), the |
| 20 | # trigger-only worker, then `pipeline.sh round`; never crumb-doctor or rebase-train.sh; nothing with PAUSE; |
| 21 | # desk-loop.sh instead of the round with KEEP-RUNNING. Nothing real runs: every program it names is a stub. |
| 22 | set -u |
| 23 | TICK=$(readlink -f "${1:?usage: cron_tick_test.sh <cron-tick.sh>}") |
| 24 | T=$(mktemp -d); trap 'rm -rf "$T"' EXIT |
| 25 | pass=0; fail=0 |
| 26 | ok() { pass=$((pass+1)); echo "ok $1"; } |
| 27 | bad() { fail=$((fail+1)); echo "FAIL $1: $2"; } |
| 28 | B=$T/.local/bin; L=$T/.local/lib/aien-local-ci; S=$T/.local/state/aien-local-ci; LOG=$T/calls |
| 29 | mkdir -p "$B" "$L" "$S" |
| 30 | stub() { printf '#!/bin/sh\necho "%s $*" >> "%s"\n%s\n' "$1" "$LOG" "${2:-}" > "$3"; chmod +x "$3"; } |
| 31 | stub sibling-map-check 'echo "sibling-map-check: 3 pass, 0 FAIL"' "$B/sibling-map-check" |
| 32 | stub aien-local-ci '' "$B/aien-local-ci" |
| 33 | stub crumb-doctor '' "$B/crumb-doctor" |
| 34 | stub pipeline.sh '' "$L/pipeline.sh" |
| 35 | stub rebase-train.sh '' "$L/rebase-train.sh" |
| 36 | stub desk-loop.sh '' "$L/desk-loop.sh" |
| 37 | run() { : > "$LOG"; HOME=$T bash "$TICK" > "$T/out" 2>&1; rc=$? |
| 38 | for _ in 1 2 3 4 5 6 7 8 9 10; do flock -n "$S/sibling-map.lock" true 2>/dev/null && break; sleep 0.2; done |
| 39 | calls=$(cat "$LOG"); } |
| 40 | |
| 41 | run |
| 42 | (( rc == 0 )) && [[ $calls == *"sibling-map-check --heal-only"* ]] && [[ $calls == *"sibling-map-check --heal --alert"* ]] \ |
| 43 | && ok "first tick: sibling map guard, heal-only and the background --heal --alert" || bad "guard" "rc=$rc calls=[$calls] $(cat "$T/out")" |
| 44 | [[ $calls == *"aien-local-ci start"* ]] && [[ $calls == *"pipeline.sh round"* ]] \ |
| 45 | && ok "trigger-only worker kept alive, then pipeline.sh round" || bad "round" "calls=[$calls]" |
| 46 | [[ $calls != *crumb-doctor* ]] && [[ $calls != *rebase-train* ]] && [[ $calls != *desk-loop* ]] \ |
| 47 | && ok "never crumb-doctor, rebase-train.sh or desk-loop.sh" || bad "retired parts" "calls=[$calls]" |
| 48 | grep -q 'sibling-map-check: 3 pass, 0 FAIL' "$S/sibling-map.last" && grep -q 'sibling-map-check: 3 pass, 0 FAIL' "$S/sibling-map.log" \ |
| 49 | && ok "background run's result kept in sibling-map.last and logged" || bad "last" "$(cat "$S/sibling-map.last" 2>&1)" |
| 50 | |
| 51 | run |
| 52 | (( rc == 0 )) && [[ $calls == *"sibling-map-check --heal-only"* ]] && [[ $calls != *"--heal --alert"* ]] \ |
| 53 | && ok "second tick inside 15 min: heal-only, no background run" || bad "rate" "rc=$rc calls=[$calls]" |
| 54 | touch -d '-20 min' "$S/sibling-map.last" |
| 55 | run |
| 56 | [[ $calls == *"sibling-map-check --heal --alert"* ]] && ok "result older than 14 min: background run again" || bad "stale last" "calls=[$calls]" |
| 57 | |
| 58 | touch "$S/KEEP-RUNNING"; run; sleep 1; calls=$(cat "$LOG") |
| 59 | [[ $calls == *"desk-loop.sh"* ]] && [[ $calls != *"pipeline.sh round"* ]] && ok "KEEP-RUNNING: desk-loop.sh instead of the round" || bad "keep-running" "calls=[$calls]" |
| 60 | rm -f "$S/KEEP-RUNNING" |
| 61 | |
| 62 | touch "$S/PAUSE"; run |
| 63 | (( rc == 0 )) && [ -z "$calls" ] && ok "PAUSE: exit 0, nothing called" || bad "pause" "rc=$rc calls=[$calls]" |
| 64 | echo "cron-tick tests: $pass passed, $fail failed"; (( fail == 0 )) |