interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

GitHub aien-dev/aien-sovereign-core-mv#451 (code only)

closed derived dfcd4a22c77096ac #451

Imported from GitHub aien-dev/aien-sovereign-core-mv#451 (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 d8b90081523d5247da4f02f64858ba5ba24faf16 · Head 1ebaa08115ec139e13bb9703187ff9188a0b17f2

Apply it

git checkout -b patch-dfcd4a22c77096ac d8b90081523d5247da4f02f64858ba5ba24faf16
curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/dfcd4a22c77096ac.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/aien-sovereign-core-mv
451
1ebaa08115ec139e13bb9703187ff9188a0b17f2
{"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":451,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/451","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:37:13Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index 233f19c7..7c2672ed 100644
--- a/.crumb
+++ b/.crumb
@@ -112,21 +112,21 @@
           "purpose": ""
         },
         {
-          "digest": "ccfbfd158c2d059c0a7dd3101068244f27805b828e44ae695b652ae18e726795",
-          "last_commit": "bba027d",
+          "digest": "c9e1e35fbf8735db1837680b11a5c69af41decd500691470f1091f861867b4da",
+          "last_commit": "01b8809",
           "name": "tools/aien-local-ci",
           "purpose": "Local CI sandbox exec contract (C8), aien-run user/caches install, Forgejo trigger hook, health "
         }
       ],
-      "children_root": "sha256:51934dfd49549a190cb949b997750b0a98ff7bd0edbfdb204d24b56f6bd6f1e5",
-      "compiled_at": "2026-10-11T21:00:13Z",
+      "children_root": "sha256:a99206c1ace0afb823facb1b5490dc9130965e4d4b57a95e83977aa4a4862be0",
+      "compiled_at": "2026-10-11T21:38:16Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:ac491df3f8ea3b2b7b79ee5af21ffb4698ae9aa989828b79e56bf4e68a3ea8f1",
+      "digest": "sha256:29bc155e3a2d98c0beda4a095d6ff3f6353c04b9cab3a49928740d6471443bab",
       "evidence_files": 187,
       "evidence_root": "sha256:27ee0353cb4d4aae2b7dbce2bfe0d9f4ef2a94cd7a4555b84684d59372503280",
-      "files": 3856,
-      "generated_at_commit": "53b8db441ccacf1de6f8a73a17e5f7a68f16d493",
-      "source_tree": "sha256:e4167decad666a3f0193df9ebac36de29f3c808620ac35068a5744c453ff94a7"
+      "files": 3857,
+      "generated_at_commit": "2921bfc0e54a59251a96decd453abbb485a0f0ec",
+      "source_tree": "sha256:4392c9f4a99aa9419b90e4528fd4a2ef95a1136dfcf5e244318364f0d16baf68"
     }
   },
   "history": [],
diff --git a/crates/aien-runtime/tests/prefill_e2e2_run.sh b/crates/aien-runtime/tests/prefill_e2e2_run.sh
index 6dc12aa4..73dca004 100755
--- a/crates/aien-runtime/tests/prefill_e2e2_run.sh
+++ b/crates/aien-runtime/tests/prefill_e2e2_run.sh
@@ -13,8 +13,9 @@
 #       release mode. Stops at the first failing stage with that stage's exit
 #       status (the forge uses &&).
 #   prefill_e2e2_run.sh mutant ID MARKER
-#       Apply prefill_e2e2_mutants/mutant_ID.patch, run the same test, restore
-#       the tree with `git checkout -- .`, and succeed only when the test
+#       Copy the tree to a private temp directory, apply the patch
+#       prefill_e2e2_mutants/mutant_ID.patch there and run the same test
+#       there (the checkout is never patched). Succeed only when the test
 #       failed and its output holds MARKER (the forge KILLED rule). A mutant
 #       that survives, or fails with another message, exits 1.
 #
@@ -32,7 +33,23 @@ cd "$here/../../.." || exit 3
 ckpt=${AIEN_E2E_CHECKPOINT:-$HOME/models/TinyLlama-1.1B-Chat-v1.0}
 out=${AIEN_E2E2_OUT_DIR:-$HOME/workspace/test-queue-logs}
 sha8=$(git rev-parse HEAD | cut -c1-8)
