interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / mk / estimation_v5.mk

81 lines · 5349 bytes Raw Blame History
1# ESTIMATION v5 (docs/estimation/protocols/est-v5.md): the v4 families (src/estimation/est_v4.c,
2# unchanged) with the est5 tool (the est4 tool with v5 paths, tags and identities) and an
3# enforced collection window. Picked up by `-include mk/*.mk`; not part of `all` or `test`.
4#
5# test-est5-tools tool tests on synthetic data (held-out refusal, open trace, binding refusals)
6# test-est5-window collector and window-check tests (no data, no load)
7# test-est-json strict-JSON receipt rules (est-json-1): unit checks + strict parse of emitted receipts
8# test-estimation-v5 v4 library tests (reused, unchanged) + the two above
9# est5 the binding tool (identity compiled in)
10ifndef ESTIMATION_V5_MK
11ESTIMATION_V5_MK := 1
12include mk/estimation_v4.mk
13.PHONY: test-est-json test-est5-tools test-est5-window test-estimation-v5 est5 est5-force
14ESTV5_DIR = $(OUT_DIR)/estimation-v5
15ESTV5_CFLAGS = $(EST_CFLAGS) -Itools/estimation
16ESTV5_TOOL_SRCS = tools/estimation/est5.c tools/estimation/est3c_common.c tools/estimation/est_replay.c \
17 src/estimation/est_v4.c src/estimation/est_pred.c src/estimation/est_mix.c $(EST_KF_SRCS)
18ESTV5_TOOL_HDRS = tools/estimation/est3c_common.h tools/estimation/est_replay.h $(ESTV4_HDRS)
19# identity baked in: commit, dirty flag, protocol SHA, D1 identity
20# (receipts/est-v5/d1.sha256), D2 identity (d2.sha256), params SHA, repo root
21ESTV5_COMMIT := $(shell git rev-parse HEAD 2>/dev/null || echo unknown)
22ESTV5_DIRTY := $(shell if [ -n "$$(git status --porcelain 2>/dev/null)" ]; then echo 1; else echo 0; fi)
23ESTV5_PROTO := $(shell sha256sum docs/estimation/protocols/est-v5.md 2>/dev/null | cut -c1-64)
24ESTV5_RC = docs/estimation/receipts/est-v5
25ESTV5_SUM = $(shell awk '$$2 == "$(2)" && length($$1) == 64 { print $$1 }' $(ESTV5_RC)/$(1) 2>/dev/null | head -1)
26ESTV5_D1RAW := $(call ESTV5_SUM,d1.sha256,machine-state.ndjson)
27ESTV5_D1MARKS := $(call ESTV5_SUM,d1.sha256,machine-state-marks.txt)
28ESTV5_D2RAW := $(call ESTV5_SUM,d2.sha256,machine-state.ndjson)
29ESTV5_D2MARKS := $(call ESTV5_SUM,d2.sha256,machine-state-marks.txt)
30ESTV5_D2SCHED := $(call ESTV5_SUM,d2.sha256,schedule.txt)
31ESTV5_PARAMS := $(shell sha256sum $(ESTV5_RC)/params.txt 2>/dev/null | cut -c1-64)
32ESTV5_ROOT := $(shell git rev-parse --show-toplevel 2>/dev/null || echo unknown)
33ESTV5_OR = $(if $(1),$(1),$(2))
34ESTV5_ID = -DTOOL_COMMIT='"$(ESTV5_COMMIT)"' -DTOOL_DIRTY=$(ESTV5_DIRTY) \
35 -DE5_PROTOCOL_SHA='"$(call ESTV5_OR,$(ESTV5_PROTO),unknown)"' \
36 -DE5_D1_RAW_SHA='"$(call ESTV5_OR,$(ESTV5_D1RAW),absent)"' -DE5_D1_MARKS_SHA='"$(call ESTV5_OR,$(ESTV5_D1MARKS),absent)"' \
37 -DE5_D2_RAW_SHA='"$(call ESTV5_OR,$(ESTV5_D2RAW),absent)"' -DE5_D2_MARKS_SHA='"$(call ESTV5_OR,$(ESTV5_D2MARKS),absent)"' \
38 -DE5_D2_SCHED_SHA='"$(call ESTV5_OR,$(ESTV5_D2SCHED),absent)"' -DE5_PARAMS_SHA='"$(call ESTV5_OR,$(ESTV5_PARAMS),absent)"' \
39 -DE5_REPO_ROOT='"$(ESTV5_ROOT)"'
40
41$(ESTV5_DIR)/toolid.stamp: est5-force
42 @mkdir -p $(ESTV5_DIR)
43 @echo '$(ESTV5_ID)' > $(ESTV5_DIR)/toolid.new; \
44 cmp -s $(ESTV5_DIR)/toolid.new $(ESTV5_DIR)/toolid.stamp || mv $(ESTV5_DIR)/toolid.new $(ESTV5_DIR)/toolid.stamp; rm -f $(ESTV5_DIR)/toolid.new
45est5-force: ;
46
47$(ESTV5_DIR)/est5: $(ESTV5_TOOL_SRCS) $(ESTV5_TOOL_HDRS) $(ESTV5_DIR)/toolid.stamp
48 $(CC) $(ESTV5_CFLAGS) $(ESTV5_ID) -o $@ $(ESTV5_TOOL_SRCS) -lm
49est5: $(ESTV5_DIR)/est5
50# test build: identities from E5_TEST_* environment variables
51$(ESTV5_DIR)/est5_test: $(ESTV5_TOOL_SRCS) $(ESTV5_TOOL_HDRS)
52 @mkdir -p $(ESTV5_DIR)
53 $(CC) $(ESTV5_CFLAGS) -DE5_TEST_BUILD -DTOOL_COMMIT='"test-build"' -DTOOL_DIRTY=1 -o $@ $(ESTV5_TOOL_SRCS) -lm
54# -Wno-format-truncation: est3c_common.c (v3, unchanged) trips a fortify false positive at -O1
55$(ESTV5_DIR)/est5_test_asan: $(ESTV5_TOOL_SRCS) $(ESTV5_TOOL_HDRS)
56 @mkdir -p $(ESTV5_DIR)
57 $(CC) $(ESTV5_CFLAGS) $(EST_ASAN) -Wno-format-truncation -DE5_TEST_BUILD -DTOOL_COMMIT='"test-build"' -DTOOL_DIRTY=1 -o $@ $(ESTV5_TOOL_SRCS) -lm
58test-est5-tools: $(ESTV5_DIR)/test_est_json $(ESTV5_DIR)/est5 $(ESTV5_DIR)/est5_test $(ESTV5_DIR)/est5_test_asan
59 sh tools/estimation/test_est5_tools.sh ./$(ESTV5_DIR)/est5_test $(ESTV5_DIR)/work ./$(ESTV5_DIR)/test_est_json
60 sh tools/estimation/test_est5_tools.sh ./$(ESTV5_DIR)/est5_test_asan $(ESTV5_DIR)/work-asan ./$(ESTV5_DIR)/test_est_json
61 @echo "test-est5-tools: fit, held-out refusal, open-trace purity, binding refusals and receipt path pass (synthetic data)"
62
63ESTJ_SRCS = tools/estimation/test_est_json.c tools/estimation/est3c_common.c tools/estimation/est_replay.c \
64 src/estimation/est_v4.c src/estimation/est_pred.c src/estimation/est_mix.c $(EST_KF_SRCS)
65$(ESTV5_DIR)/test_est_json: $(ESTJ_SRCS) $(ESTV5_TOOL_HDRS)
66 @mkdir -p $(ESTV5_DIR)
67 $(CC) $(ESTV5_CFLAGS) -Wno-format-truncation -o $@ $(ESTJ_SRCS) -lm
68$(ESTV5_DIR)/test_est_json_asan: $(ESTJ_SRCS) $(ESTV5_TOOL_HDRS)
69 @mkdir -p $(ESTV5_DIR)
70 $(CC) $(ESTV5_CFLAGS) $(EST_ASAN) -Wno-format-truncation -o $@ $(ESTJ_SRCS) -lm
71test-est-json: $(ESTV5_DIR)/test_est_json $(ESTV5_DIR)/test_est_json_asan
72 ./$(ESTV5_DIR)/test_est_json .
73 ./$(ESTV5_DIR)/test_est_json_asan .
74 @echo "test-est-json: strict-JSON receipt rules pass (plain and ASan/UBSan)"
75
76test-est5-window:
77 sh tools/estimation/test_est5_window.sh
78
79test-estimation-v5: est-v4-purity test-est-v4 test-est-json test-est5-tools test-est5-window
80 @echo "test-estimation-v5: ESTIMATION v5 passes"
81endif