Skip to content

The first exam for code agents in the physical world: frozen robot tasks from many benchmark suites, each answered with a program and verified in a separate sandbox. Runs on Harbor.

1.9 KB
Raw Blame
#!/usr/bin/env bash
# Standard and realtime mode (PROTOCOL §3, H.3: no simulator or simulation code in the agent container): the agent's image is built
# from environment/, but never takes environment/sim/, which compose mounts into the sim sidecar only (and which may
# hold the scoring code). Every COPY / ADD source of environment/Dockerfile is therefore a named path outside sim/:
# not `.` or `..`, not a wildcard. Sources from another stage or image (--from) and ADD URLs are not from environment/.
# Usage: check-standard-agent-image.sh tasks/<benchmark>/<task-dir>
set -uo pipefail
t="${1%/}"
# the sidecar modes of the mode registry (PROTOCOL §3; run_all.sh reads it once): standard, realtime
modes="${RCB_MODES_TABLE:-$(python3 "$(dirname "$0")/../scripts/task_conventions.py" modes)}"
n="$(basename "$t")"; side=0
while read -r m sidecar _tw; do [ -n "$m" ] && [[ "$n" == *"-$m" ]] && { side="$sidecar"; break; }; done <<< "$modes"
[ "$side" = 1 ] || exit 0
python3 - "$t" <<'PY'
import json, pathlib, posixpath, re, sys
t = pathlib.Path(sys.argv[1]); rc = 0
lines = [ln for ln in (t / "environment/Dockerfile").read_text().splitlines() if not ln.lstrip().startswith("#")]
text = re.sub(r"\\[ \t]*\n", " ", "\n".join(lines))   # join continued lines (comment lines are not part of them)
for line in text.splitlines():
    m = re.match(r"\s*(COPY|ADD)\s+((?:--\S+\s+)*)(.*)", line, re.I)
    if not m or "--from" in m.group(2):
        continue
    body = m.group(3).strip()
    srcs = (json.loads(body) if body.startswith("[") else body.split())[:-1]
    for src in srcs:
        if "://" in src:
            continue  # ADD <url>
        p = posixpath.normpath("/" + src).lstrip("/")   # inside the context: ".", "..", "x/.." are its root
        if not p or any(c in p for c in "*?[") or p.split("/")[0] == "sim":
            print(f"FAIL {t}: environment/Dockerfile: {m.group(1)} {src}: name files outside sim/ only")
            rc = 1
sys.exit(rc)
PY