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 / scripts / test-preflight-branch-guard.sh

43 lines · 2231 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# Verify the branch guard in both contexts using throwaway git repositories.
18set -euo pipefail
19GUARD="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/preflight-branch-guard.sh"
20WORK="$(mktemp -d "${TMPDIR:-/tmp}/aien-guard-test.XXXXXX")"
21trap 'rm -rf "$WORK"' EXIT
22cd "$WORK"
23git init -q -b main . && git -c user.name=t -c user.email=t@t commit -q --allow-empty -m init
24
25expect() { # want(0|1) description env...
26 local want="$1" desc="$2"; shift 2
27 local rc=0
28 env -u AIEN_PREFLIGHT_CONTEXT -u GITHUB_ACTIONS -u GITHUB_REF "$@" bash "$GUARD" >/dev/null 2>&1 || rc=$?
29 [ "$rc" -eq "$want" ] || { echo "FAIL: $desc (exit $rc, wanted $want)"; exit 1; }
30 echo "ok: $desc"
31}
32
33expect 1 "developer on main is refused" AIEN_PREFLIGHT_CONTEXT=developer
34expect 1 "default context on main is refused" AIEN_PREFLIGHT_NONE=1
35expect 0 "merged-tree on CI runner for main is accepted" AIEN_PREFLIGHT_CONTEXT=merged-tree GITHUB_ACTIONS=true GITHUB_REF=refs/heads/main
36expect 1 "merged-tree from a local shell is refused" AIEN_PREFLIGHT_CONTEXT=merged-tree
37expect 1 "merged-tree on CI for a PR ref is refused" AIEN_PREFLIGHT_CONTEXT=merged-tree GITHUB_ACTIONS=true GITHUB_REF=refs/pull/1/merge
38git checkout -q -b feat/x
39expect 0 "developer on feature branch is accepted" AIEN_PREFLIGHT_CONTEXT=developer
40expect 1 "unknown context is refused on a feature branch" AIEN_PREFLIGHT_CONTEXT=mereged-tree
41git checkout -q --detach
42expect 0 "developer on detached PR merge ref is accepted" AIEN_PREFLIGHT_CONTEXT=developer
43echo "PREFLIGHT_BRANCH_GUARD_TESTS_PASS"