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/seed/helix/ollm_factory/closed-loop-gate.sh # 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 / seed / helix / ollm_factory / closed-loop-gate.sh` 192 lines ยท 11027 bytes Raw Blame History 1 #!/bin/sh 2 # seed/helix/ollm_factory/closed-loop-gate.sh 3 # 5-Stage Closed-Loop Verified Self-Play & Training Factory Gate for Omega LLM. 4 # 5 # 100% pure seeded Omega + Lean 4 (zero C, zero Python, zero CUDA on host): 6 # Stage 1: Cold-regrow 4-strand BFT seeds (or reuse regrown omc_A & omc_B_fast) + build 7 # dual-strand identical `rlvr_factory`, `arboris_train`, `bench`, `ollm`, `ollm-helix-gb10`. 8 # Stage 2: Infinite Mechanical RLVR Filter + Zero-Leakage Guarantee: 9 # - Emit 252 distinct OM-2 functions + 8 error-to-fix repair/antibody records 10 # - Compile `rlvr_oracle.om` identically across Strand A & Strand B and EXECUTE it -> 11 # proves 100% (252/252) of generated functions compile & return exact ground truth! 12 # - Run `bench check` + `bench seen train/omega-llm/tools/bench/tasks.om verified_rlvr.om` 13 # and FAIL CLOSED if even 1 generated task leaks any of the 165 frozen benchmark tasks! 14 # Stage 3: Frozen-Core `OLLMSP01` Merkle-Chained Specialist Evolution + `spclip` Multi-Helix: 15 # - Train `base (L=2) -> growpro (L=3) -> fcache -> trainfc -> spext P1_rlvr.sp` 16 # - Chain `P1_rlvr.sp (L=3) -> growpro (L=4) -> fcache -> trainfc -> spext P2_repair.sp` 17 # - Verify frozen base bit-identity, `spchaineval`/`spchainsamp` exact parity, 18 # DNA-style `spclip` entropy-gated multi-helix (`MODE=1`), AND all 3 tamper controls 19 # (`rc=60` truncated, `rc=61` 1-bit flipped payload, `rc=62` wrong base / swapped link)! 20 # Stage 4: Arboris Smart Curriculum + Preemptive Anti-Forgetting Rehearsal + Adaptive Loop Depth 21 # + Sealed Judge (`core/rsi/om/eval/`) + V2 ECDSA P-256 Promotion Ratchet (`v2_main.om`)! 22 # Stage 5: Optional `--full` runs the entire Four-Wall Loop-1 RSI + 29 Lean 4 theorems gate. 23 # 24 # Usage (from repository root on AArch64 Linux): 25 # sh seed/helix/ollm_factory/closed-loop-gate.sh [--full] 26 set -eu 27 R=$(CDPATH= cd -- "$(dirname "$0")/../../.." && pwd) 28 cd "$R" 29 30 FULL=0 31 for arg in "$@"; do 32 case "$arg" in 33 --full) FULL=1 ;; 34 *) printf 'usage: closed-loop-gate.sh [--full]\n' >&2; exit 2 ;; 35 esac 36 done 37 38 bad() { printf 'OLLM_FACTORY FAIL: %s\n' "$*" >&2; exit 1; } 39 sha() { sha256sum "$1" | cut -d' ' -f1; } 40 41 B=build/ollm-factory 42 rm -rf "$B" 43 mkdir -p "$B/bin" "$B/rlvr" "$B/spec" "$B/bench" 44 45 if [ "$FULL" = "1" ]; then 46 printf '=== [STAGE 0/5] FULL FOUR-WALL RSI + 4-STRAND BFT + 29 LEAN 4 THEOREMS ===\n' 47 sh seed/helix/rsi-loop1.sh --lean 48 OMC_A=build/cold-regrowth/omc_A 49 OMC_B=build/cold-regrowth/omc_B_fast 50 else 51 printf '=== [STAGE 1/5] REGROW STRAND A & STRAND B FROM 804B SEEDS ===\n' 52 sh seed/helix/helix-from-seeds.sh 53 OMC_A=seed/out/omc 54 OMC_B=build/helix/A_fast 55 fi 56 57 printf '\n=== [STAGE 1b/5] DUAL-STRAND BUILD OF FACTORY, ARBORIS, BENCH, OLLM & OLLM-HELIX-GB10 ===\n' 58 for item in "rlvr_factory:seed/helix/ollm_factory/rlvr_factory.om" \ 59 "rlvr_compositional:seed/helix/ollm_factory/rlvr_compositional.om" \ 60 "rlvr_idioms:seed/helix/ollm_factory/rlvr_idioms.om" \ 61 "arboris_train:seed/helix/ollm_factory/arboris_train.om" \ 62 "bench:train/omega-llm/tools/bench/bench.om"; do 63 name="${item%%:*}" 64 src="${item#*:}" 65 "$OMC_A" < "$src" > "$B/bin/${name}.A" 66 "$OMC_B" < "$src" > "$B/bin/${name}.B" 67 cmp -s "$B/bin/${name}.A" "$B/bin/${name}.B" || bad "$name diverged across strands" 68 mv "$B/bin/${name}.A" "$B/bin/${name}" 69 rm -f "$B/bin/${name}.B" 70 chmod +x "$B/bin/${name}" 71 printf 'PASS %s dual-strand identical (%s)\n' "$name" "$(sha "$B/bin/${name}")" 72 done 73 74 sh seed/helix/ollm_factory/build-ollm-jit.sh "$OMC_A" "$OMC_B" "$B/bin" 75 76 printf '\n=== [STAGE 2/5] MECHANICAL RLVR DATA & REPAIR FACTORY + ZERO-LEAKAGE AUDIT ===\n' 77 "$B/bin/rlvr_factory" corpus > "$B/rlvr/verified_rlvr.om" 78 "$B/bin/rlvr_factory" repair > "$B/rlvr/verified_repair.om" 79 "$B/bin/rlvr_factory" oracle > "$B/rlvr/rlvr_oracle.om" 80 "$B/bin/rlvr_compositional" corpus 1 | tr '\0' '\n' > "$B/rlvr/verified_comp.om" 81 "$B/bin/rlvr_compositional" oracle 1 > "$B/rlvr/comp_oracle.om" 82 "$B/bin/rlvr_idioms" corpus 1 | tr '\0' '\n' > "$B/rlvr/verified_idioms.om" 83 "$B/bin/rlvr_idioms" oracle 1 > "$B/rlvr/idioms_oracle.om" 84 "$B/bin/rlvr_factory" teacher 85 86 # Mechanically compile & execute ALL synthesized functions across BOTH strands! 87 "$OMC_A" < "$B/rlvr/rlvr_oracle.om" > "$B/rlvr/rlvr_oracle.A" 88 "$OMC_B" < "$B/rlvr/rlvr_oracle.om" > "$B/rlvr/rlvr_oracle.B" 89 cmp -s "$B/rlvr/rlvr_oracle.A" "$B/rlvr/rlvr_oracle.B" || bad "rlvr_oracle diverged across strands" 90 chmod +x "$B/rlvr/rlvr_oracle.A" 91 "$B/rlvr/rlvr_oracle.A" 92 93 "$OMC_A" < "$B/rlvr/comp_oracle.om" > "$B/rlvr/comp_oracle.A" 94 "$OMC_B" < "$B/rlvr/comp_oracle.om" > "$B/rlvr/comp_oracle.B" 95 cmp -s "$B/rlvr/comp_oracle.A" "$B/rlvr/comp_oracle.B" || bad "comp_oracle diverged across strands" 96 chmod +x "$B/rlvr/comp_oracle.A" 97 "$B/rlvr/comp_oracle.A" 98 99 "$OMC_A" < "$B/rlvr/idioms_oracle.om" > "$B/rlvr/idioms_oracle.A" 100 "$OMC_B" < "$B/rlvr/idioms_oracle.om" > "$B/rlvr/idioms_oracle.B" 101 cmp -s "$B/rlvr/idioms_oracle.A" "$B/rlvr/idioms_oracle.B" || bad "idioms_oracle diverged across strands" 102 chmod +x "$B/rlvr/idioms_oracle.A" 103 "$B/rlvr/idioms_oracle.A" 104 FN_CNT=$(cat "$B/rlvr/verified_rlvr.om" "$B/rlvr/verified_comp.om" "$B/rlvr/verified_idioms.om" | grep -c '^fn solve ') 105 printf 'PASS Mechanical RLVR Oracles: %s verified OM-2 records compiled identically across both strands & 100%% executed PASS\n' "$FN_CNT" 106 107 # Frozen benchmark integrity + ZERO-LEAKAGE audit across ALL 3 RLVR generators! 108 "$B/bin/bench" check train/omega-llm/tools/bench/tasks.om train/omega-llm/tools/bench/expect.txt "$OMC_A" "$B/bench" 109 cat "$B/rlvr/verified_rlvr.om" "$B/rlvr/verified_comp.om" "$B/rlvr/verified_idioms.om" > "$B/rlvr/all_rlvr_gate.om" 110 SEEN_OUT=$("$B/bin/bench" seen train/omega-llm/tools/bench/tasks.om "$B/rlvr/all_rlvr_gate.om") 111 printf '%s\n' "$SEEN_OUT" 112 case "$SEEN_OUT" in 113 *"seen 0"*) printf 'PASS Zero-Leakage Guarantee: 0 of 165 frozen benchmark tasks appear in %s RLVR records!\n' "$FN_CNT" ;; 114 *) bad "RLVR corpus leaked a frozen benchmark task: $SEEN_OUT" ;; 115 esac 116 117 printf '\n=== [STAGE 3/5] FROZEN-CORE OLLMSP01 MERKLE SPECIALIST CHAIN + SPCLIP + TAMPER CONTROLS ===\n' 118 OLLM="$B/bin/ollm" 119 SD="$B/spec" 120 # Init compact base byte-level checkpoint (V=256, T=16, D=32, H=2, F=64, L=2, B=2) 121 "$OLLM" init "$SD/base.ck" 256 16 32 2 64 2 2 42 20 5000 1 >/dev/null 122 # Split verified_rlvr.om into train / heldout slices (bytes) 123 cp "$B/rlvr/verified_rlvr.om" "$SD/rlvr_train.bin" 124 cp "$B/rlvr/verified_repair.om" "$SD/repair_train.bin" 125 head -c 256 "$B/rlvr/verified_rlvr.om" > "$SD/held.bin" 126 127 BASE_EVAL=$("$OLLM" eval "$SD/base.ck" "$SD/held.bin" 4) 128 printf ' Base L=2 eval: %s\n' "$BASE_EVAL" 129 130 # Specialist P1 (OM-2 RLVR Systems Specialist, L=2 -> 3 via growpro + fcache + trainfc + spext) 131 "$OLLM" growpro "$SD/base.ck" "$SD/s1.ck" 3 40 5000 132 S1_STEP0=$("$OLLM" eval "$SD/s1.ck" "$SD/held.bin" 4) 133 [ "$BASE_EVAL" = "$S1_STEP0" ] || bad "growpro step-0 not bit-identical to base ($BASE_EVAL vs $S1_STEP0)" 134 "$OLLM" fcache "$SD/base.ck" "$SD/rlvr_train.bin" 16 "$SD/s1.hc" 135 "$OLLM" trainfc "$SD/s1.ck" "$SD/s1.hc" 8 4 2 2 136 "$OLLM" spext "$SD/base.ck" "$SD/s1.ck" "$SD/P1_rlvr.sp" 137 P1_EVAL=$("$OLLM" speval "$SD/base.ck" "$SD/P1_rlvr.sp" "$SD/held.bin" 4) 138 S1_EVAL=$("$OLLM" eval "$SD/s1.ck" "$SD/held.bin" 4) 139 [ "$(printf '%s' "$P1_EVAL" | awk '{print $3,$4,$5}')" = "$(printf '%s' "$S1_EVAL" | awk '{print $3,$4,$5}')" ] || bad "speval P1 mismatch ($P1_EVAL vs $S1_EVAL)" 140 printf ' PASS Specialist P1 (OM-2 RLVR, L=2->3, %s B): %s\n' "$(wc -c < "$SD/P1_rlvr.sp" | tr -d ' ')" "$P1_EVAL" 141 142 # Specialist P2 (Helix Repair Specialist chained onto base + P1 -> L=3->4 Merkle chain!) 143 "$OLLM" growpro "$SD/s1.ck" "$SD/s2.ck" 4 40 5000 144 "$OLLM" fcache "$SD/s1.ck" "$SD/repair_train.bin" 8 "$SD/s2.hc" 145 "$OLLM" trainfc "$SD/s2.ck" "$SD/s2.hc" 14 6 3 2 146 "$OLLM" spext "$SD/s1.ck" "$SD/s2.ck" "$SD/P2_repair.sp" 147 CH_EVAL=$("$OLLM" spchaineval "$SD/base.ck" "$SD/held.bin" 4 - 2 "$SD/P1_rlvr.sp" "$SD/P2_repair.sp") 148 S2_EVAL=$("$OLLM" eval "$SD/s2.ck" "$SD/held.bin" 4) 149 [ "$(printf '%s' "$CH_EVAL" | awk '{print $3,$4,$5}')" = "$(printf '%s' "$S2_EVAL" | awk '{print $3,$4,$5}')" ] || bad "spchaineval P1->P2 mismatch ($CH_EVAL vs $S2_EVAL)" 150 printf ' PASS Merkle Chain P1->P2 (L=2->3->4, %s B): %s\n' "$(wc -c < "$SD/P2_repair.sp" | tr -d ' ')" "$CH_EVAL" 151 152 # Parallel Specialist P1b (Repair branch off base) + DNA-style entropy-gated multi-helix `spclip` 153 "$OLLM" growpro "$SD/base.ck" "$SD/s1b.ck" 3 40 5000 154 "$OLLM" fcache "$SD/base.ck" "$SD/repair_train.bin" 8 "$SD/s1b.hc" 155 "$OLLM" trainfc "$SD/s1b.ck" "$SD/s1b.hc" 8 4 2 2 156 "$OLLM" spext "$SD/base.ck" "$SD/s1b.ck" "$SD/P1b_helix.sp" 157 "$OLLM" spclip "$SD/base.ck" 1 "fn solve " 16 0 42 - 2 500 2 "$SD/P1_rlvr.sp" "$SD/P2_repair.sp" 500 1 "$SD/P1b_helix.sp" > "$SD/spclip.out" 158 printf ' PASS DNA Multi-Helix spclip (MODE=1 entropy-gated, %s bytes emitted)\n' "$(wc -c < "$SD/spclip.out" | tr -d ' ')" 159 160 # Negative tamper controls on OLLMSP01 Merkle chain (rc=60, rc=61, rc=62) 161 head -c 32 "$SD/P1_rlvr.sp" > "$SD/trunc.sp" 162 rc=0; "$OLLM" speval "$SD/base.ck" "$SD/trunc.sp" "$SD/held.bin" 4 >/dev/null 2>&1 || rc=$? 163 [ "$rc" = "60" ] || bad "truncated pack expected rc=60 got $rc" 164 165 cp "$SD/P2_repair.sp" "$SD/flip.sp" 166 printf '\377' | dd of="$SD/flip.sp" bs=1 seek=64 count=1 conv=notrunc 2>/dev/null 167 rc=0; "$OLLM" spchaineval "$SD/base.ck" "$SD/held.bin" 4 - 2 "$SD/P1_rlvr.sp" "$SD/flip.sp" >/dev/null 2>&1 || rc=$? 168 [ "$rc" = "61" ] || bad "1-bit flipped pack expected rc=61 got $rc" 169 170 rc=0; "$OLLM" spchaineval "$SD/base.ck" "$SD/held.bin" 4 - 2 "$SD/P2_repair.sp" "$SD/P1_rlvr.sp" >/dev/null 2>&1 || rc=$? 171 [ "$rc" = "62" ] || bad "swapped Merkle link order expected rc=62 got $rc" 172 printf ' PASS OLLMSP01 Merkle tamper controls: truncated=rc60 flipped=rc61 swapped_link=rc62\n' 173 174 printf '\n=== [STAGE 4/5] ARBORIS CURRICULUM/REHEARSAL/DEPTH + SEALED RSI V2 P-256 RATCHET ===\n' 175 "$B/bin/arboris_train" 176 177 # Dual-strand Sealed Judge evaluator + ECDSA P-256 promotion ratchet 178 EVAL_SRCS="si/directives/om2.om core/rsi/om/eval/evaluator.om om/tls/sha2.om core/rsi/om/eval/canary.om core/rsi/om/eval/rollback.om core/rsi/om/eval/eval_test.om" 179 cat $EVAL_SRCS | "$OMC_A" > "$B/bin/rsi_eval_test.A" 180 cat $EVAL_SRCS | "$OMC_B" > "$B/bin/rsi_eval_test.B" 181 cmp -s "$B/bin/rsi_eval_test.A" "$B/bin/rsi_eval_test.B" || bad "rsi_eval_test diverged" 182 chmod +x "$B/bin/rsi_eval_test.A" 183 "$B/bin/rsi_eval_test.A" 184 185 P256_GATE_SRCS="core/rsi/om/p256/sha256.om core/rsi/om/p256/p256.om core/rsi/om/governance/receipt_v2.om core/rsi/om/governance/v2_main.om" 186 cat $P256_GATE_SRCS | "$OMC_A" > "$B/bin/rsi_v2_gate.A" 187 cat $P256_GATE_SRCS | "$OMC_B" > "$B/bin/rsi_v2_gate.B" 188 cmp -s "$B/bin/rsi_v2_gate.A" "$B/bin/rsi_v2_gate.B" || bad "rsi_v2_gate diverged" 189 chmod +x "$B/bin/rsi_v2_gate.A" 190 "$B/bin/rsi_v2_gate.A" selfcheck 191 192 printf '\nOLLM_CLOSED_LOOP_FACTORY PASS rlvr_records=%s seen=0 merkle_links=2 spclip=PASS tamper_controls=3/3 arboris_train=PASS p256_ratchet=PASS ollm_helix_gb10=DUAL_STRAND_STATIC\n' "$FN_CNT"