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/scripts/golden_path.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 / scripts / golden_path.sh` 304 lines ยท 13234 bytes Raw Blame History 1 # SPDX-License-Identifier: Apache-2.0 2 # Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 if [ "$SKIP_BUILD" -eq 0 ] || [ ! -x "$BIN" ]; then 17 echo "== Building release binary ==" 18 # Step 1 of the gate is "clean checkout, one command": scripts/pins.sh --gpu writes 19 # target/pins/env.sh so the real omega libraries link (sovereign-core #92). Without it 20 # the build carries the CPU stubs and step 2 (GB10) cannot pass. 21 if [ -f "$REPO_ROOT/target/pins/env.sh" ]; then 22 # shellcheck disable=SC1091 23 . "$REPO_ROOT/target/pins/env.sh" 24 else 25 echo "WARNING: no target/pins/env.sh (run scripts/pins.sh --gpu first); building with the CPU stubs" 26 fi#!/usr/bin/env bash 27 # AIEN 0.1 Native Golden Path acceptance harness. 28 # Executes the 10-step release gate from docs/NATIVE_GOLDEN_PATH.md against a 29 # freshly booted daemon and prints one verdict line per step. 30 # 31 # Usage: 32 # bash scripts/golden_path.sh [--skip-build] 33 # 34 # Environment: 35 # AIEN_GP_STRICT=1 any PARTIAL step fails the gate (default: PARTIAL warns) 36 # AIEN_RUNTIME_SOCK daemon socket (default /tmp/aien-runtime.sock) 37 # AIEN_CORTEX_URL Cortex base URL (default http://127.0.0.1:18080) 38 # 39 # Exit codes: 0 all steps PASS, 1 at least one FAIL, 2 only PARTIAL (non strict). 40 set -u 41 42 REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" 43 BIN="$REPO_ROOT/target/release/aien-cli" 44 SOCK="${AIEN_RUNTIME_SOCK:-/tmp/aien-runtime.sock}" 45 CORTEX_URL="${AIEN_CORTEX_URL:-http://127.0.0.1:18080}" 46 STRICT="${AIEN_GP_STRICT:-0}" 47 SKIP_BUILD=0 48 [ "${1:-}" = "--skip-build" ] && SKIP_BUILD=1 49 50 STATE_DIR="$(mktemp -d /tmp/aien-golden-ops.XXXXXX)" 51 DAEMON_LOG="$(mktemp /tmp/aien-golden-daemon.XXXXXX.log)" 52 export AIEN_RUNTIME_STATE_DIR="$STATE_DIR" 53 54 PASS=0 55 PARTIAL=0 56 FAIL=0 57 declare -a VERDICTS 58 59 record() { # record PASS|PARTIAL|FAIL "step" "detail" 60 local status="$1" step="$2" detail="$3" 61 printf '%-8s %-46s %s\n' "$status" "$step" "$detail" 62 VERDICTS+=("$status $step $detail") 63 case "$status" in 64 PASS) PASS=$((PASS + 1)) ;; 65 PARTIAL) PARTIAL=$((PARTIAL + 1)) ;; 66 FAIL) FAIL=$((FAIL + 1)) ;; 67 esac 68 } 69 70 # --------------------------------------------------------------------------- 71 # IPC helper: one JSON-line ControlEnvelope over the runtime socket. 72 # --------------------------------------------------------------------------- 73 for tool in socat jq; do command -v "$tool" >/dev/null 2>&1 || { echo "golden_path.sh needs $tool (no Python at run time)" >&2; exit 1; }; done 74 ipc() { # ipc '' ; prints response line (socat, no Python) 75 local resp 76 resp="$(printf '%s\n' "$1" | timeout 125 socat -t 120 - UNIX-CONNECT:"$SOCK" 2>/dev/null | head -n1)" 77 if [[ -z "$resp" ]]; then 78 printf '{"Error": "no response from %s"}\n' "$SOCK" 79 else 80 printf '%s\n' "$resp" 81 fi 82 } 83 84 status_json() { 85 ipc "{\"protocol_version\":1,\"request_id\":$RANDOM,\"operation_id\":$(date +%s%N),\"operator_session\":1,\"command\":\"GetRuntimeStatus\"}" 86 } 87 88 field() { # field '' '' ; unwraps the Status envelope when present 89 jq -r --arg k "$2" '(.Status // .) | (.[$k] // "")' <<<"$1" 2>/dev/null 90 } 91 92 status_field() { # status_field '' 93 field "$(status_json)" "$1" 94 } 95 96 wait_socket() { # wait for the daemon to answer status queries 97 for _ in $(seq 1 100); do 98 resp="$(status_json 2>/dev/null)" 99 if [[ "$resp" == *'"Status('* ]] || [[ "$resp" == *'active_sequences'* ]]; then 100 return 0 101 fi 102 sleep 0.2 103 done 104 return 1 105 } 106 107 stop_daemon() { 108 ipc "{\"protocol_version\":1,\"request_id\":$RANDOM,\"operation_id\":$(date +%s%N),\"operator_session\":1,\"command\":\"Shutdown\"}" >/dev/null 2>&1 109 for _ in $(seq 1 50); do 110 [ -S "$SOCK" ] || return 0 111 sleep 0.2 112 done 113 pkill -f 'aien-cli.*(daemon|--daemon)' 2>/dev/null 114 sleep 0.5 115 rm -f "$SOCK" 116 } 117 118 boot_daemon() { 119 rm -f "$SOCK" 120 "$BIN" daemon >"$DAEMON_LOG" 2>&1 & 121 DAEMON_PID=$! 122 wait_socket 123 } 124 125 trap 'stop_daemon' EXIT 126 127 # --------------------------------------------------------------------------- 128 # Build 129 # --------------------------------------------------------------------------- 130 if [ "$SKIP_BUILD" -eq 0 ] || [ ! -x "$BIN" ]; then 131 echo "== Building release binary ==" 132 (cargo build --release -p aien-cli) || { 133 echo "FATAL: release build failed" 134 exit 1 135 } 136 fi 137 [ -x "$BIN" ] || { echo "FATAL: $BIN not found"; exit 1; } 138 139 echo "== AIEN 0.1 Native Golden Path ==" 140 echo "socket: $SOCK" 141 echo "state dir: $STATE_DIR" 142 echo "daemon log: $DAEMON_LOG" 143 echo 144 145 # sc#328: the daemon requires the approval desk key by default; create it in 146 # this run's compose home before the first boot. 147 "$BIN" compose desk-key --create 1 >/dev/null || { echo "FATAL: cannot create the approval desk key" >&2; exit 1; } 148 149 # Step 1: boot from clean state with one command, never the mock backend. 150 stop_daemon 151 if boot_daemon; then 152 backend_line="$(grep -m1 'Backend:' "$DAEMON_LOG" || true)" 153 if [[ -n "$backend_line" ]] && ! grep -q 'Mock' "$DAEMON_LOG"; then 154 record PASS "1 boot clean checkout, native backend" "$backend_line" 155 else 156 record FAIL "1 boot clean checkout, native backend" "backend line missing or mock present: $(grep -m2 -E 'Backend|Model|error' "$DAEMON_LOG" | tr '\n' ' ')" 157 fi 158 else 159 record FAIL "1 boot clean checkout, native backend" "daemon did not answer on $SOCK; log: $DAEMON_LOG" 160 print_summary() { :; } 161 printf '\nFATAL: cannot continue without a daemon.\n' 162 exit 1 163 fi 164 165 # Step 2: real model loaded, active path printed. 166 model_line="$(grep -m1 'Model:' "$DAEMON_LOG" || true)" 167 if [[ "$model_line" == *"checkpoint loaded"* ]]; then 168 record PASS "2 real model on GB10" "$model_line" 169 elif [[ "$model_line" == *"reference fallback"* ]]; then 170 if [ "$STRICT" = "1" ]; then 171 record FAIL "2 real model on GB10" "$model_line" 172 else 173 record PARTIAL "2 real model on GB10" "$model_line" 174 fi 175 else 176 record FAIL "2 real model on GB10" "no Model line in daemon log" 177 fi 178 179 # Step 3: operator prompt retrieves Cortex memory over an authenticated call. 180 CORTEX_TOKEN="$(atlas-vault get CORTEX_TOKEN 2>/dev/null | tr -d '[:space:]')" 181 if [ -n "$CORTEX_TOKEN" ]; then 182 cortex_http="$(curl -s -o /dev/null -w '%{http_code}' -G "$CORTEX_URL/api/cortex/search" \ 183 -H "Authorization: Bearer $CORTEX_TOKEN" --data-urlencode 'q=sovereign runtime golden path' \ 184 --data-urlencode 'space=atlas-memory' --data-urlencode 'limit=1')" 185 if [ "$cortex_http" = "200" ]; then 186 record PASS "3 Cortex retrieval for operator prompt" "GET $CORTEX_URL/api/cortex/search -> 200 with vault bearer token" 187 else 188 record PARTIAL "3 Cortex retrieval for operator prompt" "GET $CORTEX_URL/api/cortex/search -> HTTP $cortex_http" 189 fi 190 else 191 record PARTIAL "3 Cortex retrieval for operator prompt" "CORTEX_TOKEN unavailable from atlas-vault; Cortex call skipped" 192 fi 193 194 # Step 4: branch agents with zero-copy KV sharing. 195 prompt_tokens="$(jq -cn '"golden path swarm probe" | explode' 2>/dev/null || echo '[103,108,9]')" 196 launch_resp="$(ipc "{\"protocol_version\":1,\"request_id\":$RANDOM,\"operation_id\":$(date +%s%N),\"operator_session\":1,\"command\":{\"LaunchSwarm\":{\"model_handle\":1,\"branch_count\":4,\"max_active_sequences\":8,\"max_tokens_per_branch\":8,\"root_world_id\":0,\"priority\":1,\"prompt_tokens\":$prompt_tokens}}}")" 197 swarm_id="$(jq -r '.SwarmAccepted.swarm_id // ""' <<<"$launch_resp" 2>/dev/null)" 198 if [ -n "$swarm_id" ]; then 199 # Branches may complete between launch and the first status query, so the 200 # fork proof is the copy-on-write fault count, not a transient snapshot. 201 swarms="$(status_field 'active_swarms')" 202 worlds="$(status_field 'active_worlds')" 203 cow="$(status_field 'cow_faults')" 204 if [ "${cow:-0}" -gt 0 ] 2>/dev/null; then 205 record PASS "4 branch swarm, zero-copy KV fork" "swarm $swarm_id accepted, cow_faults=$cow (post-flight snapshot: swarms=$swarms worlds=$worlds)" 206 else 207 record FAIL "4 branch swarm, zero-copy KV fork" "swarm $swarm_id accepted but cow_faults=$cow (expected >0; swarms=$swarms worlds=$worlds)" 208 fi 209 else 210 record FAIL "4 branch swarm, zero-copy KV fork" "launch response: $launch_resp" 211 swarm_id="" 212 fi 213 214 # Step 5: tokens stream end to end until the arena drains. 215 drained="" 216 for _ in $(seq 1 120); do 217 seqs="$(status_field 'active_sequences')" 218 if [ "${seqs:-1}" = "0" ]; then 219 drained=1 220 break 221 fi 222 sleep 0.5 223 done 224 if [ -n "$drained" ]; then 225 cow="$(status_field 'cow_faults')" 226 detail="active_sequences drained to 0, cow_faults=$cow (backend: $(grep -m1 'Backend: Native' "$DAEMON_LOG" | sed 's/.*Backend: //'))" 227 if [ "${cow:-0}" -gt 0 ] 2>/dev/null; then 228 record PASS "5 tokens streamed through scheduler+KV+backend" "$detail" 229 else 230 record PARTIAL "5 tokens streamed through scheduler+KV+backend" "$detail (drained but no copy-on-write faults recorded)" 231 fi 232 else 233 record FAIL "5 tokens streamed through scheduler+KV+backend" "active_sequences still $(status_field 'active_sequences') after 60s" 234 fi 235 236 # Step 6: the actual CLI policy membrane allows a safe effect to execute. 237 if cargo test -q -p aien-cli --bin aien-cli tools::tests::test_policy_approved_write_reaches_effect_handler --offline >/dev/null 2>&1; then 238 record PASS "6 policy approved effect reaches boundary" "policy-approved write reached the file effect handler" 239 else 240 record FAIL "6 policy approved effect reaches boundary" "approved effect-boundary test failed" 241 fi 242 243 # Step 7: the same CLI membrane denies an effect before execution. 244 if cargo test -q -p aien-cli --bin aien-cli tools::tests::test_path_confinement_in_tool_dispatch --offline >/dev/null 2>&1; then 245 record PASS "7 denied effect blocked before execution" "policy denial test passed before the handler ran" 246 else 247 record FAIL "7 denied effect blocked before execution" "policy denial test failed" 248 fi 249 250 # Step 8: world effect commits carry a SHA-256 over canonical bytes; the 251 # runtime suite exercises commit_draft and the canonical hashing path. 252 if (cargo test -q -p aien-runtime world --offline >/dev/null 2>&1 \ 253 && cargo test -q -p aien-cli --bin aien-cli tools::tests::effect_receipt_is_hashed_and_secret_free --offline >/dev/null 2>&1); then 254 record PASS "8 world commit SHA-256 provenance" "World and secret-free effect receipt tests passed" 255 else 256 record FAIL "8 world commit SHA-256 provenance" "cargo test -p aien-runtime failed" 257 fi 258 259 # Step 9: idempotency ledger survives restart; replayed operation is rejected. 260 cancel_op="$(date +%s%N)" 261 if [ -n "$swarm_id" ]; then 262 cancel_resp="$(ipc "{\"protocol_version\":1,\"request_id\":$RANDOM,\"operation_id\":$cancel_op,\"operator_session\":1,\"command\":{\"CancelSwarm\":$swarm_id}}")" 263 else 264 cancel_op="$(date +%s%N)" 265 cancel_resp="$(ipc "{\"protocol_version\":1,\"request_id\":$RANDOM,\"operation_id\":$cancel_op,\"operator_session\":1,\"command\":{\"CancelSwarm\":999999}}")" 266 fi 267 stop_daemon 268 if boot_daemon; then 269 replay_resp="$(ipc "{\"protocol_version\":1,\"request_id\":$RANDOM,\"operation_id\":$cancel_op,\"operator_session\":1,\"command\":{\"CancelSwarm\":${swarm_id:-999999}}}")" 270 if [[ "$replay_resp" == *"already processed"* ]]; then 271 record PASS "9 idempotency survives restart" "replayed op $cancel_op rejected: $(jq -r '(.Error // "")[:80]' <<<"$replay_resp" 2>/dev/null)" 272 else 273 record FAIL "9 idempotency survives restart" "replay response: $replay_resp" 274 fi 275 else 276 record FAIL "9 idempotency survives restart" "daemon did not come back after restart" 277 fi 278 279 # Step 10: shut down with zero leaked KV blocks and zero retained branch worlds. 280 pre_free="$(status_field 'free_kv_blocks')" 281 pre_total="$(status_field 'total_kv_blocks')" 282 pre_worlds="$(status_field 'active_worlds')" 283 if [ "${pre_free:-0}" = "${pre_total:-1}" ] && [ "${pre_worlds:-9}" -le 1 ] 2>/dev/null; then 284 record PASS "10 zero leaks at shutdown" "free=$pre_free/$pre_total kv blocks, active_worlds=$pre_worlds" 285 else 286 record FAIL "10 zero leaks at shutdown" "free=$pre_free/$pre_total kv blocks, active_worlds=$pre_worlds" 287 fi 288 289 if ipc "{\"protocol_version\":1,\"request_id\":$RANDOM,\"operation_id\":$(date +%s%N),\"operator_session\":1,\"command\":\"Shutdown\"}" | grep -q 'ShutdownAck'; then 290 : 291 else 292 record PARTIAL "10 zero leaks at shutdown" "daemon did not acknowledge Shutdown" 293 fi 294 295 echo 296 echo "== Summary: $PASS pass, $PARTIAL partial, $FAIL fail ==" 297 if [ "$FAIL" -gt 0 ]; then 298 exit 1 299 elif [ "$PARTIAL" -gt 0 ] && [ "$STRICT" = "1" ]; then 300 exit 1 301 elif [ "$PARTIAL" -gt 0 ]; then 302 exit 2 303 fi 304 exit 0