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/blob/main/mk/estimation_tools.mk # 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 branch `main` Branches Tags History `omega-mv / mk / estimation_tools.mk` 97 lines ยท 7174 bytes Raw Blame History 1 # EST-2/EST-3 replay, fit and evaluation tools (protocol v1, v2). Not part of 2 # `all` or `test`. est_replay, est_fit and est_eval are pure seeded OM-2 built by 3 # $(ESTT_OMC); the test driver test_est_tools stays C (its fixture generator needs 4 # glibc's cos and log bit for bit) and links the C est_replay.c library, as do the 5 # v3 to v6 tools. Tools may open files and print; est_types.o and est_kf.o stay 6 # pure (est-purity, unchanged). 7 ifndef ESTIMATION_TOOLS_MK 8 ESTIMATION_TOOLS_MK := 1 9 include mk/estimation.mk 10 .PHONY: test-est-tools est-tools-purity est-tools test-est-replay-parity test-est-eval-tmpdir 11 ESTT_DIR = $(OUT_DIR)/est-tools 12 ESTT_CFLAGS = $(EST_CFLAGS) -Itools/estimation 13 ESTT_LIB = tools/estimation/est_replay.c src/estimation/est_mix.c $(EST_KF_SRCS) 14 ESTT_HDRS = tools/estimation/est_replay.h $(EST_HDRS) 15 # Tool identity baked in at build time as a generated toolid.om (t_ee_tool_commit, 16 # EE_TOOL_DIRTY, EE_TEST_BUILD) composed before est_eval.om. The stamp is rewritten 17 # only when the commit or the dirty flag changes, so est_eval rebuilds then. 18 ESTT_COMMIT := $(shell git rev-parse HEAD 2>/dev/null || echo unknown) 19 ESTT_DIRTY := $(shell if [ -n "$$(git status --porcelain 2>/dev/null)" ]; then echo 1; else echo 0; fi) 20 ESTT_FORBIDDEN = 'rx_|aienos_|argus_|forge_|aegis|mmap|mprotect|fork|exec|dlopen|socket|system' 21 # OM-2 host words an estimation tool must not use (process, socket, mapping and device 22 # words), checked on every code line (not note or text lines) of the composed sources. 23 ESTT_OM_FORBIDDEN = (^|[^A-Za-z0-9_])(fork|execprog|execpure|execenv|killpid|setsid|setpgid|prlimit|socknew|connect|bind|listen|accept|send|recv|sendmsg|mapnew|mapdrop|mapread|mapwrite|mapaddr|mapget|mapset|maphold|mapbind|devctl|devcall|uvmctl|mmap|mprotect|dlopen|system|socket)([^A-Za-z0-9_]|$$)|rx_|aienos_|argus_|forge_|aegis 24 25 $(ESTT_DIR)/est_replay.o: tools/estimation/est_replay.c $(ESTT_HDRS) 26 @mkdir -p $(ESTT_DIR) 27 $(CC) $(ESTT_CFLAGS) -c -o $@ $< 28 .PHONY: est-tools-stamp 29 est-tools-stamp: 30 @mkdir -p $(ESTT_DIR) 31 @echo "$(ESTT_COMMIT) $(ESTT_DIRTY)" > $(ESTT_DIR)/toolid.new; \ 32 cmp -s $(ESTT_DIR)/toolid.new $(ESTT_DIR)/toolid.stamp || mv $(ESTT_DIR)/toolid.new $(ESTT_DIR)/toolid.stamp; rm -f $(ESTT_DIR)/toolid.new 33 $(ESTT_DIR)/toolid.stamp: | est-tools-stamp 34 $(ESTT_DIR)/toolid.om: $(ESTT_DIR)/toolid.stamp 35 printf 'text t_ee_tool_commit "%s"\nconst EE_TOOL_DIRTY ulong %s\nconst EE_TEST_BUILD ulong 0\n' '$(ESTT_COMMIT)' '$(ESTT_DIRTY)' > $@ 36 # est_eval built for tests only: run B / C2 identities and the dirty flag come from the environment 37 $(ESTT_DIR)/toolid_t.om: 38 @mkdir -p $(ESTT_DIR) 39 printf 'text t_ee_tool_commit "test-build"\nconst EE_TOOL_DIRTY ulong 1\nconst EE_TEST_BUILD ulong 1\n' > $@ 40 ESTT_OMC ?= seed/out/omc 41 ESTT_OM_LIB = src/estimation/est_defs.om src/estimation/est_math.om src/estimation/est_types.om \ 42 src/estimation/est_kf.om src/estimation/est_mix.om src/estimation/est_pred.om \ 43 src/estimation/est_v4.om tools/estimation/est_replay.om 44 ESTT_OM_MAINS = tools/estimation/est_replay_main.om tools/estimation/est_fit.om tools/estimation/est_eval.om 45 46 $(ESTT_DIR)/est_replay: $(ESTT_OM_LIB) tools/estimation/est_replay_main.om $(ESTT_OMC) 47 @mkdir -p $(ESTT_DIR) 48 cat $(ESTT_OM_LIB) tools/estimation/est_replay_main.om | $(ESTT_OMC) > $@ && chmod +x $@ 49 $(ESTT_DIR)/est_fit: $(ESTT_OM_LIB) tools/estimation/est_fit.om $(ESTT_OMC) 50 @mkdir -p $(ESTT_DIR) 51 cat $(ESTT_OM_LIB) tools/estimation/est_fit.om | $(ESTT_OMC) > $@ && chmod +x $@ 52 $(ESTT_DIR)/est_eval: $(ESTT_OM_LIB) $(ESTT_DIR)/toolid.om tools/estimation/est_eval.om $(ESTT_OMC) 53 cat $(ESTT_OM_LIB) $(ESTT_DIR)/toolid.om tools/estimation/est_eval.om | $(ESTT_OMC) > $@ && chmod +x $@ 54 $(ESTT_DIR)/est_eval_t: $(ESTT_OM_LIB) $(ESTT_DIR)/toolid_t.om tools/estimation/est_eval.om $(ESTT_OMC) 55 cat $(ESTT_OM_LIB) $(ESTT_DIR)/toolid_t.om tools/estimation/est_eval.om | $(ESTT_OMC) > $@ && chmod +x $@ 56 # the C est_replay (est_replay.c's own main) as the parity reference for the OM-2 est_replay 57 $(ESTT_DIR)/est_replay_c: $(ESTT_LIB) $(ESTT_HDRS) 58 @mkdir -p $(ESTT_DIR) 59 $(CC) $(ESTT_CFLAGS) -DEST_REPLAY_MAIN -o $@ $(ESTT_LIB) -lm 60 $(ESTT_DIR)/test_est_tools: tools/estimation/test_est_tools.c $(ESTT_LIB) $(ESTT_HDRS) 61 @mkdir -p $(ESTT_DIR) 62 $(CC) $(ESTT_CFLAGS) -o $@ tools/estimation/test_est_tools.c $(ESTT_LIB) -lm 63 64 est-tools: $(ESTT_DIR)/est_fit $(ESTT_DIR)/est_eval $(ESTT_DIR)/est_replay 65 66 est-tools-purity: est-purity $(ESTT_DIR)/est_replay.o 67 @if nm -u $(ESTT_DIR)/est_replay.o | grep -E $(ESTT_FORBIDDEN) ; then \ 68 echo "est_replay.o references an authority, World or process operation"; exit 1; fi 69 @awk -v re='$(ESTT_OM_FORBIDDEN)' '$$1 != "note" && $$1 != "text" && $$0 ~ re { print FILENAME ":" FNR ": " $$0; bad = 1 } END { exit bad }' \ 70 $(ESTT_OM_LIB) $(ESTT_OM_MAINS) || { echo "an OM-2 estimation tool uses a process, socket, mapping or device word"; exit 1; } 71 @# bite control: the same scan must catch each word class planted in a copy of a shipped tool, 72 @# and must not trip on the unplanted copy or on the words in a note or text line 73 @mkdir -p $(ESTT_DIR)/purity-bite 74 @for p in ' pid = fork' ' s = socknew 2 1 0' ' m = mapnew 4096' ' devctl 3 0 0' ' rx_world_init 0' ' argus_open 1'; do \ 75 { cat tools/estimation/est_replay_main.om; printf '%s\n' "$$p"; } > $(ESTT_DIR)/purity-bite/plant.om; \ 76 if awk -v re='$(ESTT_OM_FORBIDDEN)' '$$1 != "note" && $$1 != "text" && $$0 ~ re { bad = 1 } END { exit bad }' $(ESTT_DIR)/purity-bite/plant.om; then \ 77 echo "est-tools-purity: the OM scan does not bite on planted '$$p'"; exit 1; fi; \ 78 done 79 @{ cat tools/estimation/est_replay_main.om; printf '%s\n' 'note fork socknew rx_world_init' 'text t_bite "mapnew devctl aegis"'; } > $(ESTT_DIR)/purity-bite/plant.om; \ 80 awk -v re='$(ESTT_OM_FORBIDDEN)' '$$1 != "note" && $$1 != "text" && $$0 ~ re { bad = 1 } END { exit bad }' $(ESTT_DIR)/purity-bite/plant.om \ 81 || { echo "est-tools-purity: the OM scan trips on a note or text line (bite control baseline)"; exit 1; } 82 @echo "est-tools-purity: est_replay.o and the OM-2 tool sources use no authority/process operation (the OM scan bites on 6 planted words); est_types.o and est_kf.o pure" 83 84 # no input-size cap: more than 8192 steps, 16384 lines, 2 MiB, 8 KiB lines and 64 KiB SHA256SUMS, 85 # byte for byte as the C est_replay 86 test-est-replay-parity: $(ESTT_DIR)/est_replay $(ESTT_DIR)/est_replay_c 87 sh tools/estimation/test_est_replay_parity.sh ./$(ESTT_DIR)/est_replay_c ./$(ESTT_DIR)/est_replay $(ESTT_DIR)/work-parity 88 89 # est_eval's prefix temp directory under a 576, 577, 5000-byte and empty TMPDIR, as the C est_eval 90 test-est-eval-tmpdir: $(ESTT_DIR)/est_fit $(ESTT_DIR)/est_eval 91 sh tools/estimation/test_est_eval_tmpdir.sh ./$(ESTT_DIR)/est_fit ./$(ESTT_DIR)/est_eval $(ESTT_DIR)/work-tmpdir 92 93 test-est-tools: est-tools-purity test-est-replay-parity test-est-eval-tmpdir $(ESTT_DIR)/est_fit $(ESTT_DIR)/est_eval $(ESTT_DIR)/est_eval_t $(ESTT_DIR)/test_est_tools 94 rm -rf $(ESTT_DIR)/work 95 ./$(ESTT_DIR)/test_est_tools ./$(ESTT_DIR)/est_fit ./$(ESTT_DIR)/est_eval ./$(ESTT_DIR)/est_eval_t $(ESTT_DIR)/work 96 @echo "test-est-tools: replay, fit and evaluation tools pass on run A and synthetic data" 97 endif