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 / seed / helix / ollm_factory / architect-builder-gate.sh

157 lines · 6978 bytes Raw Blame History
1#!/bin/sh
2# seed/helix/ollm_factory/architect-builder-gate.sh
3# Dual-Strand AArch64 Host Verification Gate for the 4-Strand Architect-Builder RLVR Pipeline.
4# Zero GPU required; runs completely on AArch64 CPU.
5#
6# Verifies:
7# 1. Regrow Strand A (`seed/out/omc`) & Strand B (`build/helix/A_fast`) from 804B seeds
8# 2. Dual-strand identical compilation of `architect_client`, `strand4_attr`, `rlvr_factory`,
9# `bench`, and `ollm` (zero dynamic libraries)
10# 3. Exhaustive positive & negative self-checks (`architect_client selfcheck`, `strand4_attr selfcheck`)
11# 4. Real 4-strand `OLLMSP01` DNA specialist ensemble (`S1_arith.sp`, `S2_fold.sp`, `S3_rewrite.sp`,
12# `S4_repair.sp`) trained on a frozen base checkpoint with bit-exact `speval`, live 4-strand
13# `ollm spclip MODE=1 (S=4)` multi-helix inference, and all 3 tamper controls (`rc=60/61/62`)
14# 5. Complete end-to-end offline cycle via `architect-builder-cycle.sh --offline`
15set -eu
16R=$(CDPATH= cd -- "$(dirname "$0")/../../.." && pwd)
17cd "$R"
18
19bad() { printf 'ARCH_BUILD_GATE FAIL: %s\n' "$*" >&2; exit 1; }
20sha() { sha256sum "$1" | cut -d' ' -f1; }
21
22B=build/ab4-gate
23rm -rf "$B"
24mkdir -p "$B/bin" "$B/spec" "$B/cycle"
25
26printf '=== [1/5] REGROW STRAND A & STRAND B FROM 804B SEEDS ===\n'
27sh seed/helix/helix-from-seeds.sh
28OMC_A=seed/out/omc
29OMC_B=build/helix/A_fast
30cp "$OMC_A" "$B/bin/omc"
31chmod +x "$B/bin/omc"
32
33printf '\n=== [2/5] DUAL-STRAND BUILD OF ARCHITECT-BUILDER TOOLS & OLLM ===\n'
34for item in "architect_client:seed/helix/ollm_factory/architect_client.om" \
35 "strand4_attr:seed/helix/ollm_factory/strand4_attr.om" \
36 "rlvr_factory:seed/helix/ollm_factory/rlvr_factory.om" \
37 "bench:train/omega-llm/tools/bench/bench.om"; do
38 name="${item%%:*}"
39 src="${item#*:}"
40 "$OMC_A" < "$src" > "$B/bin/${name}.A"
41 "$OMC_B" < "$src" > "$B/bin/${name}.B"
42 cmp -s "$B/bin/${name}.A" "$B/bin/${name}.B" || bad "$name diverged across strands"
43 mv "$B/bin/${name}.A" "$B/bin/${name}"
44 rm -f "$B/bin/${name}.B"
45 chmod +x "$B/bin/${name}"
46 printf 'PASS %s dual-strand identical (%s)\n' "$name" "$(sha "$B/bin/${name}")"
47done
48
49COMMON="si/directives/om2.om \
50 train/omega-llm/native/net/http.om \
51 train/omega-llm/native/net/json.om \
52 train/omega-llm/native/net/jsonw.om \
53 train/omega-llm/native/math.om \
54 train/omega-llm/native/data.om \
55 train/omega-llm/native/lpool.om \
56 train/omega-llm/native/model.om \
57 train/omega-llm/native/adam.om \
58 train/omega-llm/native/ckpt.om \
59 train/omega-llm/native/bpe.om \
60 train/omega-llm/native/spec.om \
61 train/omega-llm/native/cli.om \
62 train/omega-llm/native/lio.om \
63 train/omega-llm/native/serve.om \
64 train/omega-llm/native/nogpu.om"
65cat $COMMON > "$B/bin/ollm_cpu.om"
66"$OMC_A" < "$B/bin/ollm_cpu.om" > "$B/bin/ollm.A"
67"$OMC_B" < "$B/bin/ollm_cpu.om" > "$B/bin/ollm.B"
68cmp -s "$B/bin/ollm.A" "$B/bin/ollm.B" || bad "ollm diverged across strands"
69mv "$B/bin/ollm.A" "$B/bin/ollm"
70rm -f "$B/bin/ollm.B"
71chmod +x "$B/bin/ollm"
72printf 'PASS ollm dual-strand identical (%s)\n' "$(sha "$B/bin/ollm")"
73
74printf '\n=== [3/5] POSITIVE & NEGATIVE SELF-CHECKS ===\n'
75"$B/bin/architect_client" selfcheck
76"$B/bin/strand4_attr" selfcheck
77
78printf '\n=== [4/5] 4-STRAND OLLMSP01 ENSEMBLE + LIVE 4-STRAND SPCLIP (MODE=1, S=4) + TAMPER ===\n'
79OLLM="$B/bin/ollm"
80SD="$B/spec"
81"$B/bin/rlvr_factory" corpus > "$SD/rlvr.bin"
82"$B/bin/rlvr_factory" repair > "$SD/repair.bin"
83head -c 256 "$SD/rlvr.bin" > "$SD/held.bin"
84
85"$OLLM" init "$SD/base.ck" 256 16 32 2 64 2 2 42 20 5000 1 >/dev/null
86BASE_EVAL=$("$OLLM" eval "$SD/base.ck" "$SD/held.bin" 4)
87
88# Train all 4 frozen-core specialist strands (L=2 -> 3) off the identical frozen base
89for pair in "S1_arith:rlvr.bin:8:4" \
90 "S2_fold:rlvr.bin:10:4" \
91 "S3_rewrite:rlvr.bin:12:4" \
92 "S4_repair:repair.bin:8:4"; do
93 sname="${pair%%:*}"
94 rest="${pair#*:}"
95 dfile="${rest%%:*}"
96 rest2="${rest#*:}"
97 steps="${rest2%%:*}"
98 bsz="${rest2#*:}"
99 "$OLLM" growpro "$SD/base.ck" "$SD/${sname}.ck" 3 40 5000
100 S0_EVAL=$("$OLLM" eval "$SD/${sname}.ck" "$SD/held.bin" 4)
101 [ "$BASE_EVAL" = "$S0_EVAL" ] || bad "$sname growpro step-0 not bit-identical to base"
102 "$OLLM" fcache "$SD/base.ck" "$SD/$dfile" 8 "$SD/${sname}.hc"
103 "$OLLM" trainfc "$SD/${sname}.ck" "$SD/${sname}.hc" "$steps" "$bsz" 2 2
104 "$OLLM" spext "$SD/base.ck" "$SD/${sname}.ck" "$SD/${sname}.sp"
105 PE=$("$OLLM" speval "$SD/base.ck" "$SD/${sname}.sp" "$SD/held.bin" 4)
106 CE=$("$OLLM" eval "$SD/${sname}.ck" "$SD/held.bin" 4)
107 [ "$(printf '%s' "$PE" | awk '{print $3,$4,$5}')" = "$(printf '%s' "$CE" | awk '{print $3,$4,$5}')" ] || bad "$sname speval mismatch"
108 printf ' PASS %s (%s B, bit-exact speval)\n' "$sname" "$(wc -c < "$SD/${sname}.sp" | tr -d ' ')"
109done
110
111# Live 4-strand DNA multi-helix spclip (MODE=1 entropy-gated, S=4 strands)
112"$OLLM" spclip "$SD/base.ck" 1 "fn solve " 16 0 42 - 4 \
113 250 1 "$SD/S1_arith.sp" \
114 250 1 "$SD/S2_fold.sp" \
115 250 1 "$SD/S3_rewrite.sp" \
116 250 1 "$SD/S4_repair.sp" > "$SD/spclip4.out"
117printf ' PASS Live 4-strand spclip MODE=1 (S=4, %s bytes emitted)\n' "$(wc -c < "$SD/spclip4.out" | tr -d ' ')"
118
119# Tamper controls (rc=60 truncated, rc=61 1-bit flipped, rc=62 wrong base / swapped link)
120head -c 32 "$SD/S1_arith.sp" > "$SD/trunc.sp"
121rc=0; "$OLLM" speval "$SD/base.ck" "$SD/trunc.sp" "$SD/held.bin" 4 >/dev/null 2>&1 || rc=$?
122[ "$rc" = "60" ] || bad "truncated pack expected rc=60 got $rc"
123
124cp "$SD/S4_repair.sp" "$SD/flip.sp"
125printf '\377' | dd of="$SD/flip.sp" bs=1 seek=64 count=1 conv=notrunc 2>/dev/null
126rc=0; "$OLLM" speval "$SD/base.ck" "$SD/flip.sp" "$SD/held.bin" 4 >/dev/null 2>&1 || rc=$?
127[ "$rc" = "61" ] || bad "flipped pack expected rc=61 got $rc"
128
129"$OLLM" init "$SD/other_base.ck" 256 16 32 2 64 2 2 99 20 5000 1 >/dev/null
130rc=0; "$OLLM" speval "$SD/other_base.ck" "$SD/S1_arith.sp" "$SD/held.bin" 4 >/dev/null 2>&1 || rc=$?
131[ "$rc" = "62" ] || bad "wrong base expected rc=62 got $rc"
132printf ' PASS 4-strand tamper controls: truncated=rc60 flipped=rc61 wrong_base=rc62\n'
133
134printf '\n=== [5/5] END-TO-END OFFLINE 4-STRAND ARCHITECT-BUILDER CYCLE ===\n'
135cat > "$B/cycle/tasks.tsv" <<'EOF'
136# Synthetic zero-leakage tasks spanning all 4 strands
137syn-001 arith compute 3 times a plus 1 for unsigned input a
138syn-002 fold accumulate weighted sum of array prefix elements
139syn-003 rewrite replace negative-sentinel elements in place with bound
140syn-004 branch clamp unsigned value into closed interval 5 to 99
141syn-005 repair fix missing loop bound and type mismatch in accumulator
142EOF
143
144sh seed/helix/ollm_factory/architect-builder-cycle.sh \
145 --offline \
146 --bin-dir "$B/bin" \
147 --work-dir "$B/cycle/run1" \
148 --base-ck "$SD/base.ck" \
149 --merges - \
150 --s1 "$SD/S1_arith.sp" \
151 --s2 "$SD/S2_fold.sp" \
152 --s3 "$SD/S3_rewrite.sp" \
153 --s4 "$SD/S4_repair.sp" \
154 --tasks "$B/cycle/tasks.tsv" \
155 --min-floor 64
156
157printf '\nARCH_BUILD_4STRAND_GATE PASS dual_strand=5/5 selfchecks=2/2 spclip_4strand=PASS tamper=3/3 offline_cycle=PASS\n'