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-release-gate-wiring.sh

122 lines · 7646 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# Static guard for where the release gate blocks (merge-owner decision on sovereign-core#268, 2026-10-07):
18# release.yml (tag push): every step that runs scripts/check-release-candidate.sh is fail-closed. The only
19# continue-on-error allowed anywhere in the file is the manual dry run:
20# continue-on-error: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }}
21# release-dry-run.yml (every pull request): only the step that runs check-release-candidate.sh on this revision
22# may be non-blocking (main may move ahead of the candidate); the publish guard and the refusal suite
23# (test-release-real-tree.sh) block.
24# scripts/test-release-gate-wiring.sh [release.yml] [release-dry-run.yml]
25# Mutation note: the self-checks below inject `continue-on-error: true` into the tag gate step (plain, and hidden
26# behind a comment holding the allowed text), weaken the allowed expression, drop the tag gate, put an `if:` on the gate
27# step and on its job, and make the refusal suite non-blocking or conditional; each must turn this guard red.
28set -euo pipefail
29ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
30REL="${1:-$ROOT/.github/workflows/release.yml}"
31DRY="${2:-$ROOT/.github/workflows/release-dry-run.yml}"
32ALLOWED="continue-on-error: \${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }}"
33
34# One line per step: "<continue-on-error value or NONE>\t<IF or NOIF>\t<step text, joined>". A step starts at any
35# "- key:" list item and ends at the next step, a job key (two-space indent) or a top-level key. IF means the step
36# carries its own `if:` condition.
37steps() {
38 awk '
39 function flush() { if (inside) printf "%s\t%s\t%s\n", (coe == "" ? "NONE" : coe), (cond ? "IF" : "NOIF"), run
40 inside = 0; coe = ""; run = ""; cond = 0 }
41 /^[[:space:]]*- [a-zA-Z_-]+:/ { flush(); inside = 1 }
42 /^([a-z]| [a-z])[a-zA-Z_-]*:/ { flush() }
43 inside && /^[[:space:]]*(- )?if:/ { cond = 1 }
44 inside && /^[[:space:]]*continue-on-error:/ { sub(/^[[:space:]]*/, ""); coe = $0; next }
45 inside { run = run " " $0 }
46 END { flush() }
47 ' "$1"
48}
49
50# Jobs (two-space key under jobs:) that carry a job-level `if:` (four-space indent) and run the release gate.
51conditional_gate_jobs() {
52 awk '
53 function flush() { if (job != "" && cond && gate) print job; job = ""; cond = 0; gate = 0 }
54 /^[a-z]/ { flush(); injobs = ($0 ~ /^jobs:/); next }
55 injobs && /^ [a-zA-Z_-]+:/ { flush(); job = $1; next }
56 injobs && /^ if:/ { cond = 1 }
57 injobs && /check-release-candidate\.sh/ { gate = 1 }
58 END { flush() }
59 ' "$1"
60}
61
62check_release() {
63 local f="$1" gates bad line
64 gates="$(steps "$f" | grep -c 'check-release-candidate\.sh' || true)"
65 [[ "$gates" -ge 2 ]] || { echo "FAIL: $f runs check-release-candidate.sh in $gates step(s), expected the tree and package gates" >&2; return 1; }
66 # every continue-on-error must be exactly the manual dry-run expression: no other value, no trailing comment
67 while IFS= read -r line; do
68 line="${line#"${line%%[![:space:]]*}"}"; line="${line%"${line##*[![:space:]]}"}"
69 [[ "$line" == "$ALLOWED" ]] || { echo "FAIL: $f has a continue-on-error other than the manual dry run: $line" >&2; return 1; }
70 done < <(grep -E '^[[:space:]]*continue-on-error:' "$f" || true)
71 # a gate step, or the job around it, must not carry a condition that can skip it
72 bad="$(steps "$f" | awk -F'\t' '$2 == "IF" && $3 ~ /check-release-candidate\.sh/' || true)"
73 [[ -z "$bad" ]] || { echo "FAIL: $f has an if: on a release gate step: $bad" >&2; return 1; }
74 bad="$(conditional_gate_jobs "$f")"
75 [[ -z "$bad" ]] || { echo "FAIL: $f has a job-level if: on a job that runs the release gate: $bad" >&2; return 1; }
76 grep -qE '^[[:space:]]+tags:' "$f" || { echo "FAIL: $f no longer runs on tag push" >&2; return 1; }
77}
78
79check_dry() {
80 local f="$1" coe cond run
81 local saw_tree=0 saw_suite=0 saw_guard=0
82 while IFS=$'\t' read -r coe cond run; do
83 if [[ "$run" == *test-release-real-tree.sh* ]]; then
84 saw_suite=1; [[ "$coe" == NONE && "$cond" == NOIF ]] || { echo "FAIL: $f refusal suite is not blocking ($coe, $cond)" >&2; return 1; }
85 elif [[ "$run" == *test-dry-run-workflow.sh* || "$run" == *test-release-gate-wiring.sh* ]]; then
86 saw_guard=1; [[ "$coe" == NONE && "$cond" == NOIF ]] || { echo "FAIL: $f static guard is not blocking ($coe, $cond)" >&2; return 1; }
87 elif [[ "$run" == *check-release-candidate.sh* ]]; then
88 saw_tree=1
89 elif [[ "$coe" != NONE ]]; then
90 echo "FAIL: $f has a non-blocking step other than the tree report: $run" >&2; return 1
91 fi
92 done < <(steps "$f")
93 [[ $saw_tree == 1 && $saw_suite == 1 && $saw_guard == 1 ]] || { echo "FAIL: $f lacks the tree report, refusal suite or static guard" >&2; return 1; }
94}
95
96check_release "$REL"
97check_dry "$DRY"
98
99# self-checks: each mutation of a copy must apply (differ from the original) and be refused
100M="$(mktemp -d)"; trap 'rm -rf "$M"' EXIT
101n=0
102must_refuse() { local what="$1" kind="$2" src="$3" mut="$4"
103 cmp -s "$src" "$mut" && { echo "FAIL: mutation did not apply ($what); update this guard" >&2; exit 1; }
104 if "$kind" "$mut" 2>/dev/null; then echo "FAIL: guard does not catch: $what" >&2; exit 1; fi
105 n=$((n + 1)); }
106sed '/^[[:space:]]*id: gate$/a\ continue-on-error: true' "$REL" > "$M/r1"
107must_refuse "continue-on-error: true on the tag gate" check_release "$REL" "$M/r1"
108sed "s/github.event_name == 'workflow_dispatch' \&\& inputs.dry_run/inputs.dry_run || true/" "$REL" > "$M/r2"
109must_refuse "weakened dry-run expression" check_release "$REL" "$M/r2"
110grep -v 'run: scripts/check-release-candidate.sh$' "$REL" > "$M/r3"
111must_refuse "tree gate removed" check_release "$REL" "$M/r3"
112sed "/^[[:space:]]*id: gate\$/a\\ if: github.event_name != 'push'" "$REL" > "$M/r4"
113must_refuse "if: on the tag gate step" check_release "$REL" "$M/r4"
114awk -v allowed="$ALLOWED" 'f == 0 && (i = index($0, allowed)) { $0 = substr($0, 1, i - 1) "continue-on-error: true # " allowed; f = 1 } 1' "$REL" > "$M/r5"
115must_refuse "continue-on-error: true hidden behind a comment holding the allowed text" check_release "$REL" "$M/r5"
116sed "/^ build-release:\$/a\\ if: github.event_name != 'push'" "$REL" > "$M/r6"
117must_refuse "job-level if: on the job that runs the gate" check_release "$REL" "$M/r6"
118sed '/run: bash scripts\/test-release-real-tree.sh/i\ continue-on-error: true' "$DRY" > "$M/d1"
119must_refuse "refusal suite made non-blocking" check_dry "$DRY" "$M/d1"
120sed '/run: bash scripts\/test-release-real-tree.sh/i\ if: false' "$DRY" > "$M/d2"
121must_refuse "refusal suite skipped by if:" check_dry "$DRY" "$M/d2"
122echo "ok: tag release gate is fail-closed (only the manual dry run may continue, no condition on a gate step or its job); dry run blocks on the publish guard and the refusal suite; $n mutants refused"