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/allen_exam_card.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 / allen_exam_card.sh` 40 lines ยท 2107 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # allen_exam_card.sh -- build the pi5-allen exam card file (\EFI\AIENOS\ALLEN.EXM, crates/allen-reflex-kernel/src/card.rs) 3 # from exam case files. Only the case id and the turns go into the card file; expected answers stay on the host 4 # (scripts/allen_pi_results.sh joins them back by id). 5 # 6 # allen_exam_card.sh ... 7 # 8 # A case file is an exam .psv (id|category|action|text|turns) or, for the bounds cases, a .cases file (id|turns). 9 # Refuses the held-out file and any path under ~/sealed: this tool is for train/dev rehearsal and bounds tests; 10 # a sealed set is staged only by the declared final scoring procedure. 11 set -euo pipefail 12 out="${1:?out file}"; shift 13 [[ $# -ge 1 ]] || { echo "usage: $0 ..." >&2; exit 2; } 14 for f in "$@"; do 15 case "$(readlink -f "$f")" in 16 */sealed/*|*heldout*) echo "REFUSE: ${f} is a held-out or sealed case file (rehearsal uses train/dev only)" >&2; exit 2 ;; 17 esac 18 [[ -r "$f" ]] || { echo "no case file ${f}" >&2; exit 2; } 19 done 20 tmp="$(mktemp)" 21 trap 'rm -f "${tmp}"' EXIT 22 printf 'AIENALX1 QUALIF-ALLEN-EXAM\n' > "${tmp}" 23 for f in "$@"; do 24 if [[ "$f" == *.psv ]]; then 25 # id|category|action|text|turns -> id|turns (turns may itself hold '|': keep everything after the 4th bar) 26 awk '!/^#/ && NF { i = index($0, "|"); id = substr($0, 1, i - 1); r = $0; 27 for (k = 0; k < 4; k++) { j = index(r, "|"); r = substr(r, j + 1) } print id "|" r }' "$f" >> "${tmp}" 28 else 29 grep -v '^#' "$f" | grep -v '^$' >> "${tmp}" 30 fi 31 done 32 n=$(( $(wc -l < "${tmp}") - 1 )) 33 bytes=$(stat -c %s "${tmp}") 34 [[ ${bytes} -le 131072 ]] || { echo "card file ${bytes} bytes > 131072" >&2; exit 1; } 35 [[ ${n} -ge 1 && ${n} -le 512 ]] || { echo "card file has ${n} cases (1..512)" >&2; exit 1; } 36 dups=$(tail -n +2 "${tmp}" | cut -d'|' -f1 | sort | uniq -d | head -3 | tr '\n' ' ') 37 [[ -z "${dups}" ]] || { echo "duplicate case ids: ${dups}" >&2; exit 1; } 38 mv "${tmp}" "${out}" 39 trap - EXIT 40 echo "card file ${out}: ${n} cases, ${bytes} bytes, sha256 $(sha256sum "${out}" | cut -d' ' -f1)"