-mkdir -p "$out" || exit 3
+# The sandbox HOME is read-only: receipts then go to a fresh directory in the sandbox's private /tmp.
+if [ -z "${AIEN_E2E2_OUT_DIR:-}" ] && [ ! -w "$HOME" ]; then
+	out=$(mktemp -d) || exit 3
+fi
+# In the user sandbox, aien-run-exec mounts the operator's ~/models read-only at
+# /var/lib/aien-run/models, which is $HOME/models there, so the default above finds the checkpoint.
+# No checkpoint: NOT_RUN with reason model_missing (exit 77 + not_run_reason, see aien-test
+# verdict.rs SELF_NOT_RUN_EXIT), never PASS. The weights' sha256 is recorded either way it runs.
+model_check() {
+	if [ ! -f "$ckpt/model.safetensors" ] || [ ! -f "$ckpt/tokenizer.json" ]; then
+		echo "checkpoint not found: $ckpt (model.safetensors, tokenizer.json)" >&2
+		obs not_run_reason '"model_missing"'
+		exit 77
+	fi
+	obs model_sha256 "\"$(sha256sum "$ckpt/model.safetensors" | cut -c1-64)\""
+}
+mkdir -p "$out" && out=$(cd "$out" && pwd) || exit 3
 
 # The leading newline keeps the line whole when a test left a partial line.
 obs() {
@@ -45,6 +62,7 @@ run_test() {
 }
 
 run_main() {
+	model_check
 	cargo fmt --all -- --check
 	rc=$?
 	obs fmt_rc "$rc"
@@ -75,14 +93,23 @@ run_mutant() {
 		exit 2
 		;;
 	esac
+	model_check
 	patch="crates/aien-runtime/tests/prefill_e2e2_mutants/mutant_$id.patch"
 	lg="$out/AIENTEST-DOGFOOD-$sha8-$id.log"
+	# The patch goes into a private copy of the tree, never into the checkout: aien-test runs gates in
+	# parallel in one checkout, and a patched file there fails their clean-tree checks (and the main leg's
+	# fmt check). The copy shares CARGO_TARGET_DIR so dependencies build once.
+	work=$(mktemp -d) || exit 3
+	trap 'rm -rf "$work"' EXIT
+	trap 'rm -rf "$work"; exit 143' HUP INT TERM
+	git ls-files -z --cached --others --exclude-standard --deduplicate |
+		tar --null --ignore-failed-read -T - -cf - | tar -xf - -C "$work" || exit 3
+	CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-$PWD/target}
+	export CARGO_TARGET_DIR
+	cd "$work" || exit 3
 	git apply "$patch" || exit 3
-	trap 'git checkout -- .; exit 143' HUP INT TERM
 	run_test "$out/AIENTEST-DOGFOOD-receipt-$sha8-$id.json" >"$lg" 2>&1
 	rc=$?
-	git checkout -- .
-	trap - HUP INT TERM
 	echo "LEG $id rc=$rc"
 	grep -n "$marker" "$lg" | head -3
 	obs mutant_test_rc "$rc"
diff --git a/docs/campaigns/scoring/test-scoring-v5.sh b/docs/campaigns/scoring/test-scoring-v5.sh
index 651b20ab..26ed395f 100755
--- a/docs/campaigns/scoring/test-scoring-v5.sh
+++ b/docs/campaigns/scoring/test-scoring-v5.sh
@@ -5,6 +5,10 @@ set -u
 HERE=$(cd "$(dirname "$0")" && pwd)
 S=$HERE/score-rows.sh T=$HERE/tests-v5
 pass=0 fail=0
+# Scratch files go to a private temp dir, never into the tree: aien-test runs gates in parallel in one
+# checkout, and a file here, even for a moment, fails another gate's clean-tree check.
+W=$(mktemp -d) || exit 1
+trap 'rm -rf "$W"' EXIT
 # expect NAME FIXTURE CAMPAIGN_VERDICT EXPECTED_ROW_VERDICTS(ctl,A,B) [EXTRA_JQ_TEST]
 expect() {
   local name=$1 fx=$2 want=$3 rows=$4 out got grows
@@ -30,16 +34,16 @@ if [ "$rc" = 0 ] && [ "$(jq -r .verdict <<<"$out")" = PASS ] && [ "$(jq '.extras
   pass=$((pass + 1)); echo "ok   extra unrequested runs reported (2), not counted"
 else fail=$((fail + 1)); echo "FAIL extra runs: rc $rc"; fi
 # external control F0 absent counts as false (fail closed)
-printf '%s\n' '{"contract":"scoring-v5","campaign":"x","rows":[{"row":"Q","role":"case","reps":1,"expected":"PASS","control":"F0","not_applicable":false}]}' >"$T/.f0.decl"
-printf '%s\n' '{"row":"Q","rep":1,"verdict":"PASS","outcome":"ok"}' >"$T/.f0.res"
-echo '{"F0":true}' >"$T/.f0.ext"
-a=$("$S" "$T/.f0.decl" "$T/.f0.res" 2>/dev/null | jq -r .verdict); b=$("$S" "$T/.f0.decl" "$T/.f0.res" "$T/.f0.ext" 2>/dev/null | jq -r .verdict)
-rm -f "$T"/.f0.decl "$T"/.f0.res "$T"/.f0.ext
+printf '%s\n' '{"contract":"scoring-v5","campaign":"x","rows":[{"row":"Q","role":"case","reps":1,"expected":"PASS","control":"F0","not_applicable":false}]}' >"$W/.f0.decl"
+printf '%s\n' '{"row":"Q","rep":1,"verdict":"PASS","outcome":"ok"}' >"$W/.f0.res"
+echo '{"F0":true}' >"$W/.f0.ext"
+a=$("$S" "$W/.f0.decl" "$W/.f0.res" 2>/dev/null | jq -r .verdict); b=$("$S" "$W/.f0.decl" "$W/.f0.res" "$W/.f0.ext" 2>/dev/null | jq -r .verdict)
+rm -f "$W"/.f0.decl "$W"/.f0.res "$W"/.f0.ext
 if [ "$a" = NOT_RUN ] && [ "$b" = PASS ]; then pass=$((pass + 1)); echo "ok   external control F0 absent NOT_RUN, present PASS"
 else fail=$((fail + 1)); echo "FAIL external F0: absent=$a present=$b"; fi
 # a bad declaration is an error, never a PASS
-echo '{"contract":"scoring-v5","campaign":"x","rows":[{"row":"Q","reps":0,"expected":"PASS"}]}' >"$T/.bad.decl"
-v=$("$S" "$T/.bad.decl" "$T/pass.jsonl" 2>/dev/null | jq -r .verdict); rm -f "$T/.bad.decl"
+echo '{"contract":"scoring-v5","campaign":"x","rows":[{"row":"Q","reps":0,"expected":"PASS"}]}' >"$W/.bad.decl"
+v=$("$S" "$W/.bad.decl" "$T/pass.jsonl" 2>/dev/null | jq -r .verdict); rm -f "$W/.bad.decl"
 if [ "$v" = ERROR ]; then pass=$((pass + 1)); echo "ok   bad declaration (reps 0) is ERROR"; else fail=$((fail + 1)); echo "FAIL bad declaration: $v"; fi
 # the real NEXT-PHASE-2 v4 results (receipt e401fffe) scored with the v4 declaration
 R=$HERE/../next-phase-2/e401fffe189506ecc0152f82bfe895c1374842746ae7cf4b5ac83462ccafe13c.json
diff --git a/tests/gates/run.sh b/tests/gates/run.sh
index 19fcaf13..3514e894 100755
--- a/tests/gates/run.sh
+++ b/tests/gates/run.sh
@@ -27,6 +27,13 @@ if [ -n "${HOME:-}" ] && [ ! -w "$HOME" ]; then
   if [ -f "$ro_home/.gitconfig" ]; then cp "$ro_home/.gitconfig" "$HOME/.gitconfig"; fi
 fi
 obs() { printf 'AIEN-OBS %s %s\n' "$1" "$2"; }
+# Inside the user sandbox (AIEN_SANDBOX_NESTED=1, set by the worker) five aien-test self-tests that would
+# start a sandbox themselves skip (they cannot nest); the receipt says so for the two steps that run them.
+nested_obs() {
+  if [ "${AIEN_SANDBOX_NESTED:-}" = 1 ]; then
+    obs nested_sandbox_skips "\"5 aien-test self-tests skipped inside the user sandbox (AIEN_SANDBOX_NESTED=1)\""
+  fi
+}
 # Outside the worktree when CARGO_TARGET_DIR is, and under target/ otherwise: the hosted test job
 # has no pin checkouts in its tree, and test_t2_f65 scans the tree (minus target/) for *.pem files,
 # which the vendored crates of a pinned aienos ship as test fixtures.
@@ -69,6 +76,7 @@ case "$step" in
     # GitHub Actions sets CI=true in every job. Tests that reach live services or check the
     # branch name (spark-adapters tier1-4) skip themselves under CI, so the hosted job never runs
     # them; without it they fail here on any branch not named feat/, fix/... or on a detached head.
+    nested_obs
     CI=true AIEN_DEV_FALLBACK=1 cargo test --workspace --verbose -- --test-threads=1
     ;;
   strict-mode)
@@ -84,6 +92,7 @@ case "$step" in
   agent-preflight)
     # Hosted: developer context on pull requests, merged-tree on pushes to main.
     # CI=true as on GitHub (see the test step): the script runs cargo test --workspace.
+    nested_obs
     CI=true AIEN_PROOF_OFF=1 AIEN_DEV_FALLBACK=1 AIEN_PREFLIGHT_CONTEXT="${AIEN_PREFLIGHT_CONTEXT:-developer}" bash scripts/agent-preflight.sh
     ;;
   zero-disk-secrets)
diff --git a/tools/aien-local-ci/.crumb b/tools/aien-local-ci/.crumb
index 48a05652..32e4baa5 100644
--- a/tools/aien-local-ci/.crumb
+++ b/tools/aien-local-ci/.crumb
@@ -3,14 +3,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-11T20:00:36Z",
+      "compiled_at": "2026-10-11T21:38:16Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:ccfbfd158c2d059c0a7dd3101068244f27805b828e44ae695b652ae18e726795",
+      "digest": "sha256:c9e1e35fbf8735db1837680b11a5c69af41decd500691470f1091f861867b4da",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 9,
-      "generated_at_commit": "cd88714f9b3c7127278ba7beb9c1046dbd09c0d1",
-      "source_tree": "sha256:2a660cec870e1cfc895189b070dac2c2f7cccdfde7b7e7221963eb9b605f9874"
+      "files": 10,
+      "generated_at_commit": "2921bfc0e54a59251a96decd453abbb485a0f0ec",
+      "source_tree": "sha256:6f1ace1d05259580387ed77d83e7fc9c366a8fd20d9cab0bf15697cf26ebd3f3"
     }
   },
   "layer": "infra",
