Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/patches/f684890bc6e4e761 # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers ## GitHub aien-dev/omega-mv#179 (code only) closed derived `f684890bc6e4e761` #179 Imported from GitHub aien-dev/omega-mv#179 (code only) GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed). Base `38919c8d87e02ac6fceeb9984ea3e99783d718ff` · Head `a0ec4979f4d25ee6f3e7d8590b81173fa77ff19b` ### Apply it ``` git checkout -b patch-f684890bc6e4e761 38919c8d87e02ac6fceeb9984ea3e99783d718ff curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/f684890bc6e4e761.patch | git am ``` Raw patch (mbox) · Diff ### Provenance This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record: ``` github-import 1 aien-dev/omega-mv 179 a0ec4979f4d25ee6f3e7d8590b81173fa77ff19b ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":179,"url":"https://github.com/aien-dev/omega-mv/pull/179","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:39Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/.github/workflows/host-suites-2.yml b/.github/workflows/host-suites-2.yml index f1bc55e51..dd97a8152 100644 --- a/.github/workflows/host-suites-2.yml +++ b/.github/workflows/host-suites-2.yml @@ -28,7 +28,7 @@ name: Host suites 2 # argus : test-argus-runtime test-machine-identity-argus # numeric2 : test-numeric-reduce-cpu test-divsqrt-host 6 s # tensor : test-tensor (M20 CPU tier, plain + ASan/UBSan + default-build -# no-test-hook nm check) test-tensor-mutations +# no-test-hook nm check) test-m20-receipt test-tensor-mutations # Pinned dependencies are read from physics.lock, aienos.lock and argus.lock. # # Deliberately NOT here: @@ -146,7 +146,7 @@ jobs: sel runtime "$core|^src/(runtime|fabric)/|^tests/runtime/|^mk/fabric\.mk$|^tests/(r15_receipt_test\.sh|r16_[a-z_]+/)|^tools/(r15_|r16_|omegatool\.c)|^spec/r16-|^docs/r16-|^evidence/R15/|^(physics|aienos)\.lock$" sel argus "^src/runtime/|^tests/runtime/|^tests/bench_rx_argus\.c$|^mk/machine-identity\.mk$|^src/(sha256|omega_evidence)\.|^(physics|aienos|argus)\.lock$" sel numeric2 "^tests/(test_omega_reduce|test_omega_divsqrt_gb10)\.c$|^tests/numeric_oracle\.h$|^src/(omega_numeric|omega_blackwell_(encoder|codegen|matmul|qmd)|sha256)" - sel tensor "^src/tensor/|^tests/test_omega_tensor\.c$|^tools/tensor_mutations\.sh$|^mk/tensor\.mk$|^src/(omega_numeric|omega_blackwell_(encoder|codegen|matmul|qmd)|sha256)" + sel tensor "^tools/m20_receipt(_mutations)?\.sh$|^tests/test_m20_receipt\.sh$|^tests/fixtures/m20_receipt/|^src/tensor/|^tests/test_omega_tensor\.c$|^tools/tensor_mutations\.sh$|^mk/tensor\.mk$|^src/(omega_numeric|omega_blackwell_(encoder|codegen|matmul|qmd)|sha256)" visor: needs: changes @@ -405,5 +405,7 @@ jobs: fetch-depth: 0 - name: M20 OMEGA_TENSOR CPU tier (plain + ASan/UBSan, test hook absent from default build; CPU only) run: make PHYSICS_DIR=/nonexistent PHYSICS_LOCK_CHECK=0 test-tensor + - name: M20 receipt writer tests (fixtures only; shell + git + jq, no device) + run: make PHYSICS_DIR=/nonexistent PHYSICS_LOCK_CHECK=0 test-m20-receipt - name: M20 OMEGA_TENSOR mutation sweep (each rule must turn the tests red) run: make PHYSICS_DIR=/nonexistent PHYSICS_LOCK_CHECK=0 test-tensor-mutations diff --git a/docs/tensor/M20_OMEGA_TENSOR.md b/docs/tensor/M20_OMEGA_TENSOR.md index 9e32f298b..439eb337b 100644 --- a/docs/tensor/M20_OMEGA_TENSOR.md +++ b/docs/tensor/M20_OMEGA_TENSOR.md @@ -111,11 +111,11 @@ removed. Order and padding mutations are caught by the E1 WP-D suite. | GB10 parity | NOT_RUN | no GB10 realization table yet; no chip run in this work | | GB10 general matmul (Tensor Core beyond narrow K/tile) | MISSING_IMPLEMENTATION | | | Crash-safe storage lifetime | MISSING_IMPLEMENTATION | storage is in-process memory only; no persistence or crash recovery | -| Reproducible receipt | MISSING_IMPLEMENTATION | no content-addressed receipt writer for this gate yet | +| Reproducible receipt | PASS (CPU) | writer implemented and host-tested: `tools/m20_receipt.sh` writes `/.json` (0444, exclusive, never overwritten), QUALIFIED only with GB10 parity GB10 PASS + matching chip evidence; `test-m20-receipt` + 11 receipt mutants in `test-tensor-mutations`, forge log HIVE-M20-receipt-175835. No real M20 receipt has been written yet because the GB10 parity evidence does not exist. | | E1 numeric closure | PASS (on main) | E1 PASSED on main 4863803; receipt merged in omega#177 | **M20 verdict: not qualified.** GB10 parity NOT_RUN; crash-safe storage -lifetime and receipt MISSING_IMPLEMENTATION. +lifetime MISSING_IMPLEMENTATION; receipt writer host PASS, no M20 receipt written yet. ## Open seams diff --git a/mk/tensor.mk b/mk/tensor.mk index 8af258b76..962c12035 100644 --- a/mk/tensor.mk +++ b/mk/tensor.mk @@ -12,6 +12,8 @@ # OMEGA_TENSOR_TEST_HOOKS. # test-tensor-mutations applies each MUT: source mutation in a scratch copy # and proves test-tensor's binary then fails +# test-m20-receipt tests/test_m20_receipt.sh: content-addressed M20 +# receipt writer tools/m20_receipt.sh (fixtures only) # test-tensor-e1-reduce alias of test-tensor (the reduction seam always # calls omega_reduce_cpu, E1 WP-D, omega #134) ifndef TENSOR_MK @@ -61,4 +63,8 @@ test-tensor-mutations: # Kept as an alias: the seam now always calls omega_reduce_cpu (E1 WP-D, #134 merged). test-tensor-e1-reduce: test-tensor + +.PHONY: test-m20-receipt +test-m20-receipt: + tests/test_m20_receipt.sh endif diff --git a/tests/fixtures/m20_receipt/binary_stub.txt b/tests/fixtures/m20_receipt/binary_stub.txt new file mode 100644 index 000000000..e9fa4a4f2 --- /dev/null +++ b/tests/fixtures/m20_receipt/binary_stub.txt @@ -0,0 +1 @@ +fixture stand-in for a test binary (hashed and stored as a .bin blob) diff --git a/tests/fixtures/m20_receipt/chip_evidence.json b/tests/fixtures/m20_receipt/chip_evidence.json new file mode 100644 index 000000000..b393dca08 --- /dev/null +++ b/tests/fixtures/m20_receipt/chip_evidence.json @@ -0,0 +1 @@ +{"fixture":"tests/fixtures/m20_receipt chip evidence stand-in, not a chip run","gate":"M20_OMEGA_TENSOR_GB10","verdict":"PASS"} diff --git a/tests/fixtures/m20_receipt/chip_evidence_other.json b/tests/fixtures/m20_receipt/chip_evidence_other.json new file mode 100644 index 000000000..347b82bd8 --- /dev/null +++ b/tests/fixtures/m20_receipt/chip_evidence_other.json @@ -0,0 +1 @@ +{"fixture":"tests/fixtures/m20_receipt chip evidence stand-in with a different hash","gate":"M20_OMEGA_TENSOR_GB10","verdict":"PASS"} diff --git a/tests/fixtures/m20_receipt/mutations_pass.log b/tests/fixtures/m20_receipt/mutations_pass.log new file mode 100644 index 000000000..430eee6eb --- /dev/null +++ b/tests/fixtures/m20_receipt/mutations_pass.log @@ -0,0 +1,4 @@ +# fixture: shape of `make test-tensor-mutations` output, not a real run +MUTATION RELEASE_BUMP: caught (4 failing checks) +MUTATION STORAGE_GEN_CHECK: caught (9 failing checks) +tensor mutation sweep: PASS (5 of 5 mutations caught) diff --git a/tests/fixtures/m20_receipt/table_all_pass.md b/tests/fixtures/m20_receipt/table_all_pass.md new file mode 100644 index 000000000..f4bf26b82 --- /dev/null +++ b/tests/fixtures/m20_receipt/table_all_pass.md @@ -0,0 +1,17 @@ +# M20 fixture table (all_pass) + +## Qualification checklist (plan E2) + +| Item | Status | Evidence | +|---|---|---| +| Shape / type checks | PASS (CPU) | `test-tensor` | +| CPU parity | PASS (CPU) | `test-tensor` | +| Mutation / refusal | PASS (CPU) | `test-tensor-mutations` | +| CI | WIRED | hosted runner, not a qualification | +| E1 numeric closure | PASS (on main) | E1 receipt | + +**M20 verdict: fixture.** + +## Open seams + +| Not | NOT_RUN | rows after the verdict are ignored | diff --git a/tests/fixtures/m20_receipt/table_gb10.md b/tests/fixtures/m20_receipt/table_gb10.md new file mode 100644 index 000000000..0978fe434 --- /dev/null +++ b/tests/fixtures/m20_receipt/table_gb10.md @@ -0,0 +1,18 @@ +# M20 fixture table (gb10) + +## Qualification checklist (plan E2) + +| Item | Status | Evidence | +|---|---|---| +| Shape / type checks | PASS (CPU) | `test-tensor` | +| CPU parity | PASS (CPU) | `test-tensor` | +| Mutation / refusal | PASS (CPU) | `test-tensor-mutations` | +| CI | WIRED | hosted runner, not a qualification | +| E1 numeric closure | PASS (on main) | E1 receipt | +| GB10 parity | PASS (GB10) | chip evidence sha256 70a987ec6835d37836d0cc415e8b609df6edda6cd560a0b86e238b24cf4bd6d8 | + +**M20 verdict: fixture.** + +## Open seams + +| Not | NOT_RUN | rows after the verdict are ignored | diff --git a/tests/fixtures/m20_receipt/table_gb10_nohash.md b/tests/fixtures/m20_receipt/table_gb10_nohash.md new file mode 100644 index 000000000..e6188b8e5 --- /dev/null +++ b/tests/fixtures/m20_receipt/table_gb10_nohash.md @@ -0,0 +1,18 @@ +# M20 fixture table (gb10_nohash) + +## Qualification checklist (plan E2) + +| Item | Status | Evidence | +|---|---|---| +| Shape / type checks | PASS (CPU) | `test-tensor` | +| CPU parity | PASS (CPU) | `test-tensor` | +| Mutation / refusal | PASS (CPU) | `test-tensor-mutations` | +| CI | WIRED | hosted runner, not a qualification | +| E1 numeric closure | PASS (on main) | E1 receipt | +| GB10 parity | PASS (GB10) | chip evidence not named | + +**M20 verdict: fixture.** + +## Open seams + +| Not | NOT_RUN | rows after the verdict are ignored | diff --git a/tests/fixtures/m20_receipt/table_missing.md b/tests/fixtures/m20_receipt/table_missing.md new file mode 100644 index 000000000..969df3536 --- /dev/null +++ b/tests/fixtures/m20_receipt/table_missing.md @@ -0,0 +1,19 @@ +# M20 fixture table (missing: GB10 parity PASS + one MISSING_IMPLEMENTATION row) + +## Qualification checklist (plan E2) + +| Item | Status | Evidence | +|---|---|---| +| Shape / type checks | PASS (CPU) | `test-tensor` | +| CPU parity | PASS (CPU) | `test-tensor` | +| Mutation / refusal | PASS (CPU) | `test-tensor-mutations` | +| CI | WIRED | hosted runner, not a qualification | +| E1 numeric closure | PASS (on main) | E1 receipt | +| GB10 parity | PASS (GB10) | chip evidence sha256 70a987ec6835d37836d0cc415e8b609df6edda6cd560a0b86e238b24cf4bd6d8 | +| Crash-safe storage lifetime | MISSING_IMPLEMENTATION | | + +**M20 verdict: fixture.** + +## Open seams + +| Not | NOT_RUN | rows after the verdict are ignored | diff --git a/tests/fixtures/m20_receipt/table_not_run.md b/tests/fixtures/m20_receipt/table_not_run.md new file mode 100644 index 000000000..5903165bd --- /dev/null +++ b/tests/fixtures/m20_receipt/table_not_run.md @@ -0,0 +1,19 @@ +# M20 fixture table (not_run: GB10 parity PASS + one NOT_RUN row) + +## Qualification checklist (plan E2) + +| Item | Status | Evidence | +|---|---|---| +| Shape / type checks | PASS (CPU) | `test-tensor` | +| CPU parity | PASS (CPU) | `test-tensor` | +| Mutation / refusal | PASS (CPU) | `test-tensor-mutations` | +| CI | WIRED | hosted runner, not a qualification | +| E1 numeric closure | PASS (on main) | E1 receipt | +| GB10 parity | PASS (GB10) | chip evidence sha256 70a987ec6835d37836d0cc415e8b609df6edda6cd560a0b86e238b24cf4bd6d8 | +| Reproducible receipt | NOT_RUN | awaiting forge | + +**M20 verdict: fixture.** + +## Open seams + +| Not | NOT_RUN | rows after the verdict are ignored | diff --git a/tests/fixtures/m20_receipt/table_reference_only.md b/tests/fixtures/m20_receipt/table_reference_only.md new file mode 100644 index 000000000..ca47e9e82 --- /dev/null +++ b/tests/fixtures/m20_receipt/table_reference_only.md @@ -0,0 +1,14 @@ +# M20 fixture table (reference_only) + +## Qualification checklist (plan E2) + +| Item | Status | Evidence | +|---|---|---| +| CI | WIRED | hosted runner | +| E1 numeric closure | PASS (on main) | E1 receipt | + +**M20 verdict: fixture.** + +## Open seams + +| Not | NOT_RUN | rows after the verdict are ignored | diff --git a/tests/fixtures/m20_receipt/table_unknown.md b/tests/fixtures/m20_receipt/table_unknown.md new file mode 100644 index 000000000..c6e96192f --- /dev/null +++ b/tests/fixtures/m20_receipt/table_unknown.md @@ -0,0 +1,18 @@ +# M20 fixture table (unknown) + +## Qualification checklist (plan E2) + +| Item | Status | Evidence | +|---|---|---| +| Shape / type checks | PASS (CPU) | `test-tensor` | +| CPU parity | PASS (CPU) | `test-tensor` | +| Mutation / refusal | PASS (CPU) | `test-tensor-mutations` | +| CI | WIRED | hosted runner, not a qualification | +| E1 numeric closure | PASS (on main) | E1 receipt | +| GB10 parity | PASS-ish | not a label | + +**M20 verdict: fixture.** + +## Open seams + +| Not | NOT_RUN | rows after the verdict are ignored | diff --git a/tests/fixtures/m20_receipt/tensor_fail.log b/tests/fixtures/m20_receipt/tensor_fail.log new file mode 100644 index 000000000..c2955095e --- /dev/null +++ b/tests/fixtures/m20_receipt/tensor_fail.log @@ -0,0 +1,10 @@ +# fixture: shape of `make test-tensor` output, not a real run +./build/test_omega_tensor +reduce seam: omega_reduce_cpu (E1 WP-D) +M20 OMEGA_TENSOR CPU tests: 409 pass, 3 fail +M20 verdict: NOT QUALIFIED (CPU tier only; GB10 parity NOT_RUN) +./build/test_omega_tensor_asan +reduce seam: omega_reduce_cpu (E1 WP-D) +M20 OMEGA_TENSOR CPU tests: 412 pass, 0 fail +M20 verdict: NOT QUALIFIED (CPU tier only; GB10 parity NOT_RUN) +test-tensor-no-hooks: PASS (test-only hook absent from default build) diff --git a/tests/fixtures/m20_receipt/tensor_pass.log b/tests/fixtures/m20_receipt/tensor_pass.log new file mode 100644 index 000000000..ecd83dc8d --- /dev/null +++ b/tests/fixtures/m20_receipt/tensor_pass.log @@ -0,0 +1,10 @@ +# fixture: shape of `make test-tensor` output, not a real run +./build/test_omega_tensor +reduce seam: omega_reduce_cpu (E1 WP-D) +M20 OMEGA_TENSOR CPU tests: 412 pass, 0 fail +M20 verdict: NOT QUALIFIED (CPU tier only; GB10 parity NOT_RUN) +./build/test_omega_tensor_asan +reduce seam: omega_reduce_cpu (E1 WP-D) +M20 OMEGA_TENSOR CPU tests: 412 pass, 0 fail +M20 verdict: NOT QUALIFIED (CPU tier only; GB10 parity NOT_RUN) +test-tensor-no-hooks: PASS (test-only hook absent from default build) diff --git a/tests/test_m20_receipt.sh b/tests/test_m20_receipt.sh new file mode 100755 index 000000000..d672f3ec0 --- /dev/null +++ b/tests/test_m20_receipt.sh @@ -0,0 +1,112 @@ +#!/bin/bash +# tests/test_m20_receipt.sh -- tests for tools/m20_receipt.sh (M20 receipt writer). +# Fixture logs and tables under tests/fixtures/m20_receipt/. Each scenario +# commits a fixture table as docs/tensor/M20_OMEGA_TENSOR.md in a throwaway git +# repo under a temp dir and writes evidence outside it. Covers reproducibility +# (two runs, same hash, byte-identical), every refusal path and every +# NOT QUALIFIED rule. M20_RECEIPT_WRITER selects the writer (used by +# tools/m20_receipt_mutations.sh to run mutants). Host only, no device. +# Shell + coreutils + git + jq. No Python. Exit 0 only if every check passes. +set -u +cd "$(dirname "$0")/.." || exit 2 +ROOT=$(pwd) +W=${M20_RECEIPT_WRITER:-$ROOT/tools/m20_receipt.sh} +FX=$ROOT/tests/fixtures/m20_receipt +T=$(mktemp -d "${TMPDIR:-/tmp}/m20-receipt-test.XXXXXX") || exit 2 +trap 'chmod -R u+w "$T" 2> /dev/null; rm -rf "$T"' EXIT INT TERM +G="git -c user.name=m20-test -c user.email=m20-test@invalid -c commit.gpgsign=false -c init.defaultBranch=main" +PASSLOG=$FX/tensor_pass.log; FAILLOG=$FX/tensor_fail.log; MUTLOG=$FX/mutations_pass.log +fail=0; total=0 +check() { # NAME CONDITION-EXIT-STATUS + total=$((total + 1)) + if [ "$2" = 0 ]; then echo "PASS $1"; else echo "FAIL $1"; fail=1; fi +} +mkrepo() { # NAME TABLE (fixture tests/fixtures/m20_receipt/table_) -> prints the repo path + local r=$T/repo-$1 + mkdir -p "$r/docs/tensor" && cp "$FX/table_$2" "$r/docs/tensor/M20_OMEGA_TENSOR.md" \ + && $G -C "$r" init -q && $G -C "$r" add -A && $G -C "$r" commit -qm fixture \ + || { echo "FATAL: cannot create fixture repo $1"; exit 2; } + echo "$r" +} +# run NAME REPO EVID TENSOR-LOG [writer args...] -> sets RC, OUT, REC +run() { + local name=$1 repo=$2 evid=$3 tlog=$4; shift 4 + OUT=$T/$name.out + "$W" --repo "$repo" --evidence-dir "$evid" --tensor-log "$tlog" --mutations-log "$MUTLOG" "$@" > "$OUT" 2>&1 + RC=$? + REC=$(sed -n 's/^receipt: \([^ ]*\) .*/\1/p' "$OUT") +} +nojson() { ! ls "$1"/*.json > /dev/null 2>&1; } +jqok() { jq -e "$2" "$1" > /dev/null 2>&1; } +sha() { sha256sum "$1" | cut -d' ' -f1; } + +# 1. All rows host PASS (+ REFERENCE rows), no GB10 parity row: host-only +# evidence never qualifies -> NOT QUALIFIED; sealed, content-addressed. +R=$(mkrepo all all_pass.md) +run all1 "$R" "$T/ev-a" "$PASSLOG" --binary "$FX/binary_stub.txt"; A=$REC +[ "$RC" = 1 ]; check "all host PASS: exit 1 (NOT QUALIFIED)" $? +[ -n "$A" ] && jqok "$A" '.verdict == "NOT QUALIFIED" and .hardware == "host" and .gate == "M20_OMEGA_TENSOR" and (.verdict_reasons | any(test("GB10 parity")))'; check "all host PASS: NOT QUALIFIED, hardware host, GB10 parity reason" $? +[ -n "$A" ] && [ "$(basename "$A" .json)" = "$(sha "$A")" ]; check "receipt name is its sha256" $? +[ -n "$A" ] && [ "$(stat -c %a "$A")" = 444 ]; check "receipt mode 0444" $? +[ -f "$T/ev-a/blobs/$(sha "$PASSLOG").log" ] && [ -f "$T/ev-a/blobs/$(sha "$MUTLOG").log" ] \ + && [ -f "$T/ev-a/blobs/$(sha "$FX/binary_stub.txt").bin" ]; check "log and binary blobs stored by digest" $? +[ -n "$A" ] && jqok "$A" "(.logs.test_tensor_sha256 == \"$(sha "$PASSLOG")\") and (.binaries[0].sha256 == \"$(sha "$FX/binary_stub.txt")\") and (.omega_commit == \"$($G -C "$R" rev-parse HEAD)\") and .omega_tree_clean_after and .omega_commit_unchanged_after and ([.rows[] | select(.label == \"host PASS\")] | length) == 3 and ([.rows[] | select(.label == \"REFERENCE\")] | length) == 2 and (has(\"started_utc\") | not)" +check "receipt fields: log/binary/commit hashes, clean after, row labels, no clock" $? + +# 2. Reproducibility: same inputs, second evidence dir -> same hash, same bytes. +run all2 "$R" "$T/ev-b" "$PASSLOG" --binary "$FX/binary_stub.txt"; B=$REC +[ "$RC" = 1 ] && [ -n "$A" ] && [ "$(basename "$A")" = "$(basename "$B")" ] && cmp -s "$A" "$B"; check "reproducible: two runs give the same hash and bytes" $? +run ts1 "$R" "$T/ev-ts1" "$PASSLOG" --started-utc 2026-10-01T00:00:00Z --finished-utc 2026-10-01T00:01:00Z; T1=$REC +run ts2 "$R" "$T/ev-ts2" "$PASSLOG" --started-utc 2026-10-01T00:00:00Z --finished-utc 2026-10-01T00:01:00Z; T2=$REC +run ts3 "$R" "$T/ev-ts3" "$PASSLOG" --started-utc 2026-10-01T00:00:01Z --finished-utc 2026-10-01T00:01:00Z; T3=$REC +[ -n "$T1" ] && [ "$(basename "$T1")" = "$(basename "$T2")" ] && [ "$(basename "$T1")" != "$(basename "$T3")" ] \ + && jqok "$T1" '.started_utc == "2026-10-01T00:00:00Z"'; check "timestamps only when passed in, and they are hashed" $? + +# 3. Never overwritten: rerun into the same dir, and a squatter with the same name. +run again "$R" "$T/ev-a" "$PASSLOG" --binary "$FX/binary_stub.txt" +[ "$RC" = 2 ] && grep -q 'already exists' "$OUT"; check "rerun into same evidence dir refused" $? +mkdir -p "$T/ev-sq" && [ -n "$A" ] && echo squatter > "$T/ev-sq/$(basename "$A")" && chmod 0644 "$T/ev-sq/$(basename "$A")" +run squat "$R" "$T/ev-sq" "$PASSLOG" --binary "$FX/binary_stub.txt" +[ "$RC" = 2 ] && [ "$(cat "$T/ev-sq/$(basename "$A")" 2> /dev/null)" = squatter ]; check "existing writable receipt name not overwritten" $? + +# 4. NOT_RUN / MISSING_IMPLEMENTATION (GB10 parity PASS, so only that rule +# can fail them) / nothing counted -> NOT QUALIFIED (receipt written). +R=$(mkrepo notrun not_run.md); run notrun "$R" "$T/ev-nr" "$PASSLOG" --chip-evidence "$FX/chip_evidence.json" +[ "$RC" = 1 ] && [ -n "$REC" ] && jqok "$REC" '.verdict == "NOT QUALIFIED" and (.verdict_reasons | any(test("NOT_RUN")))'; check "NOT_RUN row forces NOT QUALIFIED" $? +R=$(mkrepo missing missing.md); run missing "$R" "$T/ev-mi" "$PASSLOG" --chip-evidence "$FX/chip_evidence.json" +[ "$RC" = 1 ] && [ -n "$REC" ] && jqok "$REC" '.verdict == "NOT QUALIFIED" and (.verdict_reasons | any(test("MISSING_IMPLEMENTATION")))'; check "MISSING_IMPLEMENTATION row forces NOT QUALIFIED" $? +R=$(mkrepo refonly reference_only.md); run refonly "$R" "$T/ev-ro" "$PASSLOG" +[ "$RC" = 1 ] && [ -n "$REC" ] && jqok "$REC" '.verdict == "NOT QUALIFIED"'; check "only REFERENCE rows -> NOT QUALIFIED" $? + +# 5. Refusals: exit 2 and no receipt. +R=$(mkrepo dirty all_pass.md); echo stray > "$R/stray.txt"; run dirty "$R" "$T/ev-di" "$PASSLOG" +[ "$RC" = 2 ] && nojson "$T/ev-di"; check "dirty tree refused" $? +R=$(mkrepo inside all_pass.md); echo "evidence/" > "$R/.git/info/exclude"; run inside "$R" "$R/evidence" "$PASSLOG" +[ "$RC" = 2 ] && nojson "$R/evidence"; check "evidence dir inside the tree refused" $? +R=$(mkrepo unknown unknown.md); run unknown "$R" "$T/ev-un" "$PASSLOG" +[ "$RC" = 2 ] && nojson "$T/ev-un"; check "unknown row label refused" $? +R=$(mkrepo hostfail all_pass.md); run hostfail "$R" "$T/ev-hf" "$FAILLOG" +[ "$RC" = 2 ] && nojson "$T/ev-hf"; check "host PASS rows with a failing host log refused" $? + +# 6. GB10 PASS rows: need the chip evidence file and its hash in the row. +R=$(mkrepo gb10 gb10.md) +run gb10ok "$R" "$T/ev-g1" "$PASSLOG" --chip-evidence "$FX/chip_evidence.json" +[ "$RC" = 0 ] && [ -n "$REC" ] && jqok "$REC" ".verdict == \"QUALIFIED\" and .hardware == \"GB10\" and .chip_evidence_sha256 == \"$(sha "$FX/chip_evidence.json")\"" \ + && [ -f "$T/ev-g1/blobs/$(sha "$FX/chip_evidence.json").json" ]; check "GB10 PASS with matching chip evidence -> QUALIFIED, hardware GB10" $? +run gb10none "$R" "$T/ev-g2" "$PASSLOG" +[ "$RC" = 2 ] && nojson "$T/ev-g2"; check "GB10 PASS without chip evidence refused" $? +run gb10other "$R" "$T/ev-g3" "$PASSLOG" --chip-evidence "$FX/chip_evidence_other.json" +[ "$RC" = 2 ] && nojson "$T/ev-g3"; check "GB10 PASS with non-matching chip evidence refused" $? +R=$(mkrepo gb10nh gb10_nohash.md); run gb10nh "$R" "$T/ev-g4" "$PASSLOG" +[ "$RC" = 2 ] && nojson "$T/ev-g4"; check "GB10 PASS row naming no evidence, no chip file, refused" $? + +# 7. Tree changes during the run (test-only hook) -> NOT QUALIFIED with the reason. +R=$(mkrepo middirty all_pass.md) +M20_RECEIPT_TEST_MIDRUN="echo x > '$R/late.txt'" run middirty "$R" "$T/ev-md" "$PASSLOG" +[ "$RC" = 1 ] && [ -n "$REC" ] && jqok "$REC" '(.omega_tree_clean_after | not) and (.verdict_reasons | any(test("dirty after")))'; check "tree dirtied mid-run -> NOT QUALIFIED" $? +R=$(mkrepo midcommit all_pass.md) +M20_RECEIPT_TEST_MIDRUN="$G -C '$R' commit -q --allow-empty -m moved" run midcommit "$R" "$T/ev-mc" "$PASSLOG" +[ "$RC" = 1 ] && [ -n "$REC" ] && jqok "$REC" '(.omega_commit_unchanged_after | not) and (.verdict_reasons | any(test("HEAD moved")))'; check "HEAD moved mid-run -> NOT QUALIFIED" $? + +if [ "$fail" -ne 0 ]; then echo "test-m20-receipt: FAIL"; exit 1; fi +echo "test-m20-receipt: PASS ($total of $total checks)" diff --git a/tools/m20_receipt.sh b/tools/m20_receipt.sh new file mode 100755 index 000000000..05c6f36de --- /dev/null +++ b/tools/m20_receipt.sh @@ -0,0 +1,203 @@ +#!/bin/bash +# tools/m20_receipt.sh -- reproducible, content-addressed M20 OMEGA_TENSOR receipt. +# +# tools/m20_receipt.sh --tensor-log FILE --mutations-log FILE +# [--evidence-dir DIR] [--repo DIR] [--chip-evidence FILE] +# [--binary FILE]... [--started-utc T] [--finished-utc T] +# +# Inputs: the host gate logs of `make test-tensor` and `make +# test-tensor-mutations`, optionally the GB10 chip evidence JSON written by +# tests/run_tensor_chip.sh (only its path and bytes are used, never its code), +# optional binaries to hash. Row labels come from the qualification table in +# the committed docs/tensor/M20_OMEGA_TENSOR.md of the omega tree (--repo, +# default: the tree holding this script). +# +# Table labels: "PASS (CPU)" or "host PASS" -> host PASS; "PASS (GB10)" or +# "GB10 PASS" -> GB10 PASS; NOT_RUN; MISSING_IMPLEMENTATION; "WIRED" and +# "PASS (on main)" -> REFERENCE (recorded, never counted). Anything else is +# refused. +# +# Rules (each line carries a MUT: marker; tools/m20_receipt_mutations.sh +# breaks each one and requires tests/test_m20_receipt.sh to fail): +# refused (exit 2, no receipt): dirty tree before; evidence dir inside the +# tree; unknown label; host PASS rows while the host logs do not show PASS; +# a GB10 PASS row without --chip-evidence, or whose evidence cell does not +# name the sha256 of that file (first 64-hex string in the cell); an existing receipt with the same digest. +# NOT QUALIFIED (exit 1, receipt written): any NOT_RUN or +# MISSING_IMPLEMENTATION row; "GB10 parity" row not GB10 PASS; tree dirty or +# HEAD moved after the inputs were stored; the test-only mid-run hook set. +# QUALIFIED (exit 0) otherwise. +# Output: /.json (mode 0444, created exclusively, never +# overwritten) and blobs/.{log,json,bin}. Body is jq -S (sorted keys); +# no clock is read, timestamps appear only when passed in, so the same inputs +# give byte-identical JSON. +# Shell + coreutils + git + jq. No Python. +set -u +SELF_DIR=$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd) +REPO=$SELF_DIR/.. +EVID=$HOME/workspace/evidence-out/M20-OMEGA-TENSOR +TLOG=""; MLOG=""; CHIP=""; STARTED=""; FINISHED="" +BINS=() +TABLE_REL=docs/tensor/M20_OMEGA_TENSOR.md + +refuse() { echo "m20_receipt: REFUSED: $*" >&2; exit 2; } +need() { [ -n "${2:-}" ] || refuse "$1 needs a value"; } +while [ $# -gt 0 ]; do + case $1 in + --repo) need "$1" "${2:-}"; REPO=$2; shift 2 ;; + --evidence-dir) need "$1" "${2:-}"; EVID=$2; shift 2 ;; + --tensor-log) need "$1" "${2:-}"; TLOG=$2; shift 2 ;; + --mutations-log) need "$1" "${2:-}"; MLOG=$2; shift 2 ;; + --chip-evidence) need "$1" "${2:-}"; CHIP=$2; shift 2 ;; + --binary) need "$1" "${2:-}"; BINS+=("$2"); shift 2 ;; + --started-utc) need "$1" "${2:-}"; STARTED=$2; shift 2 ;; + --finished-utc) need "$1" "${2:-}"; FINISHED=$2; shift 2 ;; + -h|--help) sed -n '2,34p' "$0"; exit 0 ;; + *) refuse "unknown argument $1" ;; + esac +done +command -v jq > /dev/null || refuse "jq not found" +[ -f "$TLOG" ] || refuse "--tensor-log file missing" +[ -f "$MLOG" ] || refuse "--mutations-log file missing" +[ -z "$CHIP" ] || [ -f "$CHIP" ] || refuse "--chip-evidence file $CHIP missing" +for b in ${BINS[@]+"${BINS[@]}"}; do [ -f "$b" ] || refuse "--binary file $b missing"; done + +TOP=$(git -C "$REPO" rev-parse --show-toplevel 2> /dev/null) || refuse "$REPO is not a git tree" +TOP=$(cd -P "$TOP" && pwd) +COMMIT=$(git -C "$TOP" rev-parse HEAD) || refuse "cannot read HEAD" +[ -z "$(git -C "$TOP" status --porcelain)" ] || refuse "omega tree dirty before receipt" # MUT:DIRTY_REFUSED +EVID_ABS=$(realpath -m "$EVID") || refuse "cannot resolve evidence dir" +case "$EVID_ABS/" in "$TOP/"*) refuse "evidence dir $EVID_ABS lies inside the omega tree" ;; esac # MUT:EVID_OUTSIDE +TABLE=$TOP/$TABLE_REL +[ -f "$TABLE" ] || refuse "qualification table $TABLE_REL missing" + +WORK=$(mktemp -d "${TMPDIR:-/tmp}/m20-receipt.XXXXXX") || refuse "cannot create work dir" +trap 'rm -rf "$WORK"' EXIT +ROWS=$WORK/rows.tsv; REASONS=$WORK/reasons.txt; BINTSV=$WORK/bins.tsv +: > "$ROWS"; : > "$REASONS"; : > "$BINTSV" +NQ=0 +add_nq() { NQ=1; printf '%s\n' "$1" >> "$REASONS"; } +trim() { printf '%s' "$1" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//'; } +sha() { sha256sum "$1" | cut -d' ' -f1; } + +# Host logs PASS: both test binaries (plain + ASan/UBSan) report N pass, 0 fail, +# the no-hooks check passed, and the mutation sweep passed with nothing missed. +host_logs_pass() { + local n + n=$(grep -cE '^M20 OMEGA_TENSOR CPU tests: [1-9][0-9]* pass, 0 fail$' "$TLOG") + [ "$n" -ge 2 ] || return 1 + ! grep -qE '^M20 OMEGA_TENSOR CPU tests: [0-9]+ pass, [1-9][0-9]* fail' "$TLOG" || return 1 + grep -q '^test-tensor-no-hooks: PASS' "$TLOG" || return 1 + grep -q '^tensor mutation sweep: PASS' "$MLOG" || return 1 + ! grep -qE 'sweep: FAIL|NOT CAUGHT|NOT APPLIED|does not build' "$MLOG" +} + +TLOG_SHA=$(sha "$TLOG"); MLOG_SHA=$(sha "$MLOG"); TABLE_SHA=$(sha "$TABLE") +CHIP_SHA=""; [ -z "$CHIP" ] || CHIP_SHA=$(sha "$CHIP") + +# Table rows: the pipe table after "## Qualification checklist", up to the +# next heading or bold verdict line. +awk '/^## Qualification checklist/ {on = 1; next} + on && (/^## / || /^\*\*/) {exit} + on && /^\|/ {if ($0 ~ /^\|[-: |]*\|[[:space:]]*$/) next; print}' "$TABLE" > "$WORK/table.txt" +HAS_HOST=0; HAS_GB10=0; GB10_PARITY=0 +while IFS= read -r line; do + line=${line#|}; line=${line%|} + item=$(trim "${line%%|*}"); rest=${line#*|} + status=$(trim "${rest%%|*}"); evcell="" + [ "${rest#*|}" = "$rest" ] || evcell=${rest#*|} + [ "$item" = Item ] && continue + label=""; hw=""; ev="" + case $status in + "PASS (CPU)"|"host PASS") label="host PASS"; hw=host ;; + "PASS (GB10)"|"GB10 PASS") label="GB10 PASS"; hw=GB10 ;; + NOT_RUN|MISSING_IMPLEMENTATION) label=$status; hw=none ;; + WIRED|"PASS (on main)") label=REFERENCE; hw=none ;; + *) refuse "row '$item': unknown label '$status'" ;; # MUT:UNKNOWN_LABEL + esac + case $label in + NOT_RUN|MISSING_IMPLEMENTATION) add_nq "row '$item' is $label" ;; # MUT:NOTRUN_FORCES_NQ + "host PASS") HAS_HOST=1; ev="$TLOG_SHA,$MLOG_SHA" ;; + "GB10 PASS") + HAS_GB10=1 + ehash=$(printf '%s' "$evcell" | grep -oE '[0-9a-f]{64}' | head -1) + [ -n "$CHIP" ] || refuse "row '$item' is GB10 PASS but no --chip-evidence file was given" # MUT:GB10_NEEDS_EVIDENCE + [ "$ehash" = "$CHIP_SHA" ] || refuse "row '$item': GB10 PASS evidence hash does not match the chip evidence file" # MUT:GB10_HASH_MATCH + [ "$item" != "GB10 parity" ] || GB10_PARITY=1 + ev=$CHIP_SHA ;; + esac + printf '%s\t%s\t%s\t%s\n' "$label" "$hw" "$item" "$ev" >> "$ROWS" +done < "$WORK/table.txt" +[ -s "$ROWS" ] || refuse "no rows found in the qualification table" +if [ "$HAS_HOST" = 1 ]; then host_logs_pass || refuse "host PASS rows but the host logs do not show PASS"; fi # MUT:HOST_LOG_PASS +# M20 policy: only a GB10 parity row that is GB10 PASS with matching chip +# evidence (checked above) can qualify; host-only evidence never does. +[ "$GB10_PARITY" = 1 ] || add_nq "GB10 parity row is not GB10 PASS with matching chip evidence (host-only evidence never qualifies)" # MUT:GB10_PARITY_REQUIRED +HW=host; [ "$HAS_GB10" = 0 ] || HW=GB10 + +# store_blob SRC EXT -> prints the digest (pattern of tests/run_reduce_chip.sh). +mkdir -p "$EVID_ABS/blobs" || refuse "cannot create $EVID_ABS/blobs" +store_blob() { + local src=$1 ext=$2 d dst tmp have + d=$(sha "$src"); [ -n "$d" ] || refuse "cannot hash $src" + dst=$EVID_ABS/blobs/$d.$ext + if [ -e "$dst" ]; then + have=$(sha "$dst"); [ "$have" = "$d" ] || refuse "existing blob $dst does not match its digest" + else + tmp=$(mktemp "$EVID_ABS/blobs/.tmp.XXXXXX") || refuse "cannot create temp blob" + cp "$src" "$tmp" || { rm -f "$tmp"; refuse "cannot store $ext blob"; } + have=$(sha "$tmp"); [ "$have" = "$d" ] || { rm -f "$tmp"; refuse "stored $ext blob does not match its digest"; } + chmod 0444 "$tmp" || { rm -f "$tmp"; refuse "cannot seal $ext blob"; } + mv -n "$tmp" "$dst"; rm -f "$tmp" + have=$(sha "$dst"); [ "$have" = "$d" ] || refuse "blob $dst does not match its digest after publish" + fi + echo "$d" +} +store_blob "$TLOG" log > /dev/null || exit 2 +store_blob "$MLOG" log > /dev/null || exit 2 +[ -z "$CHIP" ] || store_blob "$CHIP" json > /dev/null || exit 2 +for b in ${BINS[@]+"${BINS[@]}"}; do + d=$(store_blob "$b" bin) || exit 2 + printf '%s\t%s\n' "$(basename "$b")" "$d" >> "$BINTSV" +done +LC_ALL=C sort -o "$BINTSV" "$BINTSV" + +# Test-only: lets tests/test_m20_receipt.sh change the tree mid-run. Setting +# it always forces NOT QUALIFIED. +if [ -n "${M20_RECEIPT_TEST_MIDRUN:-}" ]; then + add_nq "test-only mid-run hook was set" + sh -c "$M20_RECEIPT_TEST_MIDRUN" +fi +CLEAN_AFTER=false; [ -n "$(git -C "$TOP" status --porcelain)" ] || CLEAN_AFTER=true +UNCHANGED=false; [ "$(git -C "$TOP" rev-parse HEAD)" != "$COMMIT" ] || UNCHANGED=true +[ "$CLEAN_AFTER" = true ] || add_nq "omega tree dirty after the inputs were stored" # MUT:CLEAN_AFTER +[ "$UNCHANGED" = true ] || add_nq "HEAD moved during the receipt run" # MUT:COMMIT_UNCHANGED +VERDICT=QUALIFIED; [ "$NQ" = 0 ] || VERDICT="NOT QUALIFIED" + +TMP=$WORK/receipt.json +jq -S -n --arg commit "$COMMIT" --argjson clean_after "$CLEAN_AFTER" --argjson unchanged "$UNCHANGED" \ + --arg table "$TABLE_REL" --arg table_sha "$TABLE_SHA" --rawfile rows "$ROWS" --arg hw "$HW" \ + --arg tlog "$TLOG_SHA" --arg mlog "$MLOG_SHA" --arg chip "$CHIP_SHA" --rawfile bins "$BINTSV" \ + --rawfile reasons "$REASONS" --arg verdict "$VERDICT" --arg started "$STARTED" --arg finished "$FINISHED" ' + def nlines($s): $s | split("\n") | map(select(length > 0)); + {gate: "M20_OMEGA_TENSOR", writer: "tools/m20_receipt.sh v1", + omega_commit: $commit, omega_tree_clean_before: true, omega_tree_clean_after: $clean_after, + omega_commit_unchanged_after: $unchanged, + qualification_table: {path: $table, sha256: $table_sha}, + rows: [nlines($rows)[] | split("\t") | + {row: .[2], label: .[0], hardware: .[1], + evidence_sha256: (if .[3] == "" then [] else (.[3] | split(",")) end)}], + hardware: $hw, + logs: {test_tensor_sha256: $tlog, test_tensor_mutations_sha256: $mlog}, + chip_evidence_sha256: (if $chip == "" then null else $chip end), + binaries: [nlines($bins)[] | split("\t") | {name: .[0], sha256: .[1]}], + verdict: $verdict, verdict_reasons: nlines($reasons)} + + (if $started == "" then {} else {started_utc: $started} end) + + (if $finished == "" then {} else {finished_utc: $finished} end)' > "$TMP" \ + || refuse "receipt json (jq) failed, no receipt written" +[ -s "$TMP" ] || refuse "empty receipt, not written" +DIG=$(sha "$TMP") +(set -o noclobber; cat "$TMP" > "$EVID_ABS/$DIG.json") 2> /dev/null || refuse "receipt $DIG.json already exists, never overwritten" # MUT:NO_OVERWRITE +chmod 0444 "$EVID_ABS/$DIG.json" +echo "receipt: $EVID_ABS/$DIG.json verdict=$VERDICT hardware=$HW" +[ "$VERDICT" = QUALIFIED ] diff --git a/tools/m20_receipt_mutations.sh b/tools/m20_receipt_mutations.sh new file mode 100755 index 000000000..67ec48cc4 --- /dev/null +++ b/tools/m20_receipt_mutations.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# M20 receipt writer mutation sweep (sibling of tools/tensor_mutations.sh, +# which calls it). For each rule marked MUT: at the end of a line in +# tools/m20_receipt.sh, copy the writer to a scratch directory, break that one +# rule, run tests/test_m20_receipt.sh against the copy and require it to FAIL. +# A mutation that does not apply, or that the tests do not catch, fails the +# sweep. Host only, no device. Shell only (no Python). +set -u +cd "$(dirname "$0")/.." || exit 2 +SCRATCH=$(mktemp -d "${TMPDIR:-/tmp}/m20-receipt-mut.XXXXXX") || exit 2 +trap 'rm -rf "$SCRATCH"' EXIT INT TERM + +# name@sed expression (applied only to the line ending in MUT:) +MUTATIONS='DIRTY_REFUSED@s/|| refuse/|| :/ +EVID_OUTSIDE@s/) refuse/) :/ +UNKNOWN_LABEL@s/refuse "row/: "row/ +NOTRUN_FORCES_NQ@s/add_nq/:/ +GB10_NEEDS_EVIDENCE@s/|| refuse/|| :/ +GB10_HASH_MATCH@s/|| refuse/|| :/ +HOST_LOG_PASS@s/|| refuse/|| :/ +GB10_PARITY_REQUIRED@s/|| add_nq/|| :/ +CLEAN_AFTER@s/|| add_nq/|| :/ +COMMIT_UNCHANGED@s/|| add_nq/|| :/ +NO_OVERWRITE@s/set -o noclobber; //' + +# Baseline: the unmutated writer must pass, otherwise every mutant would +# look "caught". +if ! tests/test_m20_receipt.sh > "$SCRATCH/base.log" 2>&1; then + grep '^FAIL' "$SCRATCH/base.log" | head -5 + echo "m20 receipt mutation sweep: FAIL (unmutated baseline does not pass)"; exit 1 +fi +fail=0 +total=0 +old_ifs=$IFS +IFS=' +' +for m in $MUTATIONS; do + IFS=$old_ifs + name=${m%%@*}; expr=${m#*@} + total=$((total + 1)) + cp tools/m20_receipt.sh "$SCRATCH/m20_receipt.sh" + sed -i "/MUT:$name\$/ $expr" "$SCRATCH/m20_receipt.sh" + if cmp -s tools/m20_receipt.sh "$SCRATCH/m20_receipt.sh"; then + echo "MUTATION $name: NOT APPLIED (marker or pattern missing)"; fail=1; continue + fi + if M20_RECEIPT_WRITER="$SCRATCH/m20_receipt.sh" tests/test_m20_receipt.sh > "$SCRATCH/run.log" 2>&1; then + echo "MUTATION $name: NOT CAUGHT (tests still pass)"; fail=1 + else + echo "MUTATION $name: caught ($(grep -c '^FAIL' "$SCRATCH/run.log") failing checks)" + fi +done +IFS=$old_ifs +if [ "$fail" -ne 0 ]; then echo "m20 receipt mutation sweep: FAIL"; exit 1; fi +echo "m20 receipt mutation sweep: PASS ($total of $total mutations caught)" diff --git a/tools/tensor_mutations.sh b/tools/tensor_mutations.sh index 6e08af277..e780b5336 100755 --- a/tools/tensor_mutations.sh +++ b/tools/tensor_mutations.sh @@ -58,5 +58,7 @@ EOM fi done IFS=$old_ifs +# M20 receipt writer mutants (MUT: markers in tools/m20_receipt.sh), own sweep. +tools/m20_receipt_mutations.sh || fail=1 if [ "$fail" -ne 0 ]; then echo "tensor mutation sweep: FAIL"; exit 1; fi echo "tensor mutation sweep: PASS ($total of $total mutations caught)" ```