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 / synapse.mk

57 lines · 3745 bytes Raw Blame History
1# Synapse binary codec v2 in Omega (aien-dev/synapse ADR 0003 section 9 step 33, J1). Picked up by
2# `-include mk/*.mk`; not part of `all` or `test`; host only (interpreter + native AArch64, no GPU).
3# src/synapse/syn_codec.osc and syn_layout.h are generated from syn_codec.osc.in and syn_layout.lst by
4# syn_gen.sh (checked in with their output). tests/synapse/j1-corpus/corpus.bin is the corpus the Rust codec
5# sealed (provenance in tests/synapse/j1-corpus/PROVENANCE).
6# make syn-gen regenerate src/synapse/syn_codec.osc and syn_layout.h
7# make syn-gen-check regenerating gives byte-identical files
8# make test-synapse-codec check + cross-check driver, plain and ASan/UBSan (exact-size buffers), then the
9# corpus guards (tests/synapse/corpus_guard.sh) and the PACK20 layout refusal;
10# SYN_FUZZ=N (default 20000), SYN_FUZZ_SEED=S
11# make bench-synapse-codec native decode/encode timing of the accepted bases (plain build, fuzz off);
12# SYN_BENCH_REPS=N calls per base per round (default 2000), 7 rounds
13ifndef SYNAPSE_MK
14SYNAPSE_MK := 1
15.PHONY: syn-gen syn-gen-check test-synapse-codec bench-synapse-codec
16SYN_DIR = $(OUT_DIR)/synapse
17SYN_FUZZ ?= 20000
18SYN_BENCH_REPS ?= 2000
19SYN_GEN = src/synapse/syn_gen.sh
20SYN_GEN_ARGS = src/synapse/syn_layout.lst src/synapse/syn_codec.osc.in src/synapse/syn_codec.osc src/synapse/syn_layout.h
21SYN_SRCS = tests/synapse/test_syn_codec.c $(OSC_LIB)
22SYN_HDRS = src/synapse/syn_layout.h src/sha256.h $(OSC_HDRS)
23SYN_FLAGS = -std=gnu11 -Wall -Wextra -Werror -D_GNU_SOURCE -Isrc -Isrc/compiler -Isrc/synapse
24SYN_CORPUS = tests/synapse/j1-corpus/corpus.bin
25
26syn-gen:
27 sh $(SYN_GEN) gen $(SYN_GEN_ARGS)
28
29syn-gen-check:
30 sh $(SYN_GEN) check $(SYN_GEN_ARGS)
31
32$(SYN_DIR)/test_syn_codec: $(SYN_SRCS) $(SYN_HDRS)
33 @mkdir -p $(SYN_DIR)
34 $(CC) $(SYN_FLAGS) -O2 -o $@ $(SYN_SRCS)
35
36$(SYN_DIR)/test_syn_codec_asan: $(SYN_SRCS) $(SYN_HDRS)
37 @mkdir -p $(SYN_DIR)
38 $(CC) $(SYN_FLAGS) $(OSC_ASAN) -o $@ $(SYN_SRCS)
39
40bench-synapse-codec: syn-gen-check $(SYN_DIR)/test_syn_codec
41 SYN_BENCH_REPS=$(SYN_BENCH_REPS) $(abspath $(SYN_DIR)/test_syn_codec) src/synapse/syn_codec.osc $(SYN_CORPUS) 0 > $(SYN_DIR)/bench.out
42 @grep "^bench\|^SYN_J1" $(SYN_DIR)/bench.out; tail -1 $(SYN_DIR)/bench.out | grep -q "^SYN_J1_PASS$$"
43
44test-synapse-codec: syn-gen-check $(SYN_DIR)/test_syn_codec $(SYN_DIR)/test_syn_codec_asan
45 $(abspath $(SYN_DIR)/test_syn_codec) src/synapse/syn_codec.osc $(SYN_CORPUS) $(SYN_FUZZ) > $(SYN_DIR)/codec.out
46 @tail -12 $(SYN_DIR)/codec.out; tail -1 $(SYN_DIR)/codec.out | grep -q '^SYN_J1_PASS$$'
47 $(abspath $(SYN_DIR)/test_syn_codec_asan) src/synapse/syn_codec.osc $(SYN_CORPUS) $(SYN_FUZZ) > $(SYN_DIR)/codec_asan.out
48 @tail -3 $(SYN_DIR)/codec_asan.out; tail -1 $(SYN_DIR)/codec_asan.out | grep -q '^SYN_J1_PASS$$'
49 sh tests/synapse/corpus_guard.sh $(abspath $(SYN_DIR)/test_syn_codec_asan) src/synapse/syn_codec.osc $(SYN_CORPUS) \
50 $$(sed -n 's/^corpus: .* case section at byte \([0-9]*\),.*/\1/p' $(SYN_DIR)/codec.out) $(SYN_DIR)/guard
51 @sed 's/^INPUT_MAX .*/INPUT_MAX 1048576/' src/synapse/syn_layout.lst > $(SYN_DIR)/pack20.lst; \
52 if sh $(SYN_GEN) gen $(SYN_DIR)/pack20.lst src/synapse/syn_codec.osc.in $(SYN_DIR)/pack20.osc $(SYN_DIR)/pack20.h \
53 2> $(SYN_DIR)/pack20.err; then echo "pack20: WRONG, INPUT_MAX 2^20 accepted"; exit 1; fi; \
54 grep -q '^syn_gen: REFUSED PACK20:' $(SYN_DIR)/pack20.err || { cat $(SYN_DIR)/pack20.err; exit 1; }; \
55 echo "pack20: OK, $$(cat $(SYN_DIR)/pack20.err)"
56 @echo "test-synapse-codec: PASS (Rust corpus both directions + A1 malformed corpus + encode refusals + fuzz; interp + native; plain and ASan/UBSan; corpus guard; PACK20 layout refusal)"
57endif