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

64 lines · 3889 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# 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.
22set -u
23TICK=$(readlink -f "${1:?usage: cron_tick_test.sh <cron-tick.sh>}")
24T=$(mktemp -d); trap 'rm -rf "$T"' EXIT
25pass=0; fail=0
26ok() { pass=$((pass+1)); echo "ok $1"; }
27bad() { fail=$((fail+1)); echo "FAIL $1: $2"; }
28B=$T/.local/bin; L=$T/.local/lib/aien-local-ci; S=$T/.local/state/aien-local-ci; LOG=$T/calls
29mkdir -p "$B" "$L" "$S"
30stub() { printf '#!/bin/sh\necho "%s $*" >> "%s"\n%s\n' "$1" "$LOG" "${2:-}" > "$3"; chmod +x "$3"; }
31stub sibling-map-check 'echo "sibling-map-check: 3 pass, 0 FAIL"' "$B/sibling-map-check"
32stub aien-local-ci '' "$B/aien-local-ci"
33stub crumb-doctor '' "$B/crumb-doctor"
34stub pipeline.sh '' "$L/pipeline.sh"
35stub rebase-train.sh '' "$L/rebase-train.sh"
36stub desk-loop.sh '' "$L/desk-loop.sh"
37run() { : > "$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
41run
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]"
48grep -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
51run
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]"
54touch -d '-20 min' "$S/sibling-map.last"
55run
56[[ $calls == *"sibling-map-check --heal --alert"* ]] && ok "result older than 14 min: background run again" || bad "stale last" "calls=[$calls]"
57
58touch "$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]"
60rm -f "$S/KEEP-RUNNING"
61
62touch "$S/PAUSE"; run
63(( rc == 0 )) && [ -z "$calls" ] && ok "PAUSE: exit 0, nothing called" || bad "pause" "rc=$rc calls=[$calls]"
64echo "cron-tick tests: $pass passed, $fail failed"; (( fail == 0 ))