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 / estimation_v4.mk
| 1 | # ESTIMATION v4 (docs/estimation/protocols/est-v4.md): lag / AR-change / |
| 2 | # two-time-constant families (src/estimation/est_v4.c) and the est4 tool. |
| 3 | # Picked up by `-include mk/*.mk`; not part of `all` or `test`. |
| 4 | # |
| 5 | # test-est-v4 unit suite (analytic multi-step propagation), plain + ASan/UBSan |
| 6 | # est-v4-purity nm -u on est_v4.o against EST_FORBIDDEN |
| 7 | # test-est4-tools tool tests on synthetic data (held-out refusal, open trace, binding refusals) |
| 8 | # test-estimation-v4 all three |
| 9 | # est4 the binding tool (identity compiled in) |
| 10 | ifndef ESTIMATION_V4_MK |
| 11 | ESTIMATION_V4_MK := 1 |
| 12 | include mk/estimation.mk |
| 13 | .PHONY: test-est-v4 est-v4-purity test-est4-tools test-estimation-v4 est4 est4-force |
| 14 | ESTV4_DIR = $(OUT_DIR)/estimation-v4 |
| 15 | ESTV4_CFLAGS = $(EST_CFLAGS) -Itools/estimation |
| 16 | ESTV4_SRCS = src/estimation/est_v4.c src/estimation/est_pred.c src/estimation/est_mix.c $(EST_TYPES_SRCS) |
| 17 | ESTV4_HDRS = src/estimation/est_v4.h src/estimation/est_pred.h $(EST_HDRS) |
| 18 | ESTV4_TOOL_SRCS = tools/estimation/est4.c tools/estimation/est3c_common.c tools/estimation/est_replay.c \ |
| 19 | src/estimation/est_v4.c src/estimation/est_pred.c src/estimation/est_mix.c $(EST_KF_SRCS) |
| 20 | ESTV4_TOOL_HDRS = tools/estimation/est3c_common.h tools/estimation/est_replay.h $(ESTV4_HDRS) |
| 21 | # identity baked in: commit, dirty flag, protocol SHA, D1 identity |
| 22 | # (receipts/est-v4/d1.sha256), D2 identity (d2.sha256), params SHA, repo root |
| 23 | ESTV4_COMMIT := $(shell git rev-parse HEAD 2>/dev/null || echo unknown) |
| 24 | ESTV4_DIRTY := $(shell if [ -n "$$(git status --porcelain 2>/dev/null)" ]; then echo 1; else echo 0; fi) |
| 25 | ESTV4_PROTO := $(shell sha256sum docs/estimation/protocols/est-v4.md 2>/dev/null | cut -c1-64) |
| 26 | ESTV4_RC = docs/estimation/receipts/est-v4 |
| 27 | ESTV4_SUM = $(shell awk '$$2 == "$(2)" && length($$1) == 64 { print $$1 }' $(ESTV4_RC)/$(1) 2>/dev/null | head -1) |
| 28 | ESTV4_D1RAW := $(call ESTV4_SUM,d1.sha256,machine-state.ndjson) |
| 29 | ESTV4_D1MARKS := $(call ESTV4_SUM,d1.sha256,machine-state-marks.txt) |
| 30 | ESTV4_D2RAW := $(call ESTV4_SUM,d2.sha256,machine-state.ndjson) |
| 31 | ESTV4_D2MARKS := $(call ESTV4_SUM,d2.sha256,machine-state-marks.txt) |
| 32 | ESTV4_D2SCHED := $(call ESTV4_SUM,d2.sha256,schedule.txt) |
| 33 | ESTV4_PARAMS := $(shell sha256sum $(ESTV4_RC)/params.txt 2>/dev/null | cut -c1-64) |
| 34 | ESTV4_ROOT := $(shell git rev-parse --show-toplevel 2>/dev/null || echo unknown) |
| 35 | ESTV4_OR = $(if $(1),$(1),$(2)) |
| 36 | ESTV4_ID = -DTOOL_COMMIT='"$(ESTV4_COMMIT)"' -DTOOL_DIRTY=$(ESTV4_DIRTY) \ |
| 37 | -DE4_PROTOCOL_SHA='"$(call ESTV4_OR,$(ESTV4_PROTO),unknown)"' \ |
| 38 | -DE4_D1_RAW_SHA='"$(call ESTV4_OR,$(ESTV4_D1RAW),absent)"' -DE4_D1_MARKS_SHA='"$(call ESTV4_OR,$(ESTV4_D1MARKS),absent)"' \ |
| 39 | -DE4_D2_RAW_SHA='"$(call ESTV4_OR,$(ESTV4_D2RAW),absent)"' -DE4_D2_MARKS_SHA='"$(call ESTV4_OR,$(ESTV4_D2MARKS),absent)"' \ |
| 40 | -DE4_D2_SCHED_SHA='"$(call ESTV4_OR,$(ESTV4_D2SCHED),absent)"' -DE4_PARAMS_SHA='"$(call ESTV4_OR,$(ESTV4_PARAMS),absent)"' \ |
| 41 | -DE4_REPO_ROOT='"$(ESTV4_ROOT)"' |
| 42 | |
| 43 | $(ESTV4_DIR)/toolid.stamp: est4-force |
| 44 | @mkdir -p $(ESTV4_DIR) |
| 45 | @echo '$(ESTV4_ID)' > $(ESTV4_DIR)/toolid.new; \ |
| 46 | cmp -s $(ESTV4_DIR)/toolid.new $(ESTV4_DIR)/toolid.stamp || mv $(ESTV4_DIR)/toolid.new $(ESTV4_DIR)/toolid.stamp; rm -f $(ESTV4_DIR)/toolid.new |
| 47 | est4-force: ; |
| 48 | |
| 49 | $(ESTV4_DIR)/est_v4.o: src/estimation/est_v4.c $(ESTV4_HDRS) |
| 50 | @mkdir -p $(ESTV4_DIR) |
| 51 | $(CC) $(EST_CFLAGS) -c -o $@ $< |
| 52 | est-v4-purity: $(ESTV4_DIR)/est_v4.o |
| 53 | @if nm -u $^ | grep -E $(EST_FORBIDDEN) ; then \ |
| 54 | echo "est_v4.o references an operation an estimator must not have"; exit 1; fi |
| 55 | @echo "est-v4-purity: est_v4.o references no forbidden symbol" |
| 56 | |
| 57 | EST_OM_V4 = $(EST_OM_TYPES) src/estimation/est_mix.om src/estimation/est_pred.om src/estimation/est_v4.om |
| 58 | |
| 59 | $(ESTV4_DIR)/test_est_v4: $(EST_OM_V4) tests/estimation/test_est_v4.om |
| 60 | @mkdir -p $(ESTV4_DIR) |
| 61 | cat $^ | $(EST_OMC) > $@ && chmod +x $@ |
| 62 | test-est-v4: $(ESTV4_DIR)/test_est_v4 |
| 63 | ./$(ESTV4_DIR)/test_est_v4 |
| 64 | @echo "test-est-v4: v4 families, multi-step propagation and pmf agree (pure OM-2)" |
| 65 | |
| 66 | $(ESTV4_DIR)/est4: $(ESTV4_TOOL_SRCS) $(ESTV4_TOOL_HDRS) $(ESTV4_DIR)/toolid.stamp |
| 67 | $(CC) $(ESTV4_CFLAGS) $(ESTV4_ID) -o $@ $(ESTV4_TOOL_SRCS) -lm |
| 68 | est4: $(ESTV4_DIR)/est4 |
| 69 | # test build: identities from E4_TEST_* environment variables |
| 70 | $(ESTV4_DIR)/est4_test: $(ESTV4_TOOL_SRCS) $(ESTV4_TOOL_HDRS) |
| 71 | @mkdir -p $(ESTV4_DIR) |
| 72 | $(CC) $(ESTV4_CFLAGS) -DE4_TEST_BUILD -DTOOL_COMMIT='"test-build"' -DTOOL_DIRTY=1 -o $@ $(ESTV4_TOOL_SRCS) -lm |
| 73 | # -Wno-format-truncation: est3c_common.c (v3, unchanged) trips a fortify false positive at -O1 |
| 74 | $(ESTV4_DIR)/est4_test_asan: $(ESTV4_TOOL_SRCS) $(ESTV4_TOOL_HDRS) |
| 75 | @mkdir -p $(ESTV4_DIR) |
| 76 | $(CC) $(ESTV4_CFLAGS) $(EST_ASAN) -Wno-format-truncation -DE4_TEST_BUILD -DTOOL_COMMIT='"test-build"' -DTOOL_DIRTY=1 -o $@ $(ESTV4_TOOL_SRCS) -lm |
| 77 | test-est4-tools: $(ESTV4_DIR)/est4 $(ESTV4_DIR)/est4_test $(ESTV4_DIR)/est4_test_asan |
| 78 | sh tools/estimation/test_est4_tools.sh ./$(ESTV4_DIR)/est4_test $(ESTV4_DIR)/work |
| 79 | sh tools/estimation/test_est4_tools.sh ./$(ESTV4_DIR)/est4_test_asan $(ESTV4_DIR)/work-asan |
| 80 | @echo "test-est4-tools: fit, held-out refusal, open-trace purity, binding refusals and receipt path pass (synthetic data)" |
| 81 | |
| 82 | test-estimation-v4: est-v4-purity test-est-v4 test-est4-tools |
| 83 | @echo "test-estimation-v4: ESTIMATION v4 passes" |
| 84 | endif |