From 7a581c0b3fb740433e4e4800ddefa3d649a5d9e2 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Thu, 5 Nov 2026 07:42:05 -0600 Subject: [PATCH] tests: require complete SHA-256 freestanding mutant output --- .crumb | 14 ++++++------ CONTRIBUTORS.md | 1 + mk/.crumb | 8 +++---- mk/omega-gpu-engine.mk | 50 +++++++++++++++++++++++++++++++++++++----- 4 files changed, 57 insertions(+), 16 deletions(-) diff --git a/.crumb b/.crumb index 622707972..da615e3e2 100644 --- a/.crumb +++ b/.crumb @@ -59,7 +59,7 @@ "purpose": "Directory doctrine. Purpose not yet described by a human." }, { - "digest": "1d027cfb699f8ebe4ad85158dff7d7c3b1539b5eb2b53f39ec8fdd593017fb31", + "digest": "1b079afc06ebce6ba2768b2bdf05d372203cd47af8d73d0aac98de2c5ed53343", "last_commit": "e673cbb52", "name": "mk", "purpose": "Directory mk. Purpose not yet described by a human." @@ -96,7 +96,7 @@ }, { "digest": "58f22402d9b0849093ddae0c364872f3623adca238d3a07362b3b2367970de72", - "last_commit": "e673cbb52", + "last_commit": "96693b8ec", "name": "tests", "purpose": "Directory tests. Purpose not yet described by a human." }, @@ -107,15 +107,15 @@ "purpose": "Directory tools. Purpose not yet described by a human." } ], - "children_root": "sha256:aa8991b5ca6aab1084402a0675a7734db8ff47a5964a1957a806c83d450e8807", - "compiled_at": "2026-11-05T13:04:30Z", + "children_root": "sha256:8a49a3660bdacc2486d6e5a74a18ee1101da9799b0e19890b4e50174e3939612", + "compiled_at": "2026-11-05T13:40:33Z", "compiler": "crumb-compile/1", - "digest": "sha256:aac0e0cc7eb6abbd6887a3471e6f3d5db5a4c7aa49d2d72410f60a034ccfea14", + "digest": "sha256:fa617f79bf9b2b3d367223142805e3b7ed3566dced9055d5f84167bda35254ad", "evidence_files": 15321, "evidence_root": "sha256:e4e83d089b086dd1dcab0cfd4babe338eab359310746dbddc14edd655012c33f", "files": 23689, - "generated_at_commit": "e673cbb52742e8a54ca64653faa61fffbd324fd7", - "source_tree": "sha256:3994895183f3ad2ca608b43366d6212ef0f27a939d3a0c1332a3e0dc6755c859" + "generated_at_commit": "37fa50340345bbecd702e3ce49c95e9df24529d7", + "source_tree": "sha256:d8be759126a7c3eb31951ab0a11b33ff7d0ead6fbe264025d9eb8864f6fb4210" }, "owner_lane": "", "provenance": { diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 05fc8203a..733c9b883 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -110,4 +110,5 @@ Update this table in the same commit as the work it credits. | Claude Opus 5.5 | Merged main dc0d06e9 (#948 branch displacement, #967 IR cast) into the #875 OM-2 `dit` 225 / `scrub` 226 branch: reseeded omc to 38626559 at 512 functions, moved every active pin, regenerated the pinned units, and reran the #948 gate set plus the s5 dit/scrub gate (18 cases, 7 omc.om mutants detected) with a main-omc negative control and a four-mode sweep of every tracked .om. | | Claude Opus 5.5 | R15 energy preflight test: the fake package counter (and the falling cpu_p counter of decr3) now ticks every 10 ms until the case finishes instead of on a fixed 0.05/0.15 s schedule, so a preflight that starts late under load still sees it advance; delayed-start repro, 30/30 quiet and 30/30 under pinned busy loops | | Codex | Corrected Neuralese historical compiler attribution and separated active reproduction pins from dated run evidence. | +| Codex | Hardened the freestanding SHA-256 wrong-round-constant control to require a successful complete run before accepting a digest mismatch, with synthetic host-only refusal checks. | | Claude Opus 5.5 | Added `target x86efi` on current main: PE32+ output, UEFI entry/exit with callee-saved XMM and MXCSR, the target-scoped `efi` word with the general file operation `efi 12` and console `efi 13`, gate18 coverage of the scoped keyword, and `docs/X86-EFI.md`. Exercised under QEMU/OVMF only (float parity with x86linux and AArch64, efi 12 refusal codes, Read/Write-swap and MXCSR mutants); physical firmware NOT_RUN. | diff --git a/mk/.crumb b/mk/.crumb index 53de73d9a..dd832c543 100644 --- a/mk/.crumb +++ b/mk/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-11-05T13:02:29Z", + "compiled_at": "2026-11-05T13:40:33Z", "compiler": "crumb-compile/1", - "digest": "sha256:1d027cfb699f8ebe4ad85158dff7d7c3b1539b5eb2b53f39ec8fdd593017fb31", + "digest": "sha256:1b079afc06ebce6ba2768b2bdf05d372203cd47af8d73d0aac98de2c5ed53343", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 98, - "generated_at_commit": "c64349a46daf039a3c1a1205790325f31f840618", - "source_tree": "sha256:ffea04d1718cbfc2da75e9c63a02b68b755c643eb50ef81f7602ce0a567f644d" + "generated_at_commit": "37fa50340345bbecd702e3ce49c95e9df24529d7", + "source_tree": "sha256:b84f5c1d061fcea5c3145f13982774862d8d25c1664d4e374638bd3431c83918" }, "owner_lane": "", "provenance": { diff --git a/mk/omega-gpu-engine.mk b/mk/omega-gpu-engine.mk index f3251cae7..3c4373c57 100644 --- a/mk/omega-gpu-engine.mk +++ b/mk/omega-gpu-engine.mk @@ -180,16 +180,58 @@ build/test_codegen_freestanding: $(CODEGEN_FS_TEST_DEPS) $(GPU_FS_LINK) # split), and the FIPS digests must be the published ones. Controls: the hosted codegen test hashes through the # Omega binding (omega2_sha256_*), and a copy of the freestanding binding whose machine code loads round constant # K[0] as 0x428a2f99 (movz x1,#0x2f98 -> #0x2f99) must FAIL the comparison. -.PHONY: test-sha256-freestanding-parity +.PHONY: test-sha256-freestanding-parity test-sha256-freestanding-red-control SHA256_FS_PARITY_DEPS = tests/test_sha256_freestanding_parity.c src/sha256.h src/omega_api_decl.h src/omega_native.h SHA256_FS_RED = build/sha256_parity_red +# A killed digest mutant must finish normally and emit every expected case, in order. A crash, +# empty/partial output or malformed digest is a broken control, not evidence of a digest mismatch. +# Arguments: executable, mutant output, known-good output (already checked above). +define SHA256_FS_CHECK_RED +"$(1)" > "$(2)" || { echo "RED CHECK BROKEN: mutant did not complete"; exit 1; }; \ +awk 'NF != 3 || ($$1 != "fips" && $$1 != "len") || length($$3) != 64 || $$3 ~ /[^0-9a-f]/ { exit 1 }' "$(2)" \ + || { echo "RED CHECK BROKEN: malformed mutant output"; exit 1; }; \ +awk '{ print $$1, $$2 }' "$(2)" > "$(2).cases" && \ +awk '{ print $$1, $$2 }' "$(3)" > "$(2).expected-cases" && \ +cmp -s "$(2).cases" "$(2).expected-cases" \ + || { echo "RED CHECK BROKEN: mutant did not emit every expected case in order"; exit 1; }; \ +awk '{ print $$3 }' "$(2)" > "$(2).digests" && \ +awk '{ print $$3 }' "$(3)" > "$(2).expected-digests" \ + || { echo "RED CHECK BROKEN: could not read digests"; exit 1; }; \ +if cmp -s "$(2).digests" "$(2).expected-digests"; then echo "RED CHECK BROKEN: a wrong round constant passed"; exit 1; \ +else [ $$? = 1 ] || { echo "RED CHECK BROKEN: could not compare mutant output"; exit 1; }; \ +echo "red check: K[0] changed in the freestanding machine code FAILS the comparison after a complete run"; fi +endef + +# Host-only checks of the same control, with synthetic executables and output. No Omega code runs. +test-sha256-freestanding-red-control: + @set -eu; mkdir -p build; d=$$(mktemp -d build/sha256-red-control.XXXXXX); trap 'rm -rf "$$d"' EXIT; \ + printf 'fips 0 %064d\nlen 0 %064d\n' 0 0 > "$$d/reference"; \ + printf 'fips 0 %064d\nlen 0 %064d\n' 1 1 > "$$d/wrong"; \ + printf '%s\n' '#!/bin/sh' 'case "$$CASE" in' \ + 'failed-empty) exit 1 ;;' 'failed-full) cat "$$BAD"; exit 1 ;;' 'empty) exit 0 ;;' \ + 'partial) head -n 1 "$$BAD" ;;' 'malformed) printf "fips 0 bad\nlen 0 bad\n" ;;' \ + 'reordered) tail -n 1 "$$BAD"; head -n 1 "$$BAD" ;;' \ + 'extra) cat "$$BAD"; head -n 1 "$$BAD" ;;' \ + 'whitespace) sed "s/ / /g" "$$REF" ;;' 'no-newline) printf "%s" "$$(cat "$$REF")" ;;' \ + 'unchanged) cat "$$REF" ;;' 'wrong) cat "$$BAD" ;;' 'esac' > "$$d/runner"; \ + chmod +x "$$d/runner"; REF="$$d/reference"; BAD="$$d/wrong"; export REF BAD CASE; \ + for CASE in failed-empty failed-full empty partial malformed reordered extra unchanged whitespace no-newline; do \ + if ( $(call SHA256_FS_CHECK_RED,$$d/runner,$$d/red,$$d/reference) ) > "$$d/log" 2>&1; then \ + echo "FAIL SHA256 red control accepted $$CASE"; cat "$$d/log"; exit 1; \ + fi; \ + done; \ + CASE=wrong; ( $(call SHA256_FS_CHECK_RED,$$d/runner,$$d/red,$$d/reference) ) > "$$d/log" 2>&1 \ + || { echo "FAIL SHA256 red control rejected a complete digest mismatch"; cat "$$d/log"; exit 1; }; \ + echo "PASS SHA256 red control: 10 broken controls refused, complete digest mismatch accepted (synthetic host-only)" + build/test_sha256_parity_hosted: $(SHA256_FS_PARITY_DEPS) src/omega_om_units.c @mkdir -p build gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -Isrc -o $@ tests/test_sha256_freestanding_parity.c src/omega_om_units.c -pthread build/test_sha256_parity_freestanding: $(SHA256_FS_PARITY_DEPS) $(GPU_FS_DIR)/omega_om_units_fs.o @mkdir -p build gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -o $@ tests/test_sha256_freestanding_parity.c $(GPU_FS_DIR)/omega_om_units_fs.o -test-sha256-freestanding-parity: build/test_sha256_parity_hosted build/test_sha256_parity_freestanding build/test_codegen_hosted +test-sha256-freestanding-parity: build/test_sha256_parity_hosted build/test_sha256_parity_freestanding build/test_codegen_hosted \ + test-sha256-freestanding-red-control ./build/test_sha256_parity_hosted > build/sha256_parity_hosted.txt ./build/test_sha256_parity_freestanding > build/sha256_parity_freestanding.txt cmp build/sha256_parity_hosted.txt build/sha256_parity_freestanding.txt @@ -210,9 +252,7 @@ test-sha256-freestanding-parity: build/test_sha256_parity_hosted build/test_sha2 gcc $(GPU_FS_CFLAGS) -c -o $(SHA256_FS_RED)/red.o $(SHA256_FS_RED)/red.c gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -o $(SHA256_FS_RED)/parity_red tests/test_sha256_freestanding_parity.c \ $(SHA256_FS_RED)/red.o - @./$(SHA256_FS_RED)/parity_red > $(SHA256_FS_RED)/red.txt || true; \ - if cmp -s $(SHA256_FS_RED)/red.txt build/sha256_parity_hosted.txt; then echo "RED CHECK BROKEN: a wrong round constant passed"; exit 1; \ - else echo "red check: K[0] changed in the freestanding machine code FAILS the comparison ($$(cmp $(SHA256_FS_RED)/red.txt build/sha256_parity_hosted.txt | head -1))"; fi + @$(call SHA256_FS_CHECK_RED,$(SHA256_FS_RED)/parity_red,$(SHA256_FS_RED)/red.txt,build/sha256_parity_hosted.txt) test-codegen-freestanding: build/test_codegen_hosted build/test_codegen_freestanding test-gpu-fs-allowlist-control \ test-sha256-freestanding-parity ./build/test_codegen_hosted --dump > build/codegen_dump_hosted.txt