ase-benchmark-runs / scripts /verify_local.sh
bbaukema-leotrace's picture
A.S.E benchmark runs: task lists, grading scripts and per-run logs
35d269e verified
Raw History Blame Contribute Delete
3 kB
#!/usr/bin/env bash
# Verify batches locally (QEMU on arm64), sequentially. Usage: verify_local.sh [batch ...]
# Sequential by design: batches share the Docker daemon and the image cache, and A.S.E already
# parallelises inside a batch via --max_workers.
set -uo pipefail
HERE=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# The A.S.E checkout to operate on. These scripts live in leobench; the benchmark itself
# is a separate fork, so its location is configuration rather than something to hardcode.
ASE=${ASE_HOME:?set ASE_HOME to the AICGSecEval checkout}
cd "$ASE"
DS=${DS:-data/inscope_v2.json}; OUT=${OUT:-outputs/inscope}; W=${W:-8}; CYCLES=${CYCLES:-1}
PIDDIR="$OUT/_genlogs"; . "$HERE"/_procs.sh
pid_write verify_local
BATCHES=${*:-"claude_raw claude_lp codex_raw codex_lp"}
say() { echo "[$(date '+%F %T')] $*" | tee -a "$OUT/_genlogs/verify_local.log"; }
agent_of() { case "$1" in claude_*) echo claude_code;; codex_*) echo codex;; cursor_*) echo cursor;; cosine_*) echo cosine;; gemini_*) echo gemini;; esac; }
say "=== local verification: $BATCHES ==="
for b in $BATCHES; do
a=$(agent_of "$b")
# Count only this dataset's cycles: an OUT verified wave by wave already holds earlier waves'
# results, and counting those skipped a new wave (2026-10-09, A.S.E Corridor wave 4).
# The batch name comes from the command line: allow only a plain name, and pass every value
# to Python through the environment, never inside its source.
if [[ ! "$b" =~ ^[A-Za-z0-9._-]+$ ]] || [[ "$b" == *..* ]]; then
say "ERROR: invalid batch name '$b'"; exit 1
fi
n=$(VL_DS="$DS" VL_OUT="$OUT" VL_A="$a" VL_B="$b" python3 - <<'PYEOF'
import json, os
ids = {r['instance_id'] for r in json.load(open(os.environ['VL_DS']))}
base = os.path.realpath(os.path.join(os.environ['VL_OUT'], 'generated_code'))
d = os.path.realpath(os.path.join(base, os.environ['VL_A'] + '__' + os.environ['VL_B'], 'scan_results'))
if not d.startswith(base + os.sep):
raise SystemExit("scan_results path escapes the output dir")
fs = os.listdir(d) if os.path.isdir(d) else []
print(sum(1 for f in fs if f.endswith('_output.json') and f.split('_cycle')[0] in ids))
PYEOF
)
tot=$(VL_DS="$DS" VL_CYCLES="$CYCLES" python3 - <<'PYEOF'
import json, os
print(len(json.load(open(os.environ['VL_DS']))) * int(os.environ['VL_CYCLES']))
PYEOF
)
if [ "$n" -ge "$tot" ]; then say "$b already scanned ($n/$tot) - skipping"; continue; fi
say "--- $b: scanning ---"
S=$(date +%s)
.venv/bin/python invoke.py --run_step security_scan --agent --agent_name "$a" \
--batch_id "$b" --dataset_path "$DS" --num_cycles "$CYCLES" --output_dir "$OUT" \
--max_workers "$W" --github_token unused \
>> "$OUT/_genlogs/verify_local_${b}.log" 2>&1
say "$b finished in $(( ($(date +%s)-S)/60 ))m$(( ($(date +%s)-S)%60 ))s (exit $?)"
done
say "=== all requested batches done ==="
osascript -e 'display notification "All batches verified locally" with title "A.S.E verification complete" sound name "Glass"' 2>/dev/null