#!/usr/bin/bash
set -eu
run_dir=/home/smoln/runs/research-deep-20261101
cd "$run_dir/source/core"
systemctl --user show research-deep-agent.scope -p CPUQuotaPerSecUSec -p MemoryMax -p MemorySwapMax > "$run_dir/evidence/agent-resource-limits.txt"
date --iso-8601=seconds > "$run_dir/evidence/agent-started.txt"
set +e
/usr/bin/time -v -o "$run_dir/evidence/agent-resources.txt" env -i PATH=/usr/local/go/bin:/usr/bin:/bin HOME="$run_dir/empty-home" GOCACHE=/home/smoln/.cache/go-build GOPATH="$run_dir/empty-gopath" GOENV=off GOPROXY=off GOSUMDB=off GOTOOLCHAIN=local GOMAXPROCS=1 timeout 900s go test -p 1 ./internal/agent -run '^(TestBusyInputSteersRealLoopAndReopenPreservesOrderedEvents|TestStopCancelsUndeliveredBusyInputBeforeNextGoal|TestApprovalContinuationModelFailureKeepsResultInternalAndDoesNotReplay|TestApprovalContinuationRejectsChangedHistoryBeforeExecution|TestApprovalContinuationRejectsNewerOwnerGoalBeforeExecution)$' -count=1 -json -timeout=90s > "$run_dir/evidence/agent-test-events.jsonl" 2> "$run_dir/evidence/agent-stderr.txt"
status=$?
printf '%s\n' "$status" > "$run_dir/evidence/agent-exit.txt"
date --iso-8601=seconds > "$run_dir/evidence/agent-ended.txt"
exit "$status"
