diff --git a/.github/workflows/e2e-nightly.yml b/.github/workflows/e2e-nightly.yml index 34096cd..5126a5f 100644 --- a/.github/workflows/e2e-nightly.yml +++ b/.github/workflows/e2e-nightly.yml @@ -1,6 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # End-to-end run on the self-hosted SI test Spark (DRA-55, DRA-59): install -> verify -> chat -> -# uninstall of a release tag, evidence JSONL (schema si-rig-e2e/1) certified REAL by +# uninstall of a release tag, evidence JSONL (schema si-rig-e2e/2) certified REAL by # installer/rig/evcheck.om and uploaded as an artifact. Manual dispatch only, with the tag as a # required input (no default). There is no schedule: DRA-163 holds the nightly schedule until the # capacity conflict is decided, since DRA-39 allows downtime on the shared Spark only Sunday diff --git a/installer/.crumb b/installer/.crumb index ddcfafd..520a2dc 100644 --- a/installer/.crumb +++ b/installer/.crumb @@ -3,14 +3,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-11-06T13:43:55Z", + "compiled_at": "2026-11-06T22:14:11Z", "compiler": "crumb-compile/1", - "digest": "sha256:b066b2ebe7db5fe0f654e7d2967966d640f2f0f2a171ba058ad3b1bc92b17797", + "digest": "sha256:a651b7fc6fea79a67bd555fa723b964d5416161815a497056a7912f072cd29db", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 85, - "generated_at_commit": "f738be3acfa02fe6ddc09a85567ba08e52ec3b67", - "source_tree": "sha256:05fb0afa38f560e15effb7e4f9ae2ae132523ead931ddd139063c7a4877c19bb" + "files": 127, + "generated_at_commit": "c7bdc6243dad584b80615df5410d4bd86ad4e625", + "source_tree": "sha256:25d6b97552179024ffb779f99d4ed9cb63061dd20ed959b89ff8f81431c1823f" } }, "invariants": [ diff --git a/installer/HOST-DEPENDENCIES.md b/installer/HOST-DEPENDENCIES.md index 6db3c9d..079e182 100644 --- a/installer/HOST-DEPENDENCIES.md +++ b/installer/HOST-DEPENDENCIES.md @@ -101,6 +101,21 @@ chacha20poly1305, serde, serde_json, bincode) are listed with their successors i The wizard starts it with `fork`, `setsid` and `execprog`, like the engine; there is no systemd unit and no autostart. +## The end-to-end harness (`rig/e2e.sh`, test machine only) + +`rig/e2e.sh` runs on the test Spark, never on a user's machine and never in a release. Its +receipts are judged by Omega (`rig/evcheck.om`) and its `--ref` file server is `rig/fileserv.om`. +The programs it sequences, seen on 2026-11-06 (Ubuntu 24.04.5 arm64): + +| Program | Version seen | Used for | Omega replacement | +|---|---|---|---| +| `sh` (dash) | 0.5.12 | runs the harness | goes away with the script | +| `git` | 2.43.0 | `ls-remote` checks the tag; `clone --branch TAG`, or `fetch --depth 1` of a `--ref` commit | the same Omega HTTPS client the `curl` rows need, plus a Git smart-HTTP reader | +| `curl` | 8.5.0 | waits for fileserv to answer `/ping` | a `waitio`/`recv` probe in Omega, next to fileserv | +| `openssl genpkey`, `pkey`, `pkeyutl -sign -rawin` | OpenSSL 3.0.13 | makes the `--ref` run's Ed25519 key and signs that run's `SHA256SUMS` | the Ed25519 signer proposed for `sign.sh` above | +| `sudo -n`, `useradd`, `userdel --remove`, `getent`, `pkill -KILL` | sudo 1.9.15p5, passwd 4.13, libc-bin 2.39, procps 4.0.4 | `--clean-account`: makes the disposable account, runs each step as it, then kills its processes and deletes it with its home | none in Omega today: it has `getuid`/`geteuid` and `killpid` but no word to change user, so an Omega account tool needs a `setid` host word (setresgid, setgroups, setresuid) proposed to omega-mv; creating the account stays the OS's job | +| `timeout`, `sha256sum`, `tar`, `mktemp`, `awk`, `sed`, `od` | coreutils 9.4, tar 1.35, gawk 5.2.1, sed 4.9 | time limits, the FAKE-MODEL bundle's hashes and tarball, the run key in a copy of `install.sh` | goes away with the script; `sha256` is already Omega | + ## Test-only settings - `AIENOS_PROBE_ROOT`: a folder prefixed to every hardware path the doctor and `install.sh` read diff --git a/installer/rig/README.md b/installer/rig/README.md index f7134f6..0bf3641 100644 --- a/installer/rig/README.md +++ b/installer/rig/README.md @@ -52,12 +52,37 @@ on a GitHub-hosted runner. `aienos verify`, `aienos chat` (a non-empty `model>` line is also required, because chat exits 0 after an engine error), and `aienos uninstall --yes`. Every step runs even after a failure, so uninstall always runs. Each -step writes one JSON line (schema `si-rig-e2e/1`): `step`, `mode` (`REAL` or `FAKE`), -`release_tag`, `engine_sha256` (of the installed `bin/aien-serve-http`), `model_repo` and -`model_commit` (from the installed `model.manifest`), `start_utc`, `end_utc` and `exit_code`. +step writes one JSON line (schema `si-rig-e2e/2`): `step`, `mode` (`REAL`, `FAKE` or +`FAKE-MODEL`), `evidence`, `release_tag`, `source_commit` (the commit installed), `account`, +`engine_sha256` (of the installed `bin/aien-serve-http`), `model_repo` and `model_commit` (from +the installed `model.manifest`), `start_utc`, `end_utc` and `exit_code`. Step logs go to `OUT.logs/`. `--fake` replaces every step with a stub and writes `mode: FAKE`. -TAG has no default: without `--tag` e2e.sh exits 2, and in REAL mode a TAG that `git ls-remote` -does not find on origin exits 2 before anything is installed. +TAG has no default: without `--tag` (or `--ref`) e2e.sh exits 2, and in REAL mode a TAG that +`git ls-remote` does not find on origin exits 2 before anything is installed. + +Release evidence (`evidence: release`) comes only from `--tag`. A run of an unreleased commit is +`--ref SHA` instead: SHA must be exactly 40 lowercase hex digits (a short sha, a branch name or +uppercase exits 2 before anything is written), and is fetched from origin (exit 2 when it +cannot be). e2e.sh builds that commit's bundle with its own `installer/build.sh` (set `OMEGA_SRC` +and `ENGINE` as build.sh documents), signs `SHA256SUMS` with a key made for the run, and installs +through a copy of the commit's `install.sh` that trusts only that key, served over plain +`http://127.0.0.1` by `fileserv.om` (compiled with `$OMEGA_SRC/seed/out/omc`; plain because the +wizard runs curl with an empty environment, where a run certificate cannot reach it). The release +key's signature check is NOT_RUN in such a run, so its records say +`evidence: "prerelease: not release evidence"`, an empty `release_tag` and `source_commit` SHA, +and `evcheck --want REAL` refuses them. `--ref SHA --fake-model` is the same run without GPU or +model download: the commit's `installer/tests/fake-engine.om` replaces the engine, a 5 MB test +model comes from the same local server, the hardware is `installer/tests/fake-root.sh` `gb10` +(`AIENOS_PROBE_ROOT`) and the wizard's server scan reads an empty folder (`AIENOS_PROC_ROOT`), so +nothing but the run's own fileserv and fake engine is contacted. Its `model_repo`/`model_commit` +are the commit's declared model, its `engine_sha256` the fake engine's. + +`--clean-account` (REAL or `--fake-model`) runs the steps as a disposable local user: `sudo +useradd` makes `sie2e` and 6 hex digits before the install, every step runs as that user with its +own `HOME` (`sudo -u`, `env -i`), and after uninstall `sudo userdel --remove` deletes it and its +home; e2e.sh exits 1 when the user, its group or its home is still present (`OUT.logs/account.log`). +It needs passwordless sudo and keeps the run out of the caller's `$HOME`. Records say `account: +disposable`, or `caller` without the option. `sh installer/rig/answer.sh LOG CMD...` answers the plain wizard by its own prompts instead of a fixed count of newlines: the wizard asks one more question when it finds a model server already @@ -69,16 +94,29 @@ not know. One read prints no prompt in plain mode, the end of the first-chat pan `stchat`); its unique last line `. Stop it with: aienos stop` is answered with Enter. `evcheck FILE` checks the schema: exactly those members, the pinned model revision, steps in -order, the same mode, tag and engine hash in every record, and timestamps that never go back. -`evcheck --want REAL FILE` certifies a run: also all four steps, every exit code 0, a non-zero -engine hash and every record in mode `REAL`, so FAKE evidence can never be certified as REAL. +order, the same mode, evidence, tag, commit, account and engine hash in every record, and +timestamps that never go back. Release evidence needs a tag and is never `FAKE-MODEL`; +prerelease evidence needs an empty tag and a commit that is not all zeros. +`evcheck --want WANT FILE` certifies a run: also all four steps, every exit code 0 and a non-zero +engine hash, and per WANT: `REAL` needs mode `REAL` and evidence `release`, so neither FAKE nor +prerelease evidence can be certified as release evidence; `PRERELEASE` needs mode `REAL` and +prerelease evidence; `FAKE` and `FAKE-MODEL` need that mode. Exit 0 pass, 1 a problem, 2 usage, 4 unreadable. evcheck uses `vendor/json.om`, a byte copy of omega-mv `bf54b19f` `seed/json/json.om`; `e2e-test.sh` checks the copy with `cmp`. -`sh installer/rig/e2e-test.sh OMC` is the host arm (FAKE only): a FAKE run must pass evcheck, -and five negative controls must be refused (a missing member, a bad sha256, a start before the -previous end, FAKE records with `--want REAL`, and a record relabelled REAL). It also checks that -e2e.sh without `--tag` exits 2, that answer.sh answers a stand-in plain wizard correctly with and +`sh installer/rig/e2e-test.sh OMC` is the host arm (FAKE only): a FAKE `--tag` run and a FAKE +`--ref` run must pass evcheck, and negative controls must be refused: a missing member, a bad +sha256, a start before the previous end, FAKE records with `--want REAL`, a record relabelled +REAL, a schema `/1` record, a `--ref` receipt relabelled REAL with `--want REAL` (the same file +passes `--want PRERELEASE`; a `--tag` receipt relabelled REAL is the control that passes `--want +REAL`), release evidence without a tag, a prerelease with a tag or an all-zero commit, mixed +evidence, a changed commit, FAKE-MODEL as release, and a bad account. e2e.sh must exit 2 and +write nothing without `--tag`/`--ref`, for a short, symbolic, uppercase or 41-digit `--ref`, for +`--tag` with `--ref`, `--fake-model` with `--tag`, `--fake` with `--fake-model`, +`--clean-account` with `--fake`, and a `--ref` build without `OMEGA_SRC`/`ENGINE`. fileserv must +send a 3 MB file byte for byte, answer 404 for a missing file or a folder, and answer 400 for +`..`, a part starting with a dot, an empty part, a query, the bare root and a POST. It also checks +that answer.sh answers a stand-in plain wizard correctly with and without a found server, that the old fixed newline string stops at the consent when a server is found, and that an unknown prompt stops answer.sh with exit 3. Rig checks runs it on every pull request. `.github/workflows/e2e-nightly.yml` ("E2E run") runs the REAL harness on manual dispatch diff --git a/installer/rig/e2e-test.sh b/installer/rig/e2e-test.sh index f717b66..4a532b5 100755 --- a/installer/rig/e2e-test.sh +++ b/installer/rig/e2e-test.sh @@ -4,12 +4,21 @@ # sh installer/rig/e2e-test.sh OMC (OMC = omega-mv bf54b19f seed/out/omc inside its checkout) # Sequencing only; evcheck.om makes every judgment. Arms: # vendor/json.om is byte-identical to the pinned omega-mv seed/json/json.om; -# a FAKE e2e.sh run passes evcheck in schema mode and in --want FAKE; +# a FAKE --tag run and a FAKE --ref run pass evcheck in schema mode and in --want FAKE; # negative controls, each must exit 1 with the named problem: a missing member, a bad sha256, -# a start before the previous end, and the FAKE records presented with --want REAL; -# e2e.sh without --tag exits 2; answer.sh answers a stand-in plain wizard by its prompts with -# and without a found model server, the old fixed newline string fails with a found server, -# and an unknown prompt stops answer.sh with exit 3. +# a start before the previous end, the FAKE records presented with --want REAL, a schema /1 +# record, and the release/prerelease separation: a --ref receipt relabelled REAL fails +# --want REAL (and passes --want PRERELEASE; a --tag receipt relabelled REAL is the control that +# passes --want REAL), release evidence without a tag, a prerelease with a tag or an all-zero +# commit, mixed evidence, a changed source_commit, FAKE-MODEL claimed as release, a bad account; +# e2e.sh refusals exit 2 and write nothing: no --tag or --ref, a short, symbolic, uppercase or +# 41-digit --ref, --tag with --ref, --fake-model with --tag, --fake with --fake-model, +# --clean-account with --fake, a --ref build without OMEGA_SRC and ENGINE; +# fileserv.om sends a 3 MB file byte for byte and answers 404 for a missing file or a folder +# and 400 for "..", a dot part, an empty part, a query, the bare root and a POST; +# answer.sh answers a stand-in plain wizard by its prompts with and without a found model +# server, the old fixed newline string fails with a found server, and an unknown prompt stops +# answer.sh with exit 3. set -eu here=$(cd "$(dirname "$0")" && pwd) omc=${1:?usage: e2e-test.sh OMC} @@ -29,6 +38,13 @@ sh "$here/e2e.sh" --fake --tag alpha-20261029.1 --out "$out/fake.jsonl" || { ech cat "$out/fake.jsonl" "$ev" "$out/fake.jsonl" || { echo "ARM schema: want 0"; fail=1; } "$ev" --want FAKE "$out/fake.jsonl" || { echo "ARM certify-fake: want 0"; fail=1; } +r=0123456789abcdef0123456789abcdef01234567 +sh "$here/e2e.sh" --fake --ref "$r" --out "$out/ref.jsonl" || { echo "ARM fake-ref-run: want 0"; fail=1; } +cat "$out/ref.jsonl" +"$ev" "$out/ref.jsonl" || { echo "ARM ref-schema: want 0"; fail=1; } +"$ev" --want FAKE "$out/ref.jsonl" > "$out/o" || { echo "ARM ref-certify-fake: want 0"; fail=1; } +cat "$out/o" +grep -qF "evidence=prerelease" "$out/o" || { echo "ARM ref-certify-fake: not reported as prerelease"; fail=1; } # neg NAME TEXT EVCHECK-ARGS...: must exit 1 and print TEXT neg() { @@ -54,15 +70,60 @@ neg non-monotonic "line 3: start_utc is before the previous record's end_utc" "$ neg fake-as-real "certify: mode is not the wanted mode" --want REAL "$f" sed '1s/"mode":"FAKE"/"mode":"REAL"/' "$f" > "$out/mixed.jsonl" neg mixed-mode "line 2: mode differs from the first record" --want REAL "$out/mixed.jsonl" +sed '1s|"schema":"si-rig-e2e/2"|"schema":"si-rig-e2e/1"|' "$f" > "$out/v1.jsonl" +neg schema-v1 "line 1: schema is not si-rig-e2e/2" "$out/v1.jsonl" -# Missing tag: e2e.sh has no default tag and must refuse with exit 2 before writing anything. -rc=0 -sh "$here/e2e.sh" --fake --out "$out/notag.jsonl" > "$out/o" 2>&1 || rc=$? -if [ "$rc" = 2 ] && grep -qF -- "--tag TAG is required" "$out/o" && [ ! -e "$out/notag.jsonl" ]; then - echo "NEGATIVE-CONTROL missing-tag: rejected as expected (rc=2)" -else - echo "NEGATIVE-CONTROL missing-tag: rc=$rc (want 2)"; cat "$out/o"; fail=1 -fi +# Release and prerelease evidence stay apart. rr is the --ref receipt with every mode relabelled +# REAL, as a REAL --ref run would write it; tr is the --tag receipt relabelled the same way. +rr=$out/ref-real.jsonl tr=$out/tag-real.jsonl +sed 's/"mode":"FAKE"/"mode":"REAL"/' "$out/ref.jsonl" > "$rr" +sed 's/"mode":"FAKE"/"mode":"REAL"/' "$f" > "$tr" +neg ref-as-release "certify: prerelease evidence is not release evidence" --want REAL "$rr" +"$ev" --want PRERELEASE "$rr" || { echo "ARM ref-certify-prerelease: want 0"; fail=1; } +"$ev" --want REAL "$tr" || { echo "CONTROL tag-certify-real: want 0"; fail=1; } +neg tag-as-prerelease "certify: release evidence is not prerelease evidence" --want PRERELEASE "$tr" +neg ref-as-fake-model "certify: mode is not the wanted mode" --want FAKE-MODEL "$out/ref.jsonl" +sed 's/"evidence":"prerelease: not release evidence"/"evidence":"release"/' "$rr" > "$out/notag.jsonl" +neg release-without-tag "line 1: release evidence needs a release_tag" --want REAL "$out/notag.jsonl" +sed 's/"release_tag":""/"release_tag":"alpha-20261029.1"/' "$rr" > "$out/pretag.jsonl" +neg prerelease-with-tag "line 1: prerelease evidence must have an empty release_tag" "$out/pretag.jsonl" +sed "s/$r/0000000000000000000000000000000000000000/" "$rr" > "$out/prezero.jsonl" +neg prerelease-zero-commit "line 1: prerelease evidence needs a source_commit that is not all zeros" "$out/prezero.jsonl" +sed '2s/"evidence":"release"/"evidence":"prerelease: not release evidence"/' "$tr" > "$out/mixev.jsonl" +neg mixed-evidence "line 2: evidence differs from the first record" "$out/mixev.jsonl" +sed "3s/\"source_commit\":\"0/\"source_commit\":\"1/" "$rr" > "$out/mixcom.jsonl" +neg mixed-commit "line 3: source_commit differs from the first record" "$out/mixcom.jsonl" +sed 's/"mode":"FAKE"/"mode":"FAKE-MODEL"/' "$f" > "$out/fmrel.jsonl" +neg fake-model-release "line 1: FAKE-MODEL runs are prerelease evidence only" "$out/fmrel.jsonl" +sed '1s/"account":"caller"/"account":"root"/' "$rr" > "$out/acct.jsonl" +neg bad-account "line 1: account is not caller or disposable" "$out/acct.jsonl" + +# Refusals: exit 2 with the named text before anything is written. +refused() { # NAME TEXT E2E-ARGS... + name=$1 want=$2 + shift 2 + rm -rf "$out/r.jsonl" "$out/r.logs" + rc=0 + env -u OMEGA_SRC -u ENGINE sh "$here/e2e.sh" "$@" --out "$out/r.jsonl" > "$out/o" 2>&1 || rc=$? + if [ "$rc" = 2 ] && grep -qF -- "$want" "$out/o" && [ ! -e "$out/r.jsonl" ] && [ ! -e "$out/r.logs" ]; then + echo "NEGATIVE-CONTROL $name: refused as expected (rc=2, $want)" + else + echo "NEGATIVE-CONTROL $name: rc=$rc (want 2 and nothing written), wanted text: $want" + cat "$out/o" + fail=1 + fi +} +full="--ref needs a full commit sha, 40 lowercase hex digits" +refused missing-tag "--tag TAG is required" --fake +refused short-ref "$full" --fake --ref abc1234 +refused branch-ref "$full" --fake --ref main +refused upper-ref "$full" --fake --ref "$(printf %s "$r" | tr a-f A-F)" +refused long-ref "$full" --fake --ref "${r}0" +refused tag-and-ref "--tag and --ref exclude each other" --fake --tag alpha-20261029.1 --ref "$r" +refused fake-model-tag "--fake-model needs --ref" --fake-model --tag alpha-20261029.1 +refused fake-and-fake-model "--fake and --fake-model exclude each other" --fake --fake-model --ref "$r" +refused clean-fake "--clean-account needs a REAL or --fake-model run" --fake --clean-account --ref "$r" +refused ref-no-inputs "set OMEGA_SRC and ENGINE" --fake-model --ref "$r" # answer.sh against a stand-in for the plain wizard: it prints "PROMPT: " and reads one line per # question, like ask in installer/wizard/steps.om. With a found server it asks one more question @@ -124,4 +185,40 @@ if [ "$rc" = 3 ] && grep -qF "unknown prompt" "$out/o"; then else echo "NEGATIVE-CONTROL unknown-prompt: rc=$rc (want 3)"; cat "$out/o"; fail=1 fi +# fileserv.om, the --ref runs' local server: the bytes of its folder, nothing outside it. +"$omc" < "$here/fileserv.om" > "$out/fileserv" && chmod +x "$out/fileserv" +mkdir -p "$out/www/rel" "$out/www/.h" +head -c 3000000 /dev/urandom > "$out/www/rel/big.bin" +printf 'hi\n' > "$out/www/rel/a.txt" +printf 'hidden\n' > "$out/www/.h/x" +printf 'secret\n' > "$out/secret" +(cd "$out/www" && exec "$out/fileserv") > "$out/fs.log" 2>&1 < /dev/null & +fspid=$! +port= i=0 +until [ -n "$port" ] || [ "$i" -ge 50 ]; do + sleep 0.1 + i=$((i + 1)) + port=$(sed -n 's/^PORT \([0-9][0-9]*\)$/\1/p' "$out/fs.log") +done +code() { curl -s -o "$out/body" -w '%{http_code}' --path-as-is "$@" "http://127.0.0.1:$port$u" || true; } +u=/rel/big.bin +if [ "$(code)" = 200 ] && cmp -s "$out/body" "$out/www/rel/big.bin"; then + echo "ARM fileserv-get: 3000000 bytes identical" +else + echo "ARM fileserv-get: want 200 and identical bytes" + fail=1 +fi +for c in "/rel/missing 404" "/rel 404" "/../secret 400" "/rel/../../secret 400" "/.h/x 400" \ + "/rel//a.txt 400" "/rel/a.txt?x=1 400" "/ 400"; do + u=${c% *} w=${c##* } + g=$(code) + [ "$g" = "$w" ] && echo "NEGATIVE-CONTROL fileserv $u: $g as expected" \ + || { echo "NEGATIVE-CONTROL fileserv $u: got $g, want $w"; fail=1; } +done +u=/rel/a.txt +g=$(code -d x) +[ "$g" = 400 ] && echo "NEGATIVE-CONTROL fileserv POST $u: 400 as expected" \ + || { echo "NEGATIVE-CONTROL fileserv POST $u: got $g, want 400"; fail=1; } +kill "$fspid" 2>/dev/null || true + [ "$fail" = 0 ] && echo "E2E HOST TEST PASS (FAKE only; REAL NOT_RUN)" || { echo "E2E HOST TEST FAIL"; exit 1; } diff --git a/installer/rig/e2e.sh b/installer/rig/e2e.sh index 944a31a..054b47b 100755 --- a/installer/rig/e2e.sh +++ b/installer/rig/e2e.sh @@ -1,46 +1,134 @@ #!/bin/sh # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # End-to-end harness for the SI Alpha test Spark (DRA-55): install -> verify -> chat -> uninstall, -# one evidence record per step in OUT (JSONL, schema si-rig-e2e/1, checked by evcheck.om). -# sh installer/rig/e2e.sh --tag TAG --out OUT REAL: installs into $HOME on this machine -# sh installer/rig/e2e.sh --fake --tag TAG --out OUT FAKE: every step is a stub; records say FAKE +# one evidence record per step in OUT (JSONL, schema si-rig-e2e/2, checked by evcheck.om). +# sh installer/rig/e2e.sh --tag TAG --out OUT REAL release run of published TAG +# sh installer/rig/e2e.sh --ref SHA --out OUT REAL prerelease run of commit SHA +# sh installer/rig/e2e.sh --ref SHA --fake-model --out OUT FAKE-MODEL prerelease run of SHA +# sh installer/rig/e2e.sh --fake (--tag TAG | --ref SHA) --out OUT FAKE: every step is a stub +# add --clean-account to a REAL or FAKE-MODEL run to run it as a disposable local user # Sequencing only: the steps are the commands of installer/tests/run.sh, and every judgment about -# the evidence is made by evcheck.om. REAL needs a stock DGX Spark with no AienOS install, network, -# and the release TAG published; it starts the engine on the GPU. TAG has no default: a missing -# TAG exits 2, and in REAL mode a TAG that is not a tag on origin exits 2 before anything runs. -# The wizard is answered prompt by prompt by answer.sh, never by a fixed count of newlines. Every -# step runs and is recorded even after an earlier step failed, so uninstall always runs. Exit 0 -# when every step exited 0. +# the evidence is made by evcheck.om. The wizard is answered prompt by prompt by answer.sh, never +# by a fixed count of newlines. Every step runs and is recorded even after an earlier step failed, +# so uninstall always runs. Exit 0 when every step exited 0 (and, with --clean-account, the +# account and its home are gone afterwards); 2 a refused argument, before anything is written. +# +# Release evidence (evidence "release"): only --tag. TAG has no default; in REAL mode a TAG that is +# not a tag on origin exits 2 before anything runs. REAL needs a stock DGX Spark with no AienOS +# install and network; it starts the engine on the GPU. evcheck --want REAL certifies only these. +# +# Prerelease (evidence "prerelease: not release evidence", release_tag empty, source_commit SHA): +# --ref SHA takes exactly 40 lowercase hex digits; anything else exits 2. The commit is fetched +# from origin (exit 2 when it cannot be), its bundle is built by its own installer/build.sh (set +# OMEGA_SRC and ENGINE as build.sh documents), SHA256SUMS is signed with a key made for this run, +# and the install goes through a copy of the commit's install.sh that trusts only that key, from +# http://127.0.0.1 (fileserv.om, compiled with $OMEGA_SRC/seed/out/omc). The release key's +# signature check is NOT_RUN in such a run, which is why it is never release evidence. Certify a +# REAL --ref run with evcheck --want PRERELEASE. +# +# FAKE-MODEL (--fake-model, needs --ref): the same build and install, but the bundle's engine is +# the commit's installer/tests/fake-engine.om, the model is a 5 MB test model from the same local +# server, the hardware is the commit's installer/tests/fake-root.sh gb10 tree (AIENOS_PROBE_ROOT), +# and the wizard's server scan reads an empty folder (AIENOS_PROC_ROOT). Install, wizard, verify, +# chat and uninstall run for real; no GPU device is opened, no model is downloaded, and nothing +# but the run's own fileserv and fake engine (127.0.0.1:18100) is contacted. model_repo and +# model_commit are the commit's declared model +# (installer/share/model.manifest), engine_sha256 the fake engine's. evcheck --want FAKE-MODEL. +# +# --clean-account: sudo useradd makes a disposable account (sie2e and 6 hex digits) before the +# install; every step runs as that account (sudo -u, env -i, its own HOME), and afterwards sudo +# userdel --remove deletes it with its home. Needs passwordless sudo. Without it the run uses the +# caller's $HOME. Each record's account member says which ("disposable" or "caller"). set -eu -mode=REAL tag= out= +umask 022 +usage="usage: e2e.sh [--fake | --fake-model] [--clean-account] (--tag TAG | --ref SHA) --out OUT" +mode=REAL tag= ref= out= clean=0 fm=0 while [ $# -gt 0 ]; do case $1 in --fake) mode=FAKE ;; + --fake-model) fm=1 ;; + --clean-account) clean=1 ;; --tag) tag=${2:?--tag needs a value}; shift ;; + --ref) ref=${2:?--ref needs a value}; shift ;; --out) out=${2:?--out needs a value}; shift ;; - *) echo "usage: e2e.sh [--fake] --tag TAG --out OUT" >&2; exit 2 ;; + *) echo "$usage" >&2; exit 2 ;; esac shift done -[ -n "$tag" ] || { echo "e2e.sh: --tag TAG is required (a published release tag); there is no default" >&2; exit 2; } -[ -n "$out" ] || { echo "usage: e2e.sh [--fake] --tag TAG --out OUT" >&2; exit 2; } -if [ "$mode" = REAL ] && ! git ls-remote --exit-code --tags \ - https://github.com/aien-dev/sovereign-intelligence.git "refs/tags/$tag" > /dev/null; then - echo "e2e.sh: $tag is not a tag on aien-dev/sovereign-intelligence" >&2 - exit 2 +refuse() { echo "e2e.sh: $*" >&2; exit 2; } +[ -n "$tag$ref" ] || refuse "--tag TAG is required for release evidence (a published release tag), or --ref SHA for a prerelease run; there is no default" +[ -z "$tag" ] || [ -z "$ref" ] || refuse "--tag and --ref exclude each other" +if [ -n "$ref" ]; then + case $ref in + *[!0-9a-f]*) refuse "--ref needs a full commit sha, 40 lowercase hex digits: $ref" ;; + esac + [ "${#ref}" -eq 40 ] || refuse "--ref needs a full commit sha, 40 lowercase hex digits: $ref" +fi +if [ "$fm" = 1 ]; then + [ "$mode" = REAL ] || refuse "--fake and --fake-model exclude each other" + [ -n "$ref" ] || refuse "--fake-model needs --ref: a published release cannot carry the test engine and model" + mode=FAKE-MODEL +fi +[ "$clean" = 0 ] || [ "$mode" != FAKE ] || refuse "--clean-account needs a REAL or --fake-model run; FAKE installs nothing" +[ -n "$out" ] || { echo "$usage" >&2; exit 2; } +if [ -n "$ref" ] && [ "$mode" != FAKE ]; then + [ -n "${OMEGA_SRC:-}" ] && [ -n "${ENGINE:-}" ] \ + || refuse "--ref builds the commit's bundle: set OMEGA_SRC and ENGINE as installer/build.sh documents" +fi +[ "$clean" = 0 ] || sudo -n true 2>/dev/null || refuse "--clean-account needs passwordless sudo" +origin=https://github.com/aien-dev/sovereign-intelligence.git +if [ "$mode" = REAL ] && [ -n "$tag" ] && ! git ls-remote --exit-code --tags \ + "$origin" "refs/tags/$tag" > /dev/null; then + refuse "$tag is not a tag on aien-dev/sovereign-intelligence" fi here=$(cd "$(dirname "$0")" && pwd) -work=$(mktemp -d "${TMPDIR:-/tmp}/si-e2e.XXXXXX") -trap 'rm -rf "$work"' EXIT -mkdir -p "$(dirname "$out")" -: > "$out" -logs=${out%.jsonl}.logs -mkdir -p "$logs" -base=$HOME/.local/share/aienos -aienos=$base/current/bin/aienos zero=0000000000000000000000000000000000000000000000000000000000000000 -sha=$zero repo= commit= +acct= home=$HOME srvpid= +work=$(mktemp -d "${TMPDIR:-/tmp}/si-e2e.XXXXXX") +# $work/pub holds what the disposable account reads (the checkout, the installer it runs, the +# fake hardware tree, the run's TLS certificate); the run's keys stay in $work. +case $work in *[[:space:]]*) rm -rf "$work"; refuse "the scratch folder $work has white space in its name" ;; esac +chmod 711 "$work" +pub=$work/pub +mkdir "$pub" + +# Remove the disposable account, its processes and its home; 0 when the account, its group and +# its home are all gone. +drop() { + [ -n "$acct" ] || return 0 + sudo -n pkill -KILL -u "$acct" 2>/dev/null || true + i=0 + while pgrep -u "$acct" > /dev/null 2>&1 && [ "$i" -lt 20 ]; do i=$((i + 1)); sleep 0.5; done + sudo -n userdel --remove "$acct" 2>&1 || true + if getent passwd "$acct" > /dev/null || getent group "$acct" > /dev/null || [ -e "$home" ]; then + echo "e2e: account $acct or its home $home is still present" + return 1 + fi + echo "e2e: account $acct and its home $home removed" + acct= +} +cleanup() { + [ -z "$srvpid" ] || kill "$srvpid" 2>/dev/null || true + drop > /dev/null 2>&1 || true + rm -rf "$work" +} +trap cleanup EXIT +trap 'exit 130' HUP INT TERM + +if [ -n "$ref" ] && [ "$mode" != FAKE ]; then + { git init -q "$pub/si" && git -C "$pub/si" fetch -q --depth 1 "$origin" "$ref" \ + && git -C "$pub/si" checkout -q FETCH_HEAD \ + && [ "$(git -C "$pub/si" rev-parse HEAD)" = "$ref" ]; } \ + || refuse "$ref is not a commit that can be fetched from aien-dev/sovereign-intelligence" +fi + now() { date -u +%Y-%m-%dT%H:%M:%SZ; } +if [ -n "$tag" ]; then + evidence=release src=0000000000000000000000000000000000000000 +else + evidence="prerelease: not release evidence" src=$ref +fi +sha=$zero repo= commit= # The model revision as the release declares it: the url line of its model.manifest. revision() { @@ -50,41 +138,157 @@ revision() { commit=${commit%/} } +# $work/as CMD...: runs CMD as the account the steps use, with that account's HOME. +xenv= +if [ "$mode" = FAKE-MODEL ]; then + mkdir "$pub/proc-empty" + sh "$pub/si/installer/tests/fake-root.sh" "$pub/root-gb10" gb10 > /dev/null + xenv="AIENOS_PROBE_ROOT=$pub/root-gb10 AIENOS_PROC_ROOT=$pub/proc-empty" +fi +if [ "$clean" = 1 ]; then + acct=sie2e$(od -An -N3 -tx1 /dev/urandom | tr -d ' \n') + sudo -n useradd --create-home --user-group --shell /bin/sh \ + --comment "SI e2e.sh disposable account" "$acct" > "$work/account.log" 2>&1 \ + || { cat "$work/account.log" >&2; acct=; refuse "could not create the disposable account"; } + home=$(getent passwd "$acct" | cut -d: -f6) + echo "e2e: account $acct created, home $home" >> "$work/account.log" + # sudo keeps the caller's working folder, which the account may not reach: start in its HOME. + cat > "$work/as" <<-EOF + #!/bin/sh + exec sudo -n -u $acct -- env -i HOME=$home USER=$acct LOGNAME=$acct LANG=C.UTF-8 \\ + PATH=$home/.local/bin:/usr/local/bin:/usr/bin:/bin $xenv /bin/sh -c 'cd && exec "\$@"' sh "\$@" + EOF + account=disposable +else + printf '#!/bin/sh\nexec env %s "$@"\n' "$xenv" > "$work/as" + account=caller +fi +chmod 755 "$work/as" +as=$work/as +base=$home/.local/share/aienos +aienos=$base/current/bin/aienos + +# The local file server of a --ref run: fileserv.om serves $www on a port the kernel picks. +www=$pub/www +if [ -n "$ref" ] && [ "$mode" != FAKE ]; then + omc=$OMEGA_SRC/seed/out/omc + "$omc" < "$here/fileserv.om" > "$work/fileserv" || { echo "e2e.sh: fileserv.om did not compile" >&2; exit 1; } + chmod 755 "$work/fileserv" + mkdir -p "$www/rel" "$www/model" + printf 'ok\n' > "$www/ping" + (cd "$www" && exec "$work/fileserv") > "$work/http.log" 2>&1 < /dev/null & + srvpid=$! + i=0 port= + until [ -n "$port" ] && curl -fs "http://127.0.0.1:$port/ping" > /dev/null 2>&1; do + i=$((i + 1)) + [ "$i" -lt 100 ] || { cat "$work/http.log" >&2; echo "e2e.sh: fileserv did not start" >&2; exit 1; } + sleep 0.1 + port=$(sed -n 's/^PORT \([0-9][0-9]*\)$/\1/p' "$work/http.log") + done + openssl genpkey -algorithm ed25519 -out "$work/run.key" 2>/dev/null + openssl pkey -in "$work/run.key" -pubout -out "$work/run.pub.pem" +fi + +mkdir -p "$(dirname "$out")" +: > "$out" +logs=${out%.jsonl}.logs +mkdir -p "$logs" +[ ! -e "$work/account.log" ] || mv "$work/account.log" "$logs/account.log" + +# The commit's install.sh with the run's key in place of the release key (both constants). +runkey() { + hex=$(openssl pkey -pubin -in "$work/run.pub.pem" -outform DER | tail -c 32 | od -An -tx1 | tr -d ' \n') + awk -v pem="$work/run.pub.pem" -v hex="$hex" ' + /^RELEASE_PUB_HEX=/ { print "RELEASE_PUB_HEX=" hex; next } + /^RELEASE_PUB_PEM=/ { while ((getline l < pem) > 0) { out = out (out == "" ? "" : "\n") l } + print "RELEASE_PUB_PEM='"'"'" out "'"'"'"; skip = 1; next } + skip && /^-----END PUBLIC KEY-----/ { skip = 0; next } + skip { next } + { print }' "$1" +} + +# The wizard, answered prompt by prompt, then its transcript in the step log. +wizard() { + wrc=0 + sh "$here/answer.sh" "$work/wizard.out" "$as" timeout 7200 "$aienos" wizard --plain || wrc=$? + cat "$work/wizard.out" + echo "e2e: wizard prompts answered:" + cat "$work/wizard.out.prompts" + return "$wrc" +} + if [ "$mode" = FAKE ]; then # FAKE: no install happens. The engine hash is the sha256 of a fixed FAKE label, and the model # revision is read from this checkout's manifest. - sha=$(printf 'FAKE engine for si-rig-e2e/1\n' | sha256sum | cut -d' ' -f1) + sha=$(printf 'FAKE engine for si-rig-e2e/2\n' | sha256sum | cut -d' ' -f1) revision "$here/../share/model.manifest" - s_install() { echo "FAKE install $tag"; } + s_install() { echo "FAKE install ${tag:-$ref}"; } s_verify() { echo "FAKE verify"; } s_chat() { echo "FAKE chat"; echo "model> FAKE"; } s_uninstall() { echo "FAKE uninstall"; } else - s_install() { - git clone --quiet --depth 1 --branch "$tag" \ - https://github.com/aien-dev/sovereign-intelligence.git "$work/si" || return - AIENOS_NO_WIZARD=1 sh "$work/si/installer/install.sh" || return - wrc=0 - sh "$here/answer.sh" "$work/wizard.out" timeout 7200 "$aienos" wizard --plain || wrc=$? - cat "$work/wizard.out" - echo "e2e: wizard prompts answered:" - cat "$work/wizard.out.prompts" - return "$wrc" - } - s_verify() { "$aienos" verify; } - # chat exits 0 even after an engine error, so the step also needs a non-empty model> line. + if [ -n "$tag" ]; then + s_install() { + git clone --quiet --depth 1 --branch "$tag" "$origin" "$pub/si" || return + src=$(git -C "$pub/si" rev-parse HEAD) + "$as" env AIENOS_NO_WIZARD=1 sh "$pub/si/installer/install.sh" || return + wizard + } + else + [ "$mode" != FAKE-MODEL ] || revision "$pub/si/installer/share/model.manifest" + s_install() { + echo "e2e: building commit $ref with its installer/build.sh" + OMEGA_SRC=$OMEGA_SRC ENGINE=$ENGINE sh "$pub/si/installer/build.sh" "$work/build" || return + rel=$(sed -n 's/^TAG=//p' "$pub/si/installer/install.sh") + bundle=aienos-$rel-linux-arm64.tar.gz + rel_d=$www/rel + if [ "$mode" = FAKE-MODEL ]; then + "$OMEGA_SRC/seed/out/omc" < "$pub/si/installer/tests/fake-engine.om" > "$work/fake-engine" || return + mkdir "$work/model" + head -c 5000000 /dev/urandom > "$work/model/weights.bin" + printf '{"model_type":"test"}\n' > "$work/model/config.json" + st=$work/tstage + cp -a "$work/build/stage" "$st" + install -m 755 "$work/fake-engine" "$st/bin/aien-serve-http" + { + printf 'name test-model\nurl http://127.0.0.1:%s/model/\n' "$port" + printf 'bytes %s\nfiles 2\n' "$(cat "$work/model/weights.bin" "$work/model/config.json" | wc -c | tr -d ' ')" + for f in config.json weights.bin; do + printf '%s %s %s\n' "$(sha256sum "$work/model/$f" | cut -d' ' -f1)" \ + "$(wc -c < "$work/model/$f" | tr -d ' ')" "$f" + cp "$work/model/$f" "$www/model/$f" + done + } > "$st/share/aienos/model.manifest" + (cd "$st" && find . -type f ! -name SHA256SUMS | sed 's|^\./||' | LC_ALL=C sort \ + | xargs sha256sum > SHA256SUMS) + (cd "$st" && tar -czf "$rel_d/$bundle" .) + else + cp "$work/build/dist/$bundle" "$rel_d/$bundle" || return + fi + runkey "$pub/si/installer/install.sh" > "$rel_d/install.sh" + (cd "$rel_d" && sha256sum "$bundle" install.sh > SHA256SUMS \ + && openssl pkeyutl -sign -inkey "$work/run.key" -rawin -in SHA256SUMS -out SHA256SUMS.sig) || return + echo "e2e: prerelease: SHA256SUMS signed with this run's key; the release-key signature check is NOT_RUN" + "$as" env AIENOS_NO_WIZARD=1 AIENOS_BASE_URL="http://127.0.0.1:$port/rel" \ + sh "$rel_d/install.sh" || return + wizard + } + fi + s_verify() { "$as" "$aienos" verify; } + # chat exits 0 even after an engine error, so the step also needs a non-empty model> reply. With + # piped input chat's "you> " prompt has no newline after it, so the reply line starts with it. s_chat() { rc=0 - printf 'Reply with one short sentence.\n/bye\n' | timeout 900 "$aienos" chat > "$work/chat" 2>&1 || rc=$? + printf 'Reply with one short sentence.\n/bye\n' | "$as" timeout 900 "$aienos" chat > "$work/chat" 2>&1 || rc=$? cat "$work/chat" - "$aienos" stop || true + "$as" "$aienos" stop || true [ "$rc" = 0 ] || return "$rc" - grep -Eq '^model> .*[^[:space:]]' "$work/chat" || { echo "e2e: no model> reply"; return 1; } + grep -Eq '^(you> )*model> .*[^[:space:]]' "$work/chat" || { echo "e2e: no model> reply"; return 1; } } s_uninstall() { - [ -x "$aienos" ] || { echo "e2e: $aienos missing"; return 1; } - "$aienos" uninstall --yes || return - [ ! -e "$base" ] || { echo "e2e: $base still present"; return 1; } + "$as" test -x "$aienos" || { echo "e2e: $aienos missing"; return 1; } + "$as" "$aienos" uninstall --yes || return + ! "$as" test -e "$base" || { echo "e2e: $base still present"; return 1; } } fi @@ -94,15 +298,21 @@ for step in install verify chat uninstall; do rc=0 "s_$step" > "$logs/$step.log" 2>&1 || rc=$? end=$(now) - if [ "$mode" = REAL ] && [ "$step" = install ]; then - [ -x "$base/current/bin/aien-serve-http" ] \ - && sha=$(sha256sum "$base/current/bin/aien-serve-http" | cut -d' ' -f1) - [ -f "$base/current/share/aienos/model.manifest" ] \ - && revision "$base/current/share/aienos/model.manifest" + if [ "$mode" != FAKE ] && [ "$step" = install ]; then + "$as" test -x "$base/current/bin/aien-serve-http" \ + && sha=$("$as" sha256sum "$base/current/bin/aien-serve-http" | cut -d' ' -f1) + if [ "$mode" = REAL ] && "$as" cat "$base/current/share/aienos/model.manifest" > "$work/manifest" 2>/dev/null; then + revision "$work/manifest" + fi fi [ "$rc" = 0 ] || all=1 - printf '{"schema":"si-rig-e2e/1","step":"%s","mode":"%s","release_tag":"%s","engine_sha256":"%s","model_repo":"%s","model_commit":"%s","start_utc":"%s","end_utc":"%s","exit_code":%d}\n' \ - "$step" "$mode" "$tag" "$sha" "$repo" "$commit" "$start" "$end" "$rc" >> "$out" + printf '{"schema":"si-rig-e2e/2","step":"%s","mode":"%s","evidence":"%s","release_tag":"%s","source_commit":"%s","account":"%s","engine_sha256":"%s","model_repo":"%s","model_commit":"%s","start_utc":"%s","end_utc":"%s","exit_code":%d}\n' \ + "$step" "$mode" "$evidence" "$tag" "$src" "$account" "$sha" "$repo" "$commit" "$start" "$end" "$rc" >> "$out" echo "e2e: $mode $step exit $rc" done +[ ! -e "$work/http.log" ] || cp "$work/http.log" "$logs/http.log" +if [ "$clean" = 1 ]; then + drop >> "$logs/account.log" 2>&1 || all=1 + tail -n 1 "$logs/account.log" +fi exit "$all" diff --git a/installer/rig/evcheck.om b/installer/rig/evcheck.om index 2806488..ea7dc92 100644 --- a/installer/rig/evcheck.om +++ b/installer/rig/evcheck.om @@ -1,26 +1,38 @@ note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception note evcheck.om: checks the evidence JSONL of the SI Alpha end-to-end harness (DRA-55, DRA-59), -note schema si-rig-e2e/1. Usage: +note schema si-rig-e2e/2. Usage: note evcheck FILE schema mode: every record valid, any mode, any exit codes -note evcheck --want MODE FILE certify: also every record has mode MODE (REAL or FAKE), all four -note steps install verify chat uninstall are present, every exit_code is -note 0 and engine_sha256 is not all zeros +note evcheck --want WANT FILE certify: all four steps install verify chat uninstall are present, +note every exit_code is 0, engine_sha256 is not all zeros, and: +note REAL mode REAL and evidence "release": the only release evidence +note PRERELEASE mode REAL and evidence "prerelease: not release evidence" (an e2e.sh --ref run) +note FAKE mode FAKE, either evidence +note FAKE-MODEL mode FAKE-MODEL (always prerelease) note Composition (a program unit): { printf 'om2\n'; cat installer/rig/vendor/json.om note installer/rig/evcheck.om; } | omc. vendor/json.om is a byte copy of omega-mv bf54b19f note seed/json/json.om; arrays handed to js_* are locals, as its README requires. note One record per line, a JSON object with exactly these members, each once: -note schema "si-rig-e2e/1" step: one of install verify chat uninstall, in that order, no repeats -note mode "REAL" or "FAKE", the same in every record -note release_tag: 1..128 bytes, no escapes, the same in every record +note schema "si-rig-e2e/2" step: one of install verify chat uninstall, in that order, no repeats +note mode "REAL", "FAKE" or "FAKE-MODEL", the same in every record +note evidence "release" or "prerelease: not release evidence", the same in every record; +note FAKE-MODEL is prerelease only +note release_tag: 0..128 bytes, no escapes, the same in every record; 1..128 for release evidence, +note empty for prerelease evidence (e2e.sh --ref installs a commit, not a published release) +note source_commit: 40 lowercase hex digits, the same in every record; not all zeros for +note prerelease evidence (it names the commit that was built and installed) +note account "caller" (the run used the caller's HOME) or "disposable" (a user created for the run +note and removed after it), the same in every record note engine_sha256: 64 lowercase hex digits, the same in every record note model_repo "Qwen/Qwen3.6-35B-A3B-FP8" model_commit "95a723d08a9490559dae23d0cff1d9466213d989" note start_utc, end_utc: YYYY-MM-DDTHH:MM:SSZ; start <= end, and end <= the next record's start note exit_code: an integer that fits a long -note Output: PROBLEM line N: message per finding, then EVCHECK PASS records=N mode=M [certified=M] +note Output: PROBLEM line N: message per finding, then +note EVCHECK PASS records=N mode=M evidence=release|prerelease [certified=WANT] note or EVCHECK FAIL problems=K. Exit 0 pass, 1 a problem, 2 usage, 4 the file could not be read or note is larger than 262143 bytes. -note per-run state; mode 1 REAL, 2 FAKE +note per-run state; mode 1 REAL, 2 FAKE, 3 FAKE-MODEL; want 1 REAL, 2 FAKE, 3 FAKE-MODEL, +note 4 PRERELEASE; evidence 1 release, 2 prerelease; account 1 caller, 2 disposable global pb uchar 4096 global pbn ulong 1 global prob ulong 1 @@ -35,21 +47,35 @@ global lastend uchar 20 global tag0 uchar 128 global tag0n ulong 1 global sha0 uchar 64 +global ev0 ulong 1 +global acct0 ulong 1 +global com0 uchar 40 +note the current record: mode, evidence, release_tag length (129 when invalid), and whether +note source_commit is all zeros (2 when invalid) +global cmode ulong 1 +global cev ulong 1 +global ctagn ulong 1 +global czc ulong 1 note value token of each field in the current record, and how often its key appeared -global fv ulong 11 -global fc ulong 11 +global fv ulong 14 +global fc ulong 14 text t_nl "\n" text t_prob "PROBLEM line " text t_cs ": " -text t_usage "usage: evcheck [--want REAL|FAKE] FILE\n" +text t_usage "usage: evcheck [--want REAL|PRERELEASE|FAKE|FAKE-MODEL] FILE\n" text t_io "evcheck: cannot read the file, or it is larger than 262143 bytes\n" text t_pass "EVCHECK PASS records=" text t_mode " mode=" +text t_evid " evidence=" text t_cert " certified=" text t_fail "EVCHECK FAIL problems=" text t_real "REAL" text t_fake "FAKE" +text t_fm "FAKE-MODEL" +text t_prer "PRERELEASE" +text t_er "release" +text t_ep "prerelease" text t_wantf "--want" text k_sch "schema" text k_step "step" @@ -61,7 +87,14 @@ text k_comm "model_commit" text k_st "start_utc" text k_end "end_utc" text k_exit "exit_code" -text v_sch "si-rig-e2e/1" +text k_ev "evidence" +text k_com "source_commit" +text k_acct "account" +text v_sch "si-rig-e2e/2" +text v_evr "release" +text v_evp "prerelease: not release evidence" +text v_accc "caller" +text v_accd "disposable" text v_repo "Qwen/Qwen3.6-35B-A3B-FP8" text v_comm "95a723d08a9490559dae23d0cff1d9466213d989" text s_inst "install" @@ -72,13 +105,23 @@ text m_json "not one JSON object" text m_unk "unknown member" text m_dup "member appears more than once" text m_miss "missing member " -text m_sch "schema is not si-rig-e2e/1" +text m_sch "schema is not si-rig-e2e/2" text m_step "step is not install, verify, chat or uninstall" text m_order "step out of order (install, verify, chat, uninstall; no repeats)" -text m_mode "mode is not REAL or FAKE" +text m_mode "mode is not REAL, FAKE or FAKE-MODEL" text m_mmix "mode differs from the first record" -text m_tag "release_tag is not 1..128 plain bytes" +text m_tag "release_tag is not 0..128 plain bytes" text m_tagx "release_tag differs from the first record" +text m_ev "evidence is not release or prerelease: not release evidence" +text m_evx "evidence differs from the first record" +text m_tagr "release evidence needs a release_tag" +text m_tagp "prerelease evidence must have an empty release_tag" +text m_com "source_commit is not 40 lowercase hex digits" +text m_comx "source_commit differs from the first record" +text m_comz "prerelease evidence needs a source_commit that is not all zeros" +text m_fmrel "FAKE-MODEL runs are prerelease evidence only" +text m_acct "account is not caller or disposable" +text m_acctx "account differs from the first record" text m_sha "engine_sha256 is not 64 lowercase hex digits" text m_shax "engine_sha256 differs from the first record" text m_repo "model_repo is not Qwen/Qwen3.6-35B-A3B-FP8" @@ -92,6 +135,8 @@ text m_want "certify: mode is not the wanted mode" text m_steps "certify: the run does not have all four steps" text m_xnz "certify: a step exit_code is not 0" text m_zsha "certify: engine_sha256 is all zeros" +text m_prel "certify: prerelease evidence is not release evidence" +text m_relp "certify: release evidence is not prerelease evidence" note ======== output ======== @@ -123,9 +168,21 @@ if eq m 1 pr t_real ret end +if eq m 3 +pr t_fm +ret +end pr t_fake end +fn prwant w ulong to void +if eq w 4 +pr t_prer +ret +end +prmode w +end + note a finding on the current line (line 0 = the whole file) fn prob1 t view uchar * to void put prob 0 add get prob 0 1 @@ -179,6 +236,15 @@ end if js_streq ln o k_exit ret 9 end +if js_streq ln o k_ev +ret 10 +end +if js_streq ln o k_com +ret 11 +end +if js_streq ln o k_acct +ret 12 +end ret 99 end @@ -219,12 +285,24 @@ if eq i 8 pr k_end ret end +if eq i 9 pr k_exit +ret +end +if eq i 10 +pr k_ev +ret +end +if eq i 11 +pr k_com +ret +end +pr k_acct end note collects member value tokens into fv/fc; false when the record cannot be checked further fn members ln view uchar * tp view uint * to bool -for i ulong 10 +for i ulong 13 put fv i 0 put fc i 0 end @@ -245,7 +323,7 @@ put fv f add k 1 end k = js_mnext tp k end -for i ulong 10 +for i ulong 13 if eq get fc i 0 put prob 0 add get prob 0 1 pr t_prob @@ -304,6 +382,10 @@ end if js_streq ln t t_fake m = 2 end +if js_streq ln t t_fm +m = 3 +end +put cmode 0 m if eq m 0 prob1 m_mode ret @@ -320,10 +402,12 @@ end fn cktag ln view uchar * tp view uint * to void t = get fv 3 n = js_slen tp t -if or not plain tp t or eq n 0 gt n 128 +put ctagn 0 129 +if or not plain tp t gt n 128 prob1 m_tag ret end +put ctagn 0 n o = add js_off tp t 1 if eq get nrec 0 0 for i ulong n @@ -349,6 +433,110 @@ fn ishex c uchar to bool ret or and ge c 48 le c 57 and ge c 97 le c 102 end +fn ckev ln view uchar * tp view uint * to void +t = js_off tp get fv 10 +e = ulong 0 +if js_streq ln t v_evr +e = 1 +end +if js_streq ln t v_evp +e = 2 +end +put cev 0 e +if eq e 0 +prob1 m_ev +ret +end +if eq get ev0 0 0 +put ev0 0 e +ret +end +if ne e get ev0 0 +prob1 m_evx +end +end + +fn ckacct ln view uchar * tp view uint * to void +t = js_off tp get fv 12 +a = ulong 0 +if js_streq ln t v_accc +a = 1 +end +if js_streq ln t v_accd +a = 2 +end +if eq a 0 +prob1 m_acct +ret +end +if eq get acct0 0 0 +put acct0 0 a +ret +end +if ne a get acct0 0 +prob1 m_acctx +end +end + +fn ckcom ln view uchar * tp view uint * to void +t = get fv 11 +put czc 0 2 +if or not plain tp t ne js_slen tp t 40 +prob1 m_com +ret +end +o = add js_off tp t 1 +z = true +for i ulong 40 +c = get ln add o i +if not ishex c +prob1 m_com +ret +end +if ne c 48 +z = false +end +end +put czc 0 0 +if z +put czc 0 1 +end +if eq get nrec 0 0 +for i ulong 40 +put com0 i get ln add o i +end +ret +end +for i ulong 40 +if ne get com0 i get ln add o i +prob1 m_comx +ret +end +end +end + +note the rules that tie evidence to release_tag, source_commit and mode in the current record +fn ckrel to void +e = get cev 0 +n = get ctagn 0 +if eq e 1 +if eq n 0 +prob1 m_tagr +end +if eq get cmode 0 3 +prob1 m_fmrel +end +end +if eq e 2 +if and gt n 0 le n 128 +prob1 m_tagp +end +if eq get czc 0 1 +prob1 m_comz +end +end +end + fn cksha ln view uchar * tp view uint * to void t = get fv 4 if or not plain tp t ne js_slen tp t 64 @@ -519,10 +707,14 @@ end ckfix ln tp ckstep ln tp ckmode ln tp +ckev ln tp cktag ln tp +ckcom ln tp +ckacct ln tp cksha ln tp ckts ln tp ckexit ln tp +ckrel put nrec 0 add get nrec 0 1 end @@ -588,7 +780,7 @@ end ret true end -note sets want from argument i, false when it is not REAL or FAKE +note sets want from argument i, false when it is not REAL, FAKE, FAKE-MODEL or PRERELEASE fn setwant i ulong to bool if argeq i t_real put want 0 1 @@ -598,15 +790,33 @@ if argeq i t_fake put want 0 2 ret true end +if argeq i t_fm +put want 0 3 +ret true +end +if argeq i t_prer +put want 0 4 +ret true +end ret false end fn certify to void put lno 0 0 w = get want 0 -if ne get mode0 0 w +m = w +if eq w 4 +m = 1 +end +if ne get mode0 0 m prob1 m_want end +if and eq w 1 ne get ev0 0 1 +prob1 m_prel +end +if and eq w 4 ne get ev0 0 2 +prob1 m_relp +end if or ne get lstep 0 4 ne get nrec 0 4 prob1 m_steps end @@ -663,9 +873,15 @@ pr t_pass prn get nrec 0 pr t_mode prmode get mode0 0 +pr t_evid +if eq get ev0 0 1 +pr t_er +else +pr t_ep +end if ne get want 0 0 pr t_cert -prmode get want 0 +prwant get want 0 end pr t_nl ret 0 diff --git a/installer/rig/fileserv.om b/installer/rig/fileserv.om new file mode 100644 index 0000000..cfd88ad --- /dev/null +++ b/installer/rig/fileserv.om @@ -0,0 +1,287 @@ +note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +note fileserv.om: the local file server of e2e.sh --ref runs (DRA-38: no Python in the harness). +note Run in the folder to serve. It listens on 127.0.0.1 at a port the kernel picks, prints +note "PORT n" once it listens, then answers one request per connection, up to 1000000 of them: +note GET /PATH with the file's bytes (HTTP/1.0 200, Content-Length) or 404 when PATH cannot be +note read as a file, and 400 for anything else. PATH is letters, digits and . _ - / only, with no +note empty part and no part starting with a dot, so nothing outside the folder can be named. +note It is plain HTTP on purpose: the wizard runs curl with an empty environment, so a test +note certificate (CURL_CA_BUNDLE) cannot reach it. One log line per request on stdout. +note Exit 1 no socket, 2 bind or listen refused, 3 no socket address. +om2 + +global req uchar 8192 +global io uchar 65536 +global addr uchar 16 +global crlf uchar 2 +global pth uchar 1024 + +text r_200 "HTTP/1.0 200 OK" +text r_400 "HTTP/1.0 400 Bad Request" +text r_404 "HTTP/1.0 404 Not Found" +text h_len "Content-Length: " +text h_ct "Content-Type: application/octet-stream" +text t_port "PORT " +text t_get "GET /" +text t_200 " 200 " +text t_404 " 404\n" +text t_400 "400 refused request\n" +text t_nl "\n" + +fn pr t view uchar * to void +w = write 1 t 0 len t +end + +fn sendt c int t view uchar * to void +r = send c t 0 len t 0 +end + +fn eol c int to void +r = send c crlf 0 2 0 +end + +note The decimal digits of v, on the log (c 1) or on connection c. +fn decout c int v ulong to void +d = new uchar 20 0 +o = new uchar 20 0 +k = ulong 0 +x = v +while true bound 21 +put d k uchar add rem x 10 48 +k = add k 1 +x = div x 10 +if eq x 0 +break +end +end +for i ulong k +put o i get d sub sub k 1 i +end +if eq c 1 +w = write 1 o 0 k +ret +end +w = send c o 0 k 0 +end + +note True when req[0..n) holds the blank line that ends a request head. +fn hashd n ulong to bool +if lt n 4 +ret false +end +for i ulong sub n 3 +if eq get req i 13 +if eq get req add i 1 10 +if eq get req add i 2 13 +if eq get req add i 3 10 +ret true +end +end +end +end +end +ret false +end + +note Read the request head into req; its length, or 0 when none came within 5 s per read. +fn rdreq c int to ulong +n = ulong 0 +while lt n len req bound 8193 +k = waitio c 1 5000000000 +if le k 0 +ret 0 +end +r = recv c req n sub len req n 0 +if le r 0 +ret 0 +end +n = add n ulong r +if hashd n +ret n +end +end +ret 0 +end + +fn okch b uchar to bool +if and ge b 48 le b 57 +ret true +end +if and ge b 65 le b 90 +ret true +end +if and ge b 97 le b 122 +ret true +end +if or eq b 46 or eq b 95 eq b 45 +ret true +end +ret false +end + +note The requested path without its leading slash into pth; its length, or 0 when the request is +note not GET of a path as the header describes. +fn parse n ulong to ulong +if lt n len t_get +ret 0 +end +for i ulong len t_get +if ne get req i get t_get i +ret 0 +end +end +m = ulong 0 +s = true +for i ulong sub n len t_get +b = get req add len t_get i +if eq b 32 +if s +ret 0 +end +ret m +end +if eq b 47 +if s +ret 0 +end +end +if ne b 47 +if s +if eq b 46 +ret 0 +end +end +if not okch b +ret 0 +end +end +s = eq b 47 +put pth m b +m = add m 1 +if ge m len pth +ret 0 +end +end +ret 0 +end + +note The byte count of open file f, read to its end; negative when it cannot be read (a folder). +fn flen f int to long +t = long 0 +while true bound 999999 +k = read f io 0 len io +if lt k 0 +ret k +end +if eq k 0 +ret t +end +t = add t k +end +ret t +end + +note Send io[0..k) whole on connection c; false when the peer went away. +fn sendall c int k ulong to bool +o = ulong 0 +while lt o k bound 999999 +r = send c io o sub k o 0 +if le r 0 +ret false +end +o = add o ulong r +end +ret true +end + +fn notfnd c int to void +pr t_404 +sendt c r_404 +eol c +eol c +end + +fn serve c int to void +n = rdreq c +if eq n 0 +ret +end +m = parse n +if eq m 0 +pr t_400 +sendt c r_400 +eol c +eol c +ret +end +pr t_get +w = write 1 pth 0 m +f = fopen pth 0 m 524288 0 +if lt f 0 +notfnd c +ret +end +sz = flen int f +if lt sz 0 +x = fclose int f +notfnd c +ret +end +r = fseek int f 0 0 +sendt c r_200 +eol c +sendt c h_len +decout c ulong sz +eol c +sendt c h_ct +eol c +eol c +while true bound 999999 +k = read int f io 0 len io +if le k 0 +break +end +if not sendall c ulong k +break +end +end +x = fclose int f +pr t_200 +decout 1 ulong sz +pr t_nl +end + +fn main to int +put crlf 0 13 +put crlf 1 10 +put addr 0 2 +put addr 4 127 +put addr 7 1 +fd = socknew 2 524289 0 +if lt fd 0 +ret 1 +end +r = bind int fd addr 0 16 +if ne r 0 +ret 2 +end +r = listen int fd 16 +if ne r 0 +ret 2 +end +k = sockname int fd addr 0 16 +if lt k 0 +ret 3 +end +pr t_port +decout 1 add mul ulong get addr 2 256 ulong get addr 3 +pr t_nl +for i ulong 1000000 +c = accept int fd 524288 +if ge c 0 +serve int c +x = fclose int c +end +end +ret 0 +end