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/tests/allen/run.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 / tests / allen / run.sh` 244 lines ยท 15495 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 3 # Copyright 2026 Drake Stapleton (AIEN / aien-dev) 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 # ALLEN v0 host gates (spec/allen.md; ARCH-0035 PROPOSED, OS-0018 PROPOSED). 18 # Usage (from `make test-allen`): ALLEN_TOOL= ALLEN_BIND_OBJ= 19 # ALLEN_MAIN_OBJ= ALLEN_OUT= sh tests/allen/run.sh 20 # 21 # Every gate is a host test: processes, files, the resident World. None of 22 # this is hardware qualification, an OS reboot, or a machine migration; the 23 # receipt says so. The negative control (G6) is the falsifier: if a standing 24 # intent already survived a restart through the Cortex journal alone, ALLEN 25 # would be redundant and this script would FAIL it. 26 # 27 # Exit 0 = every gate PASS. Writes $ALLEN_OUT/receipt.json (host facts only; 28 # the evidence receipt under evidence/ALLEN/ is written from it by the 29 # qualifying run, with the commit bound). 30 set -u 31 T=${ALLEN_TOOL:?ALLEN_TOOL} 32 BIND=${ALLEN_BIND_OBJ:?ALLEN_BIND_OBJ} 33 MAIN=${ALLEN_MAIN_OBJ:?ALLEN_MAIN_OBJ} 34 OUT=${ALLEN_OUT:?ALLEN_OUT} 35 case $T in /*) ;; *) T=$(pwd)/$T ;; esac 36 rm -rf "$OUT" && mkdir -p "$OUT" || exit 2 37 LOG=$OUT/log.txt 38 : > "$LOG" 39 FAILS=0 40 GATES="" 41 42 AGENT_A=`a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1` 43 AGENT_B=`b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2` 44 ROOT_A=`0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a` 45 PROV=`c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3` 46 MODEL_X=`1111111111111111111111111111111111111111111111111111111111111111` 47 MODEL_Y=`2222222222222222222222222222222222222222222222222222222222222222` 48 49 say() { printf '%s\n' "$*" | tee -a "$LOG"; } 50 run() { # run NAME cmd... : stdout+stderr to $OUT/NAME.txt, rc in $RC 51 n=$1; shift 52 "$@" > "$OUT/$n.txt" 2>&1 53 RC=$? 54 { echo "## $n (rc=$RC)"; cat "$OUT/$n.txt"; } >> "$LOG" 55 return 0 56 } 57 field() { # field FILE KEY -> value after 'KEY ' on the first matching line 58 sed -n "s/^.*$2 \([^ ]*\).*$/\1/p" "$1" | head -n 1 59 } 60 gate() { # gate ID ok(0/1) "what" 61 if [ "$2" -eq 0 ]; then say "ALLEN-$1 PASS: $3"; GATES="$GATES$1=PASS " 62 else say "ALLEN-$1 FAIL: $3"; FAILS=$((FAILS + 1)); GATES="$GATES$1=FAIL "; fi 63 } 64 patch_byte() { # patch_byte IN OUT OFFSET HEXBYTE 65 cp "$1" "$2" && printf "\\$(printf '%03o' "0x$4")" | dd of="$2" bs=1 seek="$3" conv=notrunc 2>/dev/null 66 } 67 sha() { sha256sum "$1" | cut -c1-64; } 68 69 # ---- fixtures --------------------------------------------------------------- 70 run seed1 "$T" seed-journal "$OUT/j1.cx" 1 71 run seed2 "$T" seed-journal "$OUT/j2.cx" 2 72 L1=$(field "$OUT/seed1.txt" lineage); L2=$(field "$OUT/seed2.txt" lineage) 73 [ -n "$L1" ] && [ -n "$L2" ] && [ "$L1" != "$L2" ] || { say "fixture: two distinct journal lineages needed"; exit 2; } 74 run make1 "$T" make -o "$OUT/s1.bin" --agent $AGENT_A --root $ROOT_A --prov $PROV --intent 7,1000 --cortex "$OUT/j1.cx" 75 run make1b "$T" make -o "$OUT/s1b.bin" --agent $AGENT_A --root $ROOT_A --prov $PROV --intent 7,1000 --cortex "$OUT/j1.cx" 76 run make2 "$T" make -o "$OUT/s2.bin" --agent $AGENT_B --root $ROOT_A --prov $PROV --intent 7,1000 --cortex "$OUT/j1.cx" 77 run makeU "$T" make -o "$OUT/su.bin" --agent $AGENT_A --root $ROOT_A --prov $PROV --intent 7,1000 78 run makeS "$T" make -o "$OUT/ss.bin" --agent $AGENT_A --root $ROOT_A --prov $PROV --intent 7,1000 --intent 7,2000 --cortex "$OUT/j1.cx" 79 S1=$(field "$OUT/make1.txt" subject); S1B=$(field "$OUT/make1b.txt" subject); S2=$(field "$OUT/make2.txt" subject) 80 I1=$(sed -n 's/^ALLEN intent \([0-9a-f]*\) .*/\1/p' "$OUT/make1.txt" | head -n 1) 81 82 # ---- G1 identity binding ---------------------------------------------------- 83 # The subject object carries the LogicalAgentId; its id is content-addressed 84 # (same content, same id; another agent, another id); the rig binds the 85 # World's external subject number to that agent, not to a model or a process. 86 run g1 "$T" publish "$OUT/s1.bin" "$OUT/j1.cx" 87 ok=1 88 [ "$RC" -eq 0 ] && [ -n "$S1" ] && [ "$S1" = "$S1B" ] && [ "$S1" != "$S2" ] && 89 [ "$(field "$OUT/g1.txt" 'ALLEN agent')" = "$AGENT_A" ] && 90 grep -q "^ALLEN binding external_subject [0-9]* agent $AGENT_A sequence 1$" "$OUT/g1.txt" && 91 [ "$(field "$OUT/g1.txt" 'ALLEN subject')" = "$S1" ] && ok=0 92 gate G1 $ok "subject id content-addressed ($S1), bound to agent $AGENT_A; another agent gives another id" 93 # Foreign-agent and foreign-root refusal at the Store resolver is the aienos 94 # half of G1 (test_continuity_subject: t_resolve); recorded, not re-run here. 95 96 # ---- G2 restart persistence (process level) --------------------------------- 97 # Publish, let the process exit, publish again from a fresh process: the same 98 # subject id, the same intent id and the same goal are restored, and the 99 # organism's AIEN faculty wakes again on its own (assess activations 1). 100 run g2 "$T" publish "$OUT/s1.bin" "$OUT/j1.cx" 101 ok=1 102 [ "$RC" -eq 0 ] && [ "$(field "$OUT/g2.txt" 'ALLEN subject')" = "$S1" ] && 103 grep -q "^ALLEN publish intent $I1 -> EXTERNAL crumb [0-9]*$" "$OUT/g2.txt" && 104 grep -q "^ALLEN goal object seq 1 regime 7 target_ns 1000 " "$OUT/g2.txt" && 105 grep -q "^AIEN assess activations 1 in_episode_of_last_publish 1 assessment goal_seq 1 " "$OUT/g2.txt" && 106 grep -q "^ALLEN goal object seq 1 regime 7 target_ns 1000 " "$OUT/g1.txt" && ok=0 107 gate G2 $ok "second process restores subject $S1, intent $I1, goal regime 7 / 1000 ns; AIEN assess woke once" 108 # Store-level restart (two processes over one sealed Store image) is the 109 # aienos gate CK_CONTINUITY_SUBJECT_RESTART; recorded, not re-run here. 110 111 # ---- G3 memory binding ------------------------------------------------------ 112 # Fail closed: a subject only acts with the Cortex journal whose genesis record 113 # it names. Another journal, an unbound subject, and an empty journal are refused 114 # before anything is published. 115 run g3a "$T" publish "$OUT/s1.bin" "$OUT/j2.cx"; a=$RC 116 run g3b "$T" publish "$OUT/su.bin" "$OUT/j1.cx"; b=$RC 117 run g3c "$T" publish "$OUT/s1.bin" "$OUT/j3-empty.cx"; c=$RC 118 ok=1 119 [ "$a" -eq 3 ] && grep -q "Cortex lineage mismatch" "$OUT/g3a.txt" && ! grep -q "EXTERNAL crumb" "$OUT/g3a.txt" && 120 [ "$b" -eq 3 ] && grep -q "no Cortex lineage binding" "$OUT/g3b.txt" && 121 [ "$c" -eq 3 ] && grep -q "holds no genesis record" "$OUT/g3c.txt" && 122 grep -q "^ALLEN memory BOUND lineage $L1 " "$OUT/g1.txt" && ok=0 123 gate G3 $ok "bound journal accepted (lineage $L1); other journal, unbound subject, empty journal refused before publish" 124 125 # ---- G4 model independence -------------------------------------------------- 126 # Two different model digests and no model at all: identical subject bytes, 127 # identical subject id, identical intent id, identical goal. The object has no 128 # model field (continuity_subject.h); the model is provenance printed by the 129 # host tool and stored nowhere. 130 h0=$(sha "$OUT/s1.bin") 131 run g4x "$T" publish "$OUT/s1.bin" "$OUT/j1.cx" --model $MODEL_X; x=$RC 132 run g4y "$T" publish "$OUT/s1.bin" "$OUT/j1.cx" --model $MODEL_Y; y=$RC 133 h1=$(sha "$OUT/s1.bin") 134 ok=1 135 [ "$x" -eq 0 ] && [ "$y" -eq 0 ] && [ "$h0" = "$h1" ] && 136 [ "$(field "$OUT/g4x.txt" 'ALLEN subject')" = "$S1" ] && [ "$(field "$OUT/g4y.txt" 'ALLEN subject')" = "$S1" ] && 137 grep -q "^ALLEN publish intent $I1 " "$OUT/g4x.txt" && grep -q "^ALLEN publish intent $I1 " "$OUT/g4y.txt" && 138 grep -q "^ALLEN model $MODEL_X (provenance only" "$OUT/g4x.txt" && 139 grep -q "^ALLEN model none (no model required)" "$OUT/g2.txt" && 140 ! grep -q "$MODEL_X" "$OUT/s1.bin" && ok=0 141 gate G4 $ok "models X, Y and none give the same subject, intent and goal; object bytes unchanged ($h0)" 142 143 # ---- G5 no authority, no orchestrator (R16) --------------------------------- 144 # allen_bind.o: no thread, wait, clock, signal, reaction registration or 145 # capability mint symbols. allen.o (the rig) may build the World and mint for 146 # the AIEN faculty like R11's test does, but has no thread, timer, signal or 147 # reaction of its own: it publishes and observes. 148 need_absent_bind='pthread_create|^poll$|epoll|^select$|^sleep$|nanosleep|usleep|clock_|timer_|^signal$|sigaction|alarm|rx_world_add_reaction|rx_world_resume|aienos_cap_mint|rx_aien_|rx_world_publish' 149 need_absent_main='pthread_create|^poll$|epoll|^select$|^sleep$|nanosleep|usleep|clock_|timer_|^signal$|sigaction|alarm|rx_world_add_reaction|rx_world_resume|fork|execv|system' 150 ub=$(nm -u "$BIND" | awk '{print $2}' | grep -E "$need_absent_bind" || true) 151 um=$(nm -u "$MAIN" | awk '{print $2}' | grep -E "$need_absent_main" || true) 152 # Source: no loop in allen_bind.c except the fixed byte loops; no run_until/max_turns anywhere. 153 lp=$(grep -nE 'while|for *\(' src/allen/allen_bind.c | grep -vE 'i < n|i >= 0|2 \* i' || true) 154 mt=$(grep -nEi 'max_turns|max_steps|run_until|orchestrat|heartbeat|dispatch' src/allen/allen_bind.c src/allen/allen_bind.h tools/allen.c || true) 155 ok=1 156 [ -z "$ub" ] && [ -z "$um" ] && [ -z "$lp" ] && [ -z "$mt" ] && ok=0 157 [ -n "$ub$um$lp$mt" ] && say "G5 offenders: bind[$ub] main[$um] loops[$lp] words[$mt]" 158 gate G5 $ok "allen_bind.o and allen.o carry no thread/wait/timer/signal/reaction/mint symbols; no loop words in source" 159 # The cross-repo loop inventory (R16-G2, make test-r16-inventory) is run by 160 # the qualifying session on the committed tree; its result is in the receipt. 161 162 # ---- G6 negative control (the falsifier) ------------------------------------ 163 # A fresh journal; publish once (the journal records the EXTERNAL crumb and 164 # the AIEN activations); start the rig again WITHOUT ALLEN: if the World holds 165 # a goal, the intent survived through memory alone and ALLEN is redundant -> 166 # FAIL ALLEN. Then publish again: ALLEN restores it. 167 run seed6 "$T" seed-journal "$OUT/j6.cx" 6 168 run make6 "$T" make -o "$OUT/s6.bin" --agent $AGENT_A --root $ROOT_A --prov $PROV --intent 7,1000 --cortex "$OUT/j6.cx" 169 run g6a "$T" publish "$OUT/s6.bin" "$OUT/j6.cx"; a=$RC 170 run g6b "$T" probe "$OUT/j6.cx"; b=$RC 171 run g6c "$T" publish "$OUT/s6.bin" "$OUT/j6.cx"; c=$RC 172 rec_a=$(field "$OUT/g6a.txt" journal_records); rec_b=$(field "$OUT/g6b.txt" journal_records) 173 goals_b=$(field "$OUT/g6b.txt" goals_in_world) 174 ok=1 175 [ "$a" -eq 0 ] && [ "$b" -eq 0 ] && [ "$c" -eq 0 ] && 176 [ "${rec_a:-0}" -gt 1 ] && [ "$rec_b" = "$rec_a" ] && [ "$goals_b" = "0" ] && 177 grep -q "^ALLEN probe journal_records [0-9]* goals_in_world 0 goal_seq 0 assessment_goal_seq 0$" "$OUT/g6b.txt" && 178 grep -q "^ALLEN goal object seq 1 regime 7 target_ns 1000 " "$OUT/g6c.txt" && 179 grep -q "^ALLEN published 1 goals_in_world 1 " "$OUT/g6c.txt" && ok=0 180 if [ "$goals_b" != "0" ]; then say "NEGATIVE CONTROL BROKEN: intent survived without ALLEN (goals_in_world=$goals_b); ALLEN would be redundant"; fi 181 gate G6 $ok "without ALLEN the restarted World holds 0 goals although the journal holds $rec_b records; with ALLEN the goal is back" 182 183 # ---- format refusals: unknown version, corruption, truncation, trailing ------ 184 patch_byte "$OUT/s1.bin" "$OUT/r-ver.bin" 8 01 # format_version u16 -> 1 185 patch_byte "$OUT/s1.bin" "$OUT/r-agent.bin" 48 ff # agent byte -> intent id no longer derives 186 patch_byte "$OUT/s1.bin" "$OUT/r-intent.bin" 200 00 # intent id byte 187 head -c 150 "$OUT/s1.bin" > "$OUT/r-trunc.bin" 188 { cat "$OUT/s1.bin"; printf 'x'; } > "$OUT/r-trail.bin" 189 patch_byte "$OUT/s1.bin" "$OUT/r-origin.bin" 184 09 # unknown origin 190 run rv "$T" inspect "$OUT/r-ver.bin"; v=$RC 191 run ra "$T" inspect "$OUT/r-agent.bin"; a=$RC 192 run ri "$T" inspect "$OUT/r-intent.bin"; i=$RC 193 run rt "$T" inspect "$OUT/r-trunc.bin"; t=$RC 194 run rl "$T" inspect "$OUT/r-trail.bin"; l=$RC 195 run ro "$T" inspect "$OUT/r-origin.bin"; o=$RC 196 run rp "$T" publish "$OUT/r-ver.bin" "$OUT/j1.cx"; p=$RC 197 ok=1 198 [ "$v" -eq 3 ] && grep -q "unsupported continuity format version" "$OUT/rv.txt" && 199 [ "$a" -eq 3 ] && grep -q "intent id does not derive from its content" "$OUT/ra.txt" && 200 [ "$i" -eq 3 ] && grep -q "intent id does not derive from its content" "$OUT/ri.txt" && 201 [ "$t" -eq 3 ] && grep -q "truncated object\|body length mismatch" "$OUT/rt.txt" && 202 [ "$l" -eq 3 ] && grep -q "trailing bytes\|body length mismatch" "$OUT/rl.txt" && 203 [ "$o" -eq 3 ] && grep -q "unknown subject origin" "$OUT/ro.txt" && 204 [ "$p" -eq 3 ] && ! grep -q "EXTERNAL crumb" "$OUT/rp.txt" && ok=0 205 gate FORMAT $ok "unknown version, corrupted agent/intent, truncation, trailing bytes, unknown origin: all refused, nothing published" 206 207 # ---- replay: the same bytes are the same subject, never a second one -------- 208 # (The Store refuses a second genesis for one root: aienos t_sealed_store.) 209 ok=1 210 [ "$(field "$OUT/g1.txt" 'ALLEN subject')" = "$(field "$OUT/g2.txt" 'ALLEN subject')" ] && 211 [ "$(field "$OUT/g1.txt" 'ALLEN subject')" = "$(field "$OUT/g4x.txt" 'ALLEN subject')" ] && 212 [ "$($T digest "$OUT/s1.bin")" = "$S1" ] && [ "$($T digest "$OUT/s1b.bin")" = "$S1" ] && ok=0 213 gate REPLAY $ok "replaying the object yields the same subject id $S1 every time; no second subject appears" 214 215 # ---- supersession: one ACTIVE intent per slot; the older one is SUPERSEDED -- 216 run sup "$T" publish "$OUT/ss.bin" "$OUT/j1.cx"; s=$RC 217 ok=1 218 [ "$s" -eq 0 ] && [ "$(grep -c '^ALLEN intent ' "$OUT/sup.txt")" = "2" ] && 219 grep -q "^ALLEN intent [0-9a-f]* kind 1 state 3 since 1 regime 7 target_ns 1000$" "$OUT/sup.txt" && 220 grep -q "^ALLEN intent [0-9a-f]* kind 1 state 1 since 1 regime 7 target_ns 2000$" "$OUT/sup.txt" && 221 grep -q "^ALLEN published 1 goals_in_world 1 " "$OUT/sup.txt" && 222 grep -q "^ALLEN goal object seq 1 regime 7 target_ns 2000 " "$OUT/sup.txt" && ok=0 223 gate SUPERSEDE $ok "two intents in one slot: the old one is SUPERSEDED, only the new one (2000 ns) is published" 224 225 # ---- subject mismatch: another agent's object is another subject ------------ 226 run mm "$T" publish "$OUT/s2.bin" "$OUT/j1.cx"; m=$RC 227 ok=1 228 [ "$m" -eq 0 ] && [ "$(field "$OUT/mm.txt" 'ALLEN subject')" = "$S2" ] && [ "$S2" != "$S1" ] && 229 grep -q "^ALLEN binding external_subject [0-9]* agent $AGENT_B " "$OUT/mm.txt" && ok=0 230 gate MISMATCH $ok "agent B's object binds as subject $S2, never as $S1 (Store-level foreign-agent refusal: aienos t_resolve)" 231 232 # ---- receipt (host facts; the evidence receipt binds the commit) ------------ 233 { 234 printf '{\n "schema": "AIEN_ALLEN_HOST_GATES_V0",\n' 235 printf ' "outcome": "%s",\n' "$([ $FAILS -eq 0 ] && echo PASS || echo FAIL)" 236 printf ' "gates": "%s",\n' "$(echo $GATES)" 237 printf ' "subject_id": "%s",\n "intent_id": "%s",\n "lineage": "%s",\n' "$S1" "$I1" "$L1" 238 printf ' "negative_control": {"journal_records_after_publish": %s, "goals_without_allen": %s},\n' "${rec_b:-null}" "${goals_b:-null}" 239 printf ' "scope": "host processes and files on one machine; not hardware qualification, not an OS reboot, not a machine migration",\n' 240 printf ' "tool_sha256": "%s"\n}\n' "$(sha "$T")" 241 } > "$OUT/receipt.json" 242 if [ $FAILS -eq 0 ]; then say "test-allen: PASS (G1 identity, G2 restart, G3 memory, G4 model independence, G5 no authority, G6 negative control, format, replay, supersession, mismatch)"; exit 0; fi 243 say "test-allen: FAIL ($FAILS gate(s)); see $LOG" 244 exit 1