diff --git a/tools/aien-local-ci/aien-run-exec b/tools/aien-local-ci/aien-run-exec
index 08bb4aaf..91ac56ab 100755
--- a/tools/aien-local-ci/aien-run-exec
+++ b/tools/aien-local-ci/aien-run-exec
@@ -18,6 +18,10 @@
 #     not even the host's own 127.0.0.1 services; no DNS);
 #   * a transient systemd scope under aien-run.slice with cgroup caps (memory, pids, cpu) and a
 #     device policy (host|qemu: standard pseudo devices only, qemu adds /dev/kvm; gb10: all devices);
+#   * the operator's model directory (~/models of the sudo caller) mounted READ-ONLY at /var/lib/aien-run/models
+#     when both exist (install.sh makes the empty root-owned mount point), so model gates such as PREFILL-E2E-2
+#     find their checkpoint at $HOME/models without any write access to it; without it the gate reports
+#     NOT_RUN model_missing;
 #   * rlimits (no core dumps, bounded open files);
 #   * `timeout --signal=TERM --kill-after=10 SECS` for host|qemu (exit 124 on expiry);
 #   * NO timeout for gb10: chip runs are never killed; the engine's advisory timeout only marks the receipt.
@@ -160,10 +164,11 @@ esac
 # shellcheck disable=SC2016
 NS_SETUP='
 set -euo pipefail
-home=$1 profile=$2 wtroot=$3 tdir=$4; shift 4
+home=$1 profile=$2 wtroot=$3 tdir=$4 models=$5; shift 5
 for p in "$wtroot" "$tdir"; do [[ -z $p ]] || mount --bind "$p" "$p"; done
 mount --rbind "$home" "$home"
 mount -o remount,bind,ro "$home"
+if [[ -n $models ]]; then mount --bind "$models" "$home/models"; mount -o remount,bind,ro "$home/models"; fi
 priv=(/var/tmp /var/crash /var/lib/BrlAPI)
 case $profile in host|qemu) priv+=(/tmp /dev/shm /run/lock /run/screen) ;; esac
 for d in "${priv[@]}"; do
@@ -175,12 +180,19 @@ case $profile in host|qemu) ip link set lo up ;; esac
 exec "$@"
 '
 
+# Model directory of the operator who called sudo, if any (read-only bind, see the header).
+models_src=""
+if [[ -n ${SUDO_USER:-} && $SUDO_USER != root ]]; then
+  op_home=$(getent passwd "$SUDO_USER" | cut -d: -f6)
+  if [[ -n $op_home && -d $op_home/models && -d $RUN_HOME/models ]]; then models_src=$(realpath -e -- "$op_home/models"); fi
+fi
+
 inner=()
 case "$profile" in
   host|qemu) inner+=(unshare -m -n -i --propagation private --) ;;
   gb10)      inner+=(unshare -m --propagation private --) ;;
 esac
-inner+=(bash -c "$NS_SETUP" aien-run-ns "$RUN_HOME" "$profile" "$wtroot" "$tdir")
+inner+=(bash -c "$NS_SETUP" aien-run-ns "$RUN_HOME" "$profile" "$wtroot" "$tdir" "$models_src")
 inner+=(prlimit --core=0 --nofile=65536 --)
 case "$profile" in
   host|qemu) inner+=(timeout --signal=TERM --kill-after="$KILL_AFTER" "$secs") ;;
diff --git a/tools/aien-local-ci/install.sh b/tools/aien-local-ci/install.sh
index 5aef3053..807592a3 100755
--- a/tools/aien-local-ci/install.sh
+++ b/tools/aien-local-ci/install.sh
@@ -61,7 +61,7 @@ for f in .bashrc .profile .bash_logout .config Desktop; do
 done
 
 # 2. directory layout (cargo/ and target/ root-owned; only target/<repo>/{pr,main} belong to aien-run)
