diff --git a/.github/workflows/_build-platform.yml b/.github/workflows/_build-platform.yml
index 1070727..4a3d022 100644
--- a/.github/workflows/_build-platform.yml
+++ b/.github/workflows/_build-platform.yml
@@ -417,7 +417,7 @@ jobs:
[ "$rc" -eq 0 ] || exit "$rc"
# Spec 31 §5/§8.4: sign (Developer ID Application, hardened
- # runtime, the ci/runtime.entitlements pair) + notarize the macOS
+ # runtime, the ci/runtime.entitlements set) + notarize the macOS
# runtime exe IN-LEG, before the symbol-provenance check and the
# boot smoke — every downstream gate, and the publish stage's
# .sha256 sidecar, anchors the exact SIGNED bytes (sign-then-hash
@@ -426,8 +426,10 @@ jobs:
# armed + a missing secret is a fast named failure). The exe is
# left quarantine-marked: the boot smoke — the jit_llvm legs
# exercise CPython's JIT — then runs under Gatekeeper's exact
- # download path, proving the allow-jit/disable-library-validation
- # pair on the signed exe.
+ # download path, proving the entitlement set on the signed exe
+ # (the enumeration lives in ci/runtime.entitlements, asserted
+ # by key name in ci/macos-sign-notarize-runtime.sh — never
+ # re-spelled here).
- name: Sign + notarize the runtime exe (macos, spec 31)
if: matrix.os == 'macos'
shell: bash
diff --git a/README.md b/README.md
index 41a8898..573163a 100644
--- a/README.md
+++ b/README.md
@@ -99,6 +99,18 @@ incarnations:
child skips the boot and runs the interpreter, whose libc IO the shim
now serves from the VFS.
+The macOS entitlement plane of that re-exec (tebako#1117): the
+hardened runtime strips `DYLD_INSERT_LIBRARIES` at launch unless the
+exe carries `com.apple.security.cs.allow-dyld-environment-variables`
+— so `ci/runtime.entitlements` carries it, and
+`ci/macos-sign-notarize-runtime.sh` asserts it embedded by key name
+(no runner can police the class at exec time: macOS 15's dyld
+tolerates the omission; macOS 14 strips — the tebako-runtime-r#5
+class, whose python symptom is `No module named 'encodings'`). The
+mechanism determination, and why the omission never fired while every
+published python runtime shipped unsigned, is recorded in
+`docs/build-chain.md`.
+
`PYTHONHOME` is set env-first — `TEBAKO_MOUNT_ROOT` when set-and-
nonempty, else `tebako_mount_point()` (the ruby factory's era-2 rbconfig
pattern: the driver's ffi mount point is fixed before the windows
diff --git a/ci/macos-sign-notarize-runtime.sh b/ci/macos-sign-notarize-runtime.sh
index e0f79bc..fad26f9 100755
--- a/ci/macos-sign-notarize-runtime.sh
+++ b/ci/macos-sign-notarize-runtime.sh
@@ -26,7 +26,7 @@
# ci/macos-sign-notarize-runtime.sh — spec 31 §5/§8.4: sign the freshly
# built macOS runtime exe (Developer ID Application, hardened runtime,
-# the ci/runtime.entitlements pair) and notarize it, in-leg, BEFORE the
+# the ci/runtime.entitlements set) and notarize it, in-leg, BEFORE the
# symbol-provenance check and the boot smoke — every downstream gate, and
# the publish stage's .sha256 sidecar, then anchors the exact SIGNED
# bytes (sign-then-hash is mandatory).
@@ -89,18 +89,32 @@ HASH=$(security find-identity -v -p codesigning "$KC" | awk '/Developer ID Appli
[ -n "$HASH" ] || { echo "::error::no Developer ID Application identity in the p12"; exit 1; }
echo "signing identity cert: ${HASH:0:10}…"
-step "codesign (hardened runtime + the spec 31 §3 pair)"
+step "codesign (hardened runtime + the spec 31 §3 set)"
codesign --force --options runtime --timestamp --keychain "$KC" \
--entitlements ci/runtime.entitlements --sign "$HASH" "$exe"
codesign --verify --strict --verbose=1 "$exe"
codesign -dvv "$exe" 2>&1 | grep -q "TeamIdentifier=$APPLE_TEAM_ID" \
|| { echo "::error::TeamIdentifier is not $APPLE_TEAM_ID — signed by an unexpected identity"; exit 1; }
-# macOS 15 emits the embedded plist single-line — count values,
-# never key lines.
+# macOS 15 emits the embedded plist single-line — count values
+# AND grep each key by name (a count alone passes a wrong-keyed
+# profile). The name check is the load-bearing half: no CI runner can
+# police a MISSING allow-dyld-environment-variables at exec time (the
+# macos-15 runners' dyld tolerates the omission and serves the shim
+# anyway; macOS 14 strips DYLD_INSERT_LIBRARIES without it and the
+# unpatched interpreter dies shimless on the encodings import —
+# the tebako-runtime-r#5 class, tebako#1117), so the profile is
+# asserted statically here, where the bytes are still in-leg.
codesign -d --entitlements :- "$exe" > "$work/embedded.xml" 2>/dev/null || true
TRUES=$(grep -o '' "$work/embedded.xml" | wc -l | tr -d ' ')
-[ "$TRUES" = "2" ] || { cat "$work/embedded.xml"; echo "::error::entitlement pair not embedded (got $TRUES )"; exit 1; }
-echo "entitlements embedded: disable-library-validation + allow-jit"
+[ "$TRUES" = "3" ] || { cat "$work/embedded.xml"; echo "::error::entitlement set not embedded (got $TRUES )"; exit 1; }
+for key in allow-dyld-environment-variables disable-library-validation allow-jit; do
+ grep -q "com.apple.security.cs.$key" "$work/embedded.xml" || {
+ cat "$work/embedded.xml"
+ echo "::error::entitlement $key missing from the embedded profile — the tebako-runtime-r#5 class: the runner cannot be trusted to catch it at exec time (tebako#1117)"
+ exit 1
+ }
+done
+echo "entitlements embedded: allow-dyld-environment-variables + disable-library-validation + allow-jit"
step "notarize (App Store Connect API key)"
printf '%s' "$APPLE_ASC_KEY_P8" > "$work/AuthKey.p8"
diff --git a/ci/runtime.entitlements b/ci/runtime.entitlements
index 7273ad3..3443bd9 100644
--- a/ci/runtime.entitlements
+++ b/ci/runtime.entitlements
@@ -1,24 +1,56 @@
+ com.apple.security.cs.allow-dyld-environment-variables
+
com.apple.security.cs.disable-library-validation
com.apple.security.cs.allow-jit
diff --git a/docs/build-chain.md b/docs/build-chain.md
new file mode 100644
index 0000000..0cd9151
--- /dev/null
+++ b/docs/build-chain.md
@@ -0,0 +1,72 @@
+# The build chain — architecture and invariants
+
+The staged build (fetch/verify → configure/make → driver link →
+env-image pack → sidecars) lives in `tools/build_runtime`; the README's
+"The unpatched interpreter: preload shim + re-exec" section owns the
+visibility mechanism. This file records the cross-cutting planes that
+mechanism depends on, with their evidence. First plane: the macOS
+signing profile.
+
+## The macOS signing profile and the dyld stripping plane (tebako#1117)
+
+The audit question (tebako#1117, opened from the tebako-runtime-r#5
+incident): does the runtime exe (a) re-exec with
+`DYLD_INSERT_LIBRARIES` armed AND (b) need the shim for core IO
+visibility? For this factory both answers are YES, by construction:
+
+- **(a) the re-exec exists.** `build/resources/tebako_python_main.c`
+ (the fs TU) boots the driver in-process, then re-execs the exe with
+ the driver-armed env — `DYLD_INSERT_LIBRARIES` naming the
+ materialized in-image `libtfs_preload.dylib` on macOS (README's
+ two-incarnation composition).
+- **(b) the shim is the only visibility.** CPython is unpatched (the
+ tamatebako/python zero-patch contract): every interpreter read of the
+ mounted tree — the encodings import, the stdlib, site-packages — is
+ plain libc IO that only the shim serves. Ruby's patched-IO exemption
+ does not exist here.
+
+So the profile (`ci/runtime.entitlements`) MUST carry
+`com.apple.security.cs.allow-dyld-environment-variables`: on a
+hardened-runtime exe without the grant, dyld strips the variable at
+the re-exec (macOS 14 — silently, by design), the second incarnation
+runs shimless, and the boot dies
+`ModuleNotFoundError: No module named 'encodings'` — the exact
+tebako-runtime-r#5 class ("unable to open the base package"), one
+interpreter over.
+
+### Why the omission never fired before this audit (the fragile part)
+
+Every python runtime published to date ships **unsigned**
+(`APPLE_SIGNING_ENABLED` has never been armed in this repo — verified
+on the published v0.3.5 `macos-arm64` exe: `flags=0x20002
+(adhoc,linker-signed)`, no TeamIdentifier). dyld strips
+`DYLD_INSERT_LIBRARIES` only for hardened-runtime targets, so an
+adhoc exe keeps the insertion on every macOS generation and the boot
+works — that, and nothing else, is why the pydata payload's demo ran
+green on darwin-23 (native extensions reading in-image data). It is
+the "DYLD not stripped for this profile shape" answer tebako#1117
+names as fragile: the day the signing gate arms, the same bytes take
+the hardened runtime and the R#5 class fires on macOS 14. The grant
+therefore lands **while the legs still ship unsigned** — ahead of the
+gate, exactly where the shape needs it.
+
+### The evidence (darwin-23 = macOS 14.1.1, 23B81, arm64)
+
+| Probe | Result |
+|---|---|
+| Published v0.2.7 pair (the store's sha256-verified bytes), `TEBAKO_RUNTIME_IMAGE=… exe -c 'import json,zlib,ssl; open()'` | green — stdlib imports + 14132-byte libc read of an in-image path (the pydata-demo-era shape: unsigned ⇒ insertion honored) |
+| Published v0.3.5 `macos-arm64` exe, `codesign -d` | adhoc linker-signed, no hardened runtime, no entitlements — the signing gate was never armed |
+| The same-class exe adhoc-signed `--options runtime` with the OLD two-key profile, same probe | **dies** — `ModuleNotFoundError: No module named 'encodings'` (the stripping, reproduced) |
+| The same exe re-signed adding ONLY `allow-dyld-environment-variables` | green — stdlib + the libc in-image read served |
+
+### The policing (why a static assertion, not a runner)
+
+The macos-15 runners' dyld TOLERATES a missing dyld-env grant (their
+dyld keeps the variables), so no CI runner can police this class at
+exec time — the boot smoke's shim-service scenarios (`boot`'s stdlib
+imports off the mount) stay green there either way.
+`ci/macos-sign-notarize-runtime.sh` therefore asserts the embedded
+profile statically — three `` values AND each key by name —
+in-leg, where the bytes still are. A macOS-14 exec canary (the R
+factory's publish-leg shape) is the named follow-up for this repo's
+acceptance workflow.