test(substrate): integration now asserts real atom execution via Stream E

Previously expected NotImplemented stub (exit 64). Stream E wired real
subprocess exec to kei-task, so invoke now actually creates tasks.
Updated test:
- Builds kei-task in release + passes KEI_RUNTIME_BIN_DIR + KEI_TASK_DB
- Asserts exit 0 + stdout has 'id' field
- NEW assertion: invoke with empty KEI_RUNTIME_BIN_DIR → exit 127 (BinaryNotFound)
- Bad-input assertion stays (InputInvalid → exit 2)

4 end-to-end assertions now cover the full §Runtime contract.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Parfii-bot 2026-04-23 01:23:05 +08:00
parent 07b47dba7e
commit 59fd1a0362

View file

@ -22,12 +22,13 @@ trap 'rm -rf "$TMPROOT"' EXIT
fail() { echo "SUBSTRATE-INTEGRATION FAIL: $*" >&2; exit 1; }
echo "==> Building release binaries (kei-runtime, kei-sage)…"
echo "==> Building release binaries (kei-runtime, kei-sage, kei-task)…"
cd _primitives/_rust
cargo build --release -p kei-runtime -p kei-sage >/dev/null 2>&1 \
cargo build --release -p kei-runtime -p kei-sage -p kei-task >/dev/null 2>&1 \
|| fail "cargo build failed"
RT="$(pwd)/target/release/kei-runtime"
SAGE="$(pwd)/target/release/kei-sage"
BIN_DIR="$(pwd)/target/release"
cd "$ROOT"
echo "==> Scaffolding a fresh atom (kei-task::create) via new-atom.sh for isolated test corpus…"
@ -113,13 +114,25 @@ SAGE_IDS="$(echo "$DISCOVER" | awk 'NR>1 && $1 != "" {print $1}' | sort)"
[ "$RT_IDS" = "$SAGE_IDS" ] \
|| fail "runtime and sage disagree on atom IDs:\n runtime: $RT_IDS\n sage: $SAGE_IDS"
echo "==> kei-runtime invoke (expects NotImplemented → exit 64)…"
echo "==> kei-runtime invoke (expects real exec via Stream E → exit 0 + result.id)…"
set +e
"$RT" invoke --root "$TMPROOT/corpus" kei-task::create --input '{"title":"x"}' >/dev/null 2>&1
INVOKE_OUT="$(KEI_RUNTIME_BIN_DIR="$BIN_DIR" KEI_TASK_DB="$TMPROOT/task.sqlite" \
"$RT" invoke --root "$TMPROOT/corpus" kei-task::create --input '{"title":"integration"}' 2>&1)"
RC=$?
set -e
[ "$RC" -eq 64 ] \
|| fail "invoke should exit 64 (NotImplemented), got $RC"
[ "$RC" -eq 0 ] \
|| fail "invoke should exit 0 on real exec, got $RC: $INVOKE_OUT"
echo "$INVOKE_OUT" | grep -q '"id"' \
|| fail "invoke stdout missing 'id' field: $INVOKE_OUT"
echo "==> kei-runtime invoke with missing binary (expects BinaryNotFound → exit 127)…"
set +e
PATH="/usr/bin:/bin" KEI_RUNTIME_BIN_DIR="/nonexistent" \
"$RT" invoke --root "$TMPROOT/corpus" kei-task::create --input '{"title":"x"}' >/dev/null 2>&1
RC=$?
set -e
[ "$RC" -eq 127 ] \
|| fail "invoke with missing binary should exit 127, got $RC"
echo "==> kei-runtime invoke with bad input (expects InputInvalid → exit 2)…"
set +e