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/tools/trit/test.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 / tools / trit / test.sh` 324 lines ยท 27378 bytes Raw Blame History 1 #!/bin/sh 2 # test.sh -- fixture tests for tools/trit. 3 # Usage: ./test.sh from tools/trit, or sh tools/trit/test.sh from the repo root. 4 # BIN defaults to /build/trit/trit if present, else trit.bin beside this script. 5 # CBIN defaults to /build/codebook/codebook, else codebook.bin beside tools/codebook. 6 # Every case builds its own DIR/inbox under $FIX/ (kept as the fixture), runs the binary, and 7 # compares stdout, stderr and exit status exactly. Expected tokens and cursor hashes come from 8 # coreutils (head, wc, sha256sum), not from the program. 9 set -u 10 HERE=$(CDPATH= cd -- "$(dirname "$0")" && pwd) 11 ROOT=$(CDPATH= cd -- "$HERE/../.." && pwd) 12 if [ -z "${BIN:-}" ]; then 13 if [ -x "$ROOT/build/trit/trit" ]; then BIN=$ROOT/build/trit/trit 14 elif [ -x "$HERE/trit.bin" ]; then BIN=$HERE/trit.bin 15 else echo "test.sh: no trit binary ($ROOT/build/trit/trit or $HERE/trit.bin)" >&2; exit 2 16 fi 17 fi 18 case $BIN in /*) ;; *) BIN=$(pwd)/$BIN ;; esac 19 if [ -z "${CBIN:-}" ]; then 20 if [ -x "$ROOT/build/codebook/codebook" ]; then CBIN=$ROOT/build/codebook/codebook 21 elif [ -x "$HERE/../codebook/codebook.bin" ]; then CBIN=$HERE/../codebook/codebook.bin 22 else echo "test.sh: no codebook binary" >&2; exit 2 23 fi 24 fi 25 CBT=${CBT:-$HERE/../codebook/codebook.tsv} 26 FIX=${FIX:-${TMPDIR:-/tmp}/trit-fixtures.$$} 27 rm -rf "$FIX"; mkdir -p "$FIX"; chmod 700 "$FIX" 28 KEY=$FIX/.key; KEY2=$FIX/.key2; (umask 077; head -c 32 /dev/urandom > "$KEY"; head -c 32 /dev/urandom > "$KEY2") 29 chmod 600 "$KEY" "$KEY2" 30 printf 'BIN %s\nFIX %s\n' "$BIN" "$FIX" 31 pass=0; fail=0; skip=0 32 ok() { pass=$((pass+1)); printf 'PASS %s\n' "$1"; } 33 no() { fail=$((fail+1)); printf 'FAIL %s: %s\n' "$1" "$2"; } 34 skip() { skip=$((skip+1)); printf 'SKIP %s\n' "$1"; } 35 # ELF e_machine: 183=AArch64, 62=x86-64. Prefer native strace -f when the binary runs natively; 36 # otherwise qemu-user -strace if qemu is on PATH; else SKIP (never PASS). 37 elf_em() { od -An -N2 -j 18 -t u2 "$1" | tr -d ' \n'; } 38 host_em() { case "$(uname -m)" in aarch64|arm64) echo 183;; x86_64|amd64) echo 62;; *) echo 0;; esac; } 39 pick_tracer() { 40 TRC= 41 if [ "$(elf_em "$1")" = "$(host_em)" ] && command -v strace >/dev/null 2>&1; then 42 TRC=strace 43 elif command -v qemu-aarch64-static >/dev/null 2>&1; then 44 TRC=$(command -v qemu-aarch64-static) 45 elif command -v qemu-aarch64 >/dev/null 2>&1; then 46 TRC=$(command -v qemu-aarch64) 47 fi 48 } 49 # Every fixture gets DIR/codebook/{codebook.tsv,key} (a fresh random test key, never printed). 50 new() { D="$FIX/$1"; mkdir -p "$D/inbox" "$D/codebook"; cp "$CBT" "$D/codebook/codebook.tsv"; cp "$KEY" "$D/codebook/key"; chmod 600 "$D/codebook/key"; C=$1; LANE=n; TO=a; } 51 L() { printf '%s|%s|%s|%s|-\n' "$1" "$2" "$3" "$4"; } 52 # S TS SENDER TAG TEXT COUNTER DIGITS [KEYFILE]: a 6-field line signed as ocb2 (lane=$LANE, to=$TO). 53 sg() { printf '%s|%s|%s|%s|%s|%s|%s|%s|%s\n' "${LANE:-n}" "$1" "$2" "${TO:-a}" "$3" "$4" "-" "$5" "$6" | "$CBIN" sign "$CBT" "${7:-$KEY}"; } 54 S() { printf '%s|%s|%s|%s|%s|%s|%s\n' "$1" "$2" "${TO:-a}" "$3" "$4" "-" "$(sg "$1" "$2" "$3" "$4" "$5" "$6" "${7:-}")"; } 55 Se() { LANE=e S "$@"; LANE=n; } 56 HDR='# Inbox: a 57 One line per note: `YYYY-MM-DDTHH:MM|from|tag|text|ref`.' 58 # tokf LANE FILE: L: 59 tokf() { 60 nl=$(tr -dc '\n' < "$2" | wc -c | tr -d ' ') 61 off=$(head -n "$nl" "$2" | wc -c | tr -d ' ') 62 h=$(head -c "$off" "$2" | sha256sum | cut -c1-64) 63 printf '%s%s:%s' "$1" "$off" "$h" 64 } 65 # ex LANE BOT TRIT: the expected output line (nothing for 0: silence) 66 ex() { 67 if [ "$3" = 0 ]; then return; fi 68 if [ "$1" = e ]; then f="$D/inbox/$2.emergency.md"; else f="$D/inbox/$2.md"; fi 69 printf '%s %s %s' "$2" "$3" "$(tokf "$1" "$f")" 70 } 71 # run NAME EXPECT_STDOUT EXPECT_STDERR ARGS... (exit 0 when a line is printed, 1 when silent) 72 run() { 73 n=$1; eo=$2; ee=$3; shift 3 74 wrc=0; [ -z "$eo" ] && wrc=1 75 o=$("$BIN" "$D" "$@" 2>"$D/.err"); rc=$?; e=$(cat "$D/.err"); rm -f "$D/.err" 76 if [ "$rc" = "$wrc" ] && [ "$o" = "$eo" ] && [ "$e" = "$ee" ]; then ok "$C/$n"; else no "$C/$n" "rc=$rc out=[$o] err=[$e] want=$wrc [$eo] [$ee]"; fi 77 } 78 # refuse NAME RC ARGS...: expects that exit status, no stdout, and cursor files unchanged 79 refuse() { 80 n=$1; want=$2; shift 2 81 before=$(cat "$D"/inbox/*.cur 2>/dev/null | sha256sum) 82 o=$("$BIN" "$D" "$@" 2>/dev/null); rc=$? 83 after=$(cat "$D"/inbox/*.cur 2>/dev/null | sha256sum) 84 if [ "$rc" = "$want" ] && [ -z "$o" ] && [ "$before" = "$after" ]; then ok "$C/$n"; else no "$C/$n" "rc=$rc out=[$o] cursor-changed=$([ "$before" = "$after" ] && echo no || echo yes)"; fi 85 } 86 tok() { "$BIN" "$D" a 2>/dev/null | cut -d' ' -f3; } 87 T1=2026-11-15T12:00; T2=2026-11-15T12:05; T3=2026-11-15T12:10 88 89 new zero-header-only; printf '%s\n' "$HDR" > "$D/inbox/a.md"; run t "" "" a 90 new one-unread; { printf '%s\n' "$HDR"; L $T1 drake-bot turn "do it"; } > "$D/inbox/a.md"; run t "$(ex n a 1)" "" a 91 new stop-tag-unsigned; L $T1 drake-bot stop halt > "$D/inbox/a.md"; run is-1 "$(ex n a 1)" "" a 92 new stop-text-unsigned; L $T1 drake-bot fyi "STOP now" > "$D/inbox/a.md"; run is-1 "$(ex n a 1)" "" a 93 new stop-to-field; printf '%s|drake-bot|a|stop|halt|-\n' $T1 > "$D/inbox/a.md"; run is-1 "$(ex n a 1)" "" a 94 new empty-inbox; : > "$D/inbox/a.md"; run t "" "" a 95 new missing-inbox; run t "" "" a 96 new partial-line; { printf '%s\n' "$HDR"; printf '%s|x|turn|half|-' $T1; } > "$D/inbox/a.md"; run before-newline "" "" a 97 printf '\n' >> "$D/inbox/a.md"; run after-newline "$(ex n a 1)" "" a 98 new multi-bot; L $T1 x turn t > "$D/inbox/a.md"; : > "$D/inbox/b.md"; TO=c S $T1 drake stop s 1 300 > "$D/inbox/c.md"; TO=a 99 run t "$(ex n a 1) 100 $(ex n c 2)" "" a b c 101 102 # Signed lines (tools/codebook format, last '|' field ocb1::::). 103 new signed; S $T1 drake stop halt 1 300 > "$D/inbox/a.md"; run verified-300-is-2 "$(ex n a 2)" "" a 104 S $T1 drake turn work 1 100 > "$D/inbox/a.md"; run verified-100-is-1 "$(ex n a 1)" "" a 105 S $T1 drake fyi note 1 100 > "$D/inbox/a.md"; run verified-fyi-100-silent "" "" a 106 S $T1 drake fyi note 1 301 > "$D/inbox/a.md"; run verified-fyi-301-is-2 "$(ex n a 2)" "" a 107 S $T1 drake turn x 1 900300 > "$D/inbox/a.md"; run escape-then-300-unknown-is-1 "$(ex n a 1)" "" a 108 S $T1 drake fyi n 1 100 > "$D/inbox/a.md"; run to-format-sig-stripped-fyi-silent "" "" a 109 S $T1 drake turn "STOP" 1 001 > "$D/inbox/a.md"; run verified-non-3xx-STOP-is-1 "$(ex n a 1)" "" a 110 if [ -e "$D/inbox/a.drake.ctr" ]; then no "$C/read-does-not-write-counter" "ctr exists"; else ok "$C/read-does-not-write-counter"; fi 111 new tampered; S $T1 drake stop h 1 300 | sed 's/:300:/:301:/' > "$D/inbox/a.md"; run digits-changed-is-1 "$(ex n a 1)" "" a 112 S $T1 drake stop h 1 300 | sed 's/|drake|/|b|/' > "$D/inbox/a.md"; run sender-changed-is-1 "$(ex n a 1)" "" a 113 S $T1 drake stop h 1 300 "$KEY2" > "$D/inbox/a.md"; run other-key-is-1 "$(ex n a 1)" "" a 114 S $T1 drake stop h 1 300 | sed 's/:1:300:/:2:300:/' > "$D/inbox/a.md"; run counter-changed-is-1 "$(ex n a 1)" "" a 115 printf '%s|drake|stop|h|-|ocb1:%064d:1:300:%064d\n' $T1 0 0 > "$D/inbox/a.md"; run wrong-cbsha-is-1 "$(ex n a 1)" "" a 116 printf '%s|drake|stop|STOP|-\n' $T1 > "$D/inbox/a.md"; run unsigned-STOP-is-1 "$(ex n a 1)" "" a 117 new stale; printf '5\n' > "$D/inbox/a.drake.ctr"; S $T1 drake stop h 5 300 > "$D/inbox/a.md"; run equal-counter-is-1 "$(ex n a 1)" "" a 118 S $T1 drake stop h 6 300 > "$D/inbox/a.md"; run higher-counter-is-2 "$(ex n a 2)" "" a 119 printf 'junk\n' > "$D/inbox/a.drake.ctr"; run malformed-counter-file-is-1 "$(ex n a 1)" "" a 120 rm -f "$D/inbox/a.drake.ctr"; { S $T1 drake turn a 5 100; S $T2 drake stop b 3 300; } > "$D/inbox/a.md" 121 run lower-counter-later-in-batch-is-1 "$(ex n a 1)" "" a 122 new replay; S $T1 drake stop h 1 300 > "$D/inbox/a.md"; cp "$D/inbox/a.md" "$D/line" 123 run first-is-2 "$(ex n a 2)" "" a 124 t=$(tok); run ack "a 0" "" --ack a "$t" 125 if [ "$(cat "$D/inbox/a.drake.ctr")" = "1 $T1" ]; then ok "$C/ack-advanced-counter"; else no "$C/ack-advanced-counter" "$(cat "$D/inbox/a.drake.ctr" 2>&1)"; fi 126 if [ "$(stat -c %a "$D/inbox/a.drake.ctr")" = 600 ]; then ok "$C/counter-mode-600"; else no "$C/counter-mode-600" "$(stat -c %a "$D/inbox/a.drake.ctr")"; fi 127 if [ -e "$D/inbox/a.ctr.lock" ] && [ ! -e "$D/inbox/a.drake.ctr.tmp" ]; then ok "$C/lock-file-no-tmp"; else no "$C/lock-file-no-tmp" "$(ls "$D/inbox")"; fi 128 cat "$D/line" >> "$D/inbox/a.md"; run replayed-copy-is-1 "$(ex n a 1)" "" a 129 cp "$D/line" "$D/inbox/b.md"; run other-bot-copy-is-1 "$(ex n b 1)" "" b 130 new no-codebook; rm -rf "$D/codebook"; S $T1 drake stop h 1 300 > "$D/inbox/a.md"; run no-codebook-is-1 "$(ex n a 1)" "" a 131 mkdir -p "$D/codebook"; cp "$CBT" "$D/codebook/codebook.tsv"; run no-key-is-1 "$(ex n a 1)" "" a 132 cp "$KEY" "$D/codebook/key"; printf 'bad\n' >> "$D/codebook/codebook.tsv" 133 "$BIN" "$D" a >/dev/null 2>&1; rc=$?; if [ "$rc" = 4 ]; then ok "$C/invalid-codebook-exit-4"; else no "$C/invalid-codebook-exit-4" "rc=$rc"; fi 134 new syscalls; S $T1 drake stop h 1 300 > "$D/inbox/a.md"; t=$(tok) 135 pick_tracer "$BIN" 136 if [ -z "$TRC" ]; then 137 echo "note: no strace/qemu tracer; syscall order not checked" 138 skip "$C/lock-ctr-rename-dirsync-unlock-cursor-rename-dirsync" 139 else 140 if [ "$TRC" = strace ]; then 141 strace -f -o "$D/trace" "$BIN" "$D" --ack a "$t" > /dev/null 2> "$D/err" || true 142 else 143 "$TRC" -strace "$BIN" "$D" --ack a "$t" > /dev/null 2> "$D/trace" || true 144 fi 145 got=$(awk -v inbox="$D/inbox" ' 146 /flock\([0-9]+, *(2|LOCK_EX)/ { printf "L"; next } 147 /flock\([0-9]+, *(8|LOCK_UN)/ { printf "U"; next } 148 /renameat2/ { printf "R"; next } 149 /[^a-z]fsync\(/ || /^[0-9]+ fsync\(/ || / fsync\(/ { printf "F"; next } 150 index($0, "openat(AT_FDCWD, \"" inbox "\"") || index($0, "openat(AT_FDCWD,\"" inbox "\"") { printf "D"; next } 151 ' "$D/trace") 152 if [ "$got" = LFRDFUFRDF ]; then ok "$C/lock-ctr-rename-dirsync-unlock-cursor-rename-dirsync"; else no "$C/syscall-order" "$got"; fi 153 fi 154 155 new ack-advances; { printf '%s\n' "$HDR"; L $T1 x turn one; S $T2 drake stop two 1 300; } > "$D/inbox/a.md" 156 run before "$(ex n a 2)" "" a 157 t=$(tok); run ack "a 0" "" --ack a "$t" 158 run after "" "" a 159 off=$(wc -c < "$D/inbox/a.md" | tr -d ' ') 160 want=$(sha256sum < "$D/inbox/a.md" | cut -c1-64) 161 if [ "$(cat "$D/inbox/a.md.cur")" = "$off $want" ]; then ok "$C/cursor-is-offset-and-sha256"; else no "$C/cursor" "$(cat "$D/inbox/a.md.cur") want $off $want"; fi 162 if [ -e "$D/inbox/a.md.cur.tmp" ]; then no "$C/no-temp-left" "tmp exists"; else ok "$C/no-temp-left"; fi 163 run reack-same-token-is-noop "a 0" "" --ack a "$t" 164 L $T3 x turn three >> "$D/inbox/a.md"; run new-line "$(ex n a 1)" "" a 165 S $T3 drake stop p 2 300 | tr -d '\n' >> "$D/inbox/a.md"; run partial-not-counted "$(ex n a 1)" "" a 166 t=$(tok); run ack2 "a 0" "" --ack a "$t" 167 printf '\n' >> "$D/inbox/a.md"; run partial-completed "$(ex n a 2)" "" a 168 new ack-race; L $T1 x turn read-me > "$D/inbox/a.md" 169 t=$(tok); S $T2 drake stop arrived-after-read 1 300 >> "$D/inbox/a.md" 170 run ack-keeps-late-line-unread "a 0 171 $(ex n a 2)" "" --ack a "$t" 172 o=${t%%:*}; if [ "$(cat "$D/inbox/a.md.cur")" = "${o#n} ${t#*:}" ]; then ok "$C/cursor-is-exactly-the-token"; else no "$C/cursor-is-exactly-the-token" "$(cat "$D/inbox/a.md.cur") vs $t"; fi 173 if [ -e "$D/inbox/a.drake.ctr" ]; then no "$C/late-line-counter-not-advanced" "advanced"; else ok "$C/late-line-counter-not-advanced"; fi 174 t=$(tok); run ack-late-line "a 0" "" --ack a "$t" 175 new ack-race-emerg; L $T1 x turn n1 > "$D/inbox/a.md" 176 t=$(tok); Se $T2 drake alert fire 1 300 >> "$D/inbox/a.emergency.md" 177 run normal-ack-leaves-emergency "a 0 178 $(ex e a 2)" "" --ack a "$t" 179 t=$(tok); Se $T3 drake alert fire2 2 301 >> "$D/inbox/a.emergency.md" 180 run emerg-ack-keeps-late-emergency "a 0 181 $(ex e a 2)" "" --ack a "$t" 182 t=$(tok); run emerg-cleared "a 0" "" --ack a "$t" 183 new ack-refusals; { L $T1 x turn one; L $T2 x turn two; } > "$D/inbox/a.md" 184 t1=$(tokf n "$D/inbox/a.md"); h1=${t1#*:}; o1=${t1%%:*}; o1=${o1#n} 185 first=$(head -n 1 "$D/inbox/a.md"); fo=$(printf '%s\n' "$first" | wc -c | tr -d ' ') 186 fh=$(printf '%s\n' "$first" | sha256sum | cut -c1-64) 187 refuse not-line-boundary 3 --ack a "n$((o1-1)):$h1" 188 refuse mid-line-with-matching-hash 3 --ack a "n$((o1-1)):$(head -c $((o1-1)) "$D/inbox/a.md" | sha256sum | cut -c1-64)" 189 refuse past-eof 3 --ack a "n$((o1+1)):$h1" 190 refuse zero-offset 3 --ack a "n0:$h1" 191 refuse wrong-hash 3 --ack a "n$o1:$fh" 192 refuse wrong-lane 3 --ack a "e$o1:$h1" 193 refuse bad-lane-letter 3 --ack a "x$o1:$h1" 194 refuse no-colon 3 --ack a "n$o1" 195 refuse short-hex 3 --ack a "n$o1:$(printf '%s' "$h1" | cut -c1-63)" 196 refuse upper-hex 3 --ack a "n$o1:$(printf '%s' "$h1" | tr a-f A-F)" 197 refuse no-digits 3 --ack a "n:$h1" 198 refuse plain-ack-removed 2 --ack a 199 run ack-first-line "a 0 200 $(ex n a 1)" "" --ack a "n$fo:$fh" 201 run ack-all "a 0" "" --ack a "$t1" 202 refuse stale-behind-cursor 3 --ack a "n$fo:$fh" 203 { L $T1 x turn one; L $T2 x turn TWO; } > "$D/inbox/a.md" 204 refuse rewritten-since-read 3 --ack a "$t1" 205 run rewritten-shows-unread "$(ex n a 1)" "" a 206 new oracle-cursor; { L $T1 x turn one; L $T2 x turn two; } > "$D/inbox/a.md" 207 h=$(sha256sum < "$D/inbox/a.md" | cut -c1-64) 208 printf '%s %s\n' "$(wc -c < "$D/inbox/a.md" | tr -d ' ')" "$h" > "$D/inbox/a.md.cur"; run external-cursor-accepted "" "" a 209 new torn-write; { L $T1 x turn one; L $T2 x turn two; } > "$D/inbox/a.md"; t=$(tok); run ack "a 0" "" --ack a "$t" 210 printf 'garbage-from-a-crash' > "$D/inbox/a.md.cur.tmp"; run stale-tmp-ignored "" "" a 211 head -c 40 "$D/inbox/a.md.cur" > "$D/x" && mv "$D/x" "$D/inbox/a.md.cur"; run torn-cursor-fails-safe-unread "$(ex n a 1)" "" a 212 : > "$D/inbox/a.md.cur"; run empty-cursor-unread "$(ex n a 1)" "" a 213 t=$(tok); run ack-replaces-torn "a 0" "" --ack a "$t" 214 if [ -e "$D/inbox/a.md.cur.tmp" ]; then no "$C/tmp-renamed-away" "tmp exists"; else ok "$C/tmp-renamed-away"; fi 215 new cursor-past-eof; { L $T1 x turn one; L $T2 x turn two; } > "$D/inbox/a.md"; t=$(tok); run ack "a 0" "" --ack a "$t" 216 L $T1 x turn one > "$D/inbox/a.md"; run truncated "$(ex n a 1)" "" a 217 printf '99999 %064d\n' 0 > "$D/inbox/a.md.cur"; run huge-offset "$(ex n a 1)" "" a 218 new rewritten-file; { L $T1 x turn one; L $T2 x turn two; } > "$D/inbox/a.md"; t=$(tok); run ack "a 0" "" --ack a "$t" 219 { L $T1 x turn one; L $T2 x turn TWO; } > "$D/inbox/a.md"; run same-size-new-hash "$(ex n a 1)" "" a 220 new mid-line-cursor; { L $T1 x turn one; L $T2 x turn two; } > "$D/inbox/a.md"; o=$(($(wc -c < "$D/inbox/a.md")-1)) 221 printf '%s %s\n' "$o" "$(head -c "$o" "$D/inbox/a.md" | sha256sum | cut -c1-64)" > "$D/inbox/a.md.cur" 222 run hash-matching-mid-line-cursor-ignored "$(ex n a 1)" "" a 223 new bad-cursor; L $T1 x turn one > "$D/inbox/a.md"; printf 'garbage\n' > "$D/inbox/a.md.cur"; run t "$(ex n a 1)" "" a 224 new read-stop-ignored; L $T1 x stop old > "$D/inbox/a.md"; t=$(tok); run ack "a 0" "" --ack a "$t" 225 L $T2 x turn new >> "$D/inbox/a.md"; run t "$(ex n a 1)" "" a 226 227 # Emergency lane: DIR/inbox/.emergency.md. Allowlist = drake + any slug with DIR/inbox/.md. 228 # Only a verified 3xx is a 2 and jumps the normal lane; other admitted lines are 1 and wait for it. 229 new emerg-jumps-line; { L $T1 x turn n1; L $T2 x turn n2; } > "$D/inbox/a.md"; Se $T1 drake alert fire 1 300 > "$D/inbox/a.emergency.md" 230 run pending "$(ex e a 2)" "" a 231 t=$(tok); run ack-clears-emergency-only "a 0 232 $(ex n a 1)" "" --ack a "$t" 233 if [ -f "$D/inbox/a.md.cur" ]; then no "$C/normal-untouched" "normal cursor written"; else ok "$C/normal-untouched"; fi 234 t=$(tok); run ack-normal "a 0" "" --ack a "$t" 235 new emerg-unsigned-waits; L $T1 x turn n > "$D/inbox/a.md"; L $T1 drake alert fire > "$D/inbox/a.emergency.md" 236 run normal-first "$(ex n a 1)" "" a 237 t=$(tok); run then-emergency-1 "a 0 238 $(ex e a 1)" "" --ack a "$t" 239 new emerg-over-stop; S $T1 drake stop halt 3 301 > "$D/inbox/a.md"; Se $T1 drake alert f 2 300 > "$D/inbox/a.emergency.md" 240 run t "$(ex e a 2)" "" a 241 t=$(tok); run ack-then-higher-counter-stop-visible "a 0 242 $(ex n a 2)" "" --ack a "$t" 243 Se $T1 drake alert g 1 300 > "$D/inbox/a.emergency.md"; rm -f "$D/inbox/a.emergency.md.cur"; run lower-counter-emergency-is-1-and-waits "$(ex n a 2)" "" a 244 new emerg-known-bot; : > "$D/inbox/a.md"; : > "$D/inbox/six-sigma.md"; Se $T1 six-sigma alert x 1 310 > "$D/inbox/a.emergency.md"; run t "$(ex e a 2)" "" a 245 new emerg-unknown; L $T1 x turn n > "$D/inbox/a.md"; Se $T1 mallory alert x 1 300 > "$D/inbox/a.emergency.md"; run t "$(ex n a 1)" "rejected a 1" a 246 new emerg-bad-slug; : > "$D/inbox/a.md"; { L $T1 ../a fyi x; L $T1 Drake fyi x; L $T1 '' fyi x; } > "$D/inbox/a.emergency.md"; run t "" "rejected a 3" a 247 new emerg-bad-time; : > "$D/inbox/a.md"; { L 2026-11-15T25:00 drake alert x; L 2026-13-15T12:00 drake alert x; L 2026-11-15T12 drake alert x; } > "$D/inbox/a.emergency.md"; run t "" "rejected a 3" a 248 new emerg-partial; : > "$D/inbox/a.md"; printf '%s|drake|fyi|x|-' $T1 > "$D/inbox/a.emergency.md"; run t "" "" a 249 new emerg-header-only; : > "$D/inbox/a.md"; printf '# Emergency: a\n' > "$D/inbox/a.emergency.md"; run t "" "" a 250 new emerg-flood; : > "$D/inbox/a.md" 251 i=0; for m in 00 10 20 30 40; do i=$((i+1)); Se 2026-11-15T12:$m drake alert "f$m" $i 300; done > "$D/inbox/a.emergency.md" 252 run five-in-window "$(ex e a 2)" "rejected a 2" a 253 t=$(tok); run ack "a 0" "" --ack a "$t" 254 Se 2026-11-15T12:50 drake alert f50 6 300 >> "$D/inbox/a.emergency.md"; run ack-does-not-refill "" "rejected a 1" a 255 Se 2026-11-15T13:21 drake alert f81 7 300 >> "$D/inbox/a.emergency.md"; run window-slides "$(ex e a 2)" "rejected a 1" a 256 new emerg-forged-flood; : > "$D/inbox/a.md" 257 { for m in 00 01 02 03 04 05; do Se 2026-11-15T12:$m drake alert forged 9$m 300 "$KEY2"; done; Se 2026-11-15T12:06 drake alert real 1 300; Se 2026-11-15T12:07 drake alert real2 2 300; Se 2026-11-15T12:08 drake alert real3 3 301; } > "$D/inbox/a.emergency.md" 258 run forged-lines-use-no-quota "$(ex e a 2)" "" a 259 new emerg-replay-flood; : > "$D/inbox/a.md"; Se 2026-11-15T12:00 drake alert r 1 300 > "$D/line" 260 { for j in 1 2 3 4 5; do cat "$D/line"; done; Se 2026-11-15T12:06 drake alert new 2 300; Se 2026-11-15T12:07 drake alert new3 3 300; } > "$D/inbox/a.emergency.md" 261 run replays-counted-once "$(ex e a 2)" "" a 262 Se 2026-11-15T12:08 drake alert new4 4 300 >> "$D/inbox/a.emergency.md"; run fourth-distinct-rejected "$(ex e a 2)" "rejected a 1" a 263 new emerg-per-sender; : > "$D/inbox/a.md"; : > "$D/inbox/b.md" 264 { i=0; for m in 00 01 02 03; do i=$((i+1)); Se 2026-11-15T12:$m drake alert d $i 300; done; Se 2026-11-15T12:04 b alert b 1 300; } > "$D/inbox/a.emergency.md" 265 run t "$(ex e a 2)" "rejected a 1" a 266 new emerg-day-wrap; : > "$D/inbox/a.md" 267 { Se 2026-12-31T23:30 drake alert x 1 300; Se 2026-12-31T23:40 drake alert x 2 300; Se 2026-12-31T23:50 drake alert x 3 300; Se 2027-01-01T00:20 drake alert x 4 300; Se 2027-01-01T00:41 drake alert x 5 300; } > "$D/inbox/a.emergency.md" 268 run year-boundary-window "$(ex e a 2)" "rejected a 1" a 269 new emerg-rewritten; : > "$D/inbox/a.md"; Se $T1 drake alert x 1 300 > "$D/inbox/a.emergency.md"; t=$(tok); run ack "a 0" "" --ack a "$t" 270 Se $T1 drake alert y 2 300 > "$D/inbox/a.emergency.md"; run t "$(ex e a 2)" "" a 271 272 # Silence, exact STOP (now at most 1 unsigned), fyi, full-prefix cursor hash. 273 new silent; : > "$D/inbox/a.md"; : > "$D/inbox/b.md"; L $T1 x turn t > "$D/inbox/c.md" 274 run all-silent-exit-1 "" "" a b 275 run one-wakes-exit-0 "$(ex n c 1)" "" a b c 276 new stop-exact; for t in "STOPWATCH x" "STOPS" "stop" "STOP-now" "Stop"; do L $T1 x turn "$t"; done > "$D/inbox/a.md" 277 run near-misses-are-1 "$(ex n a 1)" "" a 278 printf '%s|x|a|turn|STOP|-\n' $T1 > "$D/inbox/a.md"; run to-format-text-STOP-unsigned-is-1 "$(ex n a 1)" "" a 279 printf '%s|x|turn|STOP: halt|-\n' $T1 > "$D/inbox/a.md"; run STOP-colon-unsigned-is-1 "$(ex n a 1)" "" a 280 new fyi; L $T1 x fyi "note only" > "$D/inbox/a.md"; run fyi-silent "" "" a 281 L $T2 x turn work >> "$D/inbox/a.md"; run fyi-plus-turn "$(ex n a 1)" "" a 282 L $T1 x fyi "STOP now" > "$D/inbox/a.md"; run fyi-STOP-wakes-1 "$(ex n a 1)" "" a 283 L $T1 drake fyi heads-up > "$D/inbox/a.emergency.md"; : > "$D/inbox/a.md"; run emergency-fyi-silent "" "" a 284 new prefix-hash; { L $T1 x turn one; L $T2 x turn two; } > "$D/inbox/a.md"; t=$(tok); run ack "a 0" "" --ack a "$t" 285 { L $T1 x stop one; L $T2 x turn two; } > "$D/inbox/a.md"; run earlier-line-rewritten-in-place "$(ex n a 1)" "" a 286 refuse old-token-after-earlier-rewrite 3 --ack a "$t" 287 new receipt; L $T1 x turn one > "$D/inbox/a.md"; t=$(tok) 288 run receipt-only "a 0" "" --ack a "$t" 289 run silent-after "" "" a 290 291 292 # Binding (ocb2): a keyless copy or edit of a signed 3xx line is 1, never 2. 293 new binding; S $T1 drake stop h 1 300 > "$D/inbox/a.md"; cp "$D/inbox/a.md" "$D/line" 294 run first-is-2 "$(ex n a 2)" "" a 295 TO=b S $T1 drake stop h 1 300 > "$D/inbox/a.md"; run to-mismatch-is-1 "$(ex n a 1)" "" a 296 cp "$D/line" "$D/inbox/a.emergency.md"; : > "$D/inbox/a.md"; run lane-copy-is-1 "$(ex e a 1)" "" a 297 cat "$D/line" | sed 's/|h|/|HACK|/' > "$D/inbox/a.md"; rm -f "$D/inbox/a.emergency.md" 298 run text-edit-is-1 "$(ex n a 1)" "" a 299 cat "$D/line" | sed 's/|stop|/|turn|/' > "$D/inbox/a.md"; run tag-edit-is-1 "$(ex n a 1)" "" a 300 cat "$D/line" | sed 's/|-|/|REF|/' > "$D/inbox/a.md"; run ref-edit-is-1 "$(ex n a 1)" "" a 301 cat "$D/line" | sed 's/2026-11-15T12:00/2027-11-15T12:00/' > "$D/inbox/a.md" 302 run ts-edit-is-1 "$(ex n a 1)" "" a 303 printf '1 %s\n' "$T2" > "$D/inbox/a.drake.ctr"; S $T1 drake stop h 2 300 > "$D/inbox/a.md" 304 run ts-regress-is-1 "$(ex n a 1)" "" a 305 printf '%s|drake|a|stop|h|-|ocb1:%064d:1:300:%064d\n' $T1 0 0 > "$D/inbox/a.md" 306 run ocb1-is-1 "$(ex n a 1)" "" a 307 new key-mode; S $T1 drake stop h 1 300 > "$D/inbox/a.md"; chmod 644 "$D/codebook/key" 308 "$BIN" "$D" a >/dev/null 2>&1; rc=$?; if [ "$rc" = 5 ]; then ok "$C/world-readable-key-exit-5"; else no "$C/world-readable-key-exit-5" "rc=$rc"; fi 309 new boards-key; D="$FIX/boards/kcase"; mkdir -p "$D/inbox" "$D/codebook"; C=boards-key 310 cp "$CBT" "$D/codebook/codebook.tsv"; cp "$KEY" "$D/codebook/key"; chmod 600 "$D/codebook/key" 311 S $T1 drake stop h 1 300 > "$D/inbox/a.md" 312 "$BIN" "$D" a >/dev/null 2>&1; rc=$?; if [ "$rc" = 5 ]; then ok "$C/key-inside-boards-exit-5"; else no "$C/key-inside-boards-exit-5" "rc=$rc"; fi 313 314 new usage; : > "$D/inbox/a.md" 315 for args in "../x" "A" "--ack" "--ack a" "--ack a b c" "--trust-unsigned a"; do 316 "$BIN" "$D" $args >/dev/null 2>&1; rc=$? 317 if [ "$rc" = 2 ]; then ok "$C/refuse[$args]"; else no "$C/refuse[$args]" "rc=$rc"; fi 318 done 319 "$BIN" >/dev/null 2>&1; rc=$?; if [ "$rc" = 2 ]; then ok "$C/no-args"; else no "$C/no-args" "rc=$rc"; fi 320 S $T1 drake stop h 1 300 | sed 's/:300:/:301:/' > "$D/inbox/a.md" 321 "$BIN" --trust-unsigned "$D" a >/dev/null 2>&1; rc=$?; if [ "$rc" = 2 ]; then ok "$C/trust-flag-removed"; else no "$C/trust-flag-removed" "rc=$rc"; fi 322 323 printf 'TOTAL pass=%d fail=%d skip=%d\n' "$pass" "$fail" "$skip" 324 [ "$fail" = 0 ]