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