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#138 (code only)

closed derived af02a632fc53c5d5 #138

Imported from GitHub aien-dev/aienux#138 (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 9bb40a990da35d44f99524c01f59056520a97199 · Head cadcbffafa9005abc376cad1877654a2bd9c6261

Apply it

git checkout -b patch-af02a632fc53c5d5 9bb40a990da35d44f99524c01f59056520a97199
curl -fsSL https://interplane.io/drakestapleton/aienux/patches/af02a632fc53c5d5.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
138
cadcbffafa9005abc376cad1877654a2bd9c6261
{"kind":"github-import","owner":"aien-dev","repo":"aienux","number":138,"url":"https://github.com/aien-dev/aienux/pull/138","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:35:48Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/crates/aienos-artifact-tool/src/corpus.rs b/crates/aienos-artifact-tool/src/corpus.rs
index 2e47730e..bfc5081c 100644
--- a/crates/aienos-artifact-tool/src/corpus.rs
+++ b/crates/aienos-artifact-tool/src/corpus.rs
@@ -48,7 +48,9 @@ const MOV_X8_99: u32 = 0xd280_0c68;
 const SVC_0: u32 = 0xd400_0001;
 const B_SELF: u32 = 0x1400_0000;
 const BR_X2: u32 = 0xd61f_0040;
-const MOV_X9_SP: u32 = 0x9100_03e9;
+// SUB X9, SP, #16. SP starts at the stack top (the guard page) when no caps
+// are granted, so the target must be below it to land on a mapped stack page.
+const SUB_X9_SP_16: u32 = 0xd100_43e9;
 const BR_X9: u32 = 0xd61f_0120;
 
 // Canonical offsets (ADR 0014 ยง2).
@@ -329,7 +331,7 @@ pub fn corpus() -> Result<Vec<Case>, Box<dyn Error>> {
             what: "branches onto its own stack (mapped RW+NX)",
             bytes: signed(
                 &manifest(vec![], resources(1, 1, 1, 0, 4)),
-                &words(&[MOV_X9_SP, BR_X9]),
+                &words(&[SUB_X9_SP_16, BR_X9]),
                 b"STACKPAG",
             )?,
             expect: Expect::Admitted {
diff --git a/crates/aienos-boot/src/handoff.rs b/crates/aienos-boot/src/handoff.rs
index bb9ec4ed..9849ac11 100644
--- a/crates/aienos-boot/src/handoff.rs
+++ b/crates/aienos-boot/src/handoff.rs
@@ -1418,16 +1418,39 @@ fn run_artifact_candidates(candidates: &ArtifactCandidates, kernel_root: usize)
             loader::Decision::Admitted => admitted += 1,
             loader::Decision::Rejected => rejected += 1,
         }
-        let mut out = ReportBuf::<2048>::new();
-        loader::write_candidate_line(&mut out, name, &report);
-        loader::write_grant_lines(&mut out, name, &report);
-        match loader::boot_receipt(&report, &context) {
-            (sequence, Some(bytes)) => loader::write_receipt_line(&mut out, name, sequence, &bytes),
-            (sequence, None) => {
-                let _ = writeln!(out, "receipt: {name} seq={sequence} invalid");
+        // Each part gets its own buffer (16 grant lines alone can exceed
+        // 2 KiB), and a part that still overflows is reported, never dropped
+        // silently: the host fails any run that shows `report-truncated:`.
+        let emit = |part: &str, out: &ReportBuf<4096>| {
+            send_to_console(out.as_str());
+            if out.truncated() {
+                let mut note = ReportBuf::<192>::new();
+                let _ = writeln!(note, "report-truncated: {name} part={part}");
+                send_to_console(note.as_str());
             }
+        };
+        {
+            let mut out = ReportBuf::<4096>::new();
+            loader::write_candidate_line(&mut out, name, &report);
+            emit("candidate", &out);
+        }
+        {
+            let mut out = ReportBuf::<4096>::new();
+            loader::write_grant_lines(&mut out, name, &report);
+            emit("grants", &out);
+        }
+        {
+            let mut out = ReportBuf::<4096>::new();
+            match loader::boot_receipt(&report, &context) {
+                (sequence, Some(bytes)) => {
+                    loader::write_receipt_line(&mut out, name, sequence, &bytes)
+                }
+                (sequence, None) => {
+                    let _ = writeln!(out, "receipt: {name} seq={sequence} invalid");
+                }
+            }
+            emit("receipt", &out);
         }
-        send_to_console(out.as_str());
     }
     let mut tail = ReportBuf::<128>::new();
     let _ = writeln!(
diff --git a/crates/aienos-kernel/src/artifact_loader.rs b/crates/aienos-kernel/src/artifact_loader.rs
index aa8b6cf5..76e9a75b 100644
--- a/crates/aienos-kernel/src/artifact_loader.rs
+++ b/crates/aienos-kernel/src/artifact_loader.rs
@@ -198,6 +198,11 @@ pub struct CandidateReport {
     pub outcome: TaskOutcome,
     pub code_base: u64,
     pub code_end: u64,
+    /// Mapped RW+NX data and stack ranges, `[base, end)`, for fault classification.
+    pub data_base: u64,
+    pub data_end: u64,
+    pub stack_base: u64,
+    pub stack_end: u64,
     pub bindings: ReceiptBindings,
     /// Grants installed in the task's capability table, in grant order.
     pub granted: [Option<GrantedCapability>; MAX_CAPABILITIES],
@@ -379,6 +384,9 @@ impl TaskLayout {
     pub const fn data_base(&self) -> u64 {
         self.base + (self.data_first() * PAGE) as u64
     }
+    pub const fn data_end(&self) -> u64 {
+        self.data_base() + (self.data_pages * PAGE) as u64
+    }
     pub const fn stack_base(&self) -> u64 {
         self.base + (self.stack_first() * PAGE) as u64
     }
@@ -1200,6 +1208,10 @@ where
     report.granted = task.grants;
     report.code_base = task.address_space.layout.code_base();
     report.code_end = task.address_space.layout.code_end();
+    report.data_base = task.address_space.layout.data_base();
+    report.data_end = task.address_space.layout.data_end();
+    report.stack_base = task.address_space.layout.stack_base();
+    report.stack_end = task.address_space.layout.stack_top();
     report.wx_enforced = report.bindings.wx_sealed;
     report.outcome = run_task(&mut task, platform, scheduler, executor);
     let teardown = destroy(task, platform, scheduler);
@@ -1232,6 +1244,10 @@ fn empty_report(free_before: usize) -> CandidateReport {
         outcome: TaskOutcome::not_run(),
         code_base: 0,
         code_end: 0,
+        data_base: 0,
+        data_end: 0,
+        stack_base: 0,
+        stack_end: 0,
         bindings: ReceiptBindings::default(),
         granted: [None; MAX_CAPABILITIES],
     }
@@ -1569,13 +1585,38 @@ pub fn write_receipt_line(
     let _ = writeln!(out);
 }
 
+/// Names an EL0 fault from its ESR and FAR. A label that claims a W^X or NX
+/// property requires both the architectural fault kind and the address range
+/// that property is about, so a wild or unmapped access can never prove it.
+fn classify_fault(r: &CandidateReport, esr: u64, far: u64) -> &'static str {
+    let ec = (esr >> 26) & 0x3f;
+    // ISS[5:2] of the IFSC/DFSC: 0b0011 = permission fault, 0b0001 =
+    // translation fault (any level).
+    let status = (esr >> 2) & 0xf;
+    let permission = status == 0b0011;
+    let translation = status == 0b0001;
+    let within = |base: u64, end: u64| far >= base && far < end;
+    let in_data_or_stack = within(r.data_base, r.data_end) || within(r.stack_base, r.stack_end);
+    match ec {
+        // Data abort from EL0 with ISS.WnR set: a write.
+        0x24 if esr & (1 << 6) != 0 && permission && within(r.code_base, r.code_end) => {
+            "code-write"
+        }
+        // Instruction abort from EL0.
+        0x20 if permission && in_data_or_stack => "exec-nx",
+        0x20 if translation => "exec-unmapped",
+        _ => "other",
+    }
+}
+
 /// One stable report line per candidate. Formats (QEMU checks grep these):
 ///
 /// `artifact: NAME admitted id=HEX16 tier=seed0b-test exec=EXEC bytes=identified=verified=admitted=mapped=executed wx=enforced caps=N revoked=yes reclaimed=yes frames=N syscalls=N reads=N denials=N`
 /// `artifact: NAME rejected stage=STAGE reason=REASON reclaimed=yes`
 ///
-/// EXEC is `exited:0x..`, `timeout`, `fault:code-write`, `fault:other`,
-/// `bad-syscall:N`, `resource-overrun`, or `not-run`.
+/// EXEC is `exited:0x..`, `timeout`, `fault:code-write`, `fault:exec-nx`,
+/// `fault:exec-unmapped`, `fault:other`, `bad-syscall:N`, `resource-overrun`,
+/// or `not-run`.
 pub fn write_candidate_line(out: &mut impl core::fmt::Write, name: &str, r: &CandidateReport) {
     let yes_no = |b: bool| if b { "yes" } else { "no" };
     match r.decision {
@@ -1619,18 +1660,7 @@ pub fn write_candidate_line(out: &mut impl core::fmt::Write, name: &str, r: &Can
                     let _ = write!(out, "timeout");
                 }
                 ExecutionStatus::Fault { esr, far, .. } => {
-                    // EC 0x24 data abort from EL0, ISS.WnR (bit 6) set.
-                    let write_abort = (esr >> 26) & 0x3f == 0x24 && esr & (1 << 6) != 0;
-                    // EC 0x20: instruction abort from EL0, i.e. an attempt to
-                    // execute a page mapped non-executable (data or stack).
-                    let exec_abort = (esr >> 26) & 0x3f == 0x20;
-                    if write_abort && far >= r.code_base && far < r.code_end {
-                        let _ = write!(out, "fault:code-write");
-                    } else if exec_abort && (far < r.code_base || far >= r.code_end) {
-                        let _ = write!(out, "fault:exec-nx");
-                    } else {
-                        let _ = write!(out, "fault:other");
-                    }
+                    let _ = write!(out, "fault:{}", classify_fault(r, esr, far));
                 }
                 ExecutionStatus::BadSyscall(n) => {
                     let _ = write!(out, "bad-syscall:{n}");
diff --git a/crates/aienos-kernel/src/artifact_loader_tests.rs b/crates/aienos-kernel/src/artifact_loader_tests.rs
index 8ed74a7f..0cf30d49 100644
--- a/crates/aienos-kernel/src/artifact_loader_tests.rs
+++ b/crates/aienos-kernel/src/artifact_loader_tests.rs
@@ -1206,8 +1206,13 @@ fn admitted_report(status: ExecutionStatus) -> CandidateReport {
         invalid_handle_denials: 1,
         elapsed_ticks: 10,
     };
+    // Loader layout: code, guard, data, guard, stack, guard.
     r.code_base = 0x80_0000_1000;
     r.code_end = 0x80_0000_2000;
+    r.data_base = 0x80_0000_3000;
+    r.data_end = 0x80_0000_4000;
+    r.stack_base = 0x80_0000_5000;
+    r.stack_end = 0x80_0000_6000;
     r
 }
 
@@ -1546,18 +1551,38 @@ fn receipt_line_carries_digest_and_full_record() {
 }
 
 #[test]
-fn instruction_aborts_outside_code_are_exec_nx_faults() {
-    let mut r = admitted_report(ExecutionStatus::Fault {
-        esr: 0x8200_000f, // EC 0x20: instruction abort from EL0, permission
-        far: 0x80_0000_4000,
-        elr: 0x80_0000_4000,
+fn exec_nx_needs_a_permission_fault_inside_data_or_stack() {
+    // EC 0x20 (instruction abort from EL0), IL, IFSC level-3 permission / translation.
+    const PERM: u64 = 0x8200_000f;
+    const TRANSLATION: u64 = 0x8200_0007;
+    let cases: [(u64, u64, &str); 8] = [
+        (PERM, 0x80_0000_3000, "exec-nx"),              // first data byte
+        (PERM, 0x80_0000_3ff8, "exec-nx"),              // last data word
+        (PERM, 0x80_0000_5ff0, "exec-nx"),              // stack, below the top
+        (PERM, 0x80_0000_6000, "other"),                // stack top = guard page
+        (TRANSLATION, 0x80_0000_6000, "exec-unmapped"), // what H24 used to hit
+        (TRANSLATION, 0, "exec-unmapped"),              // wild branch to address 0
+        (PERM, 0x80_0000_1000, "other"),                // code is executable
+        (PERM, 0x80_0000_4000, "other"),                // data guard page
+    ];
+    for (esr, far, want) in cases {
+        let r = admitted_report(ExecutionStatus::Fault { esr, far, elr: far });
+        assert!(
+            line(&r).contains(&std::format!(" exec=fault:{want} ")),
+            "esr={esr:#x} far={far:#x}: {}",
+            line(&r)
+        );
+    }
+}
+
+#[test]
+fn code_write_needs_a_permission_fault() {
+    // EC 0x24, WnR, DFSC level-3 translation: not a W^X proof.
+    let r = admitted_report(ExecutionStatus::Fault {
+        esr: 0x9200_0047,
+        far: 0x80_0000_1008,
+        elr: 0x80_0000_1004,
     });
-    assert!(line(&r).contains(" exec=fault:exec-nx "), "{}", line(&r));
-    r.outcome.status = ExecutionStatus::Fault {
-        esr: 0x8200_000f,
-        far: r.code_base,
-        elr: r.code_base,
-    };
     assert!(line(&r).contains(" exec=fault:other "), "{}", line(&r));
 }
 
diff --git a/docs/SEED0B_MACHINE1_QUALIFICATION.md b/docs/SEED0B_MACHINE1_QUALIFICATION.md
index 78d01eb5..abc5216a 100644
--- a/docs/SEED0B_MACHINE1_QUALIFICATION.md
+++ b/docs/SEED0B_MACHINE1_QUALIFICATION.md
@@ -102,11 +102,20 @@ AIENOS_SEED0B_EVIDENCE=evidence/seed0b_machine1_<date>.md \
 ```
 
 This mode boots nothing. It proves the staged inputs are byte-identical to a
-fresh deterministic pack, applies every qualification-boot check to the
-captured log (P26SEED allow/deny results, the matrix, frame accounting), and
-checks, signs with the TEST ONLY receipt key, and verifies every receipt.
-It requires the `SEED-0B-MACHINE1` tier, so a QEMU log cannot pass. The
-step passes only on `SEED_0B_MACHINE1: PASS`.
+fresh deterministic pack and to their `MANIFEST.sha256` (no unlisted file),
+that the manifest commit, the log's `aienos_commit` and this clean checkout's
+HEAD are one commit, and that the log shows Machine 1's CPU identity (20 cores,
+Cortex-A725/X925 boot core). It then applies every qualification-boot check to
+the captured log (P26SEED allow/deny results, the matrix, frame accounting),
+and checks, signs with the TEST ONLY receipt key, and verifies every receipt.
+
+The `SEED-0B-MACHINE1` tier label alone does not prove hardware: it is a build
+feature (`hardware-staging`), so the same image booted in QEMU prints it too.
+The CPU-identity check is what rejects a QEMU log. A captured log remains
+operator-attested; TRUST-1 measured boot is what will bind it
+cryptographically. When TRUST-1 signs `BOOTAA64.EFI`, record the signed
+image's SHA-256 alongside the manifest rather than replacing the prepared file,
+or the manifest check fails. The step passes only on `SEED_0B_MACHINE1: PASS`.
 
 ## 6. Publish
 
diff --git a/scripts/qemu_artifact_test.sh b/scripts/qemu_artifact_test.sh
index f838210f..6d0786c1 100755
--- a/scripts/qemu_artifact_test.sh
+++ b/scripts/qemu_artifact_test.sh
@@ -32,8 +32,10 @@
 # Captured-log mode (P2-9, Machine 1): AIENOS_SEED0B_SERIAL=<console log>
 # with AIENOS_SEED0B_INPUTS=<dir from scripts/seed0b_machine1_prepare.sh>
 # skips both QEMU boots, proves the staged inputs are byte-identical to a
-# fresh deterministic pack, and applies the qualification-boot checks to the
-# captured log with the SEED-0B-MACHINE1 tier (marker SEED_0B_MACHINE1).
+# fresh deterministic pack and to their MANIFEST.sha256, that the inputs, the
+# log and this clean checkout share one commit, that the log shows Machine 1's
+# CPU identity, and applies the qualification-boot checks to the captured log
+# with the SEED-0B-MACHINE1 tier (marker SEED_0B_MACHINE1).
 #
 # Needs qemu-system-aarch64 and AAVMF (Ubuntu: qemu-system-arm qemu-efi-aarch64).
 set -euo pipefail
@@ -114,12 +116,17 @@ mv "${esp_art}/expected.txt" "${work}/expected.txt"
 touch "${work}/esp/EFI/AIENOS/BOOTREPORT.TXT"
 for f in "${esp_art}"/H*.AIEN; do
     n=$(basename "${f}")
-    grep -q "^${n} " "${work}/ids.txt" || echo "${n} $("${tool}" id "${f}" 2>/dev/null || echo none)" >>"${work}/ids.txt"
+    awk -v n="${n}" '$1 == n { found = 1 } END { exit !found }' "${work}/ids.txt" || echo "${n} $("${tool}" id "${f}" 2>/dev/null || echo none)" >>"${work}/ids.txt"
 done
 candidate_count=$(find "${esp_art}" -maxdepth 1 -name '*.AIEN' | wc -l)
 if [[ -n "${captured}" ]]; then
     cats="ARTIFACT_IDENTITY"
     staged="${AIENOS_SEED0B_INPUTS}/ARTIFACTS"
+    if [[ ! -d "${staged}" ]]; then
+        echo "FAIL  ${staged} is not a directory (AIENOS_SEED0B_INPUTS must be the prepared inputs root)"
+        echo "SEED_0B_MACHINE1: FAIL"
+        exit 1
+    fi
     staged_count=$(find "${staged}" -maxdepth 1 -name '*.AIEN' | wc -l)
     [[ "${staged_count}" == "${candidate_count}" ]] || fail "staged ${staged_count} candidates, expected ${candidate_count}"
     for f in "${esp_art}"/*.AIEN; do
@@ -130,6 +137,54 @@ if [[ -n "${captured}" ]]; then
             fail "staged ${n} differs from the deterministic pack"
         fi
     done
+
+    # Bind log -> inputs -> this checkout, and log -> Machine 1. A captured log
+    # is operator-attested (TRUST-1 adds measured boot); these checks stop the
+    # honest mix-ups: a log from another commit, other inputs, or QEMU.
+    manifest="${AIENOS_SEED0B_INPUTS}/MANIFEST.sha256"
+    inputs_commit=""
+    if [[ ! -r "${manifest}" ]]; then
+        fail "prepared inputs carry MANIFEST.sha256"
+    else
+        if (cd "${AIENOS_SEED0B_INPUTS}" && grep -v '^#' MANIFEST.sha256 | sha256sum --check --strict --quiet); then
+            pass "staged inputs match MANIFEST.sha256"
+        else
+            fail "staged inputs do not match MANIFEST.sha256"
+        fi
+        listed=$(grep -vc '^#' "${manifest}" || true)
+        present=$(cd "${AIENOS_SEED0B_INPUTS}" && find . -type f ! -name MANIFEST.sha256 | wc -l)
+        if [[ "${listed}" == "${present}" ]]; then
+            pass "MANIFEST.sha256 lists every staged file (${present})"
+        else
+            fail "MANIFEST.sha256 lists ${listed} files but ${present} are staged"
+        fi
+        inputs_commit=$(sed -n 's/^# commit \([0-9a-f]\{40\}\)$/\1/p' "${manifest}")
+    fi
+    head_commit=$(git rev-parse HEAD)
+    if [[ -n "${inputs_commit}" && "${inputs_commit}" == "${head_commit}" ]]; then
+        pass "inputs were prepared from this checkout's commit ${head_commit}"
+    else
+        fail "inputs commit '${inputs_commit}' is not this checkout's HEAD ${head_commit}"
+    fi
+    if [[ -z "$(git status --porcelain)" ]]; then
+        pass "checkout is clean"
+    else
+        fail "checkout has uncommitted changes"
+    fi
+    log_commit=$(tr -d '\r' <"${captured}" | sed -n 's/^aienos_commit: //p' | sort -u)
+    if [[ -n "${inputs_commit}" && "${log_commit}" == "${inputs_commit}" ]]; then
+        pass "captured log was produced by the prepared image's commit"
+    else
+        fail "captured log commit '${log_commit}' is not the inputs commit '${inputs_commit}'"
+    fi
+    # Machine 1 CPU identity (evidence/m2_first_boot_2026-09-24.md): 20 cores,
+    # boot core Cortex-A725 (part 0xd87) or Cortex-X925 (0xd85).
+    if tr -d '\r' <"${captured}" | grep -q '^cpu_cores: 20$' && \
+       tr -d '\r' <"${captured}" | grep -qE '^boot_cpu_midr: 0x[0-9a-f]+ \(part 0xd8[57]\)$'; then
+        pass "captured log shows Machine 1 CPU identity (20 cores, A725/X925 boot core)"
+    else
+        fail "captured log does not show Machine 1 CPU identity; a QEMU log cannot qualify Machine 1"
+    fi
     cats=""
 fi
 id_prefix() { # name -> first 16 hex digits of its ArtifactId
@@ -180,6 +235,11 @@ common_checks() { # serial
     check "$1" "M3 EL0 isolation proof unchanged" "el0: ok write=granted forged=denied fault=contained exit=0"
     check "$1" "M3 typed IPC proof unchanged" "ipc: ok message=delivered cap=delegated rights=attenuated forged=denied revoked=denied"
     check "$1" "firmware read all ${candidate_count} artifact candidates" "^artifact_candidates: ${candidate_count}$"
+    if grep -q "^report-truncated:" "$1"; then
+        fail "kernel report lines were truncated: $(grep "^report-truncated:" "$1" | tr '\n' ' ')"
+    else
+        pass "no kernel report line was truncated"
+    fi
     check "$1" "final report reached the console" "report_kind: final"
     if has "$1" "report_kind: (panic|fault)"; then fail "panic or fault reported"; fi
     if has "$1" "^receipt: [^ ]+ seq=[0-9]+ invalid$"; then fail "a candidate produced no valid receipt"; fi
@@ -200,7 +260,7 @@ common_checks() { # serial
 # the host recomputes, and sign/verify with the TEST ONLY receipt key.
 receipt_check() {
     local serial="$1" name="$2" want="$3" line record kdigest out
-    line=$(grep -E "^receipt: ${name} seq=[0-9]+ digest=[0-9a-f]{64} record=[0-9a-f]{1024}$" "${serial}" | tail -1 || true)
+    line=$(grep -E "^receipt: ${name//./\\.} seq=[0-9]+ digest=[0-9a-f]{64} record=[0-9a-f]{1024}$" "${serial}" | tail -1 || true)
     if [[ -z "${line}" ]]; then
         fail "${name} receipt emitted"
         return
diff --git a/scripts/seed0b_machine1_prepare.sh b/scripts/seed0b_machine1_prepare.sh
index 46a85842..4768a303 100755
--- a/scripts/seed0b_machine1_prepare.sh
+++ b/scripts/seed0b_machine1_prepare.sh
@@ -13,9 +13,23 @@
 #   MANIFEST.sha256  sha256 of every file above, plus the commit
 set -euo pipefail
 
+out_arg="${1:?usage: seed0b_machine1_prepare.sh OUT_DIR}"
+# Resolve OUT_DIR against the caller's directory, and start from an empty one
+# so no stale file can enter ARTIFACTS/ or MANIFEST.sha256.
+mkdir -p "${out_arg}"
+out="$(cd "${out_arg}" && pwd)"
+if [[ -n "$(ls -A "${out}")" ]]; then
+    echo "STOP: ${out} is not empty; prepare into a new or empty directory." >&2
+    exit 1
+fi
 repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
 cd "${repo_root}"
-out="${1:?usage: seed0b_machine1_prepare.sh OUT_DIR}"
+case "${out}/" in
+    "${repo_root}"/*)
+        echo "STOP: OUT_DIR ${out} is inside the repository." >&2
+        exit 1
+        ;;
+esac
 if [[ -n "$(git status --porcelain)" ]]; then
     echo "STOP: worktree has uncommitted changes; qualification inputs must come from a commit." >&2
     exit 1