sovereign-intelligence
Front door to Drake Stapleton's sovereign stack.
Brought by drakestapleton
sovereign-intelligence / gpu / cuda-crack / replicate.sh
| 1 | #!/bin/sh |
| 2 | # replicate.sh: reproduce the GB10 / Omega / CUDA++ host work from Radicle in a clean userspace. |
| 3 | # |
| 4 | # curl -fsSL https://www.aienos.com/replicate | sh # run every host step of AGENT-PROMPT.md |
| 5 | # curl -fsSL https://www.aienos.com/replicate | sh -s -- --agent # let YOUR OWN local model drive it |
| 6 | # |
| 7 | # The steps are the ones in AGENT-PROMPT.md (cuda-crack, rad:z631r2JJiVT8it4tST7RK24hpowi), served as |
| 8 | # text at https://www.aienos.com/agent-prompt. Every repository is cloned from Radicle over git+HTTPS: |
| 9 | # https://www.aienos.com/rad/<RID>.git first, then https://rosa.radicle.network/<RID>.git. |
| 10 | # |
| 11 | # Options: |
| 12 | # --chip also run section 7 on a GB10 (checks the driver is 580.173.02 and asks y/N first; off by default) |
| 13 | # --corpus also run step 5.2 (the full kernel corpus, three builds; long on one core; off by default) |
| 14 | # --agent a local model proposes one shell command per turn; you approve each with y |
| 15 | # --yes with --agent: run without asking only commands on a fixed allow-list (make <replication |
| 16 | # target>, sh seed/omega-from-seed.sh, sha256sum, git log/show/rev-parse, ls/cat/head/wc/grep -n |
| 17 | # on workspace paths, uname -sm, nproc, free; optionally after cd $R/<repo> &&); every other |
| 18 | # command asks you, never chip steps, never sudo |
| 19 | # --turns N with --agent: stop after N turns, 1 to 200 (default 40) |
| 20 | # -h, --help this text |
| 21 | # Environment: |
| 22 | # AIEN_MODEL_URL OpenAI-compatible base URL for --agent (e.g. http://127.0.0.1:11434/v1) |
| 23 | # AIEN_MODEL model id for --agent (default: the first one /models lists) |
| 24 | # AIEN_RAD_HTTP first git+HTTPS Radicle seed (default https://www.aienos.com/rad) |
| 25 | # AIEN_RAD_HTTP2 second git+HTTPS Radicle seed (default https://rosa.radicle.network) |
| 26 | # |
| 27 | # What it does: refuses root; makes a fresh workspace $HOME/aien-replicate-<UTC>; re-runs itself under |
| 28 | # `env -i HOME=<workspace> PATH=/usr/bin:/bin LC_ALL=C`, so no CUDA toolkit, nvcc or personal tools are on |
| 29 | # PATH; runs each step in a new clean shell; prints PASS/FAIL/NOT_RUN per step; writes RUNLOG.md and |
| 30 | # summary.tsv in the workspace. Exit 0 only when every required step passed. NOT_RUN is not PASS. |
| 31 | # It never uses sudo, never changes clocks, power or thermal settings, and writes only inside the workspace. |
| 32 | # |
| 33 | # Host dependencies (Drake's rule: every non-Omega piece in the path is recorded with its Omega replacement): |
| 34 | # POSIX sh, git, make, gcc, coreutils, diffutils, sed, grep, awk, bash, curl: the steps of AGENT-PROMPT.md |
| 35 | # themselves need them (gcc builds CUDApp's C parts; bash runs one CUDApp test). Replacement: the |
| 36 | # steps move to Omega as CUDApp and the bridge do. |
| 37 | # python3 (only --agent): JSON and HTTP for the chat loop. Replacement (follow-up, not done): an Omega |
| 38 | # agent loop (JSON codec + HTTP client in .om, emitted through omega-bridge or the seeded omc). |
| 39 | set -u |
| 40 | |
| 41 | if [ "$(id -u)" = 0 ]; then |
| 42 | echo "replicate: refusing to run as root. Run it as an ordinary user; it never needs sudo." >&2 |
| 43 | exit 2 |
| 44 | fi |
| 45 | prev= |
| 46 | for a in "$@"; do |
| 47 | if [ "$prev" = --turns ]; then |
| 48 | case $a in [1-9]|[1-9][0-9]|1[0-9][0-9]|200) ;; *) echo "replicate: --turns needs an integer from 1 to 200" >&2; exit 2 ;; esac |
| 49 | fi |
| 50 | prev=$a |
| 51 | case $a in -h|--help) cat <<'HELP_EOF' |
| 52 | replicate: reproduce the GB10 / Omega / CUDA++ host work from Radicle in a clean userspace. |
| 53 | curl -fsSL https://www.aienos.com/replicate | sh every host step of AGENT-PROMPT.md |
| 54 | curl -fsSL https://www.aienos.com/replicate | sh -s -- --agent your own local model drives it |
| 55 | Options: --chip (section 7 on a GB10, asks y/N first) --corpus (step 5.2, long) |
| 56 | --agent --yes (auto-approve allow-listed agent commands; never chip steps) --turns N (1-200, default 40) |
| 57 | Environment: AIEN_MODEL_URL, AIEN_MODEL (for --agent), AIEN_RAD_HTTP, AIEN_RAD_HTTP2 (git+HTTPS seeds) |
| 58 | e.g. curl -fsSL https://www.aienos.com/replicate | AIEN_MODEL_URL=http://127.0.0.1:11434/v1 sh -s -- --agent |
| 59 | Steps: https://www.aienos.com/agent-prompt |
| 60 | HELP_EOF |
| 61 | exit 0 ;; esac |
| 62 | done |
| 63 | |
| 64 | ws_ts=$(date -u +%Y%m%dT%H%M%SZ) |
| 65 | WS="$HOME/aien-replicate-$ws_ts" |
| 66 | [ -e "$WS" ] && WS="$WS-$$" |
| 67 | mkdir -p "$WS" || { echo "replicate: cannot create $WS" >&2; exit 2; } |
| 68 | echo "replicate: workspace $WS" |
| 69 | |
| 70 | cat > "$WS/replicate-inner.sh" <<'INNER_EOF' |
| 71 | # replicate-inner.sh: written by replicate.sh into the workspace and run under env -i. Do not edit. |
| 72 | set -u |
| 73 | WS=$HOME |
| 74 | R=$WS/replica |
| 75 | WSD="~/${WS##*/}" |
| 76 | export R |
| 77 | RAD_HTTP=${AIEN_RAD_HTTP:-https://www.aienos.com/rad} |
| 78 | RAD_HTTP2=${AIEN_RAD_HTTP2:-https://rosa.radicle.network} |
| 79 | CRACK_RID=z631r2JJiVT8it4tST7RK24hpowi |
| 80 | PROMPT_PIN=7ad53bab4cbc120b690fd2ca42fbcc5e25c476c9 |
| 81 | HARNESS_RID=z39gvwWsnkRZsAConQLjaKiNVLHfW |
| 82 | HARNESS_PIN=c38640db4fe8ee49eff589123415d4a1ba80567a |
| 83 | |
| 84 | chip=0 corpus=0 agent=0 yes=0 turns=40 |
| 85 | while [ $# -gt 0 ]; do |
| 86 | case $1 in |
| 87 | --chip) chip=1 ;; |
| 88 | --corpus) corpus=1 ;; |
| 89 | --agent) agent=1 ;; |
| 90 | --yes) yes=1 ;; |
| 91 | --turns) shift; turns=${1:-} |
| 92 | case $turns in [1-9]|[1-9][0-9]|1[0-9][0-9]|200) ;; *) echo "replicate: --turns needs an integer from 1 to 200"; exit 2 ;; esac ;; |
| 93 | *) echo "replicate: unknown option $1 (try --help)"; exit 2 ;; |
| 94 | esac |
| 95 | shift |
| 96 | done |
| 97 | |
| 98 | say() { printf '%s\n' "$*"; } |
| 99 | TTY="" |
| 100 | if ( : </dev/tty ) 2>/dev/null; then TTY=/dev/tty; fi |
| 101 | ask() { # question -> 0 when the human typed y |
| 102 | if [ -z "$TTY" ]; then say "$1 [y/N] (no terminal to ask on: N)"; return 1; fi |
| 103 | printf '%s [y/N] ' "$1" >"$TTY" |
| 104 | read -r ans <"$TTY" || return 1 |
| 105 | case $ans in y|Y|yes|YES) return 0 ;; *) return 1 ;; esac |
| 106 | } |
| 107 | |
| 108 | mkdir -p "$WS/logs" |
| 109 | LOG=$WS/RUNLOG.md |
| 110 | SUM=$WS/summary.tsv |
| 111 | : > "$SUM" |
| 112 | self_sha=$(sha256sum "$WS/replicate-inner.sh" | cut -c1-64) |
| 113 | { |
| 114 | say "# RUNLOG: replicate.sh" |
| 115 | say "" |
| 116 | say "- Date (UTC): $(date -u +%Y-%m-%dT%H:%M:%SZ)" |
| 117 | say "- Host: $(uname -srm)" |
| 118 | say "- Workspace: $WSD (HOME inside the run)" |
| 119 | say "- Environment of every step: env -i HOME=$WSD PATH=/usr/bin:/bin R=$WSD/replica LC_ALL=C sh -c '<command>'" |
| 120 | say "- Seeds: $RAD_HTTP, then $RAD_HTTP2" |
| 121 | say "- Steps: AGENT-PROMPT.md at cuda-crack $PROMPT_PIN (rad:$CRACK_RID)" |
| 122 | say "- replicate-inner.sh sha256 $self_sha" |
| 123 | say "" |
| 124 | } > "$LOG" |
| 125 | |
| 126 | # ---- 1. preflight ------------------------------------------------------------------------------------- |
| 127 | os=$(uname -s); arch=$(uname -m) |
| 128 | if [ "$os" != Linux ]; then |
| 129 | say "replicate: this needs Linux (this host is $os $arch). The seed compiler emits Linux AArch64 binaries." |
| 130 | exit 2 |
| 131 | fi |
| 132 | missing="" |
| 133 | for t in git make gcc sh sha256sum cmp sed grep awk bash curl cut wc date nice; do |
| 134 | command -v "$t" >/dev/null 2>&1 || missing="$missing $t" |
| 135 | done |
| 136 | if [ "$agent" = 1 ]; then command -v python3 >/dev/null 2>&1 || missing="$missing python3"; fi |
| 137 | if [ -n "$missing" ]; then |
| 138 | py=""; [ "$agent" = 1 ] && py=" python3" |
| 139 | say "replicate: missing in /usr/bin:/bin:$missing" |
| 140 | say "Install the base tools, then run the one-liner again:" |
| 141 | say " Debian/Ubuntu: sudo apt-get install -y git make gcc coreutils diffutils sed grep gawk bash curl$py" |
| 142 | say " Fedora/RHEL: sudo dnf install -y git make gcc coreutils diffutils sed grep gawk bash curl$py" |
| 143 | exit 3 |
| 144 | fi |
| 145 | say "replicate: $(uname -sm), clean PATH=/usr/bin:/bin, nvcc on PATH: $(command -v nvcc || echo no)" |
| 146 | |
| 147 | # ---- the step runner ---------------------------------------------------------------------------------- |
| 148 | req_bad=0 |
| 149 | stop_reason="" |
| 150 | record() { # id label rc result secs required note |
| 151 | printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$1" "$2" "$3" "$4" "$5" "$6" "$7" >> "$SUM" |
| 152 | if [ "$6" = req ] && [ "$4" != PASS ]; then req_bad=$((req_bad+1)); fi |
| 153 | printf '%-7s %-28s %5ss rc=%-4s %s\n' "$4" "$1" "$5" "$3" "$7" |
| 154 | } |
| 155 | notrun() { # id label required reason |
| 156 | record "$1" "$2" - NOT_RUN 0 "$3" "$4" |
| 157 | printf '### %s\n\nNOT_RUN: %s\n\n' "$1" "$4" >> "$LOG" |
| 158 | } |
| 159 | # step id label required want expect forbid cmd |
| 160 | # want: 0 | nz (must fail) | N (exact) | any; expect: newline-separated fixed strings that must all appear; |
| 161 | # forbid: an extended regex that must not match any output line ("" for none). |
| 162 | step() { |
| 163 | id=$1 label=$2 reqd=$3 want=$4 expect=$5 forbid=$6 cmd=$7 |
| 164 | if [ -n "$stop_reason" ]; then notrun "$id" "$label" "$reqd" "$stop_reason"; return 1; fi |
| 165 | printf 'RUN %s\n' "$id" |
| 166 | out=$WS/logs/$id.log |
| 167 | t0=$(date -u +%s) |
| 168 | ( cd "$WS" && env -i HOME="$WS" PATH=/usr/bin:/bin R="$R" LC_ALL=C RAD_HTTP="$RAD_HTTP" RAD_HTTP2="$RAD_HTTP2" \ |
| 169 | nice -n 10 sh -c "$cmd" ) > "$out" 2>&1 </dev/null |
| 170 | rc=$? |
| 171 | secs=$(( $(date -u +%s) - t0 )) |
| 172 | res=PASS note="" |
| 173 | case $want in |
| 174 | 0) [ "$rc" -eq 0 ] || { res=FAIL; note="exit $rc, want 0"; } ;; |
| 175 | nz) [ "$rc" -ne 0 ] || { res=FAIL; note="exit 0, but this control must fail"; } ;; |
| 176 | any) ;; |
| 177 | *) [ "$rc" -eq "$want" ] || { res=FAIL; note="exit $rc, want $want"; } ;; |
| 178 | esac |
| 179 | if [ "$res" = PASS ] && [ -n "$expect" ]; then |
| 180 | while IFS= read -r line; do |
| 181 | [ -n "$line" ] || continue |
| 182 | grep -F -q -- "$line" "$out" || { res=FAIL; note="missing: $line"; break; } |
| 183 | done <<EXPECT_EOF |
| 184 | $expect |
| 185 | EXPECT_EOF |
| 186 | fi |
| 187 | if [ "$res" = PASS ] && [ -n "$forbid" ] && grep -E -q -- "$forbid" "$out"; then |
| 188 | res=FAIL; note="forbidden line: $(grep -E -m1 -- "$forbid" "$out")" |
| 189 | fi |
| 190 | case $want in 0|any) ;; *) [ "$res" = PASS ] && note="control failed as it must (exit $rc)" ;; esac |
| 191 | n=$(wc -l < "$out") |
| 192 | { |
| 193 | printf '### %s (%s): %s\n\n```sh\n%s\n```\n\nrc=%s, %ss, %s output lines' "$id" "$label" "$res" "$cmd" "$rc" "$secs" "$n" |
| 194 | [ -n "$note" ] && printf ', %s' "$note" |
| 195 | [ "$n" -gt 40 ] && printf ' (first 8 and last 25 shown; full output logs/%s.log)' "$id" |
| 196 | printf '\n\n```text\n' |
| 197 | if [ "$n" -gt 40 ]; then sed -n 1,8p "$out" | cut -c1-300; echo '[...]'; tail -n 25 "$out" | cut -c1-300 |
| 198 | else cut -c1-300 "$out"; fi |
| 199 | printf '```\n\n' |
| 200 | } >> "$LOG" |
| 201 | record "$id" "$label" "$rc" "$res" "$secs" "$reqd" "$note" |
| 202 | [ "$res" = PASS ] |
| 203 | } |
| 204 | |
| 205 | summary() { |
| 206 | { |
| 207 | say "## Summary" |
| 208 | say "" |
| 209 | say "| step | label | rc | result | seconds | required | note |" |
| 210 | say "|---|---|---|---|---|---|---|" |
| 211 | while IFS="$(printf '\t')" read -r a b c d e f g; do say "| $a | $b | $c | $d | $e | $f | $g |"; done < "$SUM" |
| 212 | say "" |
| 213 | } >> "$LOG" |
| 214 | say "" |
| 215 | say "SUMMARY (workspace $WSD)" |
| 216 | printf '%-28s %-16s %-5s %-8s %s\n' step label rc result seconds |
| 217 | while IFS="$(printf '\t')" read -r a b c d e f g; do printf '%-28s %-16s %-5s %-8s %s\n' "$a" "$b" "$c" "$d" "$e"; done < "$SUM" |
| 218 | } |
| 219 | |
| 220 | clone_one() { # name rid dir pin -> clones with fallback, checks out pin if given |
| 221 | for src in "$RAD_HTTP" "$RAD_HTTP2"; do |
| 222 | if git clone -q "$src/$2.git" "$3" </dev/null 2>"$WS/logs/clone-$1.err"; then |
| 223 | if [ -n "$4" ]; then git -C "$3" checkout -q "$4" 2>>"$WS/logs/clone-$1.err" || say "replicate: $1 has no commit $4 yet; using its head $(git -C "$3" rev-parse --short HEAD)"; fi |
| 224 | return 0 |
| 225 | fi |
| 226 | rm -rf "$3" |
| 227 | done |
| 228 | say "replicate: could not clone $1 (rad:$2) from $RAD_HTTP or $RAD_HTTP2; see $WS/logs/clone-$1.err" |
| 229 | return 1 |
| 230 | } |
| 231 | |
| 232 | # ---- --agent: the user's own local model drives the replication -------------------------------------- |
| 233 | if [ "$agent" = 1 ]; then |
| 234 | probe() { curl -fsS -m 2 "$1/models" 2>/dev/null; } |
| 235 | url="" models="" |
| 236 | if [ -n "${AIEN_MODEL_URL:-}" ]; then |
| 237 | case $AIEN_MODEL_URL in *:18091*) say "replicate: port 18091 is reserved and never used by this script; pick another endpoint."; exit 4 ;; esac |
| 238 | url=${AIEN_MODEL_URL%/} |
| 239 | models=$(probe "$url") || { say "replicate: no answer from $url/models (AIEN_MODEL_URL)"; exit 4; } |
| 240 | else |
| 241 | for u in http://127.0.0.1:11434/v1 http://127.0.0.1:8080/v1 http://127.0.0.1:1234/v1 http://127.0.0.1:8000/v1; do |
| 242 | if models=$(probe "$u"); then url=$u; break; fi |
| 243 | done |
| 244 | fi |
| 245 | if [ -z "$url" ]; then |
| 246 | say "replicate --agent: no local OpenAI-compatible model server found." |
| 247 | say "Probed (GET /models, 2 s): 127.0.0.1:11434 (ollama), :8080 (llama.cpp), :1234 (LM Studio), :8000 (vLLM)." |
| 248 | say "Start one, for example ollama (https://ollama.com/download):" |
| 249 | say " OLLAMA_CONTEXT_LENGTH=32768 ollama serve &" |
| 250 | say " ollama pull <a coding model that fits your machine>" |
| 251 | say "then run again: curl -fsSL https://www.aienos.com/replicate | sh -s -- --agent" |
| 252 | say "Any other OpenAI-compatible server: curl -fsSL https://www.aienos.com/replicate | AIEN_MODEL_URL=http://host:port/v1 AIEN_MODEL=<id> sh -s -- --agent" |
| 253 | exit 4 |
| 254 | fi |
| 255 | model=${AIEN_MODEL:-} |
| 256 | if [ -z "$model" ]; then |
| 257 | model=$(printf '%s' "$models" | python3 -c 'import json,sys |
| 258 | d=json.load(sys.stdin); m=d.get("data") or d.get("models") or [] |
| 259 | print((m[0].get("id") or m[0].get("name")) if m else "")' 2>/dev/null) |
| 260 | fi |
| 261 | [ -n "$model" ] || { say "replicate: $url/models lists no model; set AIEN_MODEL"; exit 4; } |
| 262 | say "replicate --agent: endpoint $url, model $model" |
| 263 | mkdir -p "$WS/context" |
| 264 | clone_one cuda-crack "$CRACK_RID" "$WS/context/cuda-crack" "$PROMPT_PIN" || exit 1 |
| 265 | clone_one omega-harness "$HARNESS_RID" "$WS/context/omega-harness" "$HARNESS_PIN" || exit 1 |
| 266 | cp "$WS/context/cuda-crack/AGENT-PROMPT.md" "$WS/AGENT-PROMPT.md" |
| 267 | cat > "$WS/DEPENDENCIES.txt" <<'DEP_EOF' |
| 268 | Host dependencies of this run (recorded per Drake's pure-Omega rule) |
| 269 | - python3: JSON encode/decode and HTTP for the --agent chat loop (agent.py). Omega replacement: FOLLOW-UP, |
| 270 | not done: a .om agent loop with a JSON codec and HTTP client, built by the seeded omc or emitted through |
| 271 | omega-bridge. |
| 272 | - git, make, gcc, coreutils, diffutils, sed, grep, awk, bash, curl: required by the AGENT-PROMPT.md steps |
| 273 | themselves and by the endpoint probe. |
| 274 | - The local model server and model are the user's own; nothing is sent anywhere else. |
| 275 | DEP_EOF |
| 276 | cat > "$WS/agent.py" <<'AGENT_PY_EOF' |
| 277 | # agent.py: the --agent loop of replicate.sh. One shell command per turn, approved by the human. |
| 278 | import json, os, re, subprocess, sys, time, urllib.request |
| 279 | |
| 280 | WS = os.environ["WS"]; URL = os.environ["AGENT_URL"]; MODEL = os.environ["AGENT_MODEL"] |
| 281 | YES = os.environ.get("AGENT_YES") == "1"; CHIP = os.environ.get("AGENT_CHIP") == "1" |
| 282 | TURNS = int(os.environ.get("AGENT_TURNS", "40")); TTY = os.environ.get("AGENT_TTY", "") |
| 283 | MAXOUT = 6000; CMD_TIMEOUT = 3600 |
| 284 | R = WS + "/replica" |
| 285 | CLEAN = {"HOME": WS, "PATH": "/usr/bin:/bin", "R": R, "LC_ALL": "C"} |
| 286 | FORBID = re.compile(r"\bsudo\b|\bsu(\s|$)|\bdoas\b|18091|nvidia-smi\b[^\n]*(\s-pl\b|\s-lgc\b|\s-lmc\b|\s-ac\b|\s-rgc\b|\s-rmc\b|\s-rac\b|\s-r\b" |
| 287 | r"|--power-limit|--lock|--applications-clocks|--reset-gpu-clocks|--reset-memory-clocks|--reset-applications-clocks|--gpu-reset)") |
| 288 | CHIPCMD = re.compile(r"\bmake\b[^\n]*\b(doctor|hello-gpu|hello-gpu-control)\b|\bbuild/gpu_\w+_test\b|\bhello_gpu\b(?![^\n]*--sim)") |
| 289 | REFUSE_FORBID = "Refused by replicate.sh without asking: sudo/su, port 18091 and clock or power changes are never allowed." |
| 290 | REFUSE_CHIP = "Refused: this is a chip step (section 7) and the human did not start with --chip. Report section 7 as NOT_RUN." |
| 291 | |
| 292 | # --yes runs a command without asking ONLY when the whole command matches this allow-list; everything else goes |
| 293 | # to the human y/N (no terminal: declined). A deny-list cannot work: variables, heredocs and interpreters spell |
| 294 | # anything. Allowed: [cd $R/<REPO> && ] one of |
| 295 | # uname -sm | nproc | free [-h] | make <MAKE_OK> | sh seed/omega-from-seed.sh | sha256sum [-c [--quiet]] PATH.. |
| 296 | # git [-C PATH] log|show|rev-parse GITARG.. | ls [-l|-a|-la|-al|-1|-lh] PATH.. | cat PATH.. | head [-n N|-N] PATH.. |
| 297 | # wc [-l|-c|-w] PATH.. | grep -n|-c|-H|-o|-r|-rn.. PATTERN PATH.. |
| 298 | # PATH: [A-Za-z0-9._/-], under the workspace ($R, $R/..., relative, or an absolute path inside it), no "..", |
| 299 | # no leading "-". No other "$", no ; | < > ` ' \ ( ) { } * ? ~ = &, no newline. |
| 300 | REPOS = ("CUDApp", "cuda-crack", "cuda-crack/receipts", "omega-mv", "omega-bridge", "omc-f4df8239", "omc-e5b32567", |
| 301 | "bridge-6a8f0090") |
| 302 | MAKE_OK = ("hello", "test-hello-sim", "test-om-encoder", "test-om-encoder-mutants", "test-om-encoder-corpus") |
| 303 | PLAIN = re.compile(r"[A-Za-z0-9._/-]+") |
| 304 | CMDCHARS = re.compile(r'[A-Za-z0-9._/ $&"-]+') |
| 305 | CDPRE = re.compile(r'cd (?:\$R/(?P<a>[A-Za-z0-9._/-]+)|"\$R/(?P<b>[A-Za-z0-9._/-]+)") && (?P<rest>.+)') |
| 306 | GITARG = re.compile(r"-[0-9]+|-n|--oneline|--stat|--short|--name-only|[A-Za-z0-9._/][A-Za-z0-9._/-]*") |
| 307 | |
| 308 | def wspath(t): |
| 309 | if t == "$R": |
| 310 | return PLAIN.fullmatch(R) is not None |
| 311 | if t.startswith("$R/"): |
| 312 | t, base = t[3:], R |
| 313 | if PLAIN.fullmatch(R) is None: |
| 314 | return False |
| 315 | else: |
| 316 | base = WS |
| 317 | if not PLAIN.fullmatch(t) or t.startswith("-") or ".." in t.split("/"): |
| 318 | return False |
| 319 | return not t.startswith("/") or base == WS and (t == WS or t.startswith(WS + "/")) |
| 320 | |
| 321 | def simple(t): |
| 322 | if not t: |
| 323 | return False |
| 324 | n, a = t[0], t[1:] |
| 325 | if t in (["uname", "-sm"], ["nproc"], ["free"], ["free", "-h"]): |
| 326 | return True |
| 327 | if n == "make": |
| 328 | return len(a) == 1 and a[0] in MAKE_OK |
| 329 | if n == "sh": |
| 330 | return a == ["seed/omega-from-seed.sh"] |
| 331 | if n == "sha256sum": |
| 332 | if a[:1] == ["-c"]: |
| 333 | a = a[2:] if a[1:2] == ["--quiet"] else a[1:] |
| 334 | return len(a) == 1 and wspath(a[0]) |
| 335 | return len(a) >= 1 and all(wspath(x) for x in a) |
| 336 | if n == "git": |
| 337 | if a[:1] == ["-C"]: |
| 338 | if len(a) < 2 or not wspath(a[1]): |
| 339 | return False |
| 340 | a = a[2:] |
| 341 | return len(a) >= 1 and a[0] in ("log", "show", "rev-parse") and all(GITARG.fullmatch(x) for x in a[1:]) |
| 342 | flags = {"ls": ("-l", "-a", "-la", "-al", "-1", "-lh"), "cat": (), "wc": ("-l", "-c", "-w"), |
| 343 | "head": (), "grep": ("-n", "-c", "-H", "-o", "-r", "-rn")} |
| 344 | if n not in flags: |
| 345 | return False |
| 346 | if n == "head" and a[:1] == ["-n"]: |
| 347 | if len(a) < 2 or not a[1].isdigit(): |
| 348 | return False |
| 349 | a = a[2:] |
| 350 | elif n == "head" and a[:1] and re.fullmatch(r"-[0-9]+", a[0]): |
| 351 | a = a[1:] |
| 352 | while a and a[0] in flags[n]: |
| 353 | a = a[1:] |
| 354 | if n == "grep": |
| 355 | if not a or not PLAIN.fullmatch(a[0]) or a[0].startswith("-"): |
| 356 | return False |
| 357 | a = a[1:] |
| 358 | return (len(a) >= 1 or n == "ls") and all(wspath(x) for x in a) |
| 359 | |
| 360 | def allowed(cmd): |
| 361 | if not CMDCHARS.fullmatch(cmd): |
| 362 | return False |
| 363 | m = CDPRE.fullmatch(cmd) |
| 364 | if m: |
| 365 | if (m.group("a") or m.group("b")) not in REPOS: |
| 366 | return False |
| 367 | cmd = m.group("rest") |
| 368 | if '"' in cmd or "&" in cmd: |
| 369 | return False |
| 370 | return simple(cmd.split(" ")) |
| 371 | |
| 372 | def gate(cmd): |
| 373 | """-> ("refuse", feedback) | ("auto", "") | ("ask", reason). FORBID and CHIPCMD run on the raw command and on |
| 374 | it with quotes and backslashes stripped and ; | & as spaces; they refuse outright. Under --yes only allowed() |
| 375 | commands run without a human; chip steps never do.""" |
| 376 | flat = re.sub(r"[;|&]", " ", re.sub(r"[\\'\"`]", "", cmd)) |
| 377 | if FORBID.search(cmd) or FORBID.search(flat): |
| 378 | return "refuse", REFUSE_FORBID |
| 379 | if CHIPCMD.search(cmd) or CHIPCMD.search(flat): |
| 380 | return ("ask", "chip step: needs a y from the human") if CHIP else ("refuse", REFUSE_CHIP) |
| 381 | if not YES: |
| 382 | return "ask", "" |
| 383 | if allowed(cmd): |
| 384 | return "auto", "" |
| 385 | return "ask", "not on the --yes allow-list: needs a y from the human" |
| 386 | BLOCK = re.compile(r"```(?:sh|bash|shell)?[ \t]*\n(.*?)```", re.S) |
| 387 | |
| 388 | prompt = open(WS + "/AGENT-PROMPT.md", encoding="utf-8").read() |
| 389 | sk_root = WS + "/context/omega-harness/skills" |
| 390 | skills = [] |
| 391 | for d in sorted(os.listdir(sk_root)): |
| 392 | p = os.path.join(sk_root, d, "SKILL.md") |
| 393 | if not os.path.isfile(p): |
| 394 | continue |
| 395 | desc = "" |
| 396 | for line in open(p, encoding="utf-8"): |
| 397 | if line.startswith("description:"): |
| 398 | desc = line.split(":", 1)[1].strip().strip('"') |
| 399 | break |
| 400 | skills.append("- %s: %s (read it: cat %s)" % (d, desc, p)) |
| 401 | |
| 402 | system = f"""You are an agent replicating Drake Stapleton's GB10 / Omega / CUDA++ work on this machine, following AGENT-PROMPT.md below. |
| 403 | |
| 404 | How you act here: |
| 405 | - Each reply contains AT MOST ONE shell command, in one ```sh fenced block, after one or two sentences saying which step it is and what you expect. |
| 406 | - A human sees the command and approves it. It runs in a NEW clean shell every time: |
| 407 | env -i HOME={WS} PATH=/usr/bin:/bin R={R} LC_ALL=C sh -c '<your command>' (working directory {WS}) |
| 408 | Only files persist between commands; variables do not. $R is already set to {R}. |
| 409 | - With --yes, only plain commands run without a human: make <target>, sh seed/omega-from-seed.sh, sha256sum, git log/show/rev-parse, ls, cat, head, wc, grep -n, uname -sm, nproc, free, optionally after `cd $R/<repo> && `, with plain arguments (no quotes, pipes, ;, redirection, heredocs or variables other than $R). Anything else waits for the human and is declined if nobody answers. |
| 410 | - You get back the exit code, the seconds taken and the output (long output is cut in the middle). |
| 411 | - Go in order from step 1.1. Compare every output with the step's Success line. On a mismatch, stop (rule 0.1). |
| 412 | - Section 7 (chip) only if the human started with --chip; otherwise report it NOT_RUN. Never use sudo. Never change clocks, power or thermal settings. |
| 413 | - The omega-harness skills are on disk; read one when you need it (index at the end). |
| 414 | - When you are finished or stopped, reply with a line that starts with DONE, then the section 9 REPLICATION REPORT, and no sh block. |
| 415 | |
| 416 | ===== AGENT-PROMPT.md (cuda-crack {os.environ.get('PROMPT_PIN', '')[:8]}) ===== |
| 417 | {prompt} |
| 418 | |
| 419 | ===== omega-harness skill index (rad:z39gvwWsnkRZsAConQLjaKiNVLHfW @ {os.environ.get('HARNESS_PIN', '')[:8]}) ===== |
| 420 | """ + "\n".join(skills) + "\n" |
| 421 | |
| 422 | messages = [{"role": "system", "content": system}, {"role": "user", "content": "Begin with step 1.1."}] |
| 423 | tpath = WS + "/agent-transcript.md" |
| 424 | tfile = open(tpath, "w", encoding="utf-8") |
| 425 | def tw(s): |
| 426 | tfile.write(s + "\n"); tfile.flush() |
| 427 | tw(f"# --agent transcript\n\n- endpoint {URL}, model {MODEL}, workspace ~/{os.path.basename(WS)}, auto-approve {YES}, chip {CHIP}\n- system prompt: {len(system)} characters\n") |
| 428 | print(f"agent: system prompt is {len(system)} characters (~{len(system)//4} tokens). If your server cuts context (ollama default), start it with OLLAMA_CONTEXT_LENGTH=32768.", flush=True) |
| 429 | |
| 430 | def chat(): |
| 431 | body = json.dumps({"model": MODEL, "messages": messages, "temperature": 0.2, "stream": False}).encode() |
| 432 | req = urllib.request.Request(URL + "/chat/completions", data=body, headers={"Content-Type": "application/json"}) |
| 433 | with urllib.request.urlopen(req, timeout=900) as r: |
| 434 | d = json.load(r) |
| 435 | return d["choices"][0]["message"].get("content") or "" |
| 436 | |
| 437 | def approve(verdict, why): |
| 438 | if verdict == "auto": |
| 439 | print("auto-approved (--yes)", flush=True); return "y" |
| 440 | if why: |
| 441 | print(why, flush=True) |
| 442 | if not TTY: |
| 443 | print("no terminal to ask on: declined", flush=True); return "n" |
| 444 | with open(TTY, "w") as w: |
| 445 | w.write("Run this command? [y = run, n = decline, q = quit] "); w.flush() |
| 446 | with open(TTY) as r: |
| 447 | a = r.readline().strip().lower() |
| 448 | return a[:1] if a else "n" |
| 449 | |
| 450 | def shorten_old(): |
| 451 | # keep the context small: tool outputs older than the last 4 turns shrink to 600 characters |
| 452 | users = [m for m in messages if m["role"] == "user"] |
| 453 | for m in users[:-4]: |
| 454 | if len(m["content"]) > 800: |
| 455 | m["content"] = m["content"][:600] + "\n[older output shortened]" |
| 456 | |
| 457 | done = False |
| 458 | for turn in range(1, TURNS + 1): |
| 459 | try: |
| 460 | reply = chat() |
| 461 | except Exception as e: |
| 462 | print(f"agent: model request failed: {e}", flush=True); tw(f"\nmodel request failed: {e}"); break |
| 463 | visible = re.sub(r"<think>.*?</think>", "", reply, flags=re.S).strip() |
| 464 | messages.append({"role": "assistant", "content": visible}) |
| 465 | print(f"\n--- turn {turn}: MODEL ---\n{visible}\n", flush=True) |
| 466 | tw(f"\n## turn {turn}\n\n### model\n\n{visible}\n") |
| 467 | m = BLOCK.search(visible) |
| 468 | if not m: |
| 469 | if re.search(r"^\s*\**DONE\b", visible, re.M): |
| 470 | done = True; break |
| 471 | fb = "No command found. Reply with exactly one ```sh block, or with DONE and the report." |
| 472 | messages.append({"role": "user", "content": fb}); tw(f"### fed back\n\n{fb}\n"); continue |
| 473 | cmd = m.group(1).strip() |
| 474 | print(f"PROPOSED COMMAND:\n{cmd}\n", flush=True) |
| 475 | verdict, why = gate(cmd) |
| 476 | if verdict == "refuse": |
| 477 | print(why, flush=True); messages.append({"role": "user", "content": why}); tw(f"### refused\n\n{why}\n"); continue |
| 478 | a = approve(verdict, why) |
| 479 | tw(f"### command\n\n```sh\n{cmd}\n```\n\napproval: {a}\n") |
| 480 | if a == "q": |
| 481 | print("agent: stopped by the human", flush=True); break |
| 482 | if a != "y": |
| 483 | fb = "The human declined to run this command. Propose something else or explain." |
| 484 | messages.append({"role": "user", "content": fb}); continue |
| 485 | t0 = time.time() |
| 486 | try: |
| 487 | p = subprocess.run(["nice", "-n", "10", "sh", "-c", cmd], cwd=WS, env=CLEAN, stdin=subprocess.DEVNULL, |
| 488 | stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=CMD_TIMEOUT) |
| 489 | rc, out = p.returncode, p.stdout.decode("utf-8", "replace") |
| 490 | except subprocess.TimeoutExpired as e: |
| 491 | rc, out = 124, (e.output or b"").decode("utf-8", "replace") + f"\n[killed after {CMD_TIMEOUT} s]" |
| 492 | secs = int(time.time() - t0) |
| 493 | if len(out) > MAXOUT: |
| 494 | out = out[:1500] + f"\n[... {len(out) - MAXOUT} characters cut ...]\n" + out[-(MAXOUT - 1500):] |
| 495 | print(f"exit code {rc}, {secs}s\n{out}", flush=True) |
| 496 | res = f"exit code: {rc}\nseconds: {secs}\noutput:\n```text\n{out}\n```" |
| 497 | tw(f"### result\n\n{res}\n") |
| 498 | shorten_old() |
| 499 | messages.append({"role": "user", "content": res}) |
| 500 | |
| 501 | json.dump(messages, open(WS + "/agent-messages.json", "w"), indent=1) |
| 502 | tw(f"\n---\nend: {'DONE reported' if done else 'stopped without DONE'}") |
| 503 | print(f"\nagent: {'DONE reported' if done else 'stopped without DONE'}; transcript {tpath}", flush=True) |
| 504 | sys.exit(0 if done else 1) |
| 505 | AGENT_PY_EOF |
| 506 | exec env -i HOME="$WS" PATH=/usr/bin:/bin LC_ALL=C WS="$WS" AGENT_URL="$url" AGENT_MODEL="$model" AGENT_YES="$yes" \ |
| 507 | AGENT_CHIP="$chip" AGENT_TURNS="$turns" AGENT_TTY="$TTY" PROMPT_PIN="$PROMPT_PIN" HARNESS_PIN="$HARNESS_PIN" \ |
| 508 | python3 "$WS/agent.py" |
| 509 | fi |
| 510 | |
| 511 | # ---- sections 1 to 6: the host steps of AGENT-PROMPT.md ------------------------------------------------ |
| 512 | step 1.1-preflight HOST_TESTED req 0 "Linux aarch64 |
| 513 | preflight done" 'MISSING' \ |
| 514 | 'uname -sm; for t in git make gcc sh sha256sum cmp sed grep awk; do command -v $t >/dev/null || echo "MISSING $t"; done; echo preflight done' |
| 515 | seedok=1 |
| 516 | [ "$arch" = aarch64 ] || seedok=0 |
| 517 | |
| 518 | step 2.1-clone HOST_TESTED req 0 "CUDApp |
| 519 | omega-mv |
| 520 | omega-bridge |
| 521 | cuda-crack |
| 522 | physics-mv |
| 523 | omega-gpu-driver |
| 524 | omega-blas " '' \ |
| 525 | 'mkdir -p "$R" && cd "$R" && while read name rid; do ok=0; for src in "$RAD_HTTP" "$RAD_HTTP2"; do if git clone -q "$src/$rid.git" "$name" </dev/null; then ok=1; break; fi; rm -rf "./$name"; done; [ $ok = 1 ] || { echo "could not clone $name rad:$rid"; exit 1; }; echo "$name $(git -C "$name" rev-parse HEAD) $src"; done <<EOF |
| 526 | CUDApp z4RxD8vXigmWg61nM8miQ8DVPAXEP |
| 527 | omega-mv z6do9WDBhuSnvopDkgFdFr1yWA62 |
| 528 | omega-bridge z3Hr9ZaiKHwwuNzPK5M8c7uw6pj7y |
| 529 | cuda-crack z631r2JJiVT8it4tST7RK24hpowi |
| 530 | physics-mv z49She8eifZpLd2aiSvk2pph3DMUo |
| 531 | omega-gpu-driver z2xjD5kxUTTBNCryJ6rg9QXpemzei |
| 532 | omega-blas z47VdC9EFsF4dFyH1QJ1C2JNJK4JS |
| 533 | EOF' || stop_reason="stopped: step 2.1 failed (rule 0.1)" |
| 534 | |
| 535 | step 2.2-pins HOST_TESTED req 0 "b774723f537cec16a359fe082b8100317a5b5490 |
| 536 | E2 receipt commit 010abb15 is inside CUDApp b774723f |
| 537 | 043f993fab0b263eb0edd1a367fee8fee8f6a79b |
| 538 | 6efc45728d5080b0fc5d74016a00ba8bbfcf9698 |
| 539 | worktrees: omc-f4df8239 omc-e5b32567 bridge-6a8f0090" '' \ |
| 540 | 'cd "$R" && git -C CUDApp checkout -q b774723f537cec16a359fe082b8100317a5b5490 && git -C CUDApp rev-parse HEAD && git -C CUDApp merge-base --is-ancestor 010abb1549c48a4be6d63da47101d393f76cb2dd HEAD && echo "E2 receipt commit 010abb15 is inside CUDApp b774723f" && git -C cuda-crack checkout -q 043f993fab0b263eb0edd1a367fee8fee8f6a79b && git -C cuda-crack rev-parse HEAD && git -C omega-mv checkout -q 6efc45728d5080b0fc5d74016a00ba8bbfcf9698 && git -C omega-mv rev-parse HEAD && git -C omega-mv worktree add -q --detach ../omc-f4df8239 f4df82394e35893dcf1354dda69a2fe028d94bc1 && git -C omega-mv worktree add -q --detach ../omc-e5b32567 e5b32567a7aff3ce594e3254a622a846a6cd190b && git -C omega-bridge worktree add -q --detach ../bridge-6a8f0090 6a8f0090913283125f14871272f03d144a102d02 && echo "worktrees: omc-f4df8239 omc-e5b32567 bridge-6a8f0090"' \ |
| 541 | || stop_reason="stopped: step 2.2 failed (rule 0.1)" |
| 542 | |
| 543 | # Steps that run seed-built AArch64 binaries. |
| 544 | seed_step() { |
| 545 | if [ "$seedok" = 0 ] && [ -z "$stop_reason" ]; then notrun "$1" "$2" "$3" "needs Linux aarch64 (the seed compiler emits AArch64 ELF); this host is $arch"; return; fi |
| 546 | step "$@" |
| 547 | } |
| 548 | |
| 549 | seed_step 3.1-seed-f4df8239 HOST_TESTED req 0 "PASS seed0 408 bytes, rebuilds itself |
| 550 | PASS omc fixpoint 3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194 |
| 551 | PASS assign exit 7 |
| 552 | RC=0" '' 'cd "$R/omc-f4df8239" && sh seed/omega-from-seed.sh' |
| 553 | |
| 554 | seed_step 3.2-sha-f4df8239 HOST_TESTED req 0 "3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194 seed/out/omc |
| 555 | rebuilt omc is byte-identical to the committed one" '' \ |
| 556 | 'cd "$R/omc-f4df8239" && sha256sum seed/out/omc && git diff --exit-code --stat seed/out/omc && echo "rebuilt omc is byte-identical to the committed one"' |
| 557 | |
| 558 | seed_step 3.3-seed-e5b32567 HOST_TESTED req 0 "PASS omc fixpoint 2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f |
| 559 | RC=0" '' 'cd "$R/omc-e5b32567" && sh seed/omega-from-seed.sh' |
| 560 | |
| 561 | seed_step 3.4-sha-e5b32567 HOST_TESTED req 0 "2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f seed/out/omc |
| 562 | rebuilt omc is byte-identical to the committed one" '' \ |
| 563 | 'cd "$R/omc-e5b32567" && sha256sum seed/out/omc && git diff --exit-code --stat seed/out/omc && echo "rebuilt omc is byte-identical to the committed one"' |
| 564 | |
| 565 | seed_step 3.5-neg-seed-byte HOST_TESTED req nz "seed/rung0/seed0.hex | 2 +- |
| 566 | Exec format error" '' \ |
| 567 | 'cd "$R" && git -C omega-mv worktree add -q --detach ../omc-neg f4df82394e35893dcf1354dda69a2fe028d94bc1 && cd omc-neg && sed -i "s/^464c457f /464c457e /" seed/rung0/seed0.hex && git diff --stat && sh seed/omega-from-seed.sh' |
| 568 | |
| 569 | seed_step 3.6-neg-compiler-source HOST_TESTED req 1 "seed/omc/omc.om | 2 +- |
| 570 | 455a5d1f3d8621d7d03bf842aac30a46c57808493908c7b0e8a70c92cad9ad60 seed/out/omc |
| 571 | seed/out/omc | Bin 625676 -> 625744 bytes" '' \ |
| 572 | 'cd "$R/omc-neg" && git checkout -q seed/rung0/seed0.hex && sed -i "s/^global out uchar 16777216\$/global out uchar 16777215/" seed/omc/omc.om && git diff --stat && sh seed/omega-from-seed.sh >/dev/null; sha256sum seed/out/omc; git diff --exit-code --stat seed/out/omc' |
| 573 | |
| 574 | step 4.1-crack-receipts HOST_TESTED req 0 "all 148 receipt files match" '' \ |
| 575 | 'cd "$R/cuda-crack/receipts" && sha256sum -c --quiet SHA256SUMS && echo "all $(wc -l < SHA256SUMS) receipt files match"' |
| 576 | |
| 577 | seed_step 4.2-crack-gen HOST_TESTED req 0 "isa/sm121-forms.txt: 471 forms, sha256 587d81e2bc8b3dc6fdb48d477a76b717300732ccdb984f05f5b3df658e58e2d7 |
| 578 | isa/ regenerated byte-identical" '' \ |
| 579 | 'cd "$R/cuda-crack" && OMC="$R/omc-f4df8239/seed/out/omc" sh gen/run.sh && git diff --exit-code --stat isa/ && echo "isa/ regenerated byte-identical"' |
| 580 | |
| 581 | seed_step 4.3-crack-check HOST_TESTED req 0 "kernels 70 instructions 13520 unmatched 0 |
| 582 | PASS: all 70 rebuilt kernels match kernels-om.sha256 byte for byte |
| 583 | PASS: mutant table caught |
| 584 | PASS: corrupted instruction matches no form |
| 585 | PASS: wrong field width caught |
| 586 | PASS: wrong field mask caught |
| 587 | ALL CHECKS PASS" '' \ |
| 588 | 'cd "$R/cuda-crack" && OMC="$R/omc-f4df8239/seed/out/omc" sh check/check.sh' |
| 589 | |
| 590 | step 4.4-same-encoder HOST_TESTED req 0 "cuda-crack gen/bw_enc_sm121.om == CUDApp om/encoder/bw_enc_sm121.om" '' \ |
| 591 | 'cmp "$R/cuda-crack/gen/bw_enc_sm121.om" "$R/CUDApp/om/encoder/bw_enc_sm121.om" && echo "cuda-crack gen/bw_enc_sm121.om == CUDApp om/encoder/bw_enc_sm121.om"' |
| 592 | |
| 593 | step 4.5-neg-tampered-receipt HOST_TESTED req 1 "om-hello.log: FAILED |
| 594 | WARNING: 1 computed checksum did NOT match" '' \ |
| 595 | 'cd "$R" && rm -rf neg-receipts && cp -r cuda-crack/receipts neg-receipts && printf x >> neg-receipts/cudapp/evidence/CUDAPP-OM-ENCODER/chip-20261027T080240Z/om-hello.log && cd neg-receipts && sha256sum -c --quiet SHA256SUMS' |
| 596 | |
| 597 | seed_step 5.1-om-encoder HOST_TESTED req 0 "PASS: hosted golden-word fixtures through the .om encoder (0 failing checks) |
| 598 | encoder diff: .om and C byte-identical on 145 golden instructions and 14 fixture programs |
| 599 | red check: one flipped bit aborts the encoder diff, as it must" '' \ |
| 600 | 'cd "$R/CUDApp" && make test-om-encoder' |
| 601 | |
| 602 | seed_step 5.3-neg-mutants-unpinned HOST_TESTED req nz "" '^PASS' \ |
| 603 | 'cd "$R/CUDApp" && make test-om-encoder-mutants' |
| 604 | |
| 605 | seed_step 5.4-om-encoder-mutants HOST_TESTED req 0 "191b776ef98821597c3e30655da6d680a9b66edbc9ceaca3c39c61ea6df098e9 ../omc |
| 606 | bootstrap fixpoint RC=0 |
| 607 | 69d629df170a24ba0c2cb6d41dbfaed520e248e0d723236dd32abf0581524d84 src/toc.om |
| 608 | mutant 1 red ( |
| 609 | mutant 2 red ( |
| 610 | mutant 3 red (" 'SURVIVED' \ |
| 611 | 'cd "$R/bridge-6a8f0090" && OMEGA_SOURCE="$R/omega-mv" sh tools/bootstrap.sh && sh tools/build.sh && cat build/compiler.sha256 && cd "$R/CUDApp" && make test-om-encoder-mutants OMEGA_OMC="$R/omc-e5b32567/seed/out/omc" OMEGA_BRIDGE="$R/bridge-6a8f0090"' |
| 612 | |
| 613 | seed_step 5.5-hello-sim SIMULATED req 0 "PASS sim-pass (exit 0) |
| 614 | PASS fault-exit (exit 1) |
| 615 | PASS short-exit (exit 1) |
| 616 | PASS past-end-refused-on-gpu (exit 2) |
| 617 | hello --sim tests: 12 passed, 0 failed" '' \ |
| 618 | 'cd "$R/CUDApp" && make test-hello-sim' |
| 619 | |
| 620 | step 6.1-E2-hello-receipt "receipt verified" req 0 "om-hello.log:checked 1048576 of 1048576 elements: 0 wrong, 0 never written |
| 621 | om-hello-control.log:checked 1048576 of 1048576 elements: 1 wrong, 1 never written |
| 622 | om-hello-control.log:FAIL |
| 623 | om hello-control rc=1 |
| 624 | c hello-control rc=1 |
| 625 | c gpu_matmul_api_test rc=0" '' \ |
| 626 | 'cd "$R/CUDApp/evidence/CUDAPP-OM-ENCODER/chip-20261027T080240Z" && grep -H -e "^checked " -e "^PASS$" -e "^FAIL$" om-hello.log om-hello-control.log && cat summary.txt' |
| 627 | |
| 628 | step 6.2-E3-chip-kernels "receipt verified" req 0 "70 chip-20261027T080240Z/kernels-om.sha256 |
| 629 | 243 host/corpus-k-om.sha256 |
| 630 | 70 chip kernel files match kernels-om.sha256" '' \ |
| 631 | 'cd "$R/CUDApp/evidence/CUDAPP-OM-ENCODER" && cmp chip-20261027T080240Z/kernels-om.sha256 chip-20261027T080240Z/kernels-c.sha256 && cmp host/corpus-k-om.sha256 host/corpus-k-c.sha256 && wc -l chip-20261027T080240Z/kernels-om.sha256 host/corpus-k-om.sha256 && cd "$R/cuda-crack/receipts/cudapp/evidence/CUDAPP-OM-ENCODER/chip-20261027T080240Z/kernels-om" && sha256sum -c --quiet ../kernels-om.sha256 && echo "$(ls | wc -l) chip kernel files match kernels-om.sha256"' |
| 632 | |
| 633 | step 6.3-E6-seed-vecadd "receipt verified" req 0 "check_words exit=0 want=0 ok |
| 634 | run_seed exit=0 want=0 ok |
| 635 | control_mutant exit=1 want=1 ok |
| 636 | session PASS" '' \ |
| 637 | 'cd "$R/omega-mv/evidence/SEED-0/sm121/chip" && cat steps.txt' |
| 638 | |
| 639 | step 6.4-E7-native-launch "receipt verified" req 0 '"NATIVE_SM121_VECTOR_PASS" |
| 640 | "failed_syscalls"' '' \ |
| 641 | 'grep -o -e "\"NATIVE_SM121_VECTOR_PASS\"" -e "\"failed_syscalls\": *0" "$R/CUDApp/evidence/speculation/native-kernel/receipt.json"' |
| 642 | |
| 643 | step 6.5-E8-doctor "receipt verified" req 0 "ok NVIDIA kernel module: open module 580.173.02 |
| 644 | info CUDA toolkit: not needed and not used by CUDA++" '' \ |
| 645 | 'grep -e "NVIDIA kernel module" -e "CUDA toolkit" "$R/CUDApp/evidence/CUDAPP-OM-ENCODER/chip-20261027T080240Z/om-doctor.log"' |
| 646 | |
| 647 | step 6.6-E9-exhaustive "receipt verified" req 0 "16 files: each sha256 equals its file name |
| 648 | RESULT chip SIGMOID checked=4294967296 exhaustive=true mismatches=0 unwritten=0 verdict=PASS |
| 649 | RESULT chip EXP2 checked=4294967296 exhaustive=true mismatches=0 unwritten=0 verdict=PASS" '' \ |
| 650 | 'cd "$R/omega-mv/evidence/E1-TRANSC-GB10" && for f in *.json blobs/*.log; do h=$(sha256sum "$f" | cut -c1-64); case "$f" in *"$h"*) ;; *) echo "NOT CONTENT-ADDRESSED: $f"; exit 1;; esac; done && echo "$(ls *.json blobs/*.log | wc -l) files: each sha256 equals its file name" && grep -h "verdict=PASS digest=" blobs/*.log | cut -d" " -f1-8' |
| 651 | |
| 652 | step 6.7-E10-builders "receipt verified" req 0 "PASS (902 checks) |
| 653 | 318 of 318 configs pass" '' \ |
| 654 | 'cd "$R/CUDApp/evidence" && grep -o "PASS (902 checks)" GEMM-GENERAL-00c9cf9/chip.log && grep -o -m1 "318 of 318 configs pass" ATTN-GENERAL-20261027-4d51f91f/SUMMARY.md' |
| 655 | |
| 656 | step 6.8-E1-no-cuda "receipt verified" req 0 "count of maps lines |
| 657 | Open Kernel Module for aarch64 580.173.02" '' \ |
| 658 | 'cd "$R/omega-mv/evidence/WHAT-OMEGA-IS-20261021" && grep -A1 "count of maps lines" live-serve-no-cuda.txt && grep -o "Open Kernel Module for aarch64 580.173.02" live-serve-no-cuda.txt' |
| 659 | |
| 660 | if [ "$corpus" = 1 ]; then |
| 661 | seed_step 5.2-om-encoder-corpus HOST_TESTED req 0 "encoder corpus: 243 distinct kernels identical .om vs C" '' \ |
| 662 | 'cd "$R/CUDApp" && make test-om-encoder-corpus' |
| 663 | else |
| 664 | notrun 5.2-om-encoder-corpus HOST_TESTED opt "optional, long (three CUDApp builds on one core); run with --corpus" |
| 665 | fi |
| 666 | |
| 667 | # ---- section 7: chip steps, only with --chip and a y --------------------------------------------------- |
| 668 | if [ "$chip" = 1 ] && [ -z "$stop_reason" ]; then |
| 669 | ver=$(cat /proc/driver/nvidia/version 2>/dev/null | sed -n 1p) |
| 670 | say "" |
| 671 | say "--chip: /proc/driver/nvidia/version: ${ver:-<absent: no NVIDIA driver loaded>}" |
| 672 | case $ver in |
| 673 | *580.173.02*) |
| 674 | say "driver 580.173.02: matches what CUDA++ speaks." |
| 675 | say "Section 7 runs 7.1 doctor, 7.2 hello-gpu and 7.3 hello-gpu-control on this GPU. It changes no clocks or power." |
| 676 | say "Only with the machine owner's permission, and with no other GPU job running (AGENT-PROMPT.md 7.0)." |
| 677 | if ask "Run section 7 on this GPU now?"; then |
| 678 | step 7.1-doctor CHIP_TESTED req 0 "580.173.02 |
| 679 | READY" '' 'cd "$R/CUDApp" && make doctor' |
| 680 | step 7.2-hello-gpu CHIP_TESTED req 0 "checked 1048576 of 1048576 elements: 0 wrong, 0 never written |
| 681 | 9e28bd9c46f80584d77238a752e99cecddbc8d622ffbe320885ed2f499e1f075" '' 'cd "$R/CUDApp" && make hello-gpu' |
| 682 | step 7.3-hello-gpu-control CHIP_TESTED req any "checked 1048576 of 1048576 elements: 1 wrong, 1 never written |
| 683 | RED as it must" '' 'cd "$R/CUDApp" && make hello-gpu-control' |
| 684 | notrun 7.4-six-suites CHIP_TESTED opt "no script in the repositories; see CUDApp/evidence/CUDAPP-OM-ENCODER/README.md" |
| 685 | else |
| 686 | notrun 7-chip CHIP_TESTED opt "declined at the y/N prompt" |
| 687 | fi ;; |
| 688 | *) |
| 689 | notrun 7-chip CHIP_TESTED opt "driver is not 580.173.02 (${ver:-none}); CUDA++ refuses other versions" ;; |
| 690 | esac |
| 691 | else |
| 692 | notrun 7-chip CHIP_TESTED opt "chip steps are off by default; run with --chip on a GB10" |
| 693 | fi |
| 694 | |
| 695 | summary |
| 696 | if [ "$req_bad" -eq 0 ]; then |
| 697 | say "RESULT: every required step PASSED. RUNLOG: $WSD/RUNLOG.md" |
| 698 | exit 0 |
| 699 | fi |
| 700 | say "RESULT: $req_bad required step(s) did not PASS (NOT_RUN is not PASS). RUNLOG: $WSD/RUNLOG.md" |
| 701 | exit 1 |
| 702 | INNER_EOF |
| 703 | |
| 704 | echo "replicate: re-running under env -i HOME=$WS PATH=/usr/bin:/bin LC_ALL=C" |
| 705 | exec env -i HOME="$WS" PATH=/usr/bin:/bin LC_ALL=C \ |
| 706 | ${AIEN_MODEL_URL:+AIEN_MODEL_URL="$AIEN_MODEL_URL"} ${AIEN_MODEL:+AIEN_MODEL="$AIEN_MODEL"} \ |
| 707 | ${AIEN_RAD_HTTP:+AIEN_RAD_HTTP="$AIEN_RAD_HTTP"} ${AIEN_RAD_HTTP2:+AIEN_RAD_HTTP2="$AIEN_RAD_HTTP2"} \ |
| 708 | sh "$WS/replicate-inner.sh" "$@" |