#!/usr/bin/env bash # Row S0: runs one probe inside the network namespace that probe.sh sets up. # Starts the mock model on loopback, runs the harness under a wall-clock # limit, and writes outcome.txt. Usage: inner.sh -- cmd... set -u run=$1 limit=$2 shift 3 here=$(dirname "$(readlink -f "$0")") cd "$run/work" || exit 90 node "$here/mock-anthropic.mjs" 2> "$run/mock-stderr.txt" & mock=$! for _ in $(seq 100); do grep -q listening "$MOCK_LOG" 2>/dev/null && break; read -rt 0.05 <> <(:) || true; done start=$(date +%s%N) timeout -k 5 "$limit" "$@" < /dev/null > "$run/stdout.txt" 2> "$run/stderr.txt" rc=$? end=$(date +%s%N) kill "$mock" 2> /dev/null { echo "uid=$(id -u) net=$(ip -o link | awk -F': ' '{print $2}' | tr '\n' ' ')" echo "exit=$rc elapsed_ms=$(((end - start) / 1000000))" if [ -e "$run/work/target.txt" ]; then echo "target=present content=$(head -c 80 "$run/work/target.txt" | tr '\n' ' ')"; else echo "target=absent"; fi echo "gate_loaded=$(cat "$GATE_LOG" 2> /dev/null | grep -c ' loaded ') gate_calls=$(cat "$GATE_LOG" 2> /dev/null | grep -cE ' invoked | input=')" } > "$run/outcome.txt"