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
omega-mv / mk / physics0-verify.mk
| 1 | # PD-0 independent verifier (Direction 3): ladder checker, scorer, negative |
| 2 | # controls, append-only receipts. Standalone under src/physics0/{ladder,score, |
| 3 | # controls} and tests/physics0/verify. Not part of `all` or `test`. |
| 4 | # Test-only truth generators (tests/physics0/verify/pd0_bundle.om) copy the spec |
| 5 | # equations; the verifier sources never see them (p0v-purity checks it). |
| 6 | # |
| 7 | # test-physics0-verify formats + ladder + scorer/controls in OM-2, and the live C library tests plain and ASan/UBSan |
| 8 | ifndef PHYSICS0_VERIFY_MK |
| 9 | PHYSICS0_VERIFY_MK := 1 |
| 10 | .PHONY: test-physics0-verify p0v-purity |
| 11 | P0V_COMMIT := $(shell git rev-parse --short=12 HEAD 2>/dev/null || echo unknown) |
| 12 | P0V_DIR = $(OUT_DIR)/tests-physics0-verify |
| 13 | P0V_OMC ?= seed/out/omc |
| 14 | # Pure OM-2 (wave 36): formats, codes, receipts, ladder checker, scorer and negative controls, built |
| 15 | # from .om by the seed omc. The receipt commit string is prepended as an OM text constant, the way the |
| 16 | # C build passed -DPD0_VERIFIER_COMMIT. The OM tests run without sanitizers; OM-2 itself traps an |
| 17 | # out-of-range array get or put (3), signed overflow (1), div or rem by 0 (2), a shift amount |
| 18 | # outside 0..width-1 (7) and an out-of-range conversion (5) (docs/one_layer/OMEGESE.md 9.3); |
| 19 | # unsigned arithmetic wraps as in C. Alignment, use-after-free and leak checks are not replaced. |
| 20 | P0V_OM_BASE = src/physics0/pd0_types.om src/physics0/pd0_rng.om src/physics0/pd0_wire.om src/physics0/ladder/pd0_codes.om src/physics0/ladder/pd0_fmt.om src/physics0/controls/pd0_receipt.om |
| 21 | P0V_OM_VERIFY = $(P0V_OM_BASE) src/physics0/ladder/pd0_ladder.om src/physics0/score/pd0_score.om src/physics0/controls/pd0_controls.om |
| 22 | P0V_OM_FMT = $(P0V_OM_BASE) tests/physics0/verify/test_pd0_fmt.om |
| 23 | P0V_OM_LADDER = $(P0V_OM_VERIFY) tests/physics0/verify/pd0_bundle.om tests/physics0/verify/test_pd0_ladder.om |
| 24 | P0V_OM_SCORE = $(P0V_OM_VERIFY) tests/physics0/verify/pd0_bundle.om tests/physics0/verify/test_pd0_score.om |
| 25 | P0V_OM_COMMIT = echo 'text PD0_VERIFIER_COMMIT "$(P0V_COMMIT)"' |
| 26 | # The live C verifier library (the learners and planner link it, mk/physics0-learner*.mk): its C tests |
| 27 | # keep running, plain and ASan/UBSan, beside the OM tests. |
| 28 | # -Wno-pedantic: generated binding src/omega_om_units.c uses GNU range designators; see mk/estimation.mk. |
| 29 | P0V_CFLAGS = -std=c11 -Wall -Wextra -Werror -pedantic -Wno-misleading-indentation -O2 -D_POSIX_C_SOURCE=200809L -ffp-contract=off -fno-fast-math \ |
| 30 | -Isrc -Isrc/physics0/ladder -Isrc/physics0/score -Isrc/physics0/controls -Itests/physics0/verify -DPD0_VERIFIER_COMMIT=\"$(P0V_COMMIT)\" -DGOLDEN_PATH=\"tests/physics0/verify/golden_pd0rec1_pr243.bin\" -Wno-pedantic |
| 31 | P0V_ASAN = -O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all |
| 32 | P0V_SRCS = src/physics0/ladder/pd0_fmt.c src/physics0/ladder/pd0_codes.c src/physics0/ladder/pd0_ladder.c src/physics0/score/pd0_score.c src/physics0/controls/pd0_controls.c src/physics0/controls/pd0_receipt.c src/omega_om_units.c |
| 33 | P0V_HDRS = src/physics0/ladder/pd0_fmt.h src/physics0/ladder/pd0_codes.h src/physics0/ladder/pd0_rng.h src/physics0/ladder/pd0_ladder.h src/physics0/score/pd0_score.h src/physics0/controls/pd0_controls.h src/physics0/controls/pd0_receipt.h tests/physics0/verify/truth.h tests/physics0/verify/bundle.h |
| 34 | # the verifier must not contain generator knowledge: no symbol or string from the test truth generators |
| 35 | P0V_FORBIDDEN = 'truth_|oracle_rel|rx_|aienos_|argus_|forge_|mmap|fork|exec|socket' |
| 36 | $(P0V_DIR)/test_pd0_fmt: $(P0V_OM_FMT) $(P0V_OMC) |
| 37 | @mkdir -p $(P0V_DIR)/receipts |
| 38 | { echo "om2"; $(P0V_OM_COMMIT); cat $(P0V_OM_FMT); } | $(P0V_OMC) > $@ && chmod +x $@ |
| 39 | $(P0V_DIR)/test_pd0_ladder: $(P0V_OM_LADDER) $(P0V_OMC) |
| 40 | @mkdir -p $(P0V_DIR)/receipts |
| 41 | { echo "om2"; $(P0V_OM_COMMIT); cat $(P0V_OM_LADDER); } | $(P0V_OMC) > $@ && chmod +x $@ |
| 42 | $(P0V_DIR)/test_pd0_score: $(P0V_OM_SCORE) $(P0V_OMC) |
| 43 | @mkdir -p $(P0V_DIR)/receipts |
| 44 | { echo "om2"; $(P0V_OM_COMMIT); cat $(P0V_OM_SCORE); } | $(P0V_OMC) > $@ && chmod +x $@ |
| 45 | $(P0V_DIR)/c/%: tests/physics0/verify/%.c $(P0V_SRCS) $(P0V_HDRS) |
| 46 | @mkdir -p $(P0V_DIR)/c $(P0V_DIR)/receipts |
| 47 | $(CC) $(P0V_CFLAGS) -o $@ $< $(P0V_SRCS) -lm |
| 48 | $(P0V_DIR)/c/%_asan: tests/physics0/verify/%.c $(P0V_SRCS) $(P0V_HDRS) |
| 49 | @mkdir -p $(P0V_DIR)/c $(P0V_DIR)/receipts |
| 50 | $(CC) $(P0V_CFLAGS) $(P0V_ASAN) -o $@ $< $(P0V_SRCS) -lm |
| 51 | # purity: the OM verifier sources (code lines; notes excluded) and the live C verifier objects carry no generator or authority name |
| 52 | p0v-purity: |
| 53 | @if grep -hv '^[[:space:]]*note' $(P0V_OM_VERIFY) | grep -E $(P0V_FORBIDDEN); then echo "verifier OM source references generator or authority names"; exit 1; fi |
| 54 | @# bite control: the same scan must catch each forbidden name planted in a copy of a verifier unit |
| 55 | @mkdir -p $(P0V_DIR)/purity |
| 56 | @for p in ' x = truth_get 0' ' oracle_rel_read 1' ' rx_world_init 0' ' aienos_cap_mint 0' ' pid = fork'; do \ |
| 57 | { cat src/physics0/score/pd0_score.om; printf '%s\n' "$$p"; } > $(P0V_DIR)/purity/plant.om; \ |
| 58 | grep -hv '^[[:space:]]*note' $(P0V_DIR)/purity/plant.om | grep -qE $(P0V_FORBIDDEN) \ |
| 59 | || { echo "p0v-purity: the OM scan does not bite on planted '$$p'"; exit 1; }; \ |
| 60 | done |
| 61 | @mkdir -p $(P0V_DIR)/purity |
| 62 | @for f in $(filter-out src/omega_om_units.c,$(P0V_SRCS)); do $(CC) $(P0V_CFLAGS) -c -o $(P0V_DIR)/purity/$$(basename $$f .c).o $$f || exit 1; done |
| 63 | @if nm $(P0V_DIR)/purity/*.o | grep -E $(P0V_FORBIDDEN); then echo "verifier object references generator or authority symbols"; exit 1; fi |
| 64 | @echo "p0v-purity: verifier OM sources and C library objects carry no generator or authority symbol (the OM scan bites on 5 planted names)" |
| 65 | P0V_C_TESTS = $(P0V_DIR)/c/test_pd0_ladder $(P0V_DIR)/c/test_pd0_ladder_asan $(P0V_DIR)/c/test_pd0_score $(P0V_DIR)/c/test_pd0_score_asan |
| 66 | test-physics0-verify: p0v-purity $(P0V_DIR)/test_pd0_fmt $(P0V_DIR)/test_pd0_ladder $(P0V_DIR)/test_pd0_score $(P0V_C_TESTS) |
| 67 | ./$(P0V_DIR)/test_pd0_fmt |
| 68 | ./$(P0V_DIR)/test_pd0_ladder |
| 69 | ./$(P0V_DIR)/test_pd0_score |
| 70 | @for t in $(P0V_C_TESTS); do ./$$t || exit 1; done |
| 71 | @echo "test-physics0-verify: PD-0 verifier formats, ladder, scorer and negative controls pass (OM-2, and the live C library plain + ASan/UBSan); receipts in $(P0V_DIR)/receipts" |
| 72 | endif |