#!/usr/bin/env bash
set -uo pipefail
umask 077
E="/home/cube/projects/richard/traning coach/.omo/evidence/task26/task26-gate20-corrected-harness-4e9962be49b72951c3b9ed7e1a4fe36d0ca03e757872ae03364c1ab7a790f32b-st_01a0080c";R="/home/cube/projects/richard/hermes-agent";PY="$R/.venv/bin/python";PP="$R:/home/cube/.hermes/profiles/dualcoachtest/workspace/checkin_cli";d="$E/artifacts/corrected-full-gateway";mkdir -p "$d";CMD=(env -u TMPDIR HOME=/home/cube PYTHONPATH="$PP" PYTHONDONTWRITEBYTECODE=1 "$PY" -B -m pytest -q -p no:cacheprovider --junitxml="$E/artifacts/corrected-full-gateway.junit.xml" tests/gateway);printf '%q ' "${CMD[@]}">"$d/command.txt";printf '\n'>>"$d/command.txt";env -0|sort -z>"$d/launcher-environment.nul";printf 'HOME=/home/cube\nTMPDIR=<UNSET>\nPYTHONPATH=%s\nPYTHONDONTWRITEBYTECODE=1\n' "$PP">"$d/effective-environment.txt";date -u +%Y-%m-%dT%H:%M:%S.%NZ>"$d/started-at-utc.txt";s=$(date +%s%N);cd "$R";"${CMD[@]}">"$d/stdout.txt" 2>"$d/stderr.txt"&pid=$!;wait "$pid";rc=$?;e=$(date +%s%N);date -u +%Y-%m-%dT%H:%M:%S.%NZ>"$d/ended-at-utc.txt";echo "$rc">"$d/exit-code.txt";echo "$(((e-s)/1000000))">"$d/duration-ms.txt";(cd "$d"&&sha256sum command.txt launcher-environment.nul effective-environment.txt started-at-utc.txt ended-at-utc.txt exit-code.txt duration-ms.txt stdout.txt stderr.txt>files.sha256);chmod 600 "$d"/*;exit "$rc"
