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 / check-release-trust-config.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 | # Consistency check for the release trust configuration (D3, sc#385 and sc#118). Reads PUBLIC files only. |
| 18 | # scripts/check-release-trust-config.sh [--root DIR] [--allow-rehearsal] |
| 19 | # Two states are valid: |
| 20 | # PLACEHOLDER (before the key ceremony): docs/release/allowed_signers holds no key line, install.sh has |
| 21 | # AIEN_RELEASE_SIGNER='' and there is no docs/release/ceremony-record.txt. |
| 22 | # PINNED (after the ceremony): allowed_signers holds exactly one 'aien-release ssh-ed25519 <key>' line; install.sh |
| 23 | # AIEN_RELEASE_SIGNER is that same line; the line is not the internal test key; docs/release/ceremony-record.txt |
| 24 | # exists, says mode: ceremony, its allowed_signers line equals the pinned line, and its fingerprint equals the |
| 25 | # fingerprint ssh-keygen computes from the pinned line; no private key material is in any of the three files. |
| 26 | # Anything else exits 1 and says why. --allow-rehearsal accepts a REHEARSAL record (used only by the tests). |
| 27 | set -euo pipefail |
| 28 | ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"; REH=0 |
| 29 | while [[ $# -gt 0 ]]; do |
| 30 | case "$1" in |
| 31 | --root) ROOT="$(cd "${2:?--root needs a directory}" && pwd)"; shift ;; |
| 32 | --allow-rehearsal) REH=1 ;; |
| 33 | *) echo "usage: $0 [--root DIR] [--allow-rehearsal]" >&2; exit 2 ;; |
| 34 | esac |
| 35 | shift |
| 36 | done |
| 37 | die() { echo "trust config: REFUSED: $*" >&2; exit 1; } |
| 38 | AS="$ROOT/docs/release/allowed_signers"; REC="$ROOT/docs/release/ceremony-record.txt"; INST="$ROOT/install.sh" |
| 39 | INT="$ROOT/docs/release/internal_test_signers" |
| 40 | [[ -f "$AS" && -f "$INST" ]] || die "allowed_signers or install.sh is missing" |
| 41 | keylines() { grep -vE '^[[:space:]]*(#|$)' "$1" || true; } |
| 42 | pinned="$(sed -n "s/^AIEN_RELEASE_SIGNER='\(.*\)'\$/\1/p" "$INST")" |
| 43 | grep -qE '^AIEN_RELEASE_SIGNER=' "$INST" || die "install.sh has no AIEN_RELEASE_SIGNER line" |
| 44 | line="$(keylines "$AS")"; n="$(printf '%s' "$line" | grep -c . || true)" |
| 45 | for f in "$AS" "$INST" "$REC"; do |
| 46 | [[ ! -f "$f" ]] || ! grep -q 'PRIVATE KEY' "$f" || die "private key material found in $f" |
| 47 | done |
| 48 | if [[ "$n" -eq 0 ]]; then |
| 49 | [[ -z "$pinned" ]] || die "install.sh pins a release key but allowed_signers holds none" |
| 50 | [[ ! -e "$REC" ]] || die "a ceremony record exists but allowed_signers is still the placeholder" |
| 51 | grep -q PLACEHOLDER "$AS" || die "allowed_signers holds no key and is not labelled PLACEHOLDER" |
| 52 | echo "trust config: OK (PLACEHOLDER: no public-release key pinned, nothing can verify as a release)"; exit 0 |
| 53 | fi |
| 54 | [[ "$n" -eq 1 ]] || die "allowed_signers must pin exactly one key (found $n)" |
| 55 | [[ "$line" =~ ^aien-release\ ssh-ed25519\ [A-Za-z0-9+/]+=*$ ]] || die "the pinned line is not 'aien-release ssh-ed25519 <key>' with nothing else on it" |
| 56 | [[ "$pinned" == "$line" ]] || die "install.sh AIEN_RELEASE_SIGNER differs from the key line in allowed_signers" |
| 57 | if [[ -f "$INT" ]]; then |
| 58 | ik="$(keylines "$INT" | awk '{ print $3 }')" |
| 59 | [[ -z "$ik" || "$line" != *"$ik"* ]] || die "the pinned key is the internal test key" |
| 60 | fi |
| 61 | fp="$(printf '%s\n' "$line" | awk '{ print $2" "$3 }' | ssh-keygen -lf - 2>/dev/null | awk '{ print $2 }')" |
| 62 | [[ "$fp" == SHA256:* ]] || die "ssh-keygen cannot read the pinned key" |
| 63 | [[ -f "$REC" ]] || die "a key is pinned but docs/release/ceremony-record.txt is missing" |
| 64 | rv() { sed -n "s/^$1: //p" "$REC" | head -1; } |
| 65 | mode="$(rv mode)" |
| 66 | if [[ "$REH" == 1 && "$mode" == rehearsal ]]; then :; else |
| 67 | [[ "$mode" == ceremony ]] || die "ceremony record says mode '$mode', not 'ceremony' (a rehearsal key is never a release key)" |
| 68 | ! grep -qi REHEARSAL "$REC" "$AS" || die "REHEARSAL marker found; a rehearsal key is never a release key" |
| 69 | fi |
| 70 | [[ "$(rv allowed_signers)" == "$line" ]] || die "the ceremony record's allowed_signers line differs from the pinned line" |
| 71 | [[ "$(rv fingerprint)" == "$fp" ]] || die "the ceremony record fingerprint ($(rv fingerprint)) is not the fingerprint of the pinned key ($fp)" |
| 72 | for k in date-utc operator witness; do [[ -n "$(rv $k)" ]] || die "ceremony record has no $k"; done |
| 73 | [[ "$(grep -c 'signs and verifies yes; altered file refused yes' "$REC")" -ge 2 ]] || die "ceremony record does not show two verified backups" |
| 74 | grep -q 'altered file refused yes' "$REC" || die "ceremony record has no public-key verification test" |
| 75 | echo "trust config: OK (PINNED $fp; record: $(rv operator) with witness $(rv witness), $(rv date-utc))" |