E0-3: language-neutral agent scaffold and run recorder
tools/eval (stdlib Python): one agent loop, system prompt and tool set (list/read/write/edit files, run, finish) for every language; language profiles for aji_air, rust, zig carry only toolchain invocation, docs location and command classification; bubblewrap sandbox without network, read-only toolchain and /docs; providers: Anthropic Messages, OpenAI-compatible (incl. local servers), scripted; run record per protocol §28 (hashes, versions, limits, hardware, seed, all events, patches, commands, final repository, first-generation snapshot, evaluator verdicts, cost); metrics §14-§17; resumable matrix plans; report (VSR, repair cycles, context, cost per correct solution); classify (§27 categories, caught-by, smoke-test causes). docs/evaluation/harness.md (task format for the private benchmark repository, evaluator contract, record schema); dev-tasks/dev-echo (harness development task, no benchmark family); smoke plan shape for the owner's E-S choice (binary/stream parser, bounded pipeline); self-tests in CI
This commit is contained in:
1 parent
d2932bd75a
commit
b49003bdb9
38 files changed
+1735
-5
No files matched your search
@@ -0,0 +1,104 @@
|
||||
"""Language profiles (tools/eval/languages/*.json).
|
||||
|
||||
A profile says how to invoke a toolchain and where its pinned local
|
||||
documentation is. It MUST NOT contain solution hints (protocol §5).
|
||||
|
||||
Fields:
|
||||
name language id used in task directories and records
|
||||
display human name
|
||||
toolchain {"binaries": [...], "version": [argv, ...], "bind": [paths]}
|
||||
binaries are resolved on the host and bound read-only into
|
||||
the sandbox; "version" commands are recorded (§28)
|
||||
docs {"env": VAR, "default": path}: directory or file mounted at
|
||||
/docs (read-only)
|
||||
instructions text appended to the shared system prompt
|
||||
classify {"check": [prefix, ...], "build": [...], "test": [...]}:
|
||||
command prefixes counted as verifier/compiler and test runs
|
||||
for the repair metrics (§14, §15)
|
||||
"""
|
||||
|
||||
import glob
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
from . import util
|
||||
|
||||
HERE = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "languages")
|
||||
|
||||
|
||||
def available():
|
||||
return sorted(os.path.splitext(os.path.basename(p))[0] for p in glob.glob(os.path.join(HERE, "*.json")))
|
||||
|
||||
|
||||
def load(name):
|
||||
path = os.path.join(HERE, name + ".json")
|
||||
if not os.path.exists(path):
|
||||
raise SystemExit(f"unknown language profile {name!r}; available: {', '.join(available())}")
|
||||
prof = util.read_json(path)
|
||||
prof["profile_hash"] = util.sha256_path(path)
|
||||
return prof
|
||||
|
||||
|
||||
def expand(s):
|
||||
return os.path.expandvars(os.path.expanduser(s.replace("${REPO}", util.REPO)))
|
||||
|
||||
|
||||
def resolve_binaries(prof):
|
||||
"""Host paths of the toolchain binaries and the directories to bind."""
|
||||
found, binds = {}, set()
|
||||
cmd = prof["toolchain"].get("bind_command")
|
||||
if cmd:
|
||||
r = subprocess.run(cmd, capture_output=True, text=True)
|
||||
if r.returncode != 0 or not os.path.isdir(r.stdout.strip()):
|
||||
raise SystemExit(f"{prof['name']}: {' '.join(cmd)} did not print a directory")
|
||||
binds.add(os.path.realpath(r.stdout.strip()))
|
||||
for b in prof["toolchain"].get("binaries", []):
|
||||
path = shutil.which(expand(b)) if os.sep not in b else expand(b)
|
||||
if path is None or not os.path.exists(path):
|
||||
raise SystemExit(f"{prof['name']}: toolchain binary {b!r} not found")
|
||||
real = os.path.realpath(path)
|
||||
found[os.path.basename(b)] = real
|
||||
binds.add(os.path.dirname(real))
|
||||
for extra in prof["toolchain"].get("bind", []):
|
||||
for p in glob.glob(expand(extra)):
|
||||
binds.add(os.path.realpath(p))
|
||||
# A rustc sysroot or a zig installation is self-contained: bind the
|
||||
# directory above `bin` so libraries and the standard library resolve.
|
||||
out = set()
|
||||
for d in binds:
|
||||
out.add(os.path.dirname(d) if os.path.basename(d) == "bin" else d)
|
||||
return found, sorted(out)
|
||||
|
||||
|
||||
def sandbox_path(binds):
|
||||
"""PATH inside the sandbox: `<dir>/bin` where it exists, else `<dir>`."""
|
||||
return [os.path.join(d, "bin") if os.path.isdir(os.path.join(d, "bin")) else d for d in binds]
|
||||
|
||||
|
||||
def versions(prof, env=None):
|
||||
out = []
|
||||
for argv in prof["toolchain"].get("version", []):
|
||||
try:
|
||||
r = subprocess.run([expand(a) for a in argv], capture_output=True, text=True, timeout=60, env=env)
|
||||
out.append({"argv": argv, "output": (r.stdout + r.stderr).strip()})
|
||||
except OSError as e:
|
||||
out.append({"argv": argv, "error": str(e)})
|
||||
return out
|
||||
|
||||
|
||||
def docs_path(prof):
|
||||
d = prof.get("docs") or {}
|
||||
path = os.environ.get(d.get("env", ""), "") or d.get("default", "")
|
||||
path = expand(path) if path else ""
|
||||
return path if path and os.path.exists(path) else None
|
||||
|
||||
|
||||
def classify(prof, command):
|
||||
"""'check', 'build', 'test' or None for a shell command line."""
|
||||
c = command.strip()
|
||||
for kind in ("test", "check", "build"):
|
||||
for prefix in prof.get("classify", {}).get(kind, []):
|
||||
if c == prefix or c.startswith(prefix + " "):
|
||||
return kind
|
||||
return None
|
||||
Reference in new issue
Block a user