-S install -d -o root -g root -m 0755 "$RUN_HOME/cargo" "$RUN_HOME/target"
+S install -d -o root -g root -m 0755 "$RUN_HOME/cargo" "$RUN_HOME/target" "$RUN_HOME/models"
 S chown root:root "$RUN_HOME/cargo" "$RUN_HOME/target"; S chmod 0755 "$RUN_HOME/cargo" "$RUN_HOME/target"
 for f in "$RUN_HOME"/cargo/.package-cache "$RUN_HOME"/cargo/.package-cache-mutate "$RUN_HOME"/cargo/.global-cache; do
   if S test -e "$f"; then S chown root:root "$f"; S chmod 0644 "$f"; fi
diff --git a/tools/aien-local-ci/pins b/tools/aien-local-ci/pins
new file mode 100644
index 00000000..0e82450d
--- /dev/null
+++ b/tools/aien-local-ci/pins
@@ -0,0 +1,9 @@
+# Pinned sibling commits the worker makes present in the trusted clones before a run (aien-test worker,
+# `ensure_pins`): `<repo> <source-repo> <sha40>`. A gate pins a sibling commit in its run script
+# (`pin` in tests/gates/run.sh); the sandbox has no network, so a pinned commit that is not on a fetched
+# branch must be fetched by its sha on the trusted side first. The worker fetches a missing one from the
+# trusted clone's own origin and holds it as refs/remotes/aien-pins/<sha> (wt.sh sync copies that ref
+# into the mirror). Read from the operator's trusted sc clone, beside `siblings`; never from the head.
+# Pins that come from lock files (omega.lock and the locks inside it) are not listed: they follow main.
+aien-sovereign-core  aien-protocols  353b7d4be3f00169545caec1615cffa61f7d311a   # SC-TRN1 corpus
+aien-sovereign-core  aien-protocols  b50c00d737fa5c57ea7280e2aa4b0354ff166cf5   # SC-CRB1 corpus
diff --git a/tools/aien-local-ci/tests/run.sh b/tools/aien-local-ci/tests/run.sh
index e7a02b59..9a4abba7 100755
--- a/tools/aien-local-ci/tests/run.sh
+++ b/tools/aien-local-ci/tests/run.sh
@@ -117,10 +117,31 @@ if [[ -d $RUN_HOME/mirror/aien-protocols.git && -d $RUN_HOME/mirror/aien-archite
   fi
 fi
 
+# 14c mirror origin URL (PIPELINE-FINISH): `wt.sh sync` copies the trusted clone's origin URL into the mirror, so a
+# gate that reads `git remote get-url origin` in a sandbox checkout sees the GitHub URL, as on a GitHub runner.
+cl="$HOME/workspace/pipeline/clones/aien-architecture"
+if [[ -d $cl/.git ]]; then
+  bash "$here/../wt.sh" sync aien-architecture "$cl" >/dev/null
+  want=$(git -C "$cl" remote get-url origin)
+  got=$(git -C "$RUN_HOME/mirror/aien-architecture.git" remote get-url origin 2>&1)
+  [[ -n $want && $got == "$want" ]] && ok "mirror carries the trusted clone's origin URL ($got)" || bad "mirror origin" "want=$want got=$got"
+fi
+
 # ---- review fixes (INFRA-2): nothing a check writes can reach a later check ----
 refused() { [[ $1 -eq 2 ]]; }   # exit 2 = refused by aien-run-exec before anything ran
 T_PR="$RUN_HOME/target/aien-sovereign-core/pr"; T_MAIN="$RUN_HOME/target/aien-sovereign-core/main"
 
+# 14b the operator's ~/models is visible read-only at /var/lib/aien-run/models (model gates), never writable
+if [[ -d $HOME/models && -d /var/lib/aien-run/models ]]; then
+  probe=$(cd "$HOME/models" && ls | head -1)
+  out=$(run --cwd /tmp --timeout 20 --profile host -- sh -c "M=/var/lib/aien-run/models
+    [ -e \"\$M/$probe\" ] && echo SEEN
+    touch \$M/aien-run-probe 2>/dev/null && echo MODELS-WRITABLE
+    echo done" 2>&1 | tr '\n' ' ')
+  [[ $out == "SEEN done " ]] && ok "host: ~/models mounted read-only at /var/lib/aien-run/models" || bad "models read-only" "$out"
+else
+  printf 'SKIP 14b: no ~/models or no /var/lib/aien-run/models mount point\n'
+fi
 # 14 the sandbox home is read-only inside every profile: no ~/.cargo/config.toml, no CARGO_HOME config,
 #    no swapping the registry or the cargo proxies, no new dotfiles
 for p in host gb10; do
diff --git a/tools/aien-local-ci/wt.sh b/tools/aien-local-ci/wt.sh
index 83bec449..8bd27639 100755
--- a/tools/aien-local-ci/wt.sh
+++ b/tools/aien-local-ci/wt.sh
@@ -42,6 +42,9 @@ case "$cmd" in
       git -C "$m" config core.sharedRepository 0644
     fi
     git -C "$m" fetch --quiet --prune "$clone" '+refs/heads/*:refs/heads/*' '+refs/remotes/*:refs/remotes/*' '+refs/tags/*:refs/tags/*'
+    # Gates may read the origin URL (the sc tier-1 test f62 does, as on a GitHub runner). The mirror takes the
+    # trusted clone's URL; nothing fetches through it (the sandbox has no network and cannot write the mirror).
+    if u=$(git -C "$clone" remote get-url origin 2>/dev/null); then git -C "$m" config remote.origin.url "$u"; fi
     chmod -R o+rX,o-w "$m"
     printf 'mirror %s: %s refs\n' "$m" "$(git -C "$m" for-each-ref | wc -l)"
     ;;
diff --git a/tools/aien-test/docs/LOCAL_VERIFICATION.md b/tools/aien-test/docs/LOCAL_VERIFICATION.md
index fd768fb3..d2179342 100644
--- a/tools/aien-test/docs/LOCAL_VERIFICATION.md
+++ b/tools/aien-test/docs/LOCAL_VERIFICATION.md
@@ -191,6 +191,44 @@ and prunes every mirror's worktree list. An older `wt.sh` that still makes
 the flat layout (`<wt-root>/<repo>/<sha>` is the checkout) keeps working;
 the worker then journals that no siblings were provided.
 
+
+### Pinned sibling commits and model checkpoints
+
+Some gates check out a pinned commit of a sibling (`pin <dir> <repo> <sha>` in
+`tests/gates/run.sh`, cloned from `../<repo>`). The sandbox has no network,
+so a pinned commit that is on no fetched branch must already be in the
+sibling. `tools/aien-local-ci/pins` (beside `siblings`, read from the
+operator's trusted sc clone, never from the head) lists them as
+`<repo> <source-repo> <sha40>`. Before the siblings are made, the worker
+(`ensure_pins`, trusted side, provisioning time only) fetches a missing pinned
+commit by its sha from the trusted clone's own `origin` and holds it as
+`refs/remotes/aien-pins/<sha>`, so `wt.sh sync` copies it into the mirror and
+git never prunes it. A pin that cannot be made present is a journal note; the
+gate that needs it then fails, never PASS. Pins read from lock files (omega's
+`omega.lock` and the locks inside it) follow main and are not listed.
+
+Model gates (PREFILL-E2E-2 and its eight mutant gates, `requires: host`) read
+the TinyLlama-1.1B-Chat-v1.0 checkpoint at `$HOME/models/TinyLlama-1.1B-Chat-v1.0`
+(`model.safetensors`, `tokenizer.json`). Inside the sandbox `$HOME` is
+`/var/lib/aien-run`; `aien-run-exec` mounts the sudo caller's `~/models`
+read-only at `/var/lib/aien-run/models` (empty root-owned mount point made by
+`install.sh`), so the default path resolves there. The script records the
+weights' sha256 as the observation `model_sha256`. Without the checkpoint it
+prints `AIEN-OBS not_run_reason "model_missing"` and exits 77: the verdict is
+NOT_RUN with reason `model_missing`, never PASS. Exit 77 with a plain
+lowercase `not_run_reason` is the general rule (`verdict::SELF_NOT_RUN_EXIT`);
+without that observation, or when a manifest itself expects 77, it is an
+ordinary exit.
+
+The mutant gates apply their patch to a private copy of the tree in `/tmp`,
+never to the checkout: the gates of one head run in parallel in one checkout,
+and a patched file there would fail every other gate's clean-tree check.
+
+`wt.sh sync` also copies the trusted clone's `origin` URL into the mirror, so
+`git remote get-url origin` in a sandbox checkout gives the GitHub URL, as on a
+GitHub runner (the sc tier-1 test f62 reads it). Nothing fetches through it:
+the sandbox has no network and cannot write the mirror.
+
 ## The worker
 
 For one head `REPO SHA`:
@@ -412,3 +450,14 @@ kill every line of `mutations/aien-test.mutants`.
   aien-sovereign-core; after a change to either merges, that clone's
   checkout must be moved to the new main by the operator before the worker
   uses it (the worker never touches a clone's checkout).
+- Five aien-test self-tests (`a_wrong_target_dir_is_refused_by_the_helper`,
+  `user_sandbox_when_the_helper_exists`, `worker_in_the_user_sandbox_is_ready`,
+  `worker_in_the_user_sandbox_reads_a_read_only_sibling`,
+  `worker_provides_a_sibling_checkout_and_removes_it`) start a sandbox or
+  provision sibling worktrees themselves, which `aien-run` cannot do inside the
+  sandbox. They skip only when `AIEN_SANDBOX_NESTED=1`, which the sandbox
+  wrapper sets for every program it runs (`sandbox::NESTED_MARKER`); they run
+  on GitHub runners and in operator runs. SC-TEST and SC-AGENT-PREFLIGHT record
+  the skip as the observation `nested_sandbox_skips`.
+- The model mount exposes the whole of the operator's `~/models` read-only to
+  every sandboxed gate (all model files, and anything else kept there).
diff --git a/tools/aien-test/src/sandbox.rs b/tools/aien-test/src/sandbox.rs
index 433da4da..c1d64300 100644
--- a/tools/aien-test/src/sandbox.rs
+++ b/tools/aien-test/src/sandbox.rs
@@ -52,6 +52,11 @@ impl Sandbox {
     }
 }
 
+/// Set to `1` in every program the user sandbox runs (`--env` to the helper).
+/// Tests that start a sandbox themselves skip when they see it: aien-run
+/// cannot call the helper or write `/var/lib/aien-run/wt`.
+pub const NESTED_MARKER: &str = "AIEN_SANDBOX_NESTED";
+
 /// The program and arguments to spawn for `program ARGS` under `sandbox`.
 /// `profile` is the gate's pool name; `env` the `K=V` pairs to pass through.
 pub fn command(
@@ -76,6 +81,10 @@ pub fn command(
                 "--profile".to_string(),
                 profile.to_string(),
             ];
+            // Always set: the program knows it runs inside the sandbox, so self-tests
+            // that would need to start a sandbox themselves can skip (they cannot nest).
+            v.push("--env".to_string());
+            v.push(format!("{NESTED_MARKER}=1"));
             for (k, val) in env {
                 v.push("--env".to_string());
                 v.push(format!("{k}={val}"));
@@ -174,6 +183,8 @@ mod tests {
                 "--profile",
                 "qemu",
                 "--env",
+                "AIEN_SANDBOX_NESTED=1",
+                "--env",
                 "CARGO_TARGET_DIR=/tmp/t",
                 "--",
                 "/repo/tools/run.sh",
@@ -188,11 +199,17 @@ mod tests {
     }
 
     #[test]
-    fn no_env_means_no_env_flags_and_a_tiny_timeout_rounds_up_to_one() {
+    fn no_env_means_only_the_nested_marker_and_a_tiny_timeout_rounds_up_to_one() {
         let mut s = spec();
         s.timeout = Duration::from_millis(10);
         let w = wrap(Sandbox::User, s, "host", &[]);
-        assert!(!w.args.iter().any(|a| a == "--env"));
+        let envs: Vec<&String> = w
+            .args
+            .windows(2)
+            .filter(|p| p[0] == "--env")
+            .map(|p| &p[1])
+            .collect();
+        assert_eq!(envs, vec!["AIEN_SANDBOX_NESTED=1"]);
         let pos = w.args.iter().position(|a| a == "--timeout").unwrap();
         assert_eq!(w.args[pos + 1], "1");
         assert_eq!(env_pairs(None), Vec::<(String, String)>::new());
diff --git a/tools/aien-test/src/verdict.rs b/tools/aien-test/src/verdict.rs
index baf79a44..45936337 100644
--- a/tools/aien-test/src/verdict.rs
+++ b/tools/aien-test/src/verdict.rs
@@ -240,6 +240,31 @@ pub fn pre_run(m: &Manifest, f: &Facts) -> Option<(Verdict, String)> {
     None
 }
 
+/// Exit status with which a program says it could not run because an input it
+/// does not own is absent (a model checkpoint, say), together with a
+/// `not_run_reason` observation holding a plain lowercase name. The verdict is
+/// then NOT_RUN with that reason: a refusal, never PASS. Without a valid
+/// reason, or when the manifest itself expects 77, it is an ordinary exit.
+pub const SELF_NOT_RUN_EXIT: i64 = 77;
+
+fn self_not_run(m: &Manifest, f: &Facts) -> Option<String> {
+    if f.timed_out || f.exit_status != Some(SELF_NOT_RUN_EXIT) || m.expect_exit == SELF_NOT_RUN_EXIT
+    {
+        return None;
+    }
+    let o = f
+        .observations
+        .iter()
+        .rev()
+        .find(|o| o.name == "not_run_reason")?;
+    let s = o.value.as_str()?;
+    let plain = !s.is_empty()
+        && s.len() <= 64
+        && s.bytes()
+            .all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'_');
+    plain.then(|| s.to_string())
+}
+
 pub fn derive(m: &Manifest, f: &Facts) -> Derived {
     if let Some((verdict, reason)) = pre_run(m, f) {
         return Derived {
@@ -255,6 +280,8 @@ pub fn derive(m: &Manifest, f: &Facts) -> Derived {
         .collect();
     let (verdict, reason) = if f.timed_out {
         (Verdict::Fail, "timeout".to_string())
+    } else if let Some(r) = self_not_run(m, f) {
+        (Verdict::NotRun, r)
     } else if f.exit_status != Some(m.expect_exit) {
         (Verdict::Fail, "rc_nonzero".to_string())
     } else if let Some(idx) = rules.iter().position(|r| !r.1) {
@@ -362,6 +389,43 @@ mod tests {
         assert_eq!(derive(&m(None), &f).reason, "rule:0");
     }
 
+    #[test]
+    fn exit_77_with_a_reason_is_not_run_and_nothing_else_is() {
+        let reason = |v: Value| Observation {
+            name: "not_run_reason".into(),
+            value: v,
+        };
+        let mut f = good_facts();
+        f.exit_status = Some(77);
+        f.observations.push(reason(json!("model_missing")));
+        let d = derive(&m(None), &f);
+        assert_eq!(
+            (d.verdict, d.reason.as_str()),
+            (Verdict::NotRun, "model_missing")
+        );
+        // No reason, or a reason that is not a plain name: an ordinary failure.
+        f.observations.retain(|o| o.name != "not_run_reason");
+        assert_eq!(derive(&m(None), &f).reason, "rc_nonzero");
+        for bad in [json!("Model Missing"), json!(""), json!(3), json!("a;b")] {
+            let mut g = f.clone();
+            g.observations.push(reason(bad));
+            assert_eq!(derive(&m(None), &g).reason, "rc_nonzero");
+        }
+        // The reason never turns another exit into NOT_RUN, and a timeout stays a timeout.
+        let mut g = good_facts();
+        g.exit_status = Some(1);
+        g.observations.push(reason(json!("model_missing")));
+        assert_eq!(derive(&m(None), &g).reason, "rc_nonzero");
+        let mut g = f.clone();
+        g.observations.push(reason(json!("model_missing")));
+        g.timed_out = true;
+        assert_eq!(derive(&m(None), &g).reason, "timeout");
+        // A manifest that expects 77 keeps its own meaning.
+        let m77 = m(Some(("exit: 0", "exit: 77")));
+        assert_eq!(derive(&m77, &g.clone()).reason, "timeout");
+        g.timed_out = false;
+        assert_eq!(derive(&m77, &g).verdict, Verdict::Pass);
+    }
     #[test]
     fn exit_status_must_match_expectation() {
         let mut f = good_facts();
diff --git a/tools/aien-test/src/worker.rs b/tools/aien-test/src/worker.rs
index 0af3a473..9b8a03cd 100644
--- a/tools/aien-test/src/worker.rs
+++ b/tools/aien-test/src/worker.rs
@@ -391,6 +391,108 @@ fn siblings_for(cfg: &Config, repo: &str) -> Result<Vec<Sibling>, String> {
     parse_siblings(&text, repo)
 }
 
+/// One commit a repository's gates check out from a sibling (`pin` in its
+/// `tests/gates/run.sh`): the sibling's source repository and the commit.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Pin {
+    pub source: String,
+    pub sha: String,
+}
+
+/// Parse the pin list (`tools/aien-local-ci/pins` beside the sibling map;
+/// `<repo> <source-repo> <sha40>` per line, `#` comments) and return the
+/// pins of `repo`. Every line is checked, as in the sibling map.
+pub fn parse_pins(text: &str, repo: &str) -> Result<Vec<Pin>, String> {
+    let mut out = Vec::new();
+    for (n, raw) in text.lines().enumerate() {
+        let line = raw.split('#').next().unwrap_or("").trim();
+        if line.is_empty() {
+            continue;
+        }
+        let f: Vec<&str> = line.split_whitespace().collect();
+        let bad = |why: &str| format!("pin list line {}: {why}: {raw:?}", n + 1);
+        if f.len() != 3 {
+            return Err(bad("needs <repo> <source-repo> <sha40>"));
+        }
+        if !valid_repo_key(f[0]) || !valid_repo_key(f[1]) {
+            return Err(bad("repo and source must be plain names"));
+        }
+        if !valid_sha(f[2]) {
+            return Err(bad("the commit must be a full lowercase sha"));
+        }
+        if f[0] == repo {
+            out.push(Pin {
+                source: f[1].to_string(),
+                sha: f[2].to_string(),
+            });
+        }
+    }
+    Ok(out)
+}
+
+/// The pins of `repo` from the `pins` file beside the sibling map (none
+/// without a map or without the file). A file that exists but cannot be read
+/// or parsed refuses the run, like a broken sibling map.
+fn pins_for(cfg: &Config, repo: &str) -> Result<Vec<Pin>, String> {
+    let Some(map) = &cfg.siblings else {
+        return Ok(Vec::new());
+    };
+    let path = map.with_file_name("pins");
+    if !path.exists() {
+        return Ok(Vec::new());
+    }
+    let text = fs::read_to_string(&path)
+        .map_err(|e| format!("cannot read the pin list {}: {e}", path.display()))?;
+    parse_pins(&text, repo)
+}
+
+/// Make every pinned commit of a sibling present in that sibling's trusted
+/// clone before the siblings are made, so the sandbox (which has no network)
+/// finds it. Runs on the trusted side at provisioning time only: a missing
+/// commit is fetched by its sha from the clone's own `origin`, then held by
+/// `refs/remotes/aien-pins/<sha>` so `wt.sh sync` copies it into the mirror and
+/// `git gc` keeps it. A pin that cannot be made present is a note; the gate
+/// that needs it then fails on the missing commit, never PASS.
+pub fn ensure_pins(clones: &Path, pins: &[Pin], sibs: &[Sibling], notes: &mut Vec<String>) {
+    for p in pins {
+        if !sibs.iter().any(|s| s.source == p.source) {
+            notes.push(format!(
+                "pin {}@{}: {} is not a sibling of this repository; not provided",
+                p.source, p.sha, p.source
+            ));
+            continue;
+        }
+        let src = clones.join(&p.source);
+        let want = format!("{}^{{commit}}", p.sha);
+        let present = |src: &Path| git(src, &["cat-file", "-e", &want]).is_ok();
+        if !present(&src) {
+            match git(&src, &["fetch", "--quiet", "origin", &p.sha]) {
+                Ok(_) if present(&src) => {
+                    notes.push(format!("pin {}@{}: fetched from origin", p.source, p.sha))
+                }
+                Ok(_) => {
+                    notes.push(format!(
+                        "pin {}@{}: fetch gave no such commit; not provided",
+                        p.source, p.sha
+                    ));
+                    continue;
+                }
+                Err(e) => {
+                    notes.push(format!("pin {}@{}: not provided: {e}", p.source, p.sha));
+                    continue;
+                }
+            }
+        }
+        let r = format!("refs/remotes/aien-pins/{}", p.sha);
+        if let Err(e) = git(&src, &["update-ref", &r, &p.sha]) {
+            notes.push(format!(
+                "pin {}@{}: cannot hold it in {r}: {e}",
+                p.source, p.sha
+            ));
+        }
+    }
+}
+
 /// Where a head runs: `<wt_root>/<repo>/<sha>/` holds the checkout under test
 /// at `<repo>/` and its siblings beside it, so `../<dir>` in the checkout is
 /// the sibling. `nested` is false only for an older `wt.sh` that still makes
@@ -708,9 +810,11 @@ pub fn run_once(cfg: &Config, repo: &str, sha: &str) -> Result<Summary, String>
     // The sibling map is read before anything is checked out: a broken map
     // refuses the run instead of leaving a half-made neighbourhood.
     let sibs = siblings_for(cfg, repo)?;
+    let pins = pins_for(cfg, repo)?;
     let mut notes: Vec<String> = Vec::new();
     cfg.state.beat(repo, sha, "checkout");
     let co = checkout(cfg, repo, sha, &mut notes)?;
+    ensure_pins(&cfg.clones, &pins, &sibs, &mut notes);
     let made = provision_siblings(cfg, repo, sha, &co, &sibs, &mut notes);
     let (clone, wt) = (co.clone.clone(), co.wt.clone());
     // A wt.sh worktree belongs to aien-run; the operator's git opens it only
@@ -1346,6 +1450,135 @@ pub fn run_loop(cfg: &Config, iterations: Option<u64>) -> usize {
 mod tests {
     use super::*;
 
+    #[test]
+    fn pin_list_selects_the_repository_and_refuses_bad_lines() {
+        let sha = "353b7d4be3f00169545caec1615cffa61f7d311a";
+        let list =
+            format!("# c\naien-sovereign-core aien-protocols {sha} # t\nomega physics {sha}\n");
+        let p = parse_pins(&list, "aien-sovereign-core").unwrap();
+        assert_eq!(
+            p,
+            vec![Pin {
+                source: "aien-protocols".into(),
+                sha: sha.into()
+            }]
+        );
+        assert!(parse_pins(&list, "physics").unwrap().is_empty());
+        for bad in [
+            "a b".to_string(),
+            format!("a b {sha} extra"),
+            format!("a ../b {sha}"),
+            "a b 353b7d4".to_string(),
+            format!("a b {}", sha.to_uppercase()),
+        ] {
+            assert!(parse_pins(&bad, "a").is_err(), "{bad}");
+        }
+    }
+
+    fn sh_git(dir: &Path, args: &[&str]) -> String {
+        git(dir, args).unwrap_or_else(|e| panic!("git {args:?}: {e}"))
+    }
+
+    /// The trusted clone lacks a pinned commit that only its origin has (on a
+    /// branch the clone never fetched): ensure_pins fetches it by sha and holds
+    /// it under refs/remotes/aien-pins/. Negative controls: a pin of a
+    /// repository that is not a sibling, and a commit origin does not have.
+    #[test]
+    fn ensure_pins_fetches_a_missing_pinned_commit_from_origin() {
+        let t = crate::testutil::TempDir::new("pins");
+        let origin = t.path().join("origin");
+        fs::create_dir_all(&origin).unwrap();
+        sh_git(&origin, &["init", "-q", "-b", "main"]);
+        for (k, v) in [
+            ("user.name", "t"),
+            ("user.email", "t@t"),
+            ("uploadpack.allowAnySHA1InWant", "true"),
+        ] {
+            sh_git(&origin, &["config", k, v]);
+        }
+        fs::write(origin.join("f"), "1").unwrap();
+        sh_git(&origin, &["add", "-A"]);
+        sh_git(&origin, &["commit", "-q", "-m", "one"]);
+        sh_git(&origin, &["checkout", "-q", "-b", "side"]);
+        fs::write(origin.join("f"), "2").unwrap();
+        sh_git(&origin, &["commit", "-q", "-am", "two"]);
+        let pinned = sh_git(&origin, &["rev-parse", "HEAD"]).trim().to_string();
+        sh_git(&origin, &["checkout", "-q", "main"]);
+        let clones = t.path().join("clones");
+        fs::create_dir_all(&clones).unwrap();
+        sh_git(
+            &clones,
+            &[
+                "clone",
+                "-q",
+                "--single-branch",
+                "--no-local",
+                "-b",
+                "main",
+                origin.to_str().unwrap(),
+                "src",
+            ],
+        );
+        let src = clones.join("src");
+        let want = format!("{pinned}^{{commit}}");
+        assert!(
+            git(&src, &["cat-file", "-e", &want]).is_err(),
+            "the clone must lack the pin first"
+        );
+
+        let sibs = vec![Sibling {
+            dir: "src".into(),
+            source: "src".into(),
+            git_ref: "main".into(),
+        }];
+        let absent = "0123456789abcdef0123456789abcdef01234567".to_string();
+        let pins = vec![
+            Pin {
+                source: "src".into(),
+                sha: pinned.clone(),
+            },
+            Pin {
+                source: "other".into(),
+                sha: pinned.clone(),
+            },
+            Pin {
+                source: "src".into(),
+                sha: absent.clone(),
+            },
+        ];
+        let mut notes = Vec::new();
+        ensure_pins(&clones, &pins, &sibs, &mut notes);
+        assert!(git(&src, &["cat-file", "-e", &want]).is_ok(), "{notes:?}");
+        let held = sh_git(
+            &src,
+            &["rev-parse", &format!("refs/remotes/aien-pins/{pinned}")],
+        );
+        assert_eq!(held.trim(), pinned);
+        assert!(
+            notes.iter().any(|n| n.contains("fetched from origin")),
+            "{notes:?}"
+        );
+        assert!(
+            notes.iter().any(|n| n.contains("other is not a sibling")),
+            "{notes:?}"
+        );
+        assert!(
+            notes
+                .iter()
+                .any(|n| n.contains(&absent) && n.contains("not provided")),
+            "{notes:?}"
+        );
+        assert!(git(
+            &src,
+            &[
+                "rev-parse",
+                "--verify",
+                "--quiet",
+                &format!("refs/remotes/aien-pins/{absent}")
+            ]
+        )
+        .is_err());
+    }
     #[test]
     fn sibling_map_selects_the_repository_and_refuses_bad_lines() {
         let map = "# comment\n\
diff --git a/tools/aien-test/tests/local_ci.rs b/tools/aien-test/tests/local_ci.rs
index 035df6d6..3864f8ee 100644
--- a/tools/aien-test/tests/local_ci.rs
+++ b/tools/aien-test/tests/local_ci.rs
@@ -707,6 +707,9 @@ fn bare_exec_runs_and_escapes_are_refused() {
 
 #[test]
 fn user_sandbox_when_the_helper_exists() {
+    if nested_in_sandbox("user_sandbox_when_the_helper_exists") {
+        return;
+    }
     if !Path::new(aien_test::sandbox::EXEC_HELPER).exists() {
         println!(
             "SKIP: {} is not installed (INFRA lane)",
@@ -956,6 +959,9 @@ fn symlinked_exec_out_of_the_tree_never_runs() {
 
 #[test]
 fn worker_in_the_user_sandbox_is_ready() {
+    if nested_in_sandbox("worker_in_the_user_sandbox_is_ready") {
+        return;
+    }
     let _turn = USER_SANDBOX.lock().unwrap_or_else(|e| e.into_inner());
     if !Path::new(aien_test::sandbox::EXEC_HELPER).exists() {
         println!(
@@ -1110,6 +1116,9 @@ fn only_a_wt_sh_link_is_trusted() {
 
 #[test]
 fn a_wrong_target_dir_is_refused_by_the_helper() {
+    if nested_in_sandbox("a_wrong_target_dir_is_refused_by_the_helper") {
+        return;
+    }
     if !Path::new(aien_test::sandbox::EXEC_HELPER).exists() {
         println!(
             "SKIP: {} is not installed (INFRA lane)",
@@ -1235,6 +1244,9 @@ fn gate_verdict(s: &worker::Summary, id: &str) -> Verdict {
 
 #[test]
 fn worker_provides_a_sibling_checkout_and_removes_it() {
+    if nested_in_sandbox("worker_provides_a_sibling_checkout_and_removes_it") {
+        return;
+    }
     let w = world();
     let (head_s, sib_sha, map) = sibling_world(&w);
     let mut cfg = w.config();
@@ -1283,6 +1295,9 @@ fn a_broken_sibling_map_refuses_the_run_before_any_checkout() {
 
 #[test]
 fn worker_in_the_user_sandbox_reads_a_read_only_sibling() {
+    if nested_in_sandbox("worker_in_the_user_sandbox_reads_a_read_only_sibling") {
+        return;
+    }
     let _turn = USER_SANDBOX.lock().unwrap_or_else(|e| e.into_inner());
     if !Path::new(aien_test::sandbox::EXEC_HELPER).exists() || !wt_tool().is_file() {
         println!("SKIP: exec helper or wt.sh not present (INFRA lane)");
@@ -1317,3 +1332,20 @@ fn worker_in_the_user_sandbox_reads_a_read_only_sibling() {
         "run directory left behind"
     );
 }
+
+/// True inside the user sandbox (`AIEN_SANDBOX_NESTED=1`, set by the worker's
+/// sandbox wrapper): the five tests that start a sandbox or provision sibling
+/// worktrees themselves cannot nest there (aien-run may not call the helper or
+/// write `/var/lib/aien-run/wt`), so they skip and say so. They run everywhere
+/// else: on GitHub runners and in operator runs. tests/gates/run.sh records
+/// the skip as an observation.
+fn nested_in_sandbox(test: &str) -> bool {
+    let nested = std::env::var(aien_test::sandbox::NESTED_MARKER).as_deref() == Ok("1");
+    if nested {
+        println!(
+            "SKIP-NESTED: {test}: inside the user sandbox ({}=1)",
+            aien_test::sandbox::NESTED_MARKER
+        );
+    }
+    nested
+}