interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

GitHub aien-dev/aienux#113 (code only)

closed derived 3a43624567d85e31 #113

Imported from GitHub aien-dev/aienux#113 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 35b3086858948116c864b9f96515e3925aa94687 · Head 518d8156b699ba8cd92c36d05ffb96892dd7fffe

Apply it

git checkout -b patch-3a43624567d85e31 35b3086858948116c864b9f96515e3925aa94687
curl -fsSL https://interplane.io/drakestapleton/aienux/patches/3a43624567d85e31.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/aienux
113
518d8156b699ba8cd92c36d05ffb96892dd7fffe
{"kind":"github-import","owner":"aien-dev","repo":"aienux","number":113,"url":"https://github.com/aien-dev/aienux/pull/113","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:35:45Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/scripts/m3_receipt.sh b/scripts/m3_receipt.sh
new file mode 100755
index 00000000..bfe9085c
--- /dev/null
+++ b/scripts/m3_receipt.sh
@@ -0,0 +1,312 @@
+#!/usr/bin/env bash
+# m3_receipt.sh: produce one reproducible M3 evidence receipt for the commit
+# that is checked out.
+#
+# It refuses to run on a dirty tree, records the commit and the toolchain,
+# runs `AIENOS_STRICT=1 bash scripts/verify_all.sh` (so no step may be
+# skipped) with every serial log captured, and writes
+# evidence/m3_receipt_<YYYY-MM-DD>.md with the PASS lines grouped by proof,
+# the sha256 and line count of every raw log, the limitations, and an operator
+# sign-off line that stays "pending" until the operator writes "M3 accepted".
+#
+# Raw logs are kept outside the tree (printed at the end) and are never
+# committed; the receipt carries only their hashes and line counts.
+#
+# Usage: bash scripts/m3_receipt.sh [--allow-missing]
+#   --allow-missing  write the receipt and exit 0 even when some proofs have
+#                    no PASS line yet (they are listed as MISSING).
+# Environment:
+#   AIENOS_RECEIPT_LOG_DIR  where raw logs go (default: a new mktemp dir).
+#   AIENOS_QEMU_TIMEOUT     passed through to the QEMU scripts.
+#
+# Exit status: 0 all proofs present (or --allow-missing), 1 verification
+# failed or the run changed tracked files, 2 usage or dirty tree, 3 proofs
+# MISSING without --allow-missing.
+set -euo pipefail
+
+allow_missing=0
+for arg in "$@"; do
+    case "${arg}" in
+        --allow-missing) allow_missing=1 ;;
+        -h|--help) sed -n '2,24p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;;
+        *) echo "unknown argument: ${arg}" >&2; exit 2 ;;
+    esac
+done
+
+repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+# Resolve a caller-supplied log dir against the caller's directory, before cd.
+requested_log_dir=""
+if [[ -n "${AIENOS_RECEIPT_LOG_DIR:-}" ]]; then
+    requested_log_dir="$(realpath -m -- "${AIENOS_RECEIPT_LOG_DIR}")"
+    case "${requested_log_dir}/" in
+        "$(realpath -m -- "${repo_root}")/"*)
+            echo "m3_receipt: AIENOS_RECEIPT_LOG_DIR must be outside the tree: ${requested_log_dir}" >&2
+            exit 2 ;;
+    esac
+fi
+cd "${repo_root}"
+
+# 1. The receipt must describe exactly one commit: refuse a dirty tree,
+# including untracked files that a build could pick up.
+if [[ -n "$(git status --porcelain --untracked-files=normal)" ]]; then
+    echo "m3_receipt: refusing to run on a dirty tree. Commit, stash or remove these first:" >&2
+    git status --short --untracked-files=normal >&2
+    exit 2
+fi
+
+head_sha="$(git rev-parse HEAD)"
+head_subject="$(git log -1 --format=%s HEAD)"
+branch="$(git rev-parse --abbrev-ref HEAD)"
+origin_main_local="$(git rev-parse --verify -q refs/remotes/origin/main || echo unknown)"
+origin_main_live="$(timeout 20 git ls-remote origin refs/heads/main 2>/dev/null | awk '{print $1}' || true)"
+[[ -n "${origin_main_live}" ]] || origin_main_live="unreachable"
+equals() { [[ "$1" == "${head_sha}" ]] && echo yes || echo no; }
+
+date_utc="$(date -u +%F)"
+started_utc="$(date -u +%FT%TZ)"
+receipt="evidence/m3_receipt_${date_utc}.md"
+
+log_dir="${requested_log_dir:-$(mktemp -d "${TMPDIR:-/tmp}/aienos-m3-receipt.XXXXXX")}"
+mkdir -p "${log_dir}/serial" "${log_dir}/shim"
+log_dir="$(cd "${log_dir}" && pwd)"
+if [[ -n "$(ls -A "${log_dir}/serial")" ]]; then
+    echo "m3_receipt: ${log_dir}/serial is not empty; use a fresh AIENOS_RECEIPT_LOG_DIR" >&2
+    exit 2
+fi
+: >"${log_dir}/commands.log"
+
+# 2. Record every cargo and qemu-system-aarch64 invocation with its exact
+# arguments. A thin wrapper on PATH logs the argv, plus the build-time
+# AIENOS_* variables the image embeds (option_env!), then execs the real tool.
+make_shim() { # tool name
+    local real
+    real="$(command -v "$1" || true)"
+    [[ -n "${real}" ]] || return 0
+    cat >"${log_dir}/shim/$1" <<EOF
+#!/usr/bin/env bash
+{
+    env | grep -E '^AIENOS_(COMMIT|RESTART_SECS|KEYBOARD_SECS)=' | sort | tr '\\n' ' '
+    printf '%q ' "$1" "\$@"
+    echo
+} >>"${log_dir}/commands.log"
+exec "${real}" "\$@"
+EOF
+    chmod +x "${log_dir}/shim/$1"
+}
+make_shim cargo
+make_shim qemu-system-aarch64
+
+first_line() { "$@" 2>/dev/null | head -n 1 || true; }
+sha_of() { [[ -r "$1" ]] && sha256sum "$1" | awk '{print $1}' || echo "not readable"; }
+os_name="$( (. /etc/os-release 2>/dev/null && echo "${PRETTY_NAME:-unknown}") || echo unknown)"
+rustc_v="$(first_line rustc -V)"
+cargo_v="$(first_line cargo -V)"
+qemu_v="$(first_line qemu-system-aarch64 --version)"
+swtpm_v="$(first_line swtpm --version)"
+code_fd="${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}"
+vars_fd="${AAVMF_VARS:-/usr/share/AAVMF/AAVMF_VARS.fd}"
+
+harness_cmd="AIENOS_STRICT=1 AIENOS_LOG_DIR=${log_dir}/serial bash scripts/verify_all.sh"
+[[ -z "${AIENOS_QEMU_TIMEOUT:-}" ]] || harness_cmd="AIENOS_QEMU_TIMEOUT=${AIENOS_QEMU_TIMEOUT} ${harness_cmd}"
+
+# 3. Run the strict harness.
+echo "m3_receipt: commit ${head_sha}"
+echo "m3_receipt: raw logs in ${log_dir}"
+echo "m3_receipt: running ${harness_cmd}"
+set +e
+PATH="${log_dir}/shim:${PATH}" AIENOS_STRICT=1 AIENOS_LOG_DIR="${log_dir}/serial" \
+    bash scripts/verify_all.sh 2>&1 | tee "${log_dir}/verify_all.log"
+verify_status=${PIPESTATUS[0]}
+set -e
+finished_utc="$(date -u +%FT%TZ)"
+
+tree_after="clean"
+if [[ -n "$(git status --porcelain --untracked-files=normal)" ]]; then
+    tree_after="DIRTY (the run changed the tree)"
+fi
+
+# 4. Collect PASS lines with the verify_all.sh section they came from.
+pass_tsv="${log_dir}/pass_lines.tsv"
+awk '
+    { sub(/\r$/, "") }
+    /^--- \[.*\] ---$/ { sec = $0; sub(/^--- \[/, "", sec); sub(/\] ---$/, "", sec); next }
+    /^PASS[[:space:]]|: PASS|ALL TESTS PASS/ { print sec "\t" $0 }
+' "${log_dir}/verify_all.log" >"${pass_tsv}"
+
+results="${log_dir}/results.md"
+claimed="${log_dir}/claimed.tsv"
+: >"${results}"
+: >"${claimed}"
+missing=()
+# proof name, section regex, PASS line regex (both matched lower-cased).
+proof() {
+    local name="$1" sec_re="$2" line_re="$3" hits
+    hits="$(awk -F '\t' -v s="${sec_re}" -v l="${line_re}" \
+        'tolower($1) ~ s && tolower($2) ~ l' "${pass_tsv}")"
+    {
+        echo "### ${name}"
+        echo ""
+        if [[ -z "${hits}" ]]; then
+            echo "    MISSING"
+        else
+            printf '%s\n' "${hits}" | awk -F '\t' '{ printf "    [%s] %s\n", $1, $2 }'
+        fi
+        echo ""
+    } >>"${results}"
+    if [[ -z "${hits}" ]]; then
+        missing+=("${name}")
+    else
+        printf '%s\n' "${hits}" >>"${claimed}"
+    fi
+}
+boot_sec="^qemu aarch64 uefi boot"
+smmu_sec="smmu"
+proof "Formatting" "^formatting" "formatting"
+proof "Host tests" "^host component" "host tests"
+proof "Clippy" "^clippy" "clippy"
+proof "AArch64 build" "bare-metal|aarch64 uefi image" "aarch64 build"
+proof "QEMU boot" "${boot_sec}" "pre-exit report|image is this commit|entered the kernel|kernel entered el1h|final report|qemu_boot: pass"
+proof "MMU" "${boot_sec}" "page table"
+proof "GIC/timer" "${boot_sec}" "gic|timer irq"
+proof "Preemption" "${boot_sec}" "preempt|placement"
+proof "EL0 isolation" "." "el0"
+proof "Capability" "${boot_sec}" "capabilit"
+proof "IPC" "." "(^|[^a-z])ipc([^a-z]|$)"
+proof "SMMU positive DMA" "${smmu_sec}" "iort stream|dma window translated|typed text echoed"
+proof "SMMU negative DMA" "${smmu_sec}" "negative|(dma|stream).*(block|denied|deny|fault|reject|abort)|(block|denied|deny|fault|reject|abort).*dma"
+proof "Device revocation" "." "revok|revoc"
+proof "Recovery/security regressions" "^trust-1 gate 4|^trust-1 gate 1|^recovery media tooling" "."
+proof "ABI conformance" "." "(^|[^a-z])abi([^a-z]|$)"
+
+other="$(grep -vxF -f "${claimed}" "${pass_tsv}" || true)"
+
+# 5. Hash every raw log.
+hashes="${log_dir}/hashes.txt"
+: >"${hashes}"
+for f in "${log_dir}/verify_all.log" "${log_dir}/commands.log" "${log_dir}"/serial/*.log; do
+    [[ -f "${f}" ]] || continue
+    printf '%s  %s  (%s lines)\n' "$(sha256sum "${f}" | awk '{print $1}')" \
+        "${f#"${log_dir}/"}" "$(wc -l <"${f}" | tr -d ' ')" >>"${hashes}"
+done
+serial_count="$(find "${log_dir}/serial" -name '*.log' | wc -l | tr -d ' ')"
+
+# Debug-only build features seen in the recorded commands.
+debug_features="$(grep -oE -- '--features [^ ]+' "${log_dir}/commands.log" | tr ',' '\n' \
+    | grep -oE 'debug[a-z0-9_-]*' | sort -u | tr '\n' ' ' || true)"
+
+if [[ "${verify_status}" != 0 || "${tree_after}" != "clean" ]]; then
+    overall="FAIL (verify_all.sh exit ${verify_status}, tree after run: ${tree_after})"
+    exit_code=1
+elif [[ "${#missing[@]}" -gt 0 ]]; then
+    if [[ "${allow_missing}" == 1 ]]; then
+        overall="INCOMPLETE: ${#missing[@]} proof(s) MISSING, accepted only because --allow-missing was given"
+        exit_code=0
+    else
+        overall="INCOMPLETE: ${#missing[@]} proof(s) MISSING"
+        exit_code=3
+    fi
+else
+    overall="PASS: every listed proof has at least one PASS line"
+    exit_code=0
+fi
+
+# 6. Write the receipt.
+{
+    echo "# M3 receipt ${date_utc}"
+    echo ""
+    echo "Generated by scripts/m3_receipt.sh$([[ "${allow_missing}" == 1 ]] && echo " --allow-missing")."
+    echo "Overall: ${overall}"
+    echo ""
+    echo "## Commit"
+    echo ""
+    echo "- HEAD: ${head_sha}"
+    echo "- Subject: ${head_subject}"
+    echo "- Branch: ${branch}"
+    echo "- Tree before run: clean (checked with git status --porcelain)"
+    echo "- Tree after run: ${tree_after}"
+    echo "- origin/main (local tracking ref): ${origin_main_local} (HEAD equal: $(equals "${origin_main_local}"))"
+    echo "- origin/main (live, git ls-remote): ${origin_main_live} (HEAD equal: $(equals "${origin_main_live}"))"
+    echo "- Run: ${started_utc} to ${finished_utc}"
+    echo ""
+    echo "## Environment"
+    echo ""
+    echo "- Host: $(uname -n)"
+    echo "- Arch: $(uname -m)"
+    echo "- OS: ${os_name}, kernel $(uname -r)"
+    echo "- rustc: ${rustc_v:-not found}"
+    echo "- cargo: ${cargo_v:-not found}"
+    echo "- QEMU: ${qemu_v:-not found}"
+    echo "- swtpm: ${swtpm_v:-not found}"
+    echo "- AAVMF code: ${code_fd} sha256 $(sha_of "${code_fd}")"
+    echo "- AAVMF vars: ${vars_fd} sha256 $(sha_of "${vars_fd}")"
+    echo ""
+    echo "## Commands"
+    echo ""
+    echo "Harness (exit ${verify_status}):"
+    echo ""
+    echo "    ${harness_cmd}"
+    echo ""
+    echo "Every cargo invocation, in first-use order, with the build-time AIENOS_*"
+    echo "variables that were set (recorded by a PATH wrapper, not reconstructed):"
+    echo ""
+    grep -E "(^| )cargo " "${log_dir}/commands.log" | sed 's/ *$//' | awk '!seen[$0]++' | sed 's/^/    /' || true
+    echo ""
+    echo "Every qemu-system-aarch64 invocation (temporary paths differ per run):"
+    echo ""
+    grep -E "(^| )qemu-system-aarch64 " "${log_dir}/commands.log" | sed 's/ *$//' | sed 's/^/    /' || true
+    echo ""
+    echo "## Results"
+    echo ""
+    echo "PASS lines from the harness output, grouped by proof. Each line shows the"
+    echo "verify_all.sh section it came from. One line may support more than one proof."
+    echo ""
+    cat "${results}"
+    echo "### Other PASS lines"
+    echo ""
+    if [[ -n "${other}" ]]; then
+        printf '%s\n' "${other}" | awk -F '\t' '{ printf "    [%s] %s\n", $1, $2 }'
+    else
+        echo "    none"
+    fi
+    echo ""
+    echo "## Log hashes"
+    echo ""
+    echo "Raw logs are not committed. They were kept on the run host in ${log_dir}"
+    echo "(${serial_count} serial logs)."
+    echo ""
+    sed 's/^/    /' "${hashes}"
+    echo ""
+    echo "## Limitations"
+    echo ""
+    echo "- QEMU only (virt machine, TCG). Nothing here is proven on Machine 1 (GB10) hardware."
+    echo "- One SMMUv3 instance (QEMU virt iommu=smmuv3) guarding one device stream (xHCI)."
+    echo "  Machine 1 has several SMMUs; none of them is exercised here."
+    if [[ -n "${debug_features}" ]]; then
+        echo "- Debug-only build features used by some test images: ${debug_features% }."
+        echo "  The QEMU keyboard test (no SMMU) enables identity xHCI DMA through a debug bypass;"
+        echo "  the confined path is the separate SMMU run."
+    else
+        echo "- No debug-only build features were used."
+    fi
+    echo "- The recovery boots run the host's Linux kernel from /boot with the AIENOS recovery"
+    echo "  initrd; they are not AIENOS kernel boots."
+    if [[ "${#missing[@]}" -gt 0 ]]; then
+        echo "- Not yet implemented or not yet reported by any test (MISSING above):"
+        for m in "${missing[@]}"; do echo "  - ${m}"; done
+    fi
+    if [[ "$(equals "${origin_main_live}")" != yes ]]; then
+        echo "- HEAD is not the live origin/main tip, so this receipt is not for main."
+    fi
+    echo ""
+    echo "## Operator sign-off"
+    echo ""
+    echo "Operator sign-off: pending"
+} >"${receipt}"
+
+echo ""
+echo "m3_receipt: wrote ${receipt}"
+echo "m3_receipt: ${overall}"
+if [[ "${#missing[@]}" -gt 0 ]]; then
+    echo "m3_receipt: MISSING proofs: ${missing[*]}"
+fi
+exit "${exit_code}"
diff --git a/scripts/qemu_boot_test.sh b/scripts/qemu_boot_test.sh
index 4895bb0c..0157d807 100755
--- a/scripts/qemu_boot_test.sh
+++ b/scripts/qemu_boot_test.sh
@@ -45,6 +45,7 @@ set -e
 elapsed=$(( $(date +%s) - started ))
 
 tr -d '\r' <"${log}" >"${work}/serial.txt"
+[[ -z "${AIENOS_LOG_DIR:-}" ]] || cp "${work}/serial.txt" "${AIENOS_LOG_DIR}/qemu_boot_serial.log"
 failed=0
 check() { # description, pattern
     if grep -q -- "$2" "${work}/serial.txt"; then
diff --git a/scripts/qemu_keyboard_test.sh b/scripts/qemu_keyboard_test.sh
index f9750dfb..f16862fe 100755
--- a/scripts/qemu_keyboard_test.sh
+++ b/scripts/qemu_keyboard_test.sh
@@ -165,6 +165,7 @@ done
 elapsed=$(( $(date +%s) - started ))
 
 tr -d '\r' <"${work}/serial.log" >"${work}/serial.txt" 2>/dev/null || true
+[[ -z "${AIENOS_LOG_DIR:-}" ]] || cp "${work}/serial.txt" "${AIENOS_LOG_DIR}/qemu_$([[ "${AIENOS_QEMU_SMMU:-0}" == "1" ]] && echo smmu || echo keyboard)_serial.log" 2>/dev/null || true
 failed=0
 check() { # description, pattern
     if grep -q -- "$2" "${work}/serial.txt"; then
diff --git a/scripts/qemu_security_suite.sh b/scripts/qemu_security_suite.sh
index ae54a7a9..3d3da0f2 100755
--- a/scripts/qemu_security_suite.sh
+++ b/scripts/qemu_security_suite.sh
@@ -71,6 +71,7 @@ tpm_status=$?
 set -e
 
 tr -d "\r" <"${log}" >"${work}/subtest1/serial_tpm.txt"
+[[ -z "${AIENOS_LOG_DIR:-}" ]] || cp "${work}/subtest1/serial_tpm.txt" "${AIENOS_LOG_DIR}/gate4_tpm_serial.log"
 if grep -q "kernel: alive" "${work}/subtest1/serial_tpm.txt" && grep -q "report_kind: final" "${work}/subtest1/serial_tpm.txt"; then
     echo "PASS  swTPM live boot reached kernel alive and final report"
 else
@@ -99,6 +100,7 @@ for i in $(seq 1 "${ITERATIONS}"); do
     soak_status=$?
     set -e
     tr -d "\r" <"${soak_log}" >"${soak_work}/serial_soak.txt"
+    [[ -z "${AIENOS_LOG_DIR:-}" ]] || cp "${soak_work}/serial_soak.txt" "${AIENOS_LOG_DIR}/gate4_soak_${i}_serial.log"
     if grep -q "kernel: alive" "${soak_work}/serial_soak.txt" && grep -q "report_kind: final" "${soak_work}/serial_soak.txt"; then
         echo "PASS  Soak run ${i}/${ITERATIONS}: clean boot & reset"
     else
@@ -129,6 +131,7 @@ set -e
 
 if [[ -f "${corrupt_log}" ]]; then
     tr -d "\r" <"${corrupt_log}" >"${corrupt_work}/serial_corrupt.txt"
+    [[ -z "${AIENOS_LOG_DIR:-}" ]] || cp "${corrupt_work}/serial_corrupt.txt" "${AIENOS_LOG_DIR}/gate4_corrupt_serial.log"
     if grep -q "kernel: alive" "${corrupt_work}/serial_corrupt.txt"; then
         echo "FAIL  Corrupted binary unexpectedly reached kernel alive"
         exit 1
diff --git a/scripts/qemu_verify_recovery_media.sh b/scripts/qemu_verify_recovery_media.sh
index d3189878..48b8f438 100755
--- a/scripts/qemu_verify_recovery_media.sh
+++ b/scripts/qemu_verify_recovery_media.sh
@@ -13,6 +13,7 @@ command -v qemu-system-aarch64 >/dev/null || { echo "qemu-system-aarch64 not ins
 
 if [[ "$(uname -m)" != "aarch64" ]]; then
     echo "SKIPPED: Host architecture is $(uname -m). AArch64 kernel recovery boot requires an AArch64 host or cross-built AArch64 kernel."
+    [[ "${AIENOS_STRICT:-0}" != "1" ]] || { echo "STRICT FAIL: recovery boot skipped under AIENOS_STRICT=1" >&2; exit 1; }
     exit 0
 fi
 
@@ -53,6 +54,7 @@ set -e
 elapsed=$(( $(date +%s) - started ))
 
 tr -d '\r' <"${LOG}" >"${WORK_DIR}/recovery_qemu.txt"
+[[ -z "${AIENOS_LOG_DIR:-}" ]] || cp "${WORK_DIR}/recovery_qemu.txt" "${AIENOS_LOG_DIR}/recovery_zero_disk_serial.log"
 
 failed=0
 check() {
@@ -106,6 +108,7 @@ DEV_STATUS=$?
 set -e
 
 tr -d '\r' <"${DEV_LOG}" >"${WORK_DIR}/recovery_devices.txt"
+[[ -z "${AIENOS_LOG_DIR:-}" ]] || cp "${WORK_DIR}/recovery_devices.txt" "${AIENOS_LOG_DIR}/recovery_devices_serial.log"
 echo "qemu exit ${DEV_STATUS}"
 
 failed=0
diff --git a/scripts/verify_all.sh b/scripts/verify_all.sh
index 1bbc2575..10c909a1 100755
--- a/scripts/verify_all.sh
+++ b/scripts/verify_all.sh
@@ -3,14 +3,33 @@
 # Enforces sequential integration gates on the host DGX Spark environment.
 
 set -euo pipefail
+#
+# AIENOS_STRICT=1 turns every SKIPPED step into a failure, so a green strict
+# run proves every step really ran. AIENOS_LOG_DIR=<dir> makes the QEMU
+# scripts copy their serial logs into <dir> (used by scripts/m3_receipt.sh).
+# Without either variable the behaviour is unchanged.
 
 REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+if [[ -n "${AIENOS_LOG_DIR:-}" ]]; then
+    mkdir -p "${AIENOS_LOG_DIR}"
+    AIENOS_LOG_DIR="$(cd "${AIENOS_LOG_DIR}" && pwd)"
+    export AIENOS_LOG_DIR
+fi
 cd "${REPO_ROOT}"
 
+skipped() {
+    echo "SKIPPED: $*"
+    if [[ "${AIENOS_STRICT:-0}" == "1" ]]; then
+        echo "STRICT FAIL: a step was skipped under AIENOS_STRICT=1 ($*)" >&2
+        exit 1
+    fi
+}
+
 echo "============================================================"
 echo "AIENOS Integration Verification Harness"
 echo "Host: $(uname -n) | Arch: $(uname -m) | Kernel: $(uname -r)"
 echo "Date: $(date -u +"%Y-%m-%dT%H:%M:%SZ")"
+echo "Strict: ${AIENOS_STRICT:-0} | Serial log dir: ${AIENOS_LOG_DIR:-none}"
 echo "============================================================"
 
 # Step 1: Gate 1 Verification (Config A Reference Bundle)
@@ -21,22 +40,32 @@ if [[ ! -f "evidence/config_a_reference_bundle.json" ]]; then
     ./scripts/freeze_reality.sh
 fi
 ./scripts/verify_evidence.sh "evidence/config_a_reference_bundle.json"
+echo "PASS  Gate 1 Config A reference bundle verified"
+
+# Step 1b: Formatting
+echo ""
+echo "--- [Formatting: cargo fmt --check] ---"
+cargo fmt --all --check
+echo "PASS  formatting: cargo fmt --all --check"
 
 # Step 2: Host component test suite
 echo ""
 echo "--- [Host Component Testing: Workspace Crates] ---"
 cargo test --workspace
+echo "PASS  host tests: cargo test --workspace"
 
 # Step 3: Linting & Zero-Warning Enforcement
 echo ""
 echo "--- [Clippy Verification: -D warnings] ---"
 cargo clippy --workspace --all-targets -- -D warnings
+echo "PASS  clippy: zero warnings with -D warnings"
 
 # Step 4: Bare-metal library compilation check (not a boot test)
 echo ""
 echo "--- [Bare-Metal Target Compilation Check] ---"
 cargo check -p aienos-kernel --target aarch64-unknown-none --no-default-features
 cargo build -p aienos-kernel --target aarch64-unknown-none --no-default-features
+echo "PASS  AArch64 build: aienos-kernel for aarch64-unknown-none"
 
 # Step 5: Build an AArch64 UEFI diagnostic image and inspect its PE header.
 # This verifies the firmware entry artifact format, not a hardware boot.
@@ -46,6 +75,7 @@ cargo build --release -p aienos-boot --target aarch64-unknown-uefi --features fi
 cargo run --quiet --release -p aienos-evidence -- verify-efi target/aarch64-unknown-uefi/release/aienos-boot.efi
 cargo build --release -p aienos-boot --target aarch64-unknown-uefi --features handoff --bin aienos-handoff
 cargo run --quiet --release -p aienos-evidence -- verify-efi target/aarch64-unknown-uefi/release/aienos-handoff.efi
+echo "PASS  AArch64 build: aienos-boot.efi and aienos-handoff.efi PE headers verified"
 
 # Step 6: QEMU AArch64 UEFI Boot Verification (Emulator Boot Test)
 echo ""
@@ -53,7 +83,7 @@ echo "--- [QEMU AArch64 UEFI Boot Verification] ---"
 if command -v qemu-system-aarch64 >/dev/null && [[ -r "${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}" ]]; then
     ./scripts/qemu_boot_test.sh
 else
-    echo "SKIPPED: qemu-system-aarch64 or AAVMF firmware not present on host."
+    skipped "qemu-system-aarch64 or AAVMF firmware not present on host."
 fi
 
 # Step 6b: SEED-0A USB keyboard candidate, proven in QEMU only (ADR 0012).
@@ -64,11 +94,19 @@ if command -v qemu-system-aarch64 >/dev/null && [[ -r "${AAVMF_CODE:-/usr/share/
     unset AIENOS_UNSAFE_DMA_BYPASS AIENOS_BUILD_FEATURES
     # Default mode: keyboard DMA only through a QEMU SMMUv3 stream.
     AIENOS_QEMU_SMMU=1 ./scripts/qemu_keyboard_test.sh
+else
+    skipped "qemu-system-aarch64 or AAVMF firmware not present on host."
+fi
+
+# Step 6c: SMMUv3 DMA confinement of the xHCI keyboard, QEMU only.
+echo ""
+echo "--- [SMMUv3 DMA Confinement in QEMU] ---"
+if command -v qemu-system-aarch64 >/dev/null && [[ -r "${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}" ]]; then
     ./scripts/qemu_smmu_test.sh
     # No SMMU and no bypass: the keyboard must stay unavailable, DMA off.
     AIENOS_QEMU_SMMU=0 ./scripts/qemu_keyboard_test.sh
 else
-    echo "SKIPPED: qemu-system-aarch64 or AAVMF firmware not present on host."
+    skipped "qemu-system-aarch64 or AAVMF firmware not present on host."
 fi
 
 echo ""
@@ -85,7 +123,7 @@ echo "--- [TRUST-1 Gate 4 Security Suite Verification] ---"
 if command -v qemu-system-aarch64 >/dev/null && command -v swtpm >/dev/null && [[ -r "${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}" ]]; then
     GATE4_SOAK_RUNS=3 ./scripts/qemu_security_suite.sh
 else
-    echo "SKIPPED: qemu-system-aarch64, swtpm, or AAVMF firmware not present on host."
+    skipped "qemu-system-aarch64, swtpm, or AAVMF firmware not present on host."
 fi
 
 # Step 8: TRUST-1 Gate 1 Standalone Recovery Verification (Zero-Disk Boot)
@@ -94,7 +132,7 @@ echo "--- [TRUST-1 Gate 1 Standalone Recovery Verification] ---"
 if command -v qemu-system-aarch64 >/dev/null; then
     ./scripts/qemu_verify_recovery_media.sh
 else
-    echo "SKIPPED: qemu-system-aarch64 not present on host."
+    skipped "qemu-system-aarch64 not present on host."
 fi
 
 # Step 9: Recovery Media Tooling Manifest (issue #17; host-side, no real
@@ -104,5 +142,5 @@ echo "--- [Recovery Media Tooling Manifest] ---"
 if command -v gzip >/dev/null && command -v cpio >/dev/null; then
     ./scripts/verify_recovery_tools.sh
 else
-    echo "SKIPPED: gzip or cpio not present on host."
+    skipped "gzip or cpio not present on host."
 fi