diff --git a/evidence/OMEGALLM/dra23/RECEIPT.md b/evidence/OMEGALLM/dra23/RECEIPT.md new file mode 100644 index 0000000..836fa81 --- /dev/null +++ b/evidence/OMEGALLM/dra23/RECEIPT.md @@ -0,0 +1,80 @@ +# DRA-23 receipt: own Omega LLM serving identity and GPU backend (host, 2026-11-07) + +Card si023 (kanban t_f35fbfcd), Hermes worker claude-opus-5-5. Spark `spark-b87b`, aarch64, cores 10-11, +nice 10. No GPU lease was opened and no GPU device was opened by this work; `:18091` was not bound. + +Source: aien-train main `0518c915dea370b3bffbb90d579b1daa5ba8b8f5`, omc sha256 +`2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f` (omega-mv `e5b32567`). +Probe `dra23live` sha256 `bcc179a2d091b19016f1b37a4263d29bdbb01ab61828de6dfff094fff9803aef`. + +## 1. Which build serves, and which GPU backend each build contains (static, EXERCISED) + +| Build (`tests/omegallm/build.sh`) | sha256, two independent builds | `serve` | Device node texts / `devcall` lines in the composed source | +|---|---|---|---| +| `TARGET=aarch64` `ollm` (265792 bytes, static ELF) | `819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea` both | yes (`serve.om`) | 0 / 0: no GPU backend | +| `TARGET=gb10` `ollm-gb10` (391916 bytes, static ELF) | `c35798fdeb5818f07aaf0979676469be366655dfcf77d3baa8092c3ee539a257` both | no: `noserve.om`, `cmdserve` exits 2 | 3 (`/dev/nvidiactl`, `/dev/nvidia0`, `/dev/nvidia-uvm`) / 2, all in `native/omegallm/gpu/context.om` | + +Finding: at aien-train main no build both serves and drives the GPU. A `:18091` deployment of `ollm serve` +today is CPU-only, so its live identity row is `gpu_observed none`. One canonical GPU backend on `:18091` +needs a gb10 serve build first (owner ownmodel, DRA-119/DRA-125). + +The gb10 device layer is CUDApp's. `gpu/context.om`, `vector.om`, `launch.om` have the git blob ids of +CUDApp `dcba8bb8` `native/nvrm/context.om`, `native/blackwell/vector.om`, `native/blackwell/launch.om` +(`5280fea0`, `d2c1bc83`, `fb70bee4`). CUDApp main `b774723f` is 152 commits ahead of `dcba8bb8`; in those +three files it changes only the SPDX note line (AGPL-3.0-only to Apache-2.0 WITH LLVM-exception). A gb10 +build with the three CUDApp main files substituted is bit-identical: `c35798fd…a257`. + +Gap: `tests/omegallm/build.sh` pins `net/*.om` by sha256 but not the vendored `gpu/` files. A code edit +in `gpu/context.om` (`/dev/nvidia0` to `/dev/nvidia1`) builds with rc 0 to `300052a0…cf68`; a note-only +edit builds to the same `c35798fd`. `live-18091.sh` performs the missing check (controls below). + +## 2. Probe gate (`check.sh`, EXERCISED, `DRA23CHECK PASS`, 15/15 rows) + +Against `ollm serve 18923 ck60000.bin merges4096.bin` started by the gate (ck sha256 `a53ced72…2d0f`, +merges `73a29baf…3882`), a `python3 -m http.server` fixture on 18924, and the running omega-tool-model +GPU server (inspected read-only through `/proc`, `--pid` mode). Per-row outputs in `check/`. + +| Row | Expect | Got | +|---|---|---| +| p1 own model CPU serve, exe + ck + merges hashes, `gpu none` | PASS | PASS; `/health`, `/v1/models`, chat 200; `gpu_observed none` | +| n1 wrong exe digest | `exe_sha256_mismatch` | FAIL as expected | +| n2 declared `nvrm` against the CPU server | `gpu_expect_mismatch` | FAIL as expected | +| n3 wrong ck digest | `file_sha256_mismatch` | FAIL as expected | +| n4 ck path not verbatim on the cmdline | `file_not_in_cmdline` | FAIL as expected | +| n5/n6 dynamically linked fixture | `shared_object_mapped`, `http_health_not_200` | FAIL as expected | +| n7 unknown GPU class `cuda` | usage, rc 2 | rc 2 | +| p2 GPU server, declared `nvrm` | PASS | PASS (`/dev/nvidiactl`, `/dev/nvidia0`, `/dev/nvidia-uvm` fds, no shared object) | +| n8 GPU server, declared `none` | `gpu_expect_mismatch` | FAIL as expected | +| n9 port with no listener | NOT_RUN, rc 3 | rc 3 | +| m1 mutant (digest compare disabled) on n1 | survives as PASS | PASS: n1's failure depends on the compare | +| m2 mutant (nvrm class disabled) on p2 | flips to FAIL | FAIL | +| m3 mutant (`.so` match disabled) on n5 | no `shared_object_mapped` | none reported | + +## 3. Live row script (`live-18091.sh`) + +| Run | Result | +|---|---| +| `TARGET=aarch64` against `:18091`, 2026-11-07T00:04Z | STATIC PASS (expected exe `819664d5…5ea`, census 0/0); live `verdict NOT_RUN no_listener_on_port`, rc 3 | +| `TARGET=gb10` against `:18091` | STATIC PASS (expected exe `c35798fd…a257`, 3 CUDApp_MATCH, census 3/2); live NOT_RUN, rc 3 | +| Same script, aarch64, against a test server on 18923 (pre-repo copy) | PASS, rc 0 | +| s1 commit editing `gpu/context.om` code, gb10 | `CUDApp_MISMATCH`, `STATIC FAIL vendored_device_layer`, rc 4 | +| s2 commit adding a device node text to `gpu/gg.om`, gb10 | `STATIC FAIL second_device_layer nodes=4 calls=2 want=3/2`, rc 4 | +| s3 dirty tree / s4 abbreviated REV | `DIRTY_TREE 1` rc 4 / `REV_MISMATCH` rc 4 | +| s5 the s1 commit, aarch64 | STATIC PASS 0/0: the CPU build does not include `gpu/` | + +## 4. Verdict model (Lean 4, lean MCP) + +`VerdictModel.lean`: `pass_safe`, `mixed_iff_two_classes` (all g < 16), `mixed_never_pass` checked; +axioms `propext`, `Classical.choice`, `Quot.sound` only. Control: `mixedFail 3 = false` is rejected. +This is a model of the decision logic, not a proof about the compiled probe. + +## Labels + +| Item | Label | +|---|---| +| Probe, gate, live script | IMPLEMENTED, EXERCISED (host), gate TESTED on this branch | +| Static identity of both builds, CUDApp device-layer identity | EXERCISED (host) | +| Live `:18091` row | NOT_RUN: nothing listens (35B retired; own model not deployed, DRA-125) | +| One canonical GPU backend on `:18091` | NOT_RUN: no gb10 serve build exists | +| GB10 hardware, physical numeric/correctness controls | NOT_RUN | +| Earlier 35B static receipt (`DRA-23-IDENTITY-RECEIPT.v2.json`, bin-19173f9e) | historical, retired model | diff --git a/evidence/OMEGALLM/dra23/check/builds.txt b/evidence/OMEGALLM/dra23/check/builds.txt new file mode 100644 index 0000000..8a685dd --- /dev/null +++ b/evidence/OMEGALLM/dra23/check/builds.txt @@ -0,0 +1,4 @@ +BUILD_OK bcc179a2d091b19016f1b37a4263d29bdbb01ab61828de6dfff094fff9803aef ~/work/hive/t_f35fbfcd/aien-train/../build/dra23/dra23live source_sha256 b25a917a385a89aca12a684a5a2f92938baaf35931d9019b4064bdfcc97bd8f4 +BUILD_OK ced3290e9498bccba214fd47112298597c90dc96ea33a7a514c94d7119aec965 ~/work/hive/t_f35fbfcd/aien-train/../build/dra23/dra23live-m1 source_sha256 6023601a2d415855d3197d66f9c3d6a4061108d8627b13533c5a9f5affb53cef +BUILD_OK e2afc95ec74f35c9a8dd3ec647dab4a97bad8b47890882bbeddea4eb213a4077 ~/work/hive/t_f35fbfcd/aien-train/../build/dra23/dra23live-m2 source_sha256 db0b2ff6b9032c6291ce0fea51fc23118cd2ada88fd327ad12aec60c2d45cfc3 +BUILD_OK e8c0448e5234b111fd1c77eab6f982db409040b1c7def0d671b3a972710c4d6f ~/work/hive/t_f35fbfcd/aien-train/../build/dra23/dra23live-m3 source_sha256 a16e96c63c9ff49306bdf0eda951a7d885a53704bc43596d8df159a64e76551e diff --git a/evidence/OMEGALLM/dra23/check/env.txt b/evidence/OMEGALLM/dra23/check/env.txt new file mode 100644 index 0000000..7769b2e --- /dev/null +++ b/evidence/OMEGALLM/dra23/check/env.txt @@ -0,0 +1,8 @@ +date 2026-11-07T00:01:46Z +host spark-b87b aarch64 +aien_train 0518c915dea370b3bffbb90d579b1daa5ba8b8f5 +dra23live bcc179a2d091b19016f1b37a4263d29bdbb01ab61828de6dfff094fff9803aef +ollm 819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea +ck a53ced7265818c8f6197449315e9ca4082721665022fec4f81d4538e8d6c2d0f +merges 73a29baf97619a746a21232c403bf08af71a76e48b3b2cde6d64dab766083882 +stopped server=1108130 fixture=1131534 diff --git a/evidence/OMEGALLM/dra23/check/gate.log b/evidence/OMEGALLM/dra23/check/gate.log new file mode 100644 index 0000000..61f4810 --- /dev/null +++ b/evidence/OMEGALLM/dra23/check/gate.log @@ -0,0 +1,16 @@ +CASE p1-own-model-cpu expect=rc0/- got=rc0 PASS (verdict PASS) +CASE n1-wrong-exe expect=rc1/exe_sha256_mismatch got=rc1 PASS (verdict FAIL failures 1) +CASE n2-expect-nvrm expect=rc1/gpu_expect_mismatch got=rc1 PASS (verdict FAIL failures 1) +CASE n3-wrong-ck expect=rc1/file_sha256_mismatch got=rc1 PASS (verdict FAIL failures 1) +CASE n4-ck-not-in-cmdline expect=rc1/file_not_in_cmdline got=rc1 PASS (verdict FAIL failures 1) +CASE n5-dynamic-fixture expect=rc1/shared_object_mapped got=rc1 PASS (verdict FAIL failures 12) +CASE n6-fixture-http expect=rc1/http_health_not_200 got=rc1 PASS (verdict FAIL failures 12) +CASE n7-usage expect=rc2/- got=rc2 PASS (usage: dra23live PORT EXE_SHA256|- none|nvrm|aiengpu [PATH SHA256]...) +CASE m1-mutant-wrong-exe expect=rc0/- got=rc0 PASS (verdict PASS) +CASE m3-mutant-dynamic expect=rc1/http_health_not_200 got=rc1 PASS (verdict FAIL failures 3) +CASE m3-mutant-killed PASS (mutant misses the shared objects n5 reports) +CASE p2-gpu-pid-nvrm expect=rc0/- got=rc0 PASS (verdict PASS) +CASE n8-gpu-pid-none expect=rc1/gpu_expect_mismatch got=rc1 PASS (verdict FAIL failures 1) +CASE m2-mutant-gpu-pid expect=rc1/gpu_expect_mismatch got=rc1 PASS (verdict FAIL failures 1) +CASE n9-no-listener expect=rc3/- got=rc3 PASS (verdict NOT_RUN no_listener_on_port) +DRA23CHECK PASS diff --git a/evidence/OMEGALLM/dra23/check/m1-mutant-wrong-exe.txt b/evidence/OMEGALLM/dra23/check/m1-mutant-wrong-exe.txt new file mode 100644 index 0000000..4d98dfa --- /dev/null +++ b/evidence/OMEGALLM/dra23/check/m1-mutant-wrong-exe.txt @@ -0,0 +1,20 @@ +DRA23LIVE v1 +port 18923 +gpu_expected none +listen_inode 796925381 local 0100007F:49EB +holder_pid 1108130 +exe_link ~/work/hive/t_f35fbfcd/build/ollm-aarch64-a/ollm +exe_sha256 819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea +expect bcc179a2d091b19016f1b37a4263d29bdbb01ab61828de6dfff094fff9803aef MATCH +cmd_arg 0 ~/work/hive/t_f35fbfcd/aien-train/../build/ollm-aarch64-a/ollm +cmd_arg 1 serve +cmd_arg 2 18923 +cmd_arg 3 /tmp/gk/r10/run/ck60000.bin +cmd_arg 4 ~/handoffs/omega-llm-20261101/v1-data/merges4096.bin +http /health status 200 line HTTP/1.1 200 OK +http /v1/models status 200 line HTTP/1.1 200 OK +http /v1/chat/completions status 200 line HTTP/1.1 200 OK +map_self_segments 1 +dev_fd 0 /dev/null +gpu_observed none +verdict PASS diff --git a/evidence/OMEGALLM/dra23/check/m2-mutant-gpu-pid.txt b/evidence/OMEGALLM/dra23/check/m2-mutant-gpu-pid.txt new file mode 100644 index 0000000..f5fa042 --- /dev/null +++ b/evidence/OMEGALLM/dra23/check/m2-mutant-gpu-pid.txt @@ -0,0 +1,17 @@ +DRA23LIVE v1 +mode pid_inspect +gpu_expected nvrm +holder_pid 68451 +exe_link ~/.local/share/omega-tool-model/round40-fast/server +exe_sha256 092c1953924ca7a52e19fec309065b3efb50f034bf0ba561cc819543f4734085 +map_dev /dev/nvidiactl +map_dev /dev/nvidia0 +map_self_segments 1 +dev_fd 0 /dev/null +dev_fd 5 /dev/nvidiactl +dev_fd 6 /dev/nvidia0 +dev_fd 7 /dev/nvidia-uvm +dev_fd 8 /dev/nvidia-uvm +gpu_observed none +fail gpu_expect_mismatch +verdict FAIL failures 1 diff --git a/evidence/OMEGALLM/dra23/check/m3-mutant-dynamic.txt b/evidence/OMEGALLM/dra23/check/m3-mutant-dynamic.txt new file mode 100644 index 0000000..58ae671 --- /dev/null +++ b/evidence/OMEGALLM/dra23/check/m3-mutant-dynamic.txt @@ -0,0 +1,34 @@ +DRA23LIVE v1 +port 18924 +gpu_expected none +listen_inode 797044825 local 0100007F:49EC +holder_pid 1131534 +exe_link ~/.hermes/tools/python-3.14.9+20261021-linux-arm64/bin/python3.14 +exe_sha256 9d9e7b954f88f8c1acba21bdefce6689ddcdd9004cb2f6870ef968994d747571 +cmd_arg 0 python3 +cmd_arg 1 -m +cmd_arg 2 http.server +cmd_arg 3 --bind +cmd_arg 4 127.0.0.1 +cmd_arg 5 18924 +http /health status 404 line HTTP/1.0 404 File not found +fail http_health_not_200 +http /v1/models status 404 line HTTP/1.0 404 File not found +fail http_models_not_200 +http /v1/chat/completions status 501 line HTTP/1.0 501 Unsupported method ('POST') +fail http_chat_not_200 +map_file /usr/lib/locale/locale-archive +map_file /usr/lib/aarch64-linux-gnu/libc.so.6 +map_file /usr/lib/aarch64-linux-gnu/libgcc_s.so.1 +map_file /usr/lib/aarch64-linux-gnu/librt.so.1 +map_file /usr/lib/aarch64-linux-gnu/libm.so.6 +map_file /usr/lib/aarch64-linux-gnu/libutil.so.1 +map_file /usr/lib/aarch64-linux-gnu/libdl.so.2 +map_file /usr/lib/aarch64-linux-gnu/libpthread.so.0 +map_file /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 +map_file /usr/lib/aarch64-linux-gnu/gconv/gconv-modules.cache +map_file /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 +map_self_segments 5 +dev_fd 0 /dev/null +gpu_observed none +verdict FAIL failures 3 diff --git a/evidence/OMEGALLM/dra23/check/n1-wrong-exe.txt b/evidence/OMEGALLM/dra23/check/n1-wrong-exe.txt new file mode 100644 index 0000000..9f013f6 --- /dev/null +++ b/evidence/OMEGALLM/dra23/check/n1-wrong-exe.txt @@ -0,0 +1,23 @@ +DRA23LIVE v1 +port 18923 +gpu_expected none +listen_inode 796925381 local 0100007F:49EB +holder_pid 1108130 +exe_link ~/work/hive/t_f35fbfcd/build/ollm-aarch64-a/ollm +exe_sha256 819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea +expect bcc179a2d091b19016f1b37a4263d29bdbb01ab61828de6dfff094fff9803aef MISMATCH +fail exe_sha256_mismatch +cmd_arg 0 ~/work/hive/t_f35fbfcd/aien-train/../build/ollm-aarch64-a/ollm +cmd_arg 1 serve +cmd_arg 2 18923 +cmd_arg 3 /tmp/gk/r10/run/ck60000.bin +cmd_arg 4 ~/handoffs/omega-llm-20261101/v1-data/merges4096.bin +http /health status 200 line HTTP/1.1 200 OK +http /v1/models status 200 line HTTP/1.1 200 OK +http /v1/chat/completions status 200 line HTTP/1.1 200 OK +map_self_segments 1 +dev_fd 0 /dev/null +gpu_observed none +file /tmp/gk/r10/run/ck60000.bin sha256 a53ced7265818c8f6197449315e9ca4082721665022fec4f81d4538e8d6c2d0f MATCH +file /tmp/gk/r10/run/ck60000.bin in_cmdline yes +verdict FAIL failures 1 diff --git a/evidence/OMEGALLM/dra23/check/n2-expect-nvrm.txt b/evidence/OMEGALLM/dra23/check/n2-expect-nvrm.txt new file mode 100644 index 0000000..5e03c15 --- /dev/null +++ b/evidence/OMEGALLM/dra23/check/n2-expect-nvrm.txt @@ -0,0 +1,23 @@ +DRA23LIVE v1 +port 18923 +gpu_expected nvrm +listen_inode 796925381 local 0100007F:49EB +holder_pid 1108130 +exe_link ~/work/hive/t_f35fbfcd/build/ollm-aarch64-a/ollm +exe_sha256 819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea +expect 819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea MATCH +cmd_arg 0 ~/work/hive/t_f35fbfcd/aien-train/../build/ollm-aarch64-a/ollm +cmd_arg 1 serve +cmd_arg 2 18923 +cmd_arg 3 /tmp/gk/r10/run/ck60000.bin +cmd_arg 4 ~/handoffs/omega-llm-20261101/v1-data/merges4096.bin +http /health status 200 line HTTP/1.1 200 OK +http /v1/models status 200 line HTTP/1.1 200 OK +http /v1/chat/completions status 200 line HTTP/1.1 200 OK +map_self_segments 1 +dev_fd 0 /dev/null +gpu_observed none +fail gpu_expect_mismatch +file /tmp/gk/r10/run/ck60000.bin sha256 a53ced7265818c8f6197449315e9ca4082721665022fec4f81d4538e8d6c2d0f MATCH +file /tmp/gk/r10/run/ck60000.bin in_cmdline yes +verdict FAIL failures 1 diff --git a/evidence/OMEGALLM/dra23/check/n3-wrong-ck.txt b/evidence/OMEGALLM/dra23/check/n3-wrong-ck.txt new file mode 100644 index 0000000..b53a137 --- /dev/null +++ b/evidence/OMEGALLM/dra23/check/n3-wrong-ck.txt @@ -0,0 +1,23 @@ +DRA23LIVE v1 +port 18923 +gpu_expected none +listen_inode 796925381 local 0100007F:49EB +holder_pid 1108130 +exe_link ~/work/hive/t_f35fbfcd/build/ollm-aarch64-a/ollm +exe_sha256 819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea +expect 819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea MATCH +cmd_arg 0 ~/work/hive/t_f35fbfcd/aien-train/../build/ollm-aarch64-a/ollm +cmd_arg 1 serve +cmd_arg 2 18923 +cmd_arg 3 /tmp/gk/r10/run/ck60000.bin +cmd_arg 4 ~/handoffs/omega-llm-20261101/v1-data/merges4096.bin +http /health status 200 line HTTP/1.1 200 OK +http /v1/models status 200 line HTTP/1.1 200 OK +http /v1/chat/completions status 200 line HTTP/1.1 200 OK +map_self_segments 1 +dev_fd 0 /dev/null +gpu_observed none +file /tmp/gk/r10/run/ck60000.bin sha256 a53ced7265818c8f6197449315e9ca4082721665022fec4f81d4538e8d6c2d0f MISMATCH +fail file_sha256_mismatch +file /tmp/gk/r10/run/ck60000.bin in_cmdline yes +verdict FAIL failures 1 diff --git a/evidence/OMEGALLM/dra23/check/n4-ck-not-in-cmdline.txt b/evidence/OMEGALLM/dra23/check/n4-ck-not-in-cmdline.txt new file mode 100644 index 0000000..7fc4a2d --- /dev/null +++ b/evidence/OMEGALLM/dra23/check/n4-ck-not-in-cmdline.txt @@ -0,0 +1,23 @@ +DRA23LIVE v1 +port 18923 +gpu_expected none +listen_inode 796925381 local 0100007F:49EB +holder_pid 1108130 +exe_link ~/work/hive/t_f35fbfcd/build/ollm-aarch64-a/ollm +exe_sha256 819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea +expect 819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea MATCH +cmd_arg 0 ~/work/hive/t_f35fbfcd/aien-train/../build/ollm-aarch64-a/ollm +cmd_arg 1 serve +cmd_arg 2 18923 +cmd_arg 3 /tmp/gk/r10/run/ck60000.bin +cmd_arg 4 ~/handoffs/omega-llm-20261101/v1-data/merges4096.bin +http /health status 200 line HTTP/1.1 200 OK +http /v1/models status 200 line HTTP/1.1 200 OK +http /v1/chat/completions status 200 line HTTP/1.1 200 OK +map_self_segments 1 +dev_fd 0 /dev/null +gpu_observed none +file /tmp/gk/r10/run/./ck60000.bin sha256 a53ced7265818c8f6197449315e9ca4082721665022fec4f81d4538e8d6c2d0f MATCH +file /tmp/gk/r10/run/./ck60000.bin in_cmdline no +fail file_not_in_cmdline +verdict FAIL failures 1 diff --git a/evidence/OMEGALLM/dra23/check/n5-dynamic-fixture.txt b/evidence/OMEGALLM/dra23/check/n5-dynamic-fixture.txt new file mode 100644 index 0000000..791e6c8 --- /dev/null +++ b/evidence/OMEGALLM/dra23/check/n5-dynamic-fixture.txt @@ -0,0 +1,43 @@ +DRA23LIVE v1 +port 18924 +gpu_expected none +listen_inode 797044825 local 0100007F:49EC +holder_pid 1131534 +exe_link ~/.hermes/tools/python-3.14.9+20261021-linux-arm64/bin/python3.14 +exe_sha256 9d9e7b954f88f8c1acba21bdefce6689ddcdd9004cb2f6870ef968994d747571 +cmd_arg 0 python3 +cmd_arg 1 -m +cmd_arg 2 http.server +cmd_arg 3 --bind +cmd_arg 4 127.0.0.1 +cmd_arg 5 18924 +http /health status 404 line HTTP/1.0 404 File not found +fail http_health_not_200 +http /v1/models status 404 line HTTP/1.0 404 File not found +fail http_models_not_200 +http /v1/chat/completions status 501 line HTTP/1.0 501 Unsupported method ('POST') +fail http_chat_not_200 +map_file /usr/lib/locale/locale-archive +map_file /usr/lib/aarch64-linux-gnu/libc.so.6 +fail shared_object_mapped +map_file /usr/lib/aarch64-linux-gnu/libgcc_s.so.1 +fail shared_object_mapped +map_file /usr/lib/aarch64-linux-gnu/librt.so.1 +fail shared_object_mapped +map_file /usr/lib/aarch64-linux-gnu/libm.so.6 +fail shared_object_mapped +map_file /usr/lib/aarch64-linux-gnu/libutil.so.1 +fail shared_object_mapped +map_file /usr/lib/aarch64-linux-gnu/libdl.so.2 +fail shared_object_mapped +map_file /usr/lib/aarch64-linux-gnu/libpthread.so.0 +fail shared_object_mapped +map_file /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 +fail shared_object_mapped +map_file /usr/lib/aarch64-linux-gnu/gconv/gconv-modules.cache +map_file /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 +fail shared_object_mapped +map_self_segments 5 +dev_fd 0 /dev/null +gpu_observed none +verdict FAIL failures 12 diff --git a/evidence/OMEGALLM/dra23/check/n6-fixture-http.txt b/evidence/OMEGALLM/dra23/check/n6-fixture-http.txt new file mode 100644 index 0000000..791e6c8 --- /dev/null +++ b/evidence/OMEGALLM/dra23/check/n6-fixture-http.txt @@ -0,0 +1,43 @@ +DRA23LIVE v1 +port 18924 +gpu_expected none +listen_inode 797044825 local 0100007F:49EC +holder_pid 1131534 +exe_link ~/.hermes/tools/python-3.14.9+20261021-linux-arm64/bin/python3.14 +exe_sha256 9d9e7b954f88f8c1acba21bdefce6689ddcdd9004cb2f6870ef968994d747571 +cmd_arg 0 python3 +cmd_arg 1 -m +cmd_arg 2 http.server +cmd_arg 3 --bind +cmd_arg 4 127.0.0.1 +cmd_arg 5 18924 +http /health status 404 line HTTP/1.0 404 File not found +fail http_health_not_200 +http /v1/models status 404 line HTTP/1.0 404 File not found +fail http_models_not_200 +http /v1/chat/completions status 501 line HTTP/1.0 501 Unsupported method ('POST') +fail http_chat_not_200 +map_file /usr/lib/locale/locale-archive +map_file /usr/lib/aarch64-linux-gnu/libc.so.6 +fail shared_object_mapped +map_file /usr/lib/aarch64-linux-gnu/libgcc_s.so.1 +fail shared_object_mapped +map_file /usr/lib/aarch64-linux-gnu/librt.so.1 +fail shared_object_mapped +map_file /usr/lib/aarch64-linux-gnu/libm.so.6 +fail shared_object_mapped +map_file /usr/lib/aarch64-linux-gnu/libutil.so.1 +fail shared_object_mapped +map_file /usr/lib/aarch64-linux-gnu/libdl.so.2 +fail shared_object_mapped +map_file /usr/lib/aarch64-linux-gnu/libpthread.so.0 +fail shared_object_mapped +map_file /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 +fail shared_object_mapped +map_file /usr/lib/aarch64-linux-gnu/gconv/gconv-modules.cache +map_file /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 +fail shared_object_mapped +map_self_segments 5 +dev_fd 0 /dev/null +gpu_observed none +verdict FAIL failures 12 diff --git a/evidence/OMEGALLM/dra23/check/n7-usage.txt b/evidence/OMEGALLM/dra23/check/n7-usage.txt new file mode 100644 index 0000000..23ae8a1 --- /dev/null +++ b/evidence/OMEGALLM/dra23/check/n7-usage.txt @@ -0,0 +1 @@ +usage: dra23live PORT EXE_SHA256|- none|nvrm|aiengpu [PATH SHA256]... diff --git a/evidence/OMEGALLM/dra23/check/n8-gpu-pid-none.txt b/evidence/OMEGALLM/dra23/check/n8-gpu-pid-none.txt new file mode 100644 index 0000000..7f90869 --- /dev/null +++ b/evidence/OMEGALLM/dra23/check/n8-gpu-pid-none.txt @@ -0,0 +1,17 @@ +DRA23LIVE v1 +mode pid_inspect +gpu_expected none +holder_pid 68451 +exe_link ~/.local/share/omega-tool-model/round40-fast/server +exe_sha256 092c1953924ca7a52e19fec309065b3efb50f034bf0ba561cc819543f4734085 +map_dev /dev/nvidiactl +map_dev /dev/nvidia0 +map_self_segments 1 +dev_fd 0 /dev/null +dev_fd 5 /dev/nvidiactl +dev_fd 6 /dev/nvidia0 +dev_fd 7 /dev/nvidia-uvm +dev_fd 8 /dev/nvidia-uvm +gpu_observed nvrm +fail gpu_expect_mismatch +verdict FAIL failures 1 diff --git a/evidence/OMEGALLM/dra23/check/n9-no-listener.txt b/evidence/OMEGALLM/dra23/check/n9-no-listener.txt new file mode 100644 index 0000000..b4dbcf2 --- /dev/null +++ b/evidence/OMEGALLM/dra23/check/n9-no-listener.txt @@ -0,0 +1,4 @@ +DRA23LIVE v1 +port 18925 +gpu_expected none +verdict NOT_RUN no_listener_on_port diff --git a/evidence/OMEGALLM/dra23/check/p1-own-model-cpu.txt b/evidence/OMEGALLM/dra23/check/p1-own-model-cpu.txt new file mode 100644 index 0000000..4543209 --- /dev/null +++ b/evidence/OMEGALLM/dra23/check/p1-own-model-cpu.txt @@ -0,0 +1,24 @@ +DRA23LIVE v1 +port 18923 +gpu_expected none +listen_inode 796925381 local 0100007F:49EB +holder_pid 1108130 +exe_link ~/work/hive/t_f35fbfcd/build/ollm-aarch64-a/ollm +exe_sha256 819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea +expect 819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea MATCH +cmd_arg 0 ~/work/hive/t_f35fbfcd/aien-train/../build/ollm-aarch64-a/ollm +cmd_arg 1 serve +cmd_arg 2 18923 +cmd_arg 3 /tmp/gk/r10/run/ck60000.bin +cmd_arg 4 ~/handoffs/omega-llm-20261101/v1-data/merges4096.bin +http /health status 200 line HTTP/1.1 200 OK +http /v1/models status 200 line HTTP/1.1 200 OK +http /v1/chat/completions status 200 line HTTP/1.1 200 OK +map_self_segments 1 +dev_fd 0 /dev/null +gpu_observed none +file /tmp/gk/r10/run/ck60000.bin sha256 a53ced7265818c8f6197449315e9ca4082721665022fec4f81d4538e8d6c2d0f MATCH +file /tmp/gk/r10/run/ck60000.bin in_cmdline yes +file ~/handoffs/omega-llm-20261101/v1-data/merges4096.bin sha256 73a29baf97619a746a21232c403bf08af71a76e48b3b2cde6d64dab766083882 MATCH +file ~/handoffs/omega-llm-20261101/v1-data/merges4096.bin in_cmdline yes +verdict PASS diff --git a/evidence/OMEGALLM/dra23/check/p2-gpu-pid-nvrm.txt b/evidence/OMEGALLM/dra23/check/p2-gpu-pid-nvrm.txt new file mode 100644 index 0000000..b6f4bf5 --- /dev/null +++ b/evidence/OMEGALLM/dra23/check/p2-gpu-pid-nvrm.txt @@ -0,0 +1,16 @@ +DRA23LIVE v1 +mode pid_inspect +gpu_expected nvrm +holder_pid 68451 +exe_link ~/.local/share/omega-tool-model/round40-fast/server +exe_sha256 092c1953924ca7a52e19fec309065b3efb50f034bf0ba561cc819543f4734085 +map_dev /dev/nvidiactl +map_dev /dev/nvidia0 +map_self_segments 1 +dev_fd 0 /dev/null +dev_fd 5 /dev/nvidiactl +dev_fd 6 /dev/nvidia0 +dev_fd 7 /dev/nvidia-uvm +dev_fd 8 /dev/nvidia-uvm +gpu_observed nvrm +verdict PASS diff --git a/evidence/OMEGALLM/dra23/controls/ctl.txt b/evidence/OMEGALLM/dra23/controls/ctl.txt new file mode 100644 index 0000000..29c4af4 --- /dev/null +++ b/evidence/OMEGALLM/dra23/controls/ctl.txt @@ -0,0 +1,5 @@ +CTL s1 vendored context.om code edit, gb10: rc=4 vendored context.om 00e4520cef2c3270de29bafbb063267f8d56a6d4 CUDApp_MISMATCH STATIC FAIL vendored_device_layer +CTL s5 same commit, aarch64 (the CPU build does not include gpu/): rc=3 census device_node_texts 0 devcall_lines 0 STATIC PASS expected_exe_sha256 819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea verdict NOT_RUN no_listener_on_port +CTL s2 second device node text in gg.om, gb10: rc=4 census device_node_texts 4 devcall_lines 2 STATIC FAIL second_device_layer nodes=4 calls=2 want=3/2 +CTL s3 dirty tree: rc=4 DIRTY_TREE 1 +CTL s4 abbreviated REV: rc=4 REV_MISMATCH clone at 0518c915dea370b3bffbb90d579b1daa5ba8b8f5, want 0518c915 diff --git a/evidence/OMEGALLM/dra23/controls/s1-static.txt b/evidence/OMEGALLM/dra23/controls/s1-static.txt new file mode 100644 index 0000000..9b687a0 --- /dev/null +++ b/evidence/OMEGALLM/dra23/controls/s1-static.txt @@ -0,0 +1,11 @@ +date 2026-11-07T00:04:35Z +aien_train 422442d627e8b2497be4aaa0a0e34675396a6668 target gb10 gpu_expected nvrm port 18925 +omc 2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f +dra23live bcc179a2d091b19016f1b37a4263d29bdbb01ab61828de6dfff094fff9803aef +build1 BUILD_OK 300052a0309ebd01a018215bdea9fb3fa1ee2ae43d7ae062426e2c256fdacf68 ~/work/hive/t_f35fbfcd/build/dra23/ctl-s1-vendored-edit/b1/ollm-gb10 source_sha256 0860139967f21710db7651b4811b42942ccb3d7ac6af5264d8837bc40e3ddca2 +build2 BUILD_OK 300052a0309ebd01a018215bdea9fb3fa1ee2ae43d7ae062426e2c256fdacf68 ~/work/hive/t_f35fbfcd/build/dra23/ctl-s1-vendored-edit/b2/ollm-gb10 source_sha256 0860139967f21710db7651b4811b42942ccb3d7ac6af5264d8837bc40e3ddca2 +census device_node_texts 3 devcall_lines 2 +vendored context.om 00e4520cef2c3270de29bafbb063267f8d56a6d4 CUDApp_MISMATCH +vendored vector.om d2c1bc8305943374ed3cfe7ec3db020a4d21fa58 CUDApp_MATCH +vendored launch.om fb70bee4171cd30d8f28b41a5cbdceba283de816 CUDApp_MATCH +STATIC FAIL vendored_device_layer diff --git a/evidence/OMEGALLM/dra23/controls/s2-static.txt b/evidence/OMEGALLM/dra23/controls/s2-static.txt new file mode 100644 index 0000000..1ec8602 --- /dev/null +++ b/evidence/OMEGALLM/dra23/controls/s2-static.txt @@ -0,0 +1,11 @@ +date 2026-11-07T00:04:36Z +aien_train aaeef8e5df11b276a8f2a5721a29ce9c5b21c24d target gb10 gpu_expected nvrm port 18925 +omc 2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f +dra23live bcc179a2d091b19016f1b37a4263d29bdbb01ab61828de6dfff094fff9803aef +build1 BUILD_OK 567caebe71da04551a7881e67bc1c85d5d9580bcf2d8da2f5fc332b272c00982 ~/work/hive/t_f35fbfcd/build/dra23/ctl-s2-second-node/b1/ollm-gb10 source_sha256 eef41ba671958d52472f6fce1a3303b24c8f0e4fcfc3286bb11c6242b89d6927 +build2 BUILD_OK 567caebe71da04551a7881e67bc1c85d5d9580bcf2d8da2f5fc332b272c00982 ~/work/hive/t_f35fbfcd/build/dra23/ctl-s2-second-node/b2/ollm-gb10 source_sha256 eef41ba671958d52472f6fce1a3303b24c8f0e4fcfc3286bb11c6242b89d6927 +census device_node_texts 4 devcall_lines 2 +vendored context.om 5280fea0e47acd0f91e7616770b1679cd1a72e34 CUDApp_MATCH +vendored vector.om d2c1bc8305943374ed3cfe7ec3db020a4d21fa58 CUDApp_MATCH +vendored launch.om fb70bee4171cd30d8f28b41a5cbdceba283de816 CUDApp_MATCH +STATIC FAIL second_device_layer nodes=4 calls=2 want=3/2 diff --git a/evidence/OMEGALLM/dra23/controls/s5-static.txt b/evidence/OMEGALLM/dra23/controls/s5-static.txt new file mode 100644 index 0000000..5e8951b --- /dev/null +++ b/evidence/OMEGALLM/dra23/controls/s5-static.txt @@ -0,0 +1,8 @@ +date 2026-11-07T00:04:35Z +aien_train 422442d627e8b2497be4aaa0a0e34675396a6668 target aarch64 gpu_expected none port 18925 +omc 2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f +dra23live bcc179a2d091b19016f1b37a4263d29bdbb01ab61828de6dfff094fff9803aef +build1 BUILD_OK 819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea ~/work/hive/t_f35fbfcd/build/dra23/ctl-s5-cpu-build/b1/ollm source_sha256 2d13b609945a97ad95dba8626e67588d87c6aec64043affbaf4c107af246eb96 +build2 BUILD_OK 819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea ~/work/hive/t_f35fbfcd/build/dra23/ctl-s5-cpu-build/b2/ollm source_sha256 2d13b609945a97ad95dba8626e67588d87c6aec64043affbaf4c107af246eb96 +census device_node_texts 0 devcall_lines 0 +STATIC PASS expected_exe_sha256 819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea diff --git a/evidence/OMEGALLM/dra23/live-18091/aarch64-live.txt b/evidence/OMEGALLM/dra23/live-18091/aarch64-live.txt new file mode 100644 index 0000000..b98a59b --- /dev/null +++ b/evidence/OMEGALLM/dra23/live-18091/aarch64-live.txt @@ -0,0 +1,4 @@ +DRA23LIVE v1 +port 18091 +gpu_expected none +verdict NOT_RUN no_listener_on_port diff --git a/evidence/OMEGALLM/dra23/live-18091/aarch64-static.txt b/evidence/OMEGALLM/dra23/live-18091/aarch64-static.txt new file mode 100644 index 0000000..2021a15 --- /dev/null +++ b/evidence/OMEGALLM/dra23/live-18091/aarch64-static.txt @@ -0,0 +1,8 @@ +date 2026-11-07T00:04:02Z +aien_train 0518c915dea370b3bffbb90d579b1daa5ba8b8f5 target aarch64 gpu_expected none port 18091 +omc 2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f +dra23live bcc179a2d091b19016f1b37a4263d29bdbb01ab61828de6dfff094fff9803aef +build1 BUILD_OK 819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea ~/work/hive/t_f35fbfcd/aien-train/../build/dra23/live-18091-aarch64/b1/ollm source_sha256 2d13b609945a97ad95dba8626e67588d87c6aec64043affbaf4c107af246eb96 +build2 BUILD_OK 819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea ~/work/hive/t_f35fbfcd/aien-train/../build/dra23/live-18091-aarch64/b2/ollm source_sha256 2d13b609945a97ad95dba8626e67588d87c6aec64043affbaf4c107af246eb96 +census device_node_texts 0 devcall_lines 0 +STATIC PASS expected_exe_sha256 819664d5a2284189cd9baca67681675ed2b4685e19d1d976ce071b0f6fcaa5ea diff --git a/evidence/OMEGALLM/dra23/live-18091/gb10-live.txt b/evidence/OMEGALLM/dra23/live-18091/gb10-live.txt new file mode 100644 index 0000000..76d8b14 --- /dev/null +++ b/evidence/OMEGALLM/dra23/live-18091/gb10-live.txt @@ -0,0 +1,4 @@ +DRA23LIVE v1 +port 18091 +gpu_expected nvrm +verdict NOT_RUN no_listener_on_port diff --git a/evidence/OMEGALLM/dra23/live-18091/gb10-static.txt b/evidence/OMEGALLM/dra23/live-18091/gb10-static.txt new file mode 100644 index 0000000..59c5157 --- /dev/null +++ b/evidence/OMEGALLM/dra23/live-18091/gb10-static.txt @@ -0,0 +1,11 @@ +date 2026-11-07T00:04:04Z +aien_train 0518c915dea370b3bffbb90d579b1daa5ba8b8f5 target gb10 gpu_expected nvrm port 18091 +omc 2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f +dra23live bcc179a2d091b19016f1b37a4263d29bdbb01ab61828de6dfff094fff9803aef +build1 BUILD_OK c35798fdeb5818f07aaf0979676469be366655dfcf77d3baa8092c3ee539a257 ~/work/hive/t_f35fbfcd/aien-train/../build/dra23/live-18091-gb10/b1/ollm-gb10 source_sha256 3a15298d5d3084f8162cb2fe901a7f575042e25b5529ffb7b89e432873741200 +build2 BUILD_OK c35798fdeb5818f07aaf0979676469be366655dfcf77d3baa8092c3ee539a257 ~/work/hive/t_f35fbfcd/aien-train/../build/dra23/live-18091-gb10/b2/ollm-gb10 source_sha256 3a15298d5d3084f8162cb2fe901a7f575042e25b5529ffb7b89e432873741200 +census device_node_texts 3 devcall_lines 2 +vendored context.om 5280fea0e47acd0f91e7616770b1679cd1a72e34 CUDApp_MATCH +vendored vector.om d2c1bc8305943374ed3cfe7ec3db020a4d21fa58 CUDApp_MATCH +vendored launch.om fb70bee4171cd30d8f28b41a5cbdceba283de816 CUDApp_MATCH +STATIC PASS expected_exe_sha256 c35798fdeb5818f07aaf0979676469be366655dfcf77d3baa8092c3ee539a257 diff --git a/tests/omegallm/dra23/.crumb b/tests/omegallm/dra23/.crumb new file mode 100644 index 0000000..8064d94 --- /dev/null +++ b/tests/omegallm/dra23/.crumb @@ -0,0 +1,5 @@ +{ + "schema_version": "1.0.0", + "name": "omegallm-dra23-live", + "purpose": "DRA-23 live identity probe (dra23live, Omega) for the own Omega LLM process on 127.0.0.1:18091: exe digest vs reproducible build, cmdline files, HTTP, maps and GPU device class; gate check.sh and live row live-18091.sh; read-only toward the server" +} diff --git a/tests/omegallm/dra23/README.md b/tests/omegallm/dra23/README.md new file mode 100644 index 0000000..451efcb --- /dev/null +++ b/tests/omegallm/dra23/README.md @@ -0,0 +1,31 @@ +# DRA-23 live identity probe (`dra23live`) + +DRA-23 asks for proof that the model served on `127.0.0.1:18091` consumes one canonical GPU backend. +After the 35B retirement (2026-11-06) the model on `:18091` is the own Omega LLM (`ollm serve`, +DRA-125, lead ownmodel). This directory holds the probe that checks the live process, the gate that +exercises it, and the script for the live row. + +| File | Role | +|---|---| +| `live.om` | The probe, OM-2 program mode, read-only: listener inode from `/proc/net/tcp*`, the one process holding that socket, `sha256(/proc/PID/exe)`, `/proc/PID/cmdline`, `GET /health`, `GET /v1/models`, a one-token `POST /v1/chat/completions` (so a lazily opened device is open), then `/proc/PID/maps` (no shared object may be mapped) and `/proc/PID/fd` device nodes, classified as `none`, `nvrm` (`/dev/nvidiactl`, `/dev/nvidiaN`, `/dev/nvidia-uvm`), `aiengpu` (`/dev/aien-gpu*`), `drm` or `accel`. Two classes at once is `gpu_backend_mixed`. | +| `sha256-om2.om` | FIPS 180-4 SHA-256, vendored unmodified from omega-mv `e5b32567` `om/sha256/sha256-om2.om` (blob `748c8711`, sha256 `dbf002dd…94bb`, pinned in `build.sh`). | +| `build.sh` | Composes `sha256-om2.om` (its four `export fn` become `fn`, counted) and `live.om`; compiles with the pinned omc `2c824805…` (omega-mv `e5b32567`, the aarch64 pin of `tests/omegallm/build.sh`). `--mutant m1/m2/m3` plants one-line defects. | +| `check.sh` | Gate: starts its own `ollm serve` and a dynamically linked fixture listener on test ports (never `:18091`), runs 15 rows (positive cases, negative controls, mutants) and stops only what it started. | +| `live-18091.sh` | The live row. Rebuilds the deployed aien-train revision twice (must be bit-identical: that digest is the expected `/proc/PID/exe` sha256), runs the static backend census, then runs the probe against `:18091`. Never starts or stops the server. | +| `VerdictModel.lean` | Lean 4 model of the verdict logic: PASS implies one holder, matching exe, no shared object and an observed GPU class equal to the declared one, which is none or one backend; two classes never PASS. | + +Usage: + +```sh +sh tests/omegallm/dra23/build.sh # BUILD_OK ... +OLLM=../build/ollm CK= MERGES= [GPUPID=] \ + sh tests/omegallm/dra23/check.sh # DRA23CHECK PASS +REV= CK= MERGES= \ + [TARGET=gb10] sh tests/omegallm/dra23/live-18091.sh # exit 0 PASS, 1 FAIL, 3 NOT_RUN, 4 static FAIL +../build/dra23/dra23live 18091 none|nvrm|aiengpu [PATH SHA256]... +../build/dra23/dra23live --pid PID none|nvrm|aiengpu # /proc inspection only, no HTTP +``` + +Limits: an fd/maps snapshot shows what the process holds at that instant; files are hashed when the +probe runs, not when the server loaded them; `ollm serve` reports no build identity of its own, so +identity rests on the exe digest and its reproducible rebuild. Receipts: `evidence/OMEGALLM/dra23/`. diff --git a/tests/omegallm/dra23/VerdictModel.lean b/tests/omegallm/dra23/VerdictModel.lean new file mode 100644 index 0000000..9eab97b --- /dev/null +++ b/tests/omegallm/dra23/VerdictModel.lean @@ -0,0 +1,71 @@ +/-! DRA-23 dra23live verdict model (si023, Hermes worker claude-opus-5-5). +Explicit model of harness/live.om's decision logic (gpuchk, fail counting, verdict), not the code +itself. Checked 2026-11-07 with the lean MCP (Lean 4, lean-lsp-mcp): success, axioms +pass_safe [propext, Classical.choice, Quot.sound]; mixed_iff_two_classes [propext]; +mixed_never_pass [propext]. Control: `theorem bad : mixedFail 3 = false := by decide` is rejected +("decide proved that the proposition mixedFail 3 = false is false"). -/ + +/-- gpuchk: fail tr5 when g has two or more bits (bits as gclass sets them: 1 nvrm, 2 aiengpu, 4 drm, 8 accel/kfd). -/ +def mixedFail (g : Nat) : Bool := g != 0 && (g &&& (g - 1)) != 0 + +def single (g : Nat) : Bool := g != 0 && (g &&& (g - 1)) == 0 + +/-- For every value the gclass accumulation can reach (g < 16), the tr5 test fires exactly when + more than one backend class was observed. -/ +theorem mixed_iff_two_classes : ∀ g : Fin 16, + mixedFail g.val = true ↔ (g.val ≠ 0 ∧ g.val ≠ 1 ∧ g.val ≠ 2 ∧ g.val ≠ 4 ∧ g.val ≠ 8) := by + decide + +structure Obs where + holders : Nat + exeMatch : Bool + soMapped : Nat + gseen : Nat + gexp : Nat + filesOk : Bool + httpOk : Bool + procOk : Bool + +/-- number of fail lines main can emit for these observations (tr1 ends the run early) -/ +def fails (o : Obs) : Nat := + if o.holders ≠ 1 then 1 else + (if o.exeMatch then 0 else 1) + o.soMapped + (if mixedFail o.gseen then 1 else 0) + + (if o.gseen = o.gexp then 0 else 1) + (if o.filesOk then 0 else 1) + + (if o.httpOk then 0 else 1) + (if o.procOk then 0 else 1) + +def pass (o : Obs) : Prop := fails o = 0 + +/-- Safety: PASS implies exactly one holder, matching exe, no shared object, the observed GPU + class equals the declared one, and (expectations none/nvrm/aiengpu = 0/1/2) that class is + none or a single backend. -/ +theorem pass_safe (o : Obs) (hexp : o.gexp = 0 ∨ o.gexp = 1 ∨ o.gexp = 2) (h : pass o) : + o.holders = 1 ∧ o.exeMatch = true ∧ o.soMapped = 0 ∧ o.gseen = o.gexp ∧ + o.filesOk = true ∧ o.httpOk = true ∧ (o.gseen = 0 ∨ single o.gseen = true) := by + unfold pass fails at h + by_cases h1 : o.holders ≠ 1 + · simp [h1] at h + · simp only [h1, ite_false] at h + have hx : o.exeMatch = true := by + cases hh : o.exeMatch <;> simp_all + have hg : o.gseen = o.gexp := by + by_cases hq : o.gseen = o.gexp + · exact hq + · simp [hq] at h <;> omega + have hf : o.filesOk = true := by cases hh : o.filesOk <;> simp_all + have ht : o.httpOk = true := by cases hh : o.httpOk <;> simp_all + have hs : o.soMapped = 0 := by omega + refine ⟨by omega, hx, hs, hg, hf, ht, ?_⟩ + rcases hexp with e | e | e <;> rw [hg, e] <;> decide + +/-- Negative control: two classes observed (nvrm + aiengpu = 3) never PASS. -/ +theorem mixed_never_pass (o : Obs) (hg : o.gseen = 3) : ¬ pass o := by + unfold pass fails + by_cases h1 : o.holders ≠ 1 + · simp [h1] + · simp only [h1, ite_false, hg] + have : mixedFail 3 = true := by decide + simp [this] + +#print axioms pass_safe +#print axioms mixed_iff_two_classes +#print axioms mixed_never_pass diff --git a/tests/omegallm/dra23/build.sh b/tests/omegallm/dra23/build.sh new file mode 100644 index 0000000..8c4c8d2 --- /dev/null +++ b/tests/omegallm/dra23/build.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# build.sh: compose and compile dra23live, the DRA-23 live identity probe, with the pinned seeded omc. +# Usage: sh tests/omegallm/dra23/build.sh [--mutant m1|m2|m3] +# Env: OMC (default ../omega-mv/seed/out/omc beside this clone, omega-mv e5b32567, the aarch64 pin +# tests/omegallm/build.sh uses), OUT (default ../build/dra23 beside this clone). +# Source = sha256-om2.om, vendored unmodified from omega-mv e5b32567 om/sha256/sha256-om2.om +# (git blob 748c8711d2358a94429ed63fdf9ecc7f844163df, sha256 pinned below), followed by live.om. +# The four `export fn` lines of the vendored unit become `fn` in the composed copy only (program +# mode refuses `export`, error 9); the number of changed lines is checked. +# Mutants (one changed line each, checked) plant defects that check.sh must catch: +# m1 hexeq never sees a differing digit (an exe/file sha256 mismatch would pass) +# m2 gclass never reports nvrm (raw NVIDIA RM device nodes would be invisible) +# m3 lbso never matches (a mapped shared object would pass) +set -eu +here=$(cd "$(dirname "$0")" && pwd) +root=$(cd "$here/../../.." && pwd) +OMC=${OMC:-$root/../omega-mv/seed/out/omc} +OUT=${OUT:-$root/../build/dra23} +PIN=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f +SHAPIN=dbf002dd6aa36585632b9d01d98ac3f0bd2fa0f0475082940de53638847994bb +got=$(sha256sum "$OMC" | cut -d' ' -f1) +[ "$got" = "$PIN" ] || { echo "OMC_PIN_MISMATCH $got" >&2; exit 3; } +sha=$here/sha256-om2.om +got=$(sha256sum "$sha" | cut -d' ' -f1) +[ "$got" = "$SHAPIN" ] || { echo "SHA_UNIT_PIN_MISMATCH $got" >&2; exit 3; } +mkdir -p "$OUT" +name=dra23live +sed 's/^export fn /fn /' "$sha" > "$OUT/sha.fn.om" +n=$(diff "$sha" "$OUT/sha.fn.om" | grep -c '^>' || true) +[ "$n" = 4 ] || { echo "EXPORT_EDIT $n lines, want 4" >&2; exit 4; } +cat "$OUT/sha.fn.om" "$here/live.om" > "$OUT/$name.om" +rm -f "$OUT/sha.fn.om" +if [ $# -ge 1 ]; then + [ "$1" = --mutant ] && [ $# -eq 2 ] || { echo "usage: build.sh [--mutant m1|m2|m3]" >&2; exit 2; } + case $2 in + m1) pat='s/^if ne get hx j get ex j$/if eq ulong 1 ulong 0/' ;; + m2) pat='s/^if lbpre tdnv$/if eq ulong 1 ulong 0/' ;; + m3) pat='s/^if eq get lb add j 2 111$/if eq ulong 1 ulong 0/' ;; + *) echo "usage: build.sh [--mutant m1|m2|m3]" >&2; exit 2 ;; + esac + sed "$pat" "$OUT/$name.om" > "$OUT/$name-$2.om" + n=$(diff "$OUT/$name.om" "$OUT/$name-$2.om" | grep -c '^>' || true) + [ "$n" = 1 ] || { echo "SED_CHANGED $n lines, want 1" >&2; exit 4; } + name=$name-$2 +fi +set +e +"$OMC" < "$OUT/$name.om" > "$OUT/$name.tmp" +rc=$? +set -e +if [ $rc -ne 0 ]; then rm -f "$OUT/$name.tmp"; echo "BUILD_FAIL omc rc=$rc" >&2; exit 1; fi +chmod +x "$OUT/$name.tmp" +mv "$OUT/$name.tmp" "$OUT/$name" +echo "BUILD_OK $(sha256sum "$OUT/$name" | cut -d' ' -f1) $OUT/$name source_sha256 $(sha256sum "$OUT/$name.om" | cut -d' ' -f1)" diff --git a/tests/omegallm/dra23/check.sh b/tests/omegallm/dra23/check.sh new file mode 100644 index 0000000..b072cc0 --- /dev/null +++ b/tests/omegallm/dra23/check.sh @@ -0,0 +1,110 @@ +#!/bin/sh +# check.sh: DRA-23 probe gate. Builds dra23live and its mutants (build.sh), then runs positive cases +# and negative controls against processes this script starts itself on loopback test ports +# (never :18091). The script stops only the PIDs it started. +# Env: OLLM (an aarch64 `ollm serve` build from tests/omegallm/build.sh), CK (checkpoint), MERGES +# (tokenizer merges), PORT (default 18923, the test server), FPORT (default 18924, a dynamically +# linked fixture listener, python3 -m http.server), GPUPID (optional: a running process of this +# user that holds raw NVIDIA RM device nodes, inspected read-only through /proc; absent gives +# NOT_RUN rows), CORES (taskset list, default 10-11), OMC, BOUT (build dir, default +# ../build/dra23 beside this clone), OUT (receipt directory, default $BOUT/check). +# Each row prints `CASE name expect=... got=... PASS|FAIL`. Exit 0 only when every run row matched. +set -u +here=$(cd "$(dirname "$0")" && pwd) +root=$(cd "$here/../../.." && pwd) +: "${OLLM:?}" "${CK:?}" "${MERGES:?}" +PORT=${PORT:-18923} +FPORT=${FPORT:-18924} +CORES=${CORES:-10-11} +BOUT=${BOUT:-$root/../build/dra23} +OUT=${OUT:-$BOUT/check} +if [ "$PORT" = 18091 ] || [ "$FPORT" = 18091 ]; then echo "refusing to use :18091" >&2; exit 2; fi +mkdir -p "$OUT" +for p in "$PORT" "$FPORT"; do + if ss -Hltn "sport = :$p" | grep -q .; then echo "PORT_BUSY $p" >&2; exit 2; fi +done +for m in "" m1 m2 m3; do + if [ -z "$m" ]; then r=$(OUT=$BOUT taskset -c "$CORES" nice -n 19 sh "$here/build.sh" 2>&1) + else r=$(OUT=$BOUT taskset -c "$CORES" nice -n 19 sh "$here/build.sh" --mutant "$m" 2>&1); fi + echo "$r" | grep -q '^BUILD_OK' || { echo "BUILD_FAIL $m: $r"; exit 1; } + echo "$r" >> "$OUT/builds.txt" +done +L=$BOUT/dra23live +XS=$(sha256sum "$OLLM" | cut -d' ' -f1) +CKS=$(sha256sum "$CK" | cut -d' ' -f1) +MGS=$(sha256sum "$MERGES" | cut -d' ' -f1) +# a different valid digest for the mismatch rows: the probe's own binary +WRONG=$(sha256sum "$L" | cut -d' ' -f1) +{ + echo "date $(date -u +%FT%TZ)" + echo "host $(hostname) $(uname -m)" + echo "aien_train $(git -C "$root" rev-parse HEAD)" + echo "dra23live $WRONG" + echo "ollm $XS" + echo "ck $CKS" + echo "merges $MGS" +} > "$OUT/env.txt" +srv= +fix= +stop() { + [ -n "$srv" ] && kill "$srv" 2>/dev/null && wait "$srv" 2>/dev/null + [ -n "$fix" ] && kill "$fix" 2>/dev/null && wait "$fix" 2>/dev/null + echo "stopped server=$srv fixture=$fix" >> "$OUT/env.txt" +} +trap stop EXIT +taskset -c "$CORES" nice -n 10 "$OLLM" serve "$PORT" "$CK" "$MERGES" > "$OUT/serve.log" 2>&1 & +srv=$! +i=0 +until grep -q "^PORT $PORT" "$OUT/serve.log" 2>/dev/null; do + i=$((i + 1)) + if [ $i -gt 1200 ] || ! kill -0 "$srv" 2>/dev/null; then echo "SERVE_START_FAIL"; cat "$OUT/serve.log"; exit 1; fi + sleep 0.1 +done +taskset -c "$CORES" nice -n 10 python3 -m http.server --bind 127.0.0.1 "$FPORT" > "$OUT/fixture.log" 2>&1 & +fix=$! +i=0 +until ss -Hltn "sport = :$FPORT" | grep -q .; do + i=$((i + 1)); [ $i -gt 100 ] && { echo "FIXTURE_START_FAIL"; exit 1; }; sleep 0.1 +done +bad=0 +# row NAME EXPECT_RC EXPECT_FAIL_REASON|- BINARY ARGS... +row() { + name=$1 erc=$2 ereason=$3 bin=$4 + shift 4 + taskset -c "$CORES" nice -n 10 "$bin" "$@" > "$OUT/$name.txt" 2>&1 + rc=$? + ok=1 + [ "$rc" = "$erc" ] || ok=0 + if [ "$ereason" != - ]; then grep -qx "fail $ereason" "$OUT/$name.txt" || ok=0; fi + if [ "$erc" = 0 ]; then grep -q '^fail ' "$OUT/$name.txt" && ok=0; fi + v=$(tail -1 "$OUT/$name.txt") + if [ $ok = 1 ]; then echo "CASE $name expect=rc$erc/$ereason got=rc$rc PASS ($v)" + else echo "CASE $name expect=rc$erc/$ereason got=rc$rc FAIL ($v)"; bad=1; fi +} +row p1-own-model-cpu 0 - "$L" "$PORT" "$XS" none "$CK" "$CKS" "$MERGES" "$MGS" +row n1-wrong-exe 1 exe_sha256_mismatch "$L" "$PORT" "$WRONG" none "$CK" "$CKS" +row n2-expect-nvrm 1 gpu_expect_mismatch "$L" "$PORT" "$XS" nvrm "$CK" "$CKS" +row n3-wrong-ck 1 file_sha256_mismatch "$L" "$PORT" "$XS" none "$CK" "$WRONG" +row n4-ck-not-in-cmdline 1 file_not_in_cmdline "$L" "$PORT" "$XS" none "$(dirname "$CK")/./$(basename "$CK")" "$CKS" +row n5-dynamic-fixture 1 shared_object_mapped "$L" "$FPORT" - none +row n6-fixture-http 1 http_health_not_200 "$L" "$FPORT" - none +row n7-usage 2 - "$L" "$PORT" "$XS" cuda +# mutants: each must flip the verdict of the row it targets +row m1-mutant-wrong-exe 0 - "$BOUT/dra23live-m1" "$PORT" "$WRONG" none +row m3-mutant-dynamic 1 http_health_not_200 "$BOUT/dra23live-m3" "$FPORT" - none +if grep -q '^fail shared_object_mapped' "$OUT/m3-mutant-dynamic.txt"; then + echo "CASE m3-mutant-killed FAIL (mutant still reports shared objects)"; bad=1 +else echo "CASE m3-mutant-killed PASS (mutant misses the shared objects n5 reports)"; fi +if [ -n "${GPUPID:-}" ]; then + row p2-gpu-pid-nvrm 0 - "$L" --pid "$GPUPID" nvrm + row n8-gpu-pid-none 1 gpu_expect_mismatch "$L" --pid "$GPUPID" none + row m2-mutant-gpu-pid 1 gpu_expect_mismatch "$BOUT/dra23live-m2" --pid "$GPUPID" nvrm +else + echo "CASE p2-gpu-pid-nvrm NOT_RUN (no GPUPID)" + echo "CASE n8-gpu-pid-none NOT_RUN (no GPUPID)" + echo "CASE m2-mutant-gpu-pid NOT_RUN (no GPUPID)" +fi +row n9-no-listener 3 - "$L" 18925 - none +if [ $bad = 0 ]; then echo "DRA23CHECK PASS"; exit 0; fi +echo "DRA23CHECK FAIL" +exit 1 diff --git a/tests/omegallm/dra23/live-18091.sh b/tests/omegallm/dra23/live-18091.sh new file mode 100644 index 0000000..67a623a --- /dev/null +++ b/tests/omegallm/dra23/live-18091.sh @@ -0,0 +1,89 @@ +#!/bin/sh +# live-18091.sh: the DRA-23 live row. Proves which binary serves 127.0.0.1:PORT (default 18091), +# that it is the reproducible build of a named aien-train revision, and which GPU backend it holds. +# Read-only toward the server: never starts, stops or signals it, never binds a port, never opens a +# GPU device. Run it after the own Omega LLM is deployed on :18091 (DRA-125, lead ownmodel). +# Env (required): REV (full aien-train commit that was deployed), CK and MERGES (checkpoint and +# merges paths exactly as on the server's command line). +# Env (optional): TARGET (aarch64, the CPU serve build and the only build with `serve` at aien-train +# main 0518c915; gb10 once a GPU serve build exists), GPU (none for aarch64, nvrm for gb10), +# PORT (18091), CORES (10-11), OMC, BOUT (probe build dir, default ../build/dra23 beside this +# clone), OUT (receipt dir), AIEN_TRAIN (a clean clone at REV; default a fresh shallow fetch in OUT). +# Exit: the probe's verdict (0 PASS, 1 FAIL, 3 NOT_RUN) or 4 when a static precondition fails. +set -u +here=$(cd "$(dirname "$0")" && pwd) +root=$(cd "$here/../../.." && pwd) +: "${REV:?}" "${CK:?}" "${MERGES:?}" +TARGET=${TARGET:-aarch64} +case $TARGET in aarch64) GPU=${GPU:-none} ;; gb10) GPU=${GPU:-nvrm} ;; *) echo "TARGET aarch64|gb10" >&2; exit 2 ;; esac +PORT=${PORT:-18091} +CORES=${CORES:-10-11} +OMC=${OMC:-$root/../omega-mv/seed/out/omc} +BOUT=${BOUT:-$root/../build/dra23} +OUT=${OUT:-$BOUT/live-$(date -u +%Y%m%dT%H%M%SZ)} +mkdir -p "$OUT" +r=$(OMC=$OMC OUT=$BOUT sh "$here/build.sh" 2>&1) +echo "$r" | grep -q '^BUILD_OK' || { echo "PROBE_BUILD_FAIL $r"; exit 4; } +L=$BOUT/dra23live +# CUDApp device layer the own model vendors (aien-train native/omegallm/gpu/, from CUDApp dcba8bb8); +# git blob ids at CUDApp dcba8bb8 and at CUDApp main b774723f (only the SPDX note line differs; a +# gb10 build with either set is bit-identical, c35798fd at aien-train 0518c915). +VEND="context.om 5280fea0e47acd0f91e7616770b1679cd1a72e34 bafd9058ea296fa51dfe06827ee2e8508061f6fe +vector.om d2c1bc8305943374ed3cfe7ec3db020a4d21fa58 446d364b59c37d3570602ae762ae1ea309c81f1e +launch.om fb70bee4171cd30d8f28b41a5cbdceba283de816 1842982be00f62016267e85be1f051890edc4af6" +src=${AIEN_TRAIN:-$OUT/aien-train} +if [ ! -d "$src/.git" ]; then + git init -q "$src" && git -C "$src" fetch -q --depth 1 https://github.com/aien-dev/aien-train.git "$REV" \ + && git -C "$src" checkout -q FETCH_HEAD || { echo "FETCH_FAIL $REV" | tee "$OUT/static.txt"; exit 4; } +fi +head=$(git -C "$src" rev-parse HEAD) +[ "$head" = "$REV" ] || { echo "REV_MISMATCH clone at $head, want $REV" | tee "$OUT/static.txt"; exit 4; } +dirty=$(git -C "$src" status --porcelain | wc -l) +[ "$dirty" = 0 ] || { echo "DIRTY_TREE $dirty" | tee "$OUT/static.txt"; exit 4; } +{ + echo "date $(date -u +%FT%TZ)" + echo "aien_train $head target $TARGET gpu_expected $GPU port $PORT" + echo "omc $(sha256sum "$OMC" | cut -d' ' -f1)" + echo "dra23live $(sha256sum "$L" | cut -d' ' -f1)" +} > "$OUT/static.txt" +ok=1 +# 1. two independent builds of the deployed revision must be bit-identical: that digest is the +# expected /proc/PID/exe sha256. +x1=$(cd "$src" && TARGET=$TARGET OMC=$OMC OUT=$OUT/b1 CORE=$CORES sh tests/omegallm/build.sh 2>&1 | tail -1) +x2=$(cd "$src" && TARGET=$TARGET OMC=$OMC OUT=$OUT/b2 CORE=$CORES sh tests/omegallm/build.sh 2>&1 | tail -1) +echo "build1 $x1" >> "$OUT/static.txt" +echo "build2 $x2" >> "$OUT/static.txt" +d1=$(echo "$x1" | sed -n 's/^BUILD_OK \([0-9a-f]\{64\}\) .*/\1/p') +d2=$(echo "$x2" | sed -n 's/^BUILD_OK \([0-9a-f]\{64\}\) .*/\1/p') +if [ -z "$d1" ] || [ "$d1" != "$d2" ]; then echo "STATIC FAIL reproducible_build" >> "$OUT/static.txt"; cat "$OUT/static.txt"; exit 4; fi +comp=$OUT/b1/ollm.om +# 2. static backend census of the composed source: device node texts and devcall (ioctl) lines. +nodes=$(grep -c '^text [a-z0-9]* "/dev/' "$comp") +calls=$(grep -c 'devcall ' "$comp") +echo "census device_node_texts $nodes devcall_lines $calls" >> "$OUT/static.txt" +if [ "$TARGET" = aarch64 ]; then + if [ "$nodes" != 0 ] || [ "$calls" != 0 ]; then echo "STATIC FAIL cpu_build_has_device_code" >> "$OUT/static.txt"; ok=0; fi +else + # exactly the vendored CUDApp device layer, byte-equal to CUDApp at dcba8bb8 or main b774723f, + # and no device node or devcall outside it + echo "$VEND" | while read -r f b1 b2; do + got=$(git -C "$src" hash-object "native/omegallm/gpu/$f") + if [ "$got" = "$b1" ] || [ "$got" = "$b2" ]; then echo "vendored $f $got CUDApp_MATCH"; else echo "vendored $f $got CUDApp_MISMATCH"; fi + done >> "$OUT/static.txt" + if grep -q CUDApp_MISMATCH "$OUT/static.txt"; then echo "STATIC FAIL vendored_device_layer" >> "$OUT/static.txt"; ok=0; fi + want=$(grep -c 'devcall ' "$src/native/omegallm/gpu/context.om") + if [ "$nodes" != 3 ] || [ "$calls" != "$want" ]; then + echo "STATIC FAIL second_device_layer nodes=$nodes calls=$calls want=3/$want" >> "$OUT/static.txt"; ok=0 + fi +fi +[ $ok = 1 ] || { cat "$OUT/static.txt"; exit 4; } +echo "STATIC PASS expected_exe_sha256 $d1" >> "$OUT/static.txt" +cat "$OUT/static.txt" +# 3. the live probe against the running server +cks=$(sha256sum "$CK" | cut -d' ' -f1) +mgs=$(sha256sum "$MERGES" | cut -d' ' -f1) +taskset -c "$CORES" nice -n 10 "$L" "$PORT" "$d1" "$GPU" "$CK" "$cks" "$MERGES" "$mgs" > "$OUT/live.txt" 2>&1 +rc=$? +cat "$OUT/live.txt" +echo "LIVE rc=$rc receipt $OUT" +exit $rc diff --git a/tests/omegallm/dra23/live.om b/tests/omegallm/dra23/live.om new file mode 100644 index 0000000..3ab828c --- /dev/null +++ b/tests/omegallm/dra23/live.om @@ -0,0 +1,1357 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note dra23live: DRA-23 live identity probe for the model process bound to 127.0.0.1:PORT. +note Composed after the vendored om/sha256/sha256-om2.om (omega-mv e5b32567) by build.sh, which +note turns its four `export fn` lines into `fn` (the only change) so the unit is a program. +note Read-only: it never binds a port, never opens a GPU device, never signals a process. +note Usage: dra23live PORT EXE_SHA256|- GPU [PATH SHA256]... +note PORT decimal 1..65535; the listener is looked up in /proc/net/tcp and /proc/net/tcp6 +note EXE 64 lowercase hex digits the /proc/PID/exe bytes must hash to, or - to only report +note GPU none, nvrm (raw NVIDIA RM nodes /dev/nvidiactl, /dev/nvidiaN, /dev/nvidia-uvm, +note the device layer vendored from CUDApp native/nvrm/context.om) or aiengpu (/dev/aien-gpu*) +note PATH SHA files (checkpoint, tokenizer merges) that must hash to SHA now and appear verbatim +note as one argument of /proc/PID/cmdline; at most 8 pairs +note Steps: listener inode -> the one process holding that socket -> exe sha256 -> cmdline -> +note GET /health and a one-token POST /v1/chat/completions (so a lazily opened device is open) -> +note /proc/PID/maps (no shared object may be mapped) and /proc/PID/fd device nodes -> one GPU class. +note Exit 0 verdict PASS, 1 verdict FAIL, 2 usage, 3 verdict NOT_RUN (nothing listens on PORT). +note Limits: an fd/maps snapshot shows what the process holds at that instant; files are hashed now, +note not at load time; the server reports no build identity of its own. + +text hexd "0123456789abcdef" +text tnl "\n" +text tsp " " +text thead "DRA23LIVE v1\n" +text tport "port " +text tusage "usage: dra23live PORT EXE_SHA256|- none|nvrm|aiengpu [PATH SHA256]...\n" +text tnone "none" +text tnvrm "nvrm" +text taien "aiengpu" +text tdrm "drm" +text tmixed "mixed" +text taccel "accel" +text tdash "-" +text tnet4 "/proc/net/tcp" +text tnet6 "/proc/net/tcp6" +text tproc "/proc" +text tprocs "/proc/" +text tfd "/fd" +text tfds "/fd/" +text texe "/exe" +text tmaps "/maps" +text tcmdl "/cmdline" +text tsock "socket:[" +text tsockz "]" +text tdev "/dev/" +text tdnv "/dev/nvidia" +text tdai "/dev/aien-gpu" +text tddri "/dev/dri/" +text tdacc "/dev/accel" +text tdkfd "/dev/kfd" +text tso ".so" +text tlino "listen_inode " +text tladdr " local " +text tholder "holder_pid " +text txlink "exe_link " +text txsha "exe_sha256 " +text tmatch " MATCH\n" +text tmism " MISMATCH\n" +text texpect "expect " +text tcarg "cmd_arg " +text tmapf "map_file " +text tmapd "map_dev " +text tmaps2 "map_self_segments " +text tdevfd "dev_fd " +text tgpu "gpu_observed " +text tgexp "gpu_expected " +text tfile "file " +text tfsha " sha256 " +text tincmd " in_cmdline " +text tyes "yes" +text tno "no" +text thttp "http " +text tstat " status " +text tline " line " +text tfail "fail " +text tvpass "verdict PASS\n" +text tvfail "verdict FAIL failures " +text tvnr "verdict NOT_RUN no_listener_on_port\n" +text tget1 "GET /health HTTP/1.1" +text tget2 "GET /v1/models HTTP/1.1" +text tpost "POST /v1/chat/completions HTTP/1.1" +text thost "Host: 127.0.0.1" +text tclose "Connection: close" +text tctype "Content-Type: application/json" +text tclen "Content-Length: " +text tbody "{\"model\":\"ollm\",\"messages\":[{\"role\":\"user\",\"content\":\"ping\"}],\"max_tokens\":1,\"temperature\":0}" +text thlth "/health" +text tmods "/v1/models" +text tchat "/v1/chat/completions" +text tr1 "holder_count_not_1" +text tr2 "exe_sha256_mismatch" +text tr3 "exe_unreadable" +text tr4 "shared_object_mapped" +text tr5 "gpu_backend_mixed" +text tr6 "gpu_expect_mismatch" +text tr7 "file_sha256_mismatch" +text tr8 "file_unreadable" +text tr9 "file_not_in_cmdline" +text tr10 "http_health_not_200" +text tr11 "http_models_not_200" +text tr12 "http_chat_not_200" +text tr13 "proc_unreadable" +text tr14 "listener_not_loopback" +text tr15 "proc_file_truncated" +text tlo4 "0100007F" +text tlo6 "00000000000000000000000001000000" +text tlo6m "0000000000000000FFFF00000100007F" + +note Path under construction and its length. +global pb uchar 1024 +global plen ulong 1 +note A symbolic link target (fd entry, exe) and its length. +global lb uchar 4096 +global llen ulong 1 +note The exe link, kept for the maps comparison. +global xl uchar 4096 +global xlen ulong 1 +note File contents (/proc/net/tcp*, maps) and their length. +note one spare element: eager `and` conditions may read fb[flen] when flen is the capacity +global fb uchar 983041 +global flen ulong 1 +note /proc/PID/cmdline. +global cb uchar 65536 +global clen ulong 1 +note getdents buffers: /proc and /proc/PID/fd. +global db uchar 32768 +global d2 uchar 32768 +note Argument bytes. +global ab uchar 1024 +note Digest hex computed, expected hex. +global hx uchar 64 +global ex uchar 64 +note Listener inodes and local-address loopback flags. +global ino ulong 8 +global iloop uchar 8 +global nino ulong 1 +note "socket:[INODE]" for each listener inode. +global sk uchar 512 +global sklen ulong 8 +note Holder pids. +global pids ulong 16 +global npid ulong 1 +note Port, failures, GPU class bits seen, self segments. +global gport ulong 1 +global nfail ulong 1 +global gseen ulong 1 +global nself ulong 1 +note HTTP request and response. +global rq uchar 1024 +global rqlen ulong 1 +global hb uchar 16385 +global hlen ulong 1 +global sa uchar 16 + +note ---------------------------------------------------------------- output +fn outt t view uchar * to void +k = write 1 t 0 len t +end +fn outn v ulong to void +b = new uchar 24 0 +i = ulong 24 +x = v +c = true +while c bound 30 +i = sub i 1 +put b i uchar add 48 rem x 10 +x = div x 10 +if eq x 0 +c = false +end +end +k = write 1 b i sub 24 i +end +fn outlb to void +k = write 1 lb 0 get llen 0 +end +fn outpb to void +k = write 1 pb 0 get plen 0 +end +fn outhx to void +k = write 1 hx 0 64 +end +fn fail t view uchar * to void +outt tfail +outt t +outt tnl +put nfail 0 add get nfail 0 1 +end + +note ---------------------------------------------------------------- paths +fn pclr to void +put plen 0 0 +end +fn padd t view uchar * to void +p = get plen 0 +for i ulong len t +put pb add p i get t i +end +put plen 0 add p len t +end +fn paddn v ulong to void +b = new uchar 24 0 +i = ulong 24 +x = v +c = true +while c bound 30 +i = sub i 1 +put b i uchar add 48 rem x 10 +x = div x 10 +if eq x 0 +c = false +end +end +p = get plen 0 +for j ulong sub 24 i +put pb add p j get b add i j +end +put plen 0 add p sub 24 i +end +note append db[o .. o+k) or d2[o .. o+k) +fn padddb o ulong k ulong to void +p = get plen 0 +for i ulong k +put pb add p i get db add o i +end +put plen 0 add p k +end +fn paddd2 o ulong k ulong to void +p = get plen 0 +for i ulong k +put pb add p i get d2 add o i +end +put plen 0 add p k +end +fn ppid pid ulong t view uchar * to void +pclr +padd tprocs +paddn pid +padd t +end + +note ---------------------------------------------------------------- argument parsing +fn argto i ulong to ulong +r = argread i ab 0 1024 +if or lt r 1 gt r 1023 +outt tusage +exit 2 +end +ret ulong r +end +fn argnum i ulong to ulong +n = argto i +if gt n 10 +outt tusage +exit 2 +end +v = ulong 0 +for j ulong n +d = get ab j +if or lt d 48 gt d 57 +outt tusage +exit 2 +end +v = add mul v 10 ulong sub d 48 +end +ret v +end +note arg i must be 64 lowercase hex digits (into ex); returns false for "-" +fn argsha i ulong to bool +n = argto i +if and eq n 1 eq get ab 0 45 +ret false +end +if ne n 64 +outt tusage +exit 2 +end +for j ulong 64 +d = get ab j +if and or lt d 48 gt d 57 or lt d 97 gt d 102 +outt tusage +exit 2 +end +put ex j d +end +ret true +end +fn abis t view uchar * n ulong to bool +if ne n len t +ret false +end +for j ulong n +if ne get ab j get t j +ret false +end +end +ret true +end +fn argpath i ulong to void +n = argto i +pclr +for j ulong n +put pb j get ab j +end +put plen 0 n +end + +note ---------------------------------------------------------------- whole files into fb +fn slurp to long +fd = fopen pb 0 get plen 0 0 0 +if lt fd 0 +ret fd +end +f = int fd +n = ulong 0 +go = true +while go bound 999999 +if ge n 983040 +go = false +else +r = read f fb n sub 983040 n +if le r 0 +go = false +else +n = add n ulong r +end +end +end +k = fclose f +put flen 0 n +if ge n 983040 +fail tr15 +end +ret long n +end + +note ---------------------------------------------------------------- sha256 of the file at pb into hx +fn tohex o view uchar 32 to void +for j ulong 32 +x = get o j +p = mul j 2 +put hx p get hexd shr x 4 +put hx add p 1 get hexd and x 15 +end +end +fn hashpb to long +c = new uchar 104 0 +b = new uchar 65536 0 +o = new uchar 32 0 +fd = fopen pb 0 get plen 0 0 0 +if lt fd 0 +ret fd +end +f = int fd +sha256_init c +t = ulong 0 +go = true +while go bound 999999 +r = read f b 0 65536 +if lt r 0 +k = fclose f +ret r +end +if eq r 0 +go = false +else +sha256_update c part b 0 ulong r +t = add t ulong r +end +end +k = fclose f +sha256_final c o +tohex o +ret long t +end +fn hexeq to bool +for j ulong 64 +if ne get hx j get ex j +ret false +end +end +ret true +end + +note ---------------------------------------------------------------- line and field scanning in fb +fn isws c uchar to bool +ret or eq c 32 eq c 9 +end +note end of the line starting at s (index of the newline, or flen) +fn eol s ulong to ulong +n = get flen 0 +i = s +while lt i n bound 999999 +if eq get fb i 10 +ret i +end +i = add i 1 +end +ret n +end +note start of field k (0-based, blank-separated) in fb[s .. e), or e +fn fieldat s ulong e ulong k ulong to ulong +i = s +f = ulong 0 +inw = false +while lt i e bound 999999 +w = isws get fb i +if w +inw = false +else +if eq inw false +if eq f k +ret i +end +f = add f 1 +inw = true +end +end +i = add i 1 +end +ret e +end +fn tokend s ulong e ulong to ulong +i = s +while lt i e bound 999999 +if isws get fb i +ret i +end +i = add i 1 +end +ret e +end +fn hexv c uchar to ulong +if and ge c 48 le c 57 +ret ulong sub c 48 +end +if and ge c 65 le c 70 +ret add ulong sub c 65 10 +end +if and ge c 97 le c 102 +ret add ulong sub c 97 10 +end +ret 16 +end + +note ---------------------------------------------------------------- listeners in /proc/net/tcp* +note A local address is loopback when it is 0100007F (IPv4), ::1 or ::ffff:127.0.0.1 (IPv6), as +note /proc/net/tcp* print them (each 32-bit word in host order, hex digits upper case). +fn fbeq s ulong t view uchar * to bool +for j ulong len t +if ne get fb add s j get t j +ret false +end +end +ret true +end +fn isloop s ulong n ulong to bool +if eq n 8 +ret fbeq s tlo4 +end +if ne n 32 +ret false +end +if fbeq s tlo6 +ret true +end +ret fbeq s tlo6m +end +fn addino v ulong lp bool to void +n = get nino 0 +for j ulong n +if eq get ino j v +ret +end +end +if ge n 8 +ret +end +put ino n v +put iloop n uchar 0 +if lp +put iloop n uchar 1 +end +put nino 0 add n 1 +end +fn colon a ulong ae ulong to ulong +c = a +while and lt c ae ne get fb c 58 bound 999999 +c = add c 1 +end +ret c +end +fn hexport c ulong to ulong +p = ulong 0 +for j ulong 4 +p = or shl p 4 hexv get fb add add c 1 j +end +ret p +end +fn islisten s ulong e ulong to bool +st = fieldat s e 3 +if ne get fb st 48 +ret false +end +ret eq get fb add st 1 65 +end +fn decat q ulong qe ulong to ulong +v = ulong 0 +for j ulong sub qe q +v = add mul v 10 ulong sub get fb add q j 48 +end +ret v +end +fn tcpkeep s ulong e ulong a ulong c ulong ae ulong to void +q = fieldat s e 9 +qe = tokend q e +v = decat q qe +lp = isloop a sub c a +outt tlino +outn v +outt tladdr +k = write 1 fb a sub ae a +outt tnl +addino v lp +end +fn tcpline s ulong e ulong to void +a = fieldat s e 1 +ae = tokend a e +c = colon a ae +if ne sub ae c 5 +ret +end +if ne hexport c get gport 0 +ret +end +if islisten s e +tcpkeep s e a c ae +end +end +fn tcpscan t view uchar * to void +pclr +padd t +r = slurp +if lt r 0 +ret +end +n = get flen 0 +s = eol 0 +s = add s 1 +while lt s n bound 999999 +e = eol s +tcpline s e +s = add e 1 +end +end + +note ---------------------------------------------------------------- holders of the listener socket +note lb (length llen) equals "socket:[INODE]" for some listener inode +fn issock to bool +n = get llen 0 +if lt n 10 +ret false +end +for j ulong 8 +if ne get lb j get tsock j +ret false +end +end +if ne get lb sub n 1 93 +ret false +end +v = ulong 0 +for j ulong sub n 9 +d = get lb add 8 j +if or lt d 48 gt d 57 +ret false +end +v = add mul v 10 ulong sub d 48 +end +for j ulong get nino 0 +if eq get ino j v +ret true +end +end +ret false +end +fn addpid pid ulong to void +n = get npid 0 +for j ulong n +if eq get pids j pid +ret +end +end +if lt n 16 +put pids n pid +put npid 0 add n 1 +end +end +fn readlb to long +r = readlnk pb 0 get plen 0 lb 0 4096 +if lt r 0 +put llen 0 0 +ret r +end +put llen 0 ulong r +ret r +end +note getdents64 record at o: reclen at o+16 (u16 little endian), name from o+19, NUL-terminated +fn d2rl o ulong to ulong +ret or ulong get d2 add o 16 shl ulong get d2 add o 17 8 +end +fn d2nl o ulong to ulong +k = ulong 0 +while ne get d2 add add o 19 k 0 bound 256 +k = add k 1 +end +ret k +end +fn dbrl o ulong to ulong +ret or ulong get db add o 16 shl ulong get db add o 17 8 +end +fn dbnl o ulong to ulong +k = ulong 0 +while ne get db add add o 19 k 0 bound 256 +k = add k 1 +end +ret k +end +note one /proc/PID/fd entry at d2[o]: mode 0 looks for the listener socket, mode 1 for devices +fn fdent pid ulong o ulong md ulong to void +k = d2nl o +if eq get d2 add o 19 46 +ret +end +ppid pid tfds +paddd2 add o 19 k +x = readlb +if le x 0 +ret +end +if eq md 0 +if issock +addpid pid +end +ret +end +if lbpre tdev +g = gclass +put gseen 0 or get gseen 0 g +outt tdevfd +k2 = write 1 d2 add o 19 k +outt tsp +outlb +outt tnl +end +end +note every entry of /proc/PID/fd; f is the fd directory's descriptor +fn fdwalk pid ulong f int md ulong to void +go = true +while go bound 999999 +r = getdnts f d2 0 32768 +if le r 0 +ret +end +o = ulong 0 +while lt o ulong r bound 999999 +fdent pid o md +o = add o d2rl o +end +end +end +fn chkpid pid ulong to void +ppid pid tfd +fd = fopen pb 0 get plen 0 16384 0 +if lt fd 0 +ret +end +f = int fd +fdwalk pid f 0 +k = fclose f +end +fn isnum o ulong k ulong to ulong +v = ulong 0 +if or eq k 0 gt k 10 +ret 0 +end +for j ulong k +d = get db add o j +if or lt d 48 gt d 57 +ret 0 +end +v = add mul v 10 ulong sub d 48 +end +ret v +end +fn scanproc to void +pclr +padd tproc +fd = fopen pb 0 get plen 0 16384 0 +if lt fd 0 +fail tr13 +ret +end +f = int fd +go = true +while go bound 999999 +r = getdnts f db 0 32768 +if le r 0 +go = false +else +o = ulong 0 +while lt o ulong r bound 999999 +k = dbnl o +pid = isnum add o 19 k +if gt pid 0 +chkpid pid +end +o = add o dbrl o +end +end +end +k = fclose f +end + +note ---------------------------------------------------------------- GPU class of a device path in lb +note bits: 1 nvrm, 2 aiengpu, 4 drm, 8 accel/kfd; 0 for a device that is not a GPU node +fn lbpre t view uchar * to bool +n = get llen 0 +if lt n len t +ret false +end +for j ulong len t +if ne get lb j get t j +ret false +end +end +ret true +end +fn gclass to ulong +if lbpre tdai +ret 2 +end +if lbpre tdnv +ret 1 +end +if lbpre tddri +ret 4 +end +if lbpre tdacc +ret 8 +end +if lbpre tdkfd +ret 8 +end +ret 0 +end +fn outgc g ulong to void +if eq g 0 +outt tnone +ret +end +if eq g 1 +outt tnvrm +ret +end +if eq g 2 +outt taien +ret +end +if eq g 4 +outt tdrm +ret +end +if eq g 8 +outt taccel +ret +end +outt tmixed +end + +note ---------------------------------------------------------------- /proc/PID/maps +note lb = fb[s .. e) +fn fbtolb s ulong e ulong to void +n = sub e s +if gt n 4096 +n = 4096 +end +for j ulong n +put lb j get fb add s j +end +put llen 0 n +end +fn lbisx to bool +n = get llen 0 +if ne n get xlen 0 +ret false +end +for j ulong n +if ne get lb j get xl j +ret false +end +end +ret true +end +note lb contains ".so" followed by end, "." or blank +fn soend q ulong n ulong to bool +if ge q n +ret true +end +c = get lb q +ret or eq c 46 eq c 32 +end +fn lbso to bool +n = get llen 0 +if lt n 3 +ret false +end +for j ulong sub n 2 +if eq get lb j 46 +if eq get lb add j 1 115 +if eq get lb add j 2 111 +if soend add j 3 n +ret true +end +end +end +end +end +ret false +end +note fb[p .. e) equals the previous line's path fb[ps .. pe) (consecutive segments of one file) +fn fbsame p ulong e ulong ps ulong pe ulong to bool +if le pe ps +ret false +end +if ne sub e p sub pe ps +ret false +end +for j ulong sub e p +if ne get fb add p j get fb add ps j +ret false +end +end +ret true +end +fn mapline s ulong e ulong ps ulong pe ulong to void +p = fieldat s e 5 +if ge p e +ret +end +if eq get fb p 91 +ret +end +fbtolb p e +if lbisx +put nself 0 add get nself 0 1 +ret +end +if fbsame p e ps pe +ret +end +if lbpre tdev +g = gclass +put gseen 0 or get gseen 0 g +outt tmapd +outlb +outt tnl +ret +end +outt tmapf +outlb +outt tnl +if lbso +fail tr4 +end +end +fn mapscan pid ulong to void +ppid pid tmaps +r = slurp +if lt r 0 +fail tr13 +ret +end +n = get flen 0 +s = ulong 0 +ps = ulong 0 +pe = ulong 0 +while lt s n bound 999999 +e = eol s +mapline s e ps pe +p = fieldat s e 5 +if lt p e +ps = p +pe = e +end +s = add e 1 +end +outt tmaps2 +outn get nself 0 +outt tnl +end + +note ---------------------------------------------------------------- /proc/PID/fd device nodes +fn fdscan pid ulong to void +ppid pid tfd +fd = fopen pb 0 get plen 0 16384 0 +if lt fd 0 +fail tr13 +ret +end +f = int fd +fdwalk pid f 1 +k = fclose f +end + +note ---------------------------------------------------------------- /proc/PID/cmdline +fn cmdread pid ulong to void +ppid pid tcmdl +r = slurp +n = get flen 0 +if gt n 65536 +n = 65536 +end +for j ulong n +put cb j get fb j +end +put clen 0 n +i = ulong 0 +s = ulong 0 +a = ulong 0 +while lt i n bound 999999 +if eq get cb i 0 +outt tcarg +outn a +outt tsp +k = write 1 cb s sub i s +outt tnl +a = add a 1 +s = add i 1 +end +i = add i 1 +end +end +note pb equals one NUL-terminated argument of cb +fn pbincmd to bool +n = get clen 0 +m = get plen 0 +s = ulong 0 +i = ulong 0 +while lt i n bound 999999 +if eq get cb i 0 +if eq sub i s m +same = true +for j ulong m +if ne get cb add s j get pb j +same = false +end +end +if same +ret true +end +end +s = add i 1 +end +i = add i 1 +end +ret false +end + +note ---------------------------------------------------------------- HTTP on 127.0.0.1:PORT +fn rqclr to void +put rqlen 0 0 +end +fn rqadd t view uchar * to void +p = get rqlen 0 +for i ulong len t +put rq add p i get t i +end +put rqlen 0 add p len t +end +fn rqcrlf to void +p = get rqlen 0 +put rq p 13 +put rq add p 1 10 +put rqlen 0 add p 2 +end +fn rqaddn v ulong to void +b = new uchar 24 0 +i = ulong 24 +x = v +c = true +while c bound 30 +i = sub i 1 +put b i uchar add 48 rem x 10 +x = div x 10 +if eq x 0 +c = false +end +end +p = get rqlen 0 +for j ulong sub 24 i +put rq add p j get b add i j +end +put rqlen 0 add p sub 24 i +end +fn rqhead t view uchar * to void +rqclr +rqadd t +rqcrlf +rqadd thost +rqcrlf +rqadd tclose +rqcrlf +end +note send rq, read the response into hb until close or tmo seconds; returns the status code or 0 +fn exch tmo ulong to ulong +put hlen 0 0 +put sa 0 2 +put sa 1 0 +put sa 2 uchar shr get gport 0 8 +put sa 3 uchar and get gport 0 255 +put sa 4 127 +put sa 5 0 +put sa 6 0 +put sa 7 1 +s = int socknew 2 1 0 +if lt s 0 +ret 0 +end +c = connect s sa 0 16 +if lt c 0 +k = fclose s +ret 0 +end +o = ulong 0 +n = get rqlen 0 +while lt o n bound 999999 +w = send s rq o sub n o 0 +if le w 0 +k = fclose s +ret 0 +end +o = add o ulong w +end +t0 = monons +h = ulong 0 +go = true +while go bound 999999 +if ge h 16384 +go = false +else +el = div ulong sub monons t0 1000000000 +if ge el tmo +go = false +else +z = waitio s 1 1000000000 +if gt z 0 +r = recv s hb h sub 16384 h 0 +if le r 0 +go = false +else +h = add h ulong r +end +end +end +end +end +k = fclose s +put hlen 0 h +if lt h 12 +ret 0 +end +v = ulong 0 +for j ulong 3 +d = get hb add 9 j +if or lt d 48 gt d 57 +ret 0 +end +v = add mul v 10 ulong sub d 48 +end +ret v +end +fn outhttp t view uchar * code ulong to void +outt thttp +outt t +outt tstat +outn code +outt tline +h = get hlen 0 +i = ulong 0 +while and lt i h ne get hb i 13 bound 16385 +i = add i 1 +end +k = write 1 hb 0 i +outt tnl +end +fn httpall to void +rqhead tget1 +rqcrlf +v = exch 30 +outhttp thlth v +if ne v 200 +fail tr10 +end +rqhead tget2 +rqcrlf +v = exch 30 +outhttp tmods v +if ne v 200 +fail tr11 +end +rqhead tpost +rqadd tctype +rqcrlf +rqadd tclen +rqaddn len tbody +rqcrlf +rqcrlf +rqadd tbody +v = exch 600 +outhttp tchat v +if ne v 200 +fail tr12 +end +end + +note ---------------------------------------------------------------- expected files +fn filechk i ulong to void +argpath i +hs = argsha add i 1 +r = hashpb +outt tfile +outpb +if lt r 0 +outt tnl +fail tr8 +ret +end +outt tfsha +outhx +if hs +if hexeq +outt tmatch +else +outt tmism +fail tr7 +end +else +outt tnl +end +outt tfile +outpb +outt tincmd +if pbincmd +outt tyes +outt tnl +else +outt tno +outt tnl +fail tr9 +end +end + +note ---------------------------------------------------------------- main +note Inspection-only mode: dra23live --pid PID GPU reads /proc/PID (exe hash, maps, fd devices) +note and checks the GPU class only; no listener lookup and no HTTP request are made. +text tpidm "--pid" +text tmode "mode pid_inspect\n" +fn pidmode na ulong to int +if ne na 4 +outt tusage +ret 2 +end +pid = argnum 2 +gn = argto 3 +gx = ulong 99 +if abis tnone gn +gx = 0 +end +if abis tnvrm gn +gx = 1 +end +if abis taien gn +gx = 2 +end +if or eq gx 99 eq pid 0 +outt tusage +ret 2 +end +outt thead +outt tmode +outt tgexp +outgc gx +outt tnl +outt tholder +outn pid +outt tnl +r = inspect pid +g = get gseen 0 +gpuchk g gx +ret verdict +end +note exe link, exe hash, maps and fd devices of pid; returns the exe hash status +fn inspect pid ulong to long +ppid pid texe +r = readlb +outt txlink +outlb +outt tnl +for j ulong get llen 0 +put xl j get lb j +end +put xlen 0 get llen 0 +ppid pid texe +h = hashpb +if lt h 0 +fail tr3 +else +outt txsha +outhx +outt tnl +end +mapscan pid +fdscan pid +ret h +end +fn gpuchk g ulong gx ulong to void +outt tgpu +outgc g +outt tnl +if and ne g 0 ne and g sub g 1 0 +fail tr5 +end +if ne g gx +fail tr6 +end +end +fn verdict to int +if eq get nfail 0 0 +outt tvpass +ret 0 +end +outt tvfail +outn get nfail 0 +outt tnl +ret 1 +end +fn main to int +na = ulong argcnt +if ge na 2 +n1 = argto 1 +if abis tpidm n1 +ret pidmode na +end +end +if or lt na 4 gt na 20 +outt tusage +ret 2 +end +if ne rem sub na 4 2 0 +outt tusage +ret 2 +end +pt = argnum 1 +if or eq pt 0 gt pt 65535 +outt tusage +ret 2 +end +put gport 0 pt +xs = argsha 2 +gn = argto 3 +gx = ulong 99 +if abis tnone gn +gx = 0 +end +if abis tnvrm gn +gx = 1 +end +if abis taien gn +gx = 2 +end +if eq gx 99 +outt tusage +ret 2 +end +outt thead +outt tport +outn pt +outt tnl +outt tgexp +outgc gx +outt tnl +tcpscan tnet4 +tcpscan tnet6 +if eq get nino 0 0 +outt tvnr +ret 3 +end +for j ulong get nino 0 +if eq get iloop j 0 +fail tr14 +end +end +scanproc +for j ulong get npid 0 +outt tholder +outn get pids j +outt tnl +end +if ne get npid 0 1 +fail tr1 +outt tvfail +outn get nfail 0 +outt tnl +ret 1 +end +pid = get pids 0 +ppid pid texe +r = readlb +outt txlink +outlb +outt tnl +for j ulong get llen 0 +put xl j get lb j +end +put xlen 0 get llen 0 +ppid pid texe +r = hashpb +if lt r 0 +fail tr3 +else +outt txsha +outhx +outt tnl +if xs +outt texpect +k = write 1 ex 0 64 +if hexeq +outt tmatch +else +outt tmism +fail tr2 +end +end +end +cmdread pid +httpall +mapscan pid +fdscan pid +g = get gseen 0 +gpuchk g gx +i = ulong 4 +while lt i na bound 20 +filechk i +i = add i 2 +end +ret verdict +end diff --git a/tests/omegallm/dra23/sha256-om2.om b/tests/omegallm/dra23/sha256-om2.om new file mode 100644 index 0000000..748c871 --- /dev/null +++ b/tests/omegallm/dra23/sha256-om2.om @@ -0,0 +1,344 @@ +note SPDX-License-Identifier: Apache-2.0 +note sha256-om2.om: FIPS 180-4 SHA-256 in OM-2 (spec/omegese-om2.md, #747/#748, ledger L838). +note The four entries are the API of src/sha256.h, exported through omega-bridge ABI v2 as +note omega2_sha256_init/update/final/hash; the bridge's generated omega_api.h maps the C names. +note +note Invariants: +note - All hashing state is the caller's 104-byte context (layout shactx below, equal to sha256_ctx +note on LP64 AArch64). Nothing else persists between calls, so a byte copy of a live context is an +note equivalent context (erratum E3). +note - count is the number of bytes absorbed since init, modulo 2^64. buf[0 .. count mod 64) holds the +note pending bytes of the current block; the rest of buf is unspecified. state is the chaining value +note after the count div 64 whole blocks. +note - final reads the context and writes only the digest, so the context is unchanged by it. The +note contract promises less (after final the context is unspecified, memory safety only). +note - Every branch and every loop count depends only on lengths, never on message bytes (section 8). +note - Indices into the unsized input view are checked at run time (trap 3); indices into sized +note arrays inside unrolled bodies are constants and checked when compiled. +note bridge c-type shactx sha256_ctx +note bridge c-define SHA256_DIGEST_SIZE 32 +note bridge c-define SHA256_BLOCK_SIZE 64 +om2 + +layout shactx 104 +field state uint 8 at 0 little +field count ulong at 32 little +field buf uchar 64 at 40 little +end + +note K[0..63]: the first 32 bits of the fractional parts of the cube roots of the first 64 primes. +note Copied mechanically from seed/qualification/om2/fixtures/sha256-k.dec (tool-computed, never typed). +fn kinit k edit uint 64 to void +put k 0 0x428a2f98 +put k 1 0x71374491 +put k 2 0xb5c0fbcf +put k 3 0xe9b5dba5 +put k 4 0x3956c25b +put k 5 0x59f111f1 +put k 6 0x923f82a4 +put k 7 0xab1c5ed5 +put k 8 0xd807aa98 +put k 9 0x12835b01 +put k 10 0x243185be +put k 11 0x550c7dc3 +put k 12 0x72be5d74 +put k 13 0x80deb1fe +put k 14 0x9bdc06a7 +put k 15 0xc19bf174 +put k 16 0xe49b69c1 +put k 17 0xefbe4786 +put k 18 0x0fc19dc6 +put k 19 0x240ca1cc +put k 20 0x2de92c6f +put k 21 0x4a7484aa +put k 22 0x5cb0a9dc +put k 23 0x76f988da +put k 24 0x983e5152 +put k 25 0xa831c66d +put k 26 0xb00327c8 +put k 27 0xbf597fc7 +put k 28 0xc6e00bf3 +put k 29 0xd5a79147 +put k 30 0x06ca6351 +put k 31 0x14292967 +put k 32 0x27b70a85 +put k 33 0x2e1b2138 +put k 34 0x4d2c6dfc +put k 35 0x53380d13 +put k 36 0x650a7354 +put k 37 0x766a0abb +put k 38 0x81c2c92e +put k 39 0x92722c85 +put k 40 0xa2bfe8a1 +put k 41 0xa81a664b +put k 42 0xc24b8b70 +put k 43 0xc76c51a3 +put k 44 0xd192e819 +put k 45 0xd6990624 +put k 46 0xf40e3585 +put k 47 0x106aa070 +put k 48 0x19a4c116 +put k 49 0x1e376c08 +put k 50 0x2748774c +put k 51 0x34b0bcb5 +put k 52 0x391c0cb3 +put k 53 0x4ed8aa4a +put k 54 0x5b9cca4f +put k 55 0x682e6ff3 +put k 56 0x748f82ee +put k 57 0x78a5636f +put k 58 0x84c87814 +put k 59 0x8cc70208 +put k 60 0x90befffa +put k 61 0xa4506ceb +put k 62 0xbef9a3f7 +put k 63 0xc67178f2 +end + +note H(0): the first 32 bits of the fractional parts of the square roots of the first 8 primes +note (fixtures/sha256-iv.dec). +fn iv s edit uint 8 to void +put s 0 0x6a09e667 +put s 1 0xbb67ae85 +put s 2 0x3c6ef372 +put s 3 0xa54ff53a +put s 4 0x510e527f +put s 5 0x9b05688c +put s 6 0x1f83d9ab +put s 7 0x5be0cd19 +end + +note Message schedule of the block m[o .. o+64). w is fresh: its incoming contents are never read. +note The compiler proves that every get of w reads an element written earlier in this function +note (error 27 otherwise): w[0..16) are the block's big-endian words, w[16..64) the FIPS recurrence. +fn sched w edit uint 64 fresh m view uchar * o ulong to void +q = ulong 0 +x = uint 0 +y = uint 0 +for i ulong 16 unroll +q = add o mul i 4 +x = uint get m q +x = or shl x 8 uint get m add q 1 +x = or shl x 8 uint get m add q 2 +put w i or shl x 8 uint get m add q 3 +end +for i ulong 48 unroll +x = get w add i 1 +y = get w add i 14 +x = add add get w i get w add i 9 xor xor rotr x 7 rotr x 18 shr x 3 +put w add i 16 add x xor xor rotr y 17 rotr y 19 shr y 10 +end +end + +note The 64 rounds on the chaining value s. One round body, emitted 64 times by unroll; i is a constant +note in each copy, so get kt i and get w i need no run-time check. uint arithmetic wraps mod 2^32. +note Ch(e,f,g) = (e and f) xor (not e and g) is written g xor (e and (f xor g)); Maj(a,b,c) = +note (a and b) xor (a and c) xor (b and c) is written (a and b) or (c and (a or b)). Both are bitwise +note identities. h first becomes T1, then T1 + T2, which is the next a; the names then shift by one. +note The sums are built a term per line and each Sigma in two lines through t: 12 names are live, and +note omc hands out 16 registers with no spilling (error 12 under compiler-s1/s2 for longer lines). +fn rounds s edit uint 8 w view uint 64 kt view uint 64 to void +a = get s 0 +b = get s 1 +c = get s 2 +d = get s 3 +e = get s 4 +f = get s 5 +g = get s 6 +h = get s 7 +t = uint 0 +for i ulong 64 unroll +h = add h get kt i +h = add h get w i +t = xor rotr e 6 rotr e 11 +t = xor t rotr e 25 +h = add h t +h = add h xor g and e xor f g +d = add d h +t = xor rotr a 2 rotr a 13 +t = xor t rotr a 22 +h = add h t +t = and c or a b +h = add h or and a b t +t = h +h = g +g = f +f = e +e = d +d = c +c = b +b = a +a = t +end +put s 0 add get s 0 a +put s 1 add get s 1 b +put s 2 add get s 2 c +put s 3 add get s 3 d +put s 4 add get s 4 e +put s 5 add get s 5 f +put s 6 add get s 6 g +put s 7 add get s 7 h +end + +note One block m[o .. o+64) into s. sched and rounds stay calls: inlined, their names would share +note one 16-register frame with this function's parameters (no spilling, error 12). +fn compress s edit uint 8 w edit uint 64 kt view uint 64 m view uchar * o ulong to void +sched w m o +rounds s w kt +end + +note The whole blocks of m (len m is a multiple of 64 and at most 2^25, so under 2^19 passes). +fn run s edit uint 8 w edit uint 64 kt view uint 64 m view uchar * to void +for j ulong shr len m 6 +compress s w kt m shl j 6 +end +end + +note The whole blocks of m (len m a multiple of 64). A rolled loop traps 4 after 1000000 passes +note (OMEGESE.md section 2; omc s_for), so m is cut into runs of 2^25 bytes (2^19 blocks): +note len m = top * 2^44 + mid * 2^25 + rest, and no loop passes 2^20 times. top reaches 1000000 +note only above 1.7e19 bytes, which no AArch64 address space holds. +fn blocks s edit uint 8 w edit uint 64 kt view uint 64 m view uchar * to void +q = ulong 0 +for a ulong shr len m 44 +for b ulong 0x80000 +run s w kt part m q 0x2000000 +q = add q 0x2000000 +end +end +for b ulong and shr len m 25 0x7ffff +run s w kt part m q 0x2000000 +q = add q 0x2000000 +end +run s w kt part m q sub len m q +end + +note Pad the k pending bytes already in p (k < 64; p was all zero past them): 0x80, zeros, and the +note 64-bit big-endian bit length of the n-byte message in the last 8 bytes of one or two blocks. +fn finish s edit uint 8 w edit uint 64 kt view uint 64 p edit uchar 128 k ulong n ulong to void +put p k 0x80 +e = ulong 64 +if ge k 56 +e = 128 +end +bits = shl n 3 +for i ulong 8 unroll +put p sub e add i 1 uchar and shr bits mul i 8 0xff +end +compress s w kt view p 0 +if eq e 128 +compress s w kt view p 64 +end +end + +export fn sha256_init c edit shactx to void +s = new uint 8 0 +iv s +for i ulong 8 unroll +put c state i get s i +end +put c count 0 +end + +note k bytes of d from o into the context's buffer at bi (bi + k <= 64). A function of its own: inside +note absorb the copy loop needs more than the 16 registers (error 12 under compiler-s4). +fn tobuf c edit shactx bi ulong d view uchar * o ulong k ulong to void +for i ulong k +put c buf add bi i get d add o i +end +end + +note Whole blocks are hashed straight from d; the bytes that complete a pending block go through blk. +fn absorb c edit shactx d view uchar * bi ulong to void +n = len d +s = new uint 8 0 +w = new uint 64 0 +kt = new uint 64 0 +blk = new uchar 64 0 +kinit kt +for i ulong 8 unroll +put s i get c state i +end +off = ulong 0 +if gt bi 0 +off = sub 64 bi +for i ulong bi +put blk i get c buf i +end +for i ulong off +put blk add bi i get d i +end +compress s w kt view blk 0 +end +nb = shr sub n off 6 +blocks s w kt part d off shl nb 6 +off = add off shl nb 6 +tobuf c 0 d off sub n off +for i ulong 8 unroll +put c state i get s i +end +end + +note Any length, including 0 and >= 2^32. lt n sub 64 bi cannot wrap (bi < 64); add bi n could. +export fn sha256_update c edit shactx d view uchar * to void +n = len d +cnt = get c count +bi = and cnt 63 +put c count add cnt n +if lt n sub 64 bi +tobuf c bi d 0 n +ret +end +absorb c d bi +end + +export fn sha256_final c edit shactx o out uchar 32 to void +s = new uint 8 0 +w = new uint 64 0 +kt = new uint 64 0 +p = new uchar 128 0 +v = ulong 0 +kinit kt +for i ulong 8 unroll +put s i get c state i +end +cnt = get c count +k = and cnt 63 +for i ulong k +put p i get c buf i +end +finish s w kt p k cnt +for i ulong 8 unroll +v = ulong get s i +for j ulong 4 unroll +put o add mul i 4 j uchar and shr v sub 24 mul j 8 0xff +end +end +end + +note Equal to init, update(d), final on a fresh context (section 7), with the state in locals. o may +note overlap d: the binding copies o out only after the call returns status 0. +export fn sha256_hash d view uchar * o out uchar 32 to void +s = new uint 8 0 +w = new uint 64 0 +kt = new uint 64 0 +p = new uchar 128 0 +v = ulong 0 +kinit kt +iv s +n = len d +nb = shr n 6 +blocks s w kt part d 0 shl nb 6 +off = shl nb 6 +k = sub n off +for i ulong k +put p i get d add off i +end +finish s w kt p k n +for i ulong 8 unroll +v = ulong get s i +for j ulong 4 unroll +put o add mul i 4 j uchar and shr v sub 24 mul j 8 0xff +end +end +end