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/aienux/blob/main/scripts/ck_allen_canvas_test.sh # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / scripts / ck_allen_canvas_test.sh` 82 lines ยท 4051 bytes Raw Blame History 1 #!/bin/sh 2 # ck_allen_canvas_test.sh -- host test of Allen's canvas: the scene language 3 # the model writes (native/kernel/svc/allen_scene.c) and the way it is painted 4 # round Allen (native/kernel/ui/canvas.c, hooked into ui/allen_ui.c). 5 # 1. Kernel build rules: both files compile freestanding with general 6 # registers only (no floating point anywhere) and call nothing outside 7 # the kernel but memset/memcpy/memmove. 8 # 2. The parser on fixed scenes, then a fuzz pass (random bytes, mutated 9 # scenes, word soup; each input in a buffer of exactly its length) under 10 # AddressSanitizer and UndefinedBehaviorSanitizer, with counts. 11 # 3. Frames at 3840x2160: Allen forms, then plain answers and each sample 12 # scene after a line; partial redraws must match full ones; pictures to 13 # target/native-kernel-allen-canvas/*.png; frame times printed. 14 # 4. --live: asks the model server (127.0.0.1:18091, one request at a time, 15 # waiting politely while it is busy) the questions in 16 # evidence/allen-canvas/questions.txt with the prompt in 17 # crates/allen-courier/scene_prompt.txt, keeps every raw reply in 18 # $LIVE_DIR (default evidence/allen-canvas/replies; a round cut off part 19 # way resumes there), then parses and paints each one 20 # (live-*.png) and reports how many parsed cleanly. 21 # --replies DIR: the same from replies already kept (no model needed). 22 # Ends with "AIENOS_ALLEN_CANVAS: PASS" or "AIENOS_ALLEN_CANVAS: FAIL ". 23 set -u 24 cd "$(dirname "$0")/.." 25 K=native/kernel 26 OUT=target/native-kernel-allen-canvas 27 EVID=evidence/allen-canvas 28 LIVE=0 29 REPLIES="" 30 while [ $# -gt 0 ]; do 31 case "$1" in 32 --live) LIVE=1 ;; 33 --replies) REPLIES="$2"; shift ;; 34 *) echo "usage: $0 [--live] [--replies DIR]"; exit 2 ;; 35 esac 36 shift 37 done 38 W=$(mktemp -d "${TMPDIR:-/tmp}/ck_allen_canvas.XXXXXX") 39 trap 'rm -rf "$W"' EXIT 40 fail() { echo "AIENOS_ALLEN_CANVAS: FAIL $*"; exit 1; } 41 CC=${HOSTCC:-cc} 42 mkdir -p "$OUT" 43 44 # 1. as the kernel builds it 45 for f in svc/allen_scene ui/canvas; do 46 $CC -std=gnu11 -O2 -ffreestanding -fno-builtin -mgeneral-regs-only -fno-stack-protector -Wall -Wextra -Werror \ 47 -c -o "$W/$(basename $f).o" "$K/$f.c" || fail "$f.c does not build freestanding with general registers only" 48 extra=$(nm -u "$W/$(basename $f).o" | awk '{print $2}' | grep -v -E '^(ck_|memset$|memcpy$|memmove$)' || true) 49 [ -z "$extra" ] || fail "$f.c calls outside the kernel: $extra" 50 done 51 echo "kernel rules: allen_scene.c and canvas.c build freestanding, no floating point, no outside calls" 52 53 SRC="$K/ui/tests/canvas_test.c $K/ui/canvas.c $K/svc/allen_scene.c $K/ui/allen_ui.c $K/svc/allen_code.c $K/ui/paint.c $K/ui/night.c \ 54 $K/ui/mind.c $K/ui/flow.c $K/ui/allen_font.c $K/ui/sky_real.c $K/ui/sky_data.c" 55 56 # 2. parser and fuzz under the sanitizers 57 $CC -std=gnu11 -O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer -Wall -Wextra \ 58 -Werror -o "$W/san" $SRC || fail "test does not build with the sanitizers" 59 "$W/san" --parse-only --fuzz "${CANVAS_FUZZ:-300000}" || fail "parser or fuzz" 60 61 # 4a. live: ask the model first (its replies are kept as evidence) 62 if [ "$LIVE" = 1 ]; then 63 cargo build -q --release -p allen-courier --bin allen-scene || fail "allen-scene does not build" 64 REPLIES="${LIVE_DIR:-$EVID/replies}" 65 mkdir -p "$REPLIES" 66 target/release/allen-scene --questions "$EVID/questions.txt" --out "$REPLIES" \ 67 --prompt crates/allen-courier/scene_prompt.txt --wait-max 1800 || fail "the model could not be asked" 68 fi 69 70 # 3 (and 4b). frames, at full speed 71 $CC -std=gnu11 -O2 -Wall -Wextra -Werror -o "$W/test" $SRC || fail "test does not build" 72 if [ -n "$REPLIES" ]; then 73 "$W/test" "$OUT" --fuzz 20000 --replies "$REPLIES" > "$W/log" 2>&1 74 rc=$? 75 cat "$W/log" 76 [ $rc = 0 ] || fail "canvas checks" 77 grep -E '^(live |LIVE:|note: frames|note: startup)' "$W/log" > "$REPLIES/parse-report.txt" 78 else 79 "$W/test" "$OUT" --fuzz 20000 || fail "canvas checks" 80 fi 81 echo "pictures: $OUT" 82 echo "AIENOS_ALLEN_CANVAS: PASS"