Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/tools/aien-local-ci/pipeline.sh # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / tools / aien-local-ci / pipeline.sh` 444 lines ยท 24218 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 # pipeline.sh: Spark side of the local pipeline (ADR 0033, amended 2026-10-24: Spark qualification is the Alpha 18 # stage, not a merge gate). 19 # 20 # pipeline.sh publish|merge|alpha|round [--repos a,b] (round = publish, then merge, then alpha) 21 # 22 # publish copy every signed bundle the worker wrote ($STATE/bundles///bundle.json) that verifies 23 # (verify-bundle exit 0 PASS or 1 FAIL with a key from origin/main:.aien/verify.pub) byte-exact to the 24 # receipts clone, one commit per round, pull --rebase and push (3 attempts, never forced). 25 # merge merge open pull requests labeled exactly ready-to-merge that are not drafts and merge cleanly. No Spark 26 # bundle, no status check and no up-to-date requirement: the Spark never blocks a merge (Drake 2026-10-24). 27 # alpha tag the newest commit on main whose published bundle is a full-scope PASS (every gate, GPU included, 28 # `aien-test verify-bundle --require-full`) as alpha/YYYYMMDD.N, an annotated tag naming the bundle digest, 29 # and push the tag. Never moves a branch. Run `aien-alpha REPO` to qualify main's head on the Spark. 30 # 31 # It never reads the signing key and never signs anything. One instance at a time (flock; a second one exits 0). 32 # Every action and every refusal is one JSON line in $STATE/pipeline.jsonl. 33 # Exit: 0 round done (refusals included), 2 usage or configuration error. 34 set -euo pipefail 35 36 STATE=${AIEN_STATE:-$HOME/.local/state/aien-local-ci} 37 CLONES=${AIEN_CLONES:-$HOME/workspace/pipeline/clones} 38 RECEIPTS=${AIEN_RECEIPTS:-$HOME/workspace/pipeline/aien-receipts} 39 RECEIPTS_BRANCH=${AIEN_RECEIPTS_BRANCH:-main} 40 BIN=${AIEN_TEST_BIN:-$HOME/workspace/pipeline/target-sc/release/aien-test} 41 OWNER=${AIEN_GH_OWNER:-aien-dev} 42 REPOS=${AIEN_REPOS:-aien-sovereign-core,omega,aienux,physics,aien-protocols,aegis-runtime,spark-rsi,aien-architecture,benchmarks,synapse,interplane} 43 GH=${GH:-gh} 44 GIT=${GIT:-git} 45 MERGE_LABEL="ready-to-merge" 46 ALPHA_PREFIX="alpha/" 47 # alpha-held/: " " of the Alpha candidate last recorded as HELD_PUBLISH_BLOCKED (see do_alpha). 48 HELD_DIR=$STATE/alpha-held 49 # Receipts live on Radicle (RadBackend 2026-11-07): rad:`z4HXNamwwXyfN11ZBJXAQpdMKvojz`, fetched from the node storage; 50 # the push is signed by RadPublish (pushurl here is blocked). Was https://github.com/$OWNER/aien-receipts/blob/. 51 RECEIPTS_URL=${AIEN_RECEIPTS_URL:-https://radicle.network/nodes/rosa.radicle.network/rad:`z4HXNamwwXyfN11ZBJXAQpdMKvojz`/tree/$RECEIPTS_BRANCH} 52 53 usage() { echo "usage: pipeline.sh publish|merge|alpha|round [--repos a,b]" >&2; exit 2; } 54 die() { echo "pipeline.sh: $*" >&2; exit 2; } 55 56 [[ $# -ge 1 ]] || usage 57 cmd=$1; shift 58 case "$cmd" in publish|merge|alpha|round) ;; *) usage ;; esac 59 while [[ $# -gt 0 ]]; do 60 case "$1" in 61 --repos) [[ $# -ge 2 ]] || usage; REPOS=$2; shift 2 ;; 62 *) usage ;; 63 esac 64 done 65 IFS=, read -r -a repo_list <<< "$REPOS" 66 [[ ${#repo_list[@]} -gt 0 ]] || die "no repositories named" 67 for r in "${repo_list[@]}"; do 68 [[ $r =~ ^[A-Za-z0-9._-]+$ && $r != . && $r != .. ]] || die "bad repository name '$r'" 69 done 70 71 command -v jq >/dev/null || die "jq not found" 72 command -v flock >/dev/null || die "flock not found" 73 command -v sha256sum >/dev/null || die "sha256sum not found" 74 command -v "$GIT" >/dev/null || die "git ($GIT) not found" 75 [[ -d $CLONES ]] || die "clones directory $CLONES missing" 76 [[ -d $RECEIPTS/.git ]] || die "receipts clone $RECEIPTS is not a git clone" 77 [[ -x $BIN ]] || die "aien-test binary $BIN missing or not executable" 78 if [[ $cmd == merge || $cmd == round ]]; then command -v "$GH" >/dev/null || die "gh ($GH) not found"; fi 79 80 mkdir -p "$STATE" 81 JOURNAL=$STATE/pipeline.jsonl 82 exec 9>>"$STATE/pipeline.lock" 83 # A second instance exits 0 at once; AIEN_LOCK_WAIT=SECS (aien-alpha) waits that long for the running one instead. 84 if [[ ${AIEN_LOCK_WAIT:-0} =~ ^[1-9][0-9]*$ ]]; then flock -w "$AIEN_LOCK_WAIT" 9 || exit 0; else flock -n 9 || exit 0; fi 85 WORK=$(mktemp -d "$STATE/.pipeline.XXXXXX") 86 trap 'rm -rf "$WORK"' EXIT 87 GH_DEFER=$WORK/gh-deferred 88 # ghc ARGS...: every GitHub call goes through here. ~/.local/bin/gh (the shared rate-limit guard) exits 98 when it 89 # refuses (allowance reserved or rate-limit marker set): then this run makes no further GitHub call, and every 90 # journal line from then on carries deferred="gh guard exit 98: try next round". Never a retry loop, never a FAIL. 91 ghc() { 92 local rc=0 93 [[ -e $GH_DEFER ]] && return 98 94 "$GH" "$@" || rc=$? 95 [[ $rc != 98 ]] || : > "$GH_DEFER" 96 return "$rc" 97 } 98 99 # journal key=value ...: one JSON line in the journal (built by jq), a short line on stdout. 100 journal() { 101 local args=(--arg utc "$(date -u +%Y-%m-%dT%H:%M:%SZ)") kv 102 for kv in "$@"; do args+=(--arg "${kv%%=*}" "${kv#*=}"); done 103 [[ ! -e $GH_DEFER ]] || args+=(--arg deferred "gh guard exit 98: try next round") 104 jq -nc "${args[@]}" '$ARGS.named' >> "$JOURNAL" 105 echo "$*" 106 } 107 108 digest() { sha256sum "$1" | cut -d' ' -f1; } 109 110 # keys CLONE REF: the trusted public keys at REF, one per line (same rule as aien-test: '#' comments, 64 hex). 111 keys() { 112 "$GIT" -C "$1" show "$2:.aien/verify.pub" 2>/dev/null | sed 's/#.*//' | tr -d ' \t\r' | tr 'A-F' 'a-f' \ 113 | grep -E '^[0-9a-f]{64}$' || true 114 } 115 116 # anchor_gates CLONE SHA: the gates listed in .aien/always at the first parent of SHA (the trust anchor of 117 # aien-receipts tools/replay_receipt.py), comma separated in file order. Same parse as that tool: lines starting with 118 # '#' and blank lines are skipped, surrounding whitespace is stripped. Fails (no output) when SHA or its first parent 119 # is not in the trusted clone or that parent has no .aien/always. Never read from the bundle or from SHA itself: a 120 # commit that deletes a gate is still judged by the gates it was written against. 121 anchor_gates() { 122 local always 123 always=$("$GIT" -C "$1" show "$2^1:.aien/always" 2>/dev/null) || return 1 124 printf '%s\n' "$always" | awk '!/^#/ { gsub(/^[ \t\r\f\v]+|[ \t\r\f\v]+$/, ""); if (length) print }' \ 125 | paste -sd, - 126 } 127 128 # verify FILE REPO SHA KEYS [REQUIRE] [full] [hostonly]: verify-bundle with every key; prints the best exit code 129 # (0, 1, 2, 3, other) and the list of codes. --repo and --commit come from the caller (the path), never from the 130 # bundle. A sixth argument "full" adds --require-full: only a full-scope (Alpha) qualification can pass. A seventh 131 # argument "hostonly" adds --allow-host-only, which the alpha pass sets only when the repository's own gate 132 # manifests at origin/main declare no gb10 gate (see declares_gb10): a repository that declares one still needs 133 # its GPU run, so the Alpha rule keeps its teeth where it was written for. 134 verify() { 135 local file=$1 repo=$2 sha=$3 keylist=$4 require=${5:-} scope=${6:-} hostonly=${7:-} key rc codes="" best="" 136 local extra=() 137 [[ -n $require ]] && extra+=(--require "$require") 138 [[ $scope == full ]] && extra+=(--require-full) 139 [[ $hostonly == hostonly ]] && extra+=(--allow-host-only) 140 while IFS= read -r key; do 141 [[ -n $key ]] || continue 142 rc=0 143 "$BIN" verify-bundle "$file" --repo "github.com/$OWNER/$repo" --commit "$sha" --pubkey "$key" "${extra[@]}" \ 144 >/dev/null 2>&1 || rc=$? 145 codes+="${codes:+,}$rc" 146 done <<< "$keylist" 147 for rc in 0 1 2 3; do [[ ,$codes, == *",$rc,"* ]] && { best=$rc; break; }; done 148 echo "${best:-${codes%%,*}} ${codes:-none}" 149 } 150 151 # declares_gb10 CLONE REF: conservatively require GPU proof unless a successful 152 # search establishes absence. nvrm is a GPU alias in the manifest parser. JSON 153 # Unicode escapes are ambiguous to this text scan, so retain GPU proof for them 154 # too (possibly over-conservative for unrelated metadata). No manifests retains 155 # the existing host-only policy. A read error never grants a waiver. 156 declares_gb10() { 157 local rc=0 158 "$GIT" -C "$1" grep -F -q -l -e gb10 -e nvrm -e '\u' "$2" -- '*.gate' 2>/dev/null || rc=$? 159 [[ $rc != 1 ]] 160 } 161 162 verdict_name() { case "$1" in 0) echo PASS ;; 1) echo FAIL ;; 2) echo NOT_RUN ;; 3) echo REJECTED ;; *) echo "EXIT_$1" ;; esac; } 163 164 declare -A SLUGS=() 165 SLUG_DIR=$STATE/slugs 166 SLUG_TTL=${AIEN_SLUG_TTL:-86400} 167 # slug REPO: canonical owner/name on GitHub (aien-dev/ may redirect, e.g. to aien-dev/-mv), resolved once 168 # per run. Cached on disk in $STATE/slugs/: used while younger than AIEN_SLUG_TTL seconds (24 h); refreshed 169 # with one `gh api` call when missing or older; an older cached name is still used when the refresh fails (an 170 # exhausted API limit must not refuse every pull request). Every name, cached or fresh, passes the same regex. 171 slug() { 172 local s="" f=$SLUG_DIR/$1 age="" fresh 173 if [[ -z ${SLUGS[$1]:-} ]]; then 174 [[ -f $f ]] && { s=$(head -n 1 "$f"); age=$(( $(date +%s) - $(stat -c %Y "$f") )); } 175 if [[ -n $s && $age -lt $SLUG_TTL && $s =~ ^[A-Za-z0-9._-]+/[A-Za-z0-9._-]+$ ]]; then 176 journal action=slug repo="$1" result=cached slug="$s" >/dev/null 177 elif fresh=$(ghc api "repos/$OWNER/$1" --jq .full_name 2>/dev/null) && [[ $fresh =~ ^[A-Za-z0-9._-]+/[A-Za-z0-9._-]+$ ]]; then 178 s=$fresh 179 mkdir -p "$SLUG_DIR" && printf '%s\n' "$s" > "$f.tmp" && mv "$f.tmp" "$f" 180 journal action=slug repo="$1" result=refreshed slug="$s" >/dev/null 181 elif [[ -n $s && $s =~ ^[A-Za-z0-9._-]+/[A-Za-z0-9._-]+$ ]]; then 182 journal action=slug repo="$1" result=stale-cache slug="$s" reason="refresh failed, cache is ${age}s old" >/dev/null 183 else 184 return 1 185 fi 186 SLUGS[$1]=$s 187 fi 188 echo "${SLUGS[$1]}" 189 } 190 191 fetch_receipts() { "$GIT" -C "$RECEIPTS" fetch -q origin; } 192 193 do_publish() { 194 local branch dirty repo clone keylist require f sha tmp ldig dest old v best codes listed=() records=() n 195 branch=$("$GIT" -C "$RECEIPTS" symbolic-ref --short HEAD 2>/dev/null || true) 196 if [[ $branch != "$RECEIPTS_BRANCH" ]]; then 197 journal action=publish result=refused reason="receipts clone is on '$branch', not $RECEIPTS_BRANCH"; return 0 198 fi 199 dirty=$("$GIT" -C "$RECEIPTS" status --porcelain) 200 if [[ -n $dirty ]]; then 201 journal action=publish result=refused reason="receipts clone has uncommitted changes"; return 0 202 fi 203 if ! "$GIT" -C "$RECEIPTS" pull -q --rebase origin "$RECEIPTS_BRANCH"; then 204 journal action=publish result=refused reason="receipts pull failed"; return 0 205 fi 206 for repo in "${repo_list[@]}"; do 207 [[ -d $STATE/bundles/$repo ]] || continue 208 clone=$CLONES/$repo 209 if [[ ! -d $clone ]]; then journal action=publish repo="$repo" result=skipped reason="no trusted clone"; continue; fi 210 if ! "$GIT" -C "$clone" fetch -q origin; then 211 journal action=publish repo="$repo" result=skipped reason="fetch of trusted clone failed"; continue 212 fi 213 keylist=$(keys "$clone" origin/main) 214 if [[ -z $keylist ]]; then 215 journal action=publish repo="$repo" result=skipped reason="not enrolled (no key in origin/main:.aien/verify.pub)"; continue 216 fi 217 for f in "$STATE/bundles/$repo"/*/bundle.json; do 218 [[ -f $f ]] || continue 219 sha=$(basename "$(dirname "$f")") 220 [[ $sha =~ ^[0-9a-f]{40}$ ]] || continue 221 tmp=$WORK/candidate.json 222 cp -- "$f" "$tmp" 223 ldig=$(digest "$tmp") 224 dest=$RECEIPTS/$repo/$sha/bundle.json 225 old="" 226 if [[ -f $dest ]]; then old=$(digest "$dest"); [[ $old == "$ldig" ]] && continue; fi 227 if ! jq -e '.plan | has("blocked")' "$tmp" >/dev/null 2>&1; then 228 journal action=publish repo="$repo" sha="$sha" result=refused reason="bundle unreadable or has no plan.blocked"; continue 229 fi 230 if ! jq -e '.plan.blocked == null' "$tmp" >/dev/null; then 231 journal action=publish repo="$repo" sha="$sha" result=skipped reason="plan.blocked is not null"; continue 232 fi 233 # Required gates come from the trust anchor (first parent's .aien/always), never from the bundle: with no 234 # --require, verify-bundle checks only what the bundle itself marks required, so a commit that removed a gate 235 # from its own plan published as PASS (aien-receipts `264da364`, finding F2). 236 if ! require=$(anchor_gates "$clone" "$sha"); then 237 journal action=publish repo="$repo" sha="$sha" result=refused \ 238 reason="no trust anchor: $sha^1:.aien/always is not in the trusted clone"; continue 239 fi 240 v=$(verify "$tmp" "$repo" "$sha" "$keylist" "$require"); best=${v%% *}; codes=${v#* } 241 if [[ $best != 0 && $best != 1 ]]; then 242 journal action=publish repo="$repo" sha="$sha" result=refused \ 243 reason="verify-bundle $(verdict_name "$best") (exit codes per key: $codes)"; continue 244 fi 245 mkdir -p "$(dirname "$dest")" 246 cp -- "$tmp" "$dest" 247 "$GIT" -C "$RECEIPTS" add -- "$repo/$sha/bundle.json" 248 listed+=("$repo/$sha $(verdict_name "$best") sha256:$ldig${old:+ replaces sha256:$old}") 249 records+=("$repo $sha $ldig $(verdict_name "$best")") 250 done 251 done 252 n=${#listed[@]} 253 [[ $n -gt 0 ]] || return 0 254 if ! "$GIT" -C "$RECEIPTS" commit -q -m "publish $n bundle(s)" -m "$(printf '%s\n' "${listed[@]}")"; then 255 "$GIT" -C "$RECEIPTS" reset -q --hard "origin/$RECEIPTS_BRANCH" 256 journal action=publish result=failed reason="receipts commit failed"; return 0 257 fi 258 local attempt pushed=0 259 for attempt in 1 2 3; do 260 if "$GIT" -C "$RECEIPTS" push -q origin "HEAD:$RECEIPTS_BRANCH"; then pushed=1; break; fi 261 if ! "$GIT" -C "$RECEIPTS" pull -q --rebase origin "$RECEIPTS_BRANCH"; then 262 "$GIT" -C "$RECEIPTS" rebase --abort 2>/dev/null || true 263 break 264 fi 265 done 266 local rec 267 if [[ $pushed == 1 ]]; then 268 for rec in "${records[@]}"; do 269 read -r repo sha ldig v <<< "$rec" 270 journal action=publish repo="$repo" sha="$sha" result=published verdict="$v" digest="$ldig" reason="pushed" 271 done 272 else 273 # Only this round's own commit is dropped (the tree was clean before); the next round recomputes it. 274 "$GIT" -C "$RECEIPTS" fetch -q origin 2>/dev/null || true 275 "$GIT" -C "$RECEIPTS" reset -q --hard "origin/$RECEIPTS_BRANCH" 276 for rec in "${records[@]}"; do 277 read -r repo sha ldig v <<< "$rec" 278 journal action=publish repo="$repo" sha="$sha" result=failed digest="$ldig" reason="push failed after 3 attempts" 279 done 280 fi 281 } 282 283 # merge_one REPO SLUG NUM SHA: the PR is still at SHA, not a draft, and merges without conflicts. Nothing else: 284 # no bundle, no status check, no up-to-date rule. Journals the outcome. 285 merge_one() { 286 local repo=$1 s=$2 num=$3 sha=$4 pr state head draft 287 merge_refuse() { journal action=merge repo="$repo" pr="$num" sha="$sha" result=refused reason="$1"; } 288 if ! pr=$(ghc api "repos/$s/pulls/$num" --jq '"\(.mergeable_state // "unknown") \(.head.sha) \(.draft)"'); then 289 merge_refuse "cannot read pull request"; return 0 290 fi 291 read -r state head draft <<< "$pr" 292 [[ $head == "$sha" ]] || { merge_refuse "head moved to $head"; return 0; } 293 [[ $draft == false ]] || { merge_refuse "draft"; return 0; } 294 case $state in 295 clean|behind|has_hooks) ;; 296 unstable) 297 # GitHub says "unstable" when a check failed or is still running and no branch rule 298 # requires it. A failed hosted check (crumb verify, fmt, tests) is a refusal, not a 299 # formality: on 2026-10-25 sc#751 merged on CRUMB-VERIFY FAIL and left main with stale 300 # crumbs. Pending checks: wait for the next round. 301 local runs 302 if ! runs=$(ghc api "repos/$s/commits/$head/check-runs?per_page=100" \ 303 --jq '[.check_runs[] | {name, status, conclusion}]'); then 304 merge_refuse "cannot read the head's check runs"; return 0 305 fi 306 local failed pending 307 # A completed run must explicitly name an accepted result. Stale, null, missing 308 # and future conclusions are not success; unfinished runs still wait below. 309 failed=$(jq -r '[.[] | select(.status == "completed" and (.conclusion | IN("success","skipped","neutral") | not)) | .name] | join(", ")' <<< "$runs") 310 [[ -z $failed ]] || { merge_refuse "hosted checks failed on this head: $failed"; return 0; } 311 pending=$(jq -r '[.[] | select(.status != "completed") | .name] | join(", ")' <<< "$runs") 312 if [[ -n $pending ]]; then 313 journal action=merge repo="$repo" pr="$num" sha="$sha" result=wait reason="hosted checks still running: $pending" 314 return 0 315 fi ;; 316 dirty) merge_refuse "conflicts with the base: merge the base in and push"; return 0 ;; 317 unknown) 318 journal action=merge repo="$repo" pr="$num" sha="$sha" result=wait reason="GitHub has not computed mergeability yet" 319 return 0 ;; 320 *) merge_refuse "mergeable state $state"; return 0 ;; 321 esac 322 if ghc pr merge "$num" -R "$s" --merge --match-head-commit "$sha"; then 323 journal action=merge repo="$repo" pr="$num" sha="$sha" result=merged reason="labeled, not a draft, merges cleanly ($state)" 324 else 325 journal action=merge repo="$repo" pr="$num" sha="$sha" result=failed reason="gh pr merge failed" 326 fi 327 } 328 329 do_merge() { 330 local repo s prs num sha draft labeled 331 # Drake 2026-10-18: "stop all agents from trying to merge". Merge-only stop; publish and alpha keep going. 332 if [[ -e $STATE/MERGE-PAUSE ]]; then journal action=merge result=paused reason="MERGE-PAUSE present"; return 0; fi 333 for repo in "${repo_list[@]}"; do 334 if ! s=$(slug "$repo"); then journal action=merge repo="$repo" result=refused reason="cannot resolve GitHub slug"; continue; fi 335 if ! prs=$(ghc api "repos/$s/pulls?state=open&per_page=100" --jq \ 336 ".[] | [.number, .head.sha, .draft, ([.labels[].name] | index(\"$MERGE_LABEL\") != null)] | @tsv"); then 337 journal action=merge repo="$repo" result=refused reason="cannot list pull requests"; continue 338 fi 339 while IFS=$'\t' read -r num sha draft labeled; do 340 [[ -n $num ]] || continue 341 # Unlabeled pull requests are not the pipeline's to merge: skipped without a journal line (every round). 342 [[ $labeled == true ]] || continue 343 if [[ ! $sha =~ ^[0-9a-f]{40}$ ]]; then 344 journal action=merge repo="$repo" pr="$num" result=refused reason="bad head sha"; continue 345 fi 346 if [[ $draft != false ]]; then 347 journal action=merge repo="$repo" pr="$num" sha="$sha" result=refused reason="draft"; continue 348 fi 349 merge_one "$repo" "$s" "$num" "$sha" 350 done <<< "$prs" 351 done 352 } 353 354 # alpha_name CLONE: the next free alpha/YYYYMMDD.N name (UTC date, N from 1). 355 alpha_name() { 356 local day n=1 357 day=$(date -u +%Y%m%d) 358 while "$GIT" -C "$1" rev-parse -q --verify "refs/tags/$ALPHA_PREFIX$day.$n" >/dev/null; do n=$((n + 1)); done 359 echo "$ALPHA_PREFIX$day.$n" 360 } 361 362 # do_alpha: per repository, the newest commit on origin/main with a published full-scope PASS bundle becomes the next 363 # Alpha, unless it already carries an alpha tag or the current Alpha already contains it. 364 do_alpha() { 365 local repo clone keylist require cands sha tmp v best best_sha best_time t latest name dig msg hostonly purl held 366 if ! fetch_receipts; then journal action=alpha result=refused reason="receipts fetch failed"; return 0; fi 367 for repo in "${repo_list[@]}"; do 368 clone=$CLONES/$repo 369 [[ -d $clone ]] || continue 370 # One cheap scan per repository: only bundles whose signed plan says scope full are looked at. 371 cands=$("$GIT" -C "$RECEIPTS" grep -lE '"scope"[[:space:]]*:[[:space:]]*"full"' "origin/$RECEIPTS_BRANCH" -- "$repo/" 2>/dev/null \ 372 | sed -n "s|^origin/$RECEIPTS_BRANCH:$repo/\([0-9a-f]\{40\}\)/bundle.json\$|\1|p" || true) 373 [[ -n $cands ]] || continue 374 if ! "$GIT" -C "$clone" fetch -q origin main '+refs/tags/alpha/*:refs/tags/alpha/*'; then 375 journal action=alpha repo="$repo" result=refused reason="fetch of trusted clone failed"; continue 376 fi 377 keylist=$(keys "$clone" origin/main) 378 if [[ -z $keylist ]]; then 379 journal action=alpha repo="$repo" result=skipped reason="not enrolled (no key in origin/main:.aien/verify.pub)"; continue 380 fi 381 require=$("$GIT" -C "$clone" show "origin/main:.aien/always" 2>/dev/null | grep -v '^#' | grep -v '^$' | paste -sd, - || true) 382 best_sha="" best_time=0 383 while IFS= read -r sha; do 384 "$GIT" -C "$clone" merge-base --is-ancestor "$sha" origin/main 2>/dev/null || continue 385 t=$("$GIT" -C "$clone" log -1 --format=%ct "$sha") 386 (( t > best_time )) || continue 387 tmp=$WORK/alpha.json 388 "$GIT" -C "$RECEIPTS" show "origin/$RECEIPTS_BRANCH:$repo/$sha/bundle.json" > "$tmp" 2>/dev/null || continue 389 # Check both the trusted current policy and the candidate's committed 390 # manifests. Removing a GPU gate later cannot waive an older candidate. 391 hostonly="" 392 if ! declares_gb10 "$clone" origin/main && ! declares_gb10 "$clone" "$sha"; then 393 hostonly=hostonly 394 fi 395 v=$(verify "$tmp" "$repo" "$sha" "$keylist" "$require" full "$hostonly"); best=${v%% *} 396 if [[ $best != 0 ]]; then 397 journal action=alpha repo="$repo" sha="$sha" result=skipped reason="verify-bundle --require-full $(verdict_name "$best")" 398 continue 399 fi 400 best_sha=$sha best_time=$t 401 done <<< "$cands" 402 [[ -n $best_sha ]] || continue 403 [[ -z $("$GIT" -C "$clone" tag -l "${ALPHA_PREFIX}*" --points-at "$best_sha") ]] || continue 404 latest=$("$GIT" -C "$clone" for-each-ref --sort=-creatordate --count=1 --format='%(*objectname)' "refs/tags/${ALPHA_PREFIX%/}/") 405 if [[ -n $latest ]] && "$GIT" -C "$clone" merge-base --is-ancestor "$best_sha" "$latest" 2>/dev/null; then continue; fi 406 # An Alpha tag is public. A push URL of the form blocked-:// (how the desk holds a clone; pushInsteadOf 407 # included, get-url expands it) means publishing is held: no tag is made and nothing is pushed. The hold is 408 # journaled once per candidate and push URL (state in $HELD_DIR/); it is looked at again only when the 409 # candidate or the URL changes. Any other push failure keeps the old path (tag deleted, retried next round). 410 purl=$("$GIT" -C "$clone" remote get-url --push origin 2>/dev/null || true) 411 if [[ $purl =~ ^blocked-[A-Za-z0-9.+-]*: ]]; then 412 held="$best_sha $purl" 413 if [[ $(cat "$HELD_DIR/$repo" 2>/dev/null) != "$held" ]]; then 414 mkdir -p "$HELD_DIR" && printf '%s\n' "$held" > "$HELD_DIR/$repo.tmp" && mv -f "$HELD_DIR/$repo.tmp" "$HELD_DIR/$repo" 415 journal action=alpha repo="$repo" sha="$best_sha" result=held reason="HELD_PUBLISH_BLOCKED: push URL $purl" 416 fi 417 continue 418 fi 419 rm -f "$HELD_DIR/$repo" 420 name=$(alpha_name "$clone") 421 "$GIT" -C "$RECEIPTS" show "origin/$RECEIPTS_BRANCH:$repo/$best_sha/bundle.json" > "$WORK/alpha.json" 422 dig=$(digest "$WORK/alpha.json") 423 msg=$(printf 'Alpha: %s %s\n\nEvery gate passed on the Spark: full-scope qualification, GPU gates included.\nbundle: sha256:%s\nreceipt: %s/%s/%s/bundle.json\nchecked: aien-test verify-bundle --require-full, exit 0 (PASS)\n' \ 424 "$repo" "$best_sha" "$dig" "$RECEIPTS_URL" "$repo" "$best_sha") 425 if ! GIT_COMMITTER_NAME=${AIEN_TAGGER_NAME:-AIEN Spark pipeline} GIT_COMMITTER_EMAIL=${AIEN_TAGGER_EMAIL:-aien-spark@users.noreply.github.com} \ 426 "$GIT" -C "$clone" tag -a "$name" "$best_sha" -m "$msg"; then 427 journal action=alpha repo="$repo" sha="$best_sha" result=failed reason="git tag $name failed"; continue 428 fi 429 if "$GIT" -C "$clone" push -q origin "refs/tags/$name"; then 430 journal action=alpha repo="$repo" sha="$best_sha" tag="$name" digest="$dig" result=tagged reason="full-scope PASS on main" 431 else 432 "$GIT" -C "$clone" tag -d "$name" >/dev/null 433 journal action=alpha repo="$repo" sha="$best_sha" tag="$name" result=failed reason="tag push failed" 434 fi 435 done 436 } 437 438 case "$cmd" in 439 publish) do_publish ;; 440 merge) do_merge ;; 441 alpha) do_alpha ;; 442 round) do_publish; do_merge; do_alpha ;; 443 esac 444 exit 0