eval: evaluator environment, evaluator.log, ajieval evaluate
The evaluator now receives AJIEVAL_LANGUAGE, AJIEVAL_TOOLCHAIN_PATH and AJIEVAL_TOOLCHAIN_DIRS (the toolchain exactly as the agent's sandbox had it), its full output is saved as evaluator.log in the run directory, and ajieval evaluate runs an evaluator on any workspace exactly as the harness does. harness.md documents what a sandboxing evaluator should do (bind the toolchain dirs, private CARGO_HOME + --offline, build without the agent's target/ and caches, report infrastructure failures distinctly).
This commit is contained in:
1 parent
93cf553a77
commit
2ee1ff192f
27 files changed
+91
-7
No files matched your search
@@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "echo"
|
||||
version = "0.1.0"
|
||||
@@ -0,0 +1 @@
|
||||
{"rustc_fingerprint":12138803327433613668,"outputs":{"17276427787476938915":{"success":true,"status":"","code":0,"stdout":"rustc 1.99.0 (b940084d7 2026-09-28)\nbinary: rustc\ncommit-hash: b940084d7eb6a299eb4bfeb8e34901bc051e7ac4\ncommit-date: 2026-09-28\nhost: x86_64-unknown-linux-gnu\nrelease: 1.99.0\nLLVM version: 23.1.1\n","stderr":""},"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/shkmv/.rustup/toolchains/1.99.0-x86_64-unknown-linux-gnu\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_primitive_alignment=\"16\"\ntarget_has_atomic_primitive_alignment=\"32\"\ntarget_has_atomic_primitive_alignment=\"64\"\ntarget_has_atomic_primitive_alignment=\"8\"\ntarget_has_atomic_primitive_alignment=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""}},"successes":{}}
|
||||
@@ -0,0 +1,3 @@
|
||||
Signature: 8a477f597d28d172789f06886806bc55
|
||||
# This file is a cache directory tag created by cargo.
|
||||
# For information about cache directory tags see https://bford.info/cachedir/
|
||||
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
+1
@@ -0,0 +1 @@
|
||||
22f82d773cfb6ce9
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"rustc":5244445300240561903,"features":"[]","declared_features":"[]","target":12538796586915257791,"profile":7333259681545804295,"path":4942398508502643691,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/echo-cd02f4ae2050300b/dep-bin-echo","checksum":false}}],"rustflags":[],"config":9396254390672932401,"compile_kind":0}
|
||||
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
||||
This file has an mtime of when this was started.
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
/home/shkmv/Work/aji/docs/evaluation/dev-tasks/dev-echo/lang/rust/target/debug/deps/echo-cd02f4ae2050300b.d: src/main.rs
|
||||
|
||||
/home/shkmv/Work/aji/docs/evaluation/dev-tasks/dev-echo/lang/rust/target/debug/deps/echo-cd02f4ae2050300b: src/main.rs
|
||||
|
||||
src/main.rs:
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
/home/shkmv/Work/aji/docs/evaluation/dev-tasks/dev-echo/lang/rust/target/debug/echo: /home/shkmv/Work/aji/docs/evaluation/dev-tasks/dev-echo/lang/rust/src/main.rs
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Whitespace-only changes.
@@ -93,7 +93,28 @@ The harness calls `CMD WORKSPACE LANGUAGE TASK_DIR` outside the agent's sandbox.
|
||||
{"accepted": true, "gates": {"verifier": true, "public_tests": true, "hidden_functional": true, "hidden_regression": true, "fuzz": true, "resources": true, "deterministic_runs": true, "schedule_exploration": true}}
|
||||
```
|
||||
|
||||
`accepted` follows protocol §13: all mandatory gates pass, with no partial success. The evaluator runs untrusted code, so it must sandbox that code itself. The record stores the hash of the evaluator, or of `--evaluator-hash-path`, and the full verdict.
|
||||
`accepted` follows protocol §13: all mandatory gates pass, with no partial success.
|
||||
|
||||
**Evaluator environment.** The harness calls the evaluator with the caller's environment plus three variables that describe the language toolchain exactly as the agent's sandbox had it:
|
||||
|
||||
| Variable | Contents |
|
||||
|---|---|
|
||||
| `AJIEVAL_LANGUAGE` | `aji_air`, `rust` or `zig` |
|
||||
| `AJIEVAL_TOOLCHAIN_PATH` | the toolchain's PATH entries, `:`-separated |
|
||||
| `AJIEVAL_TOOLCHAIN_DIRS` | the directories to bind read-only, one per line |
|
||||
|
||||
An evaluator that sandboxes the code it builds and runs should:
|
||||
|
||||
- bind `AJIEVAL_TOOLCHAIN_DIRS` read-only and put `AJIEVAL_TOOLCHAIN_PATH` first on PATH, rather than relying on shims such as `~/.cargo/bin` or mise, which need the real HOME;
|
||||
- set a private `CARGO_HOME` and build with `--offline` (Rust);
|
||||
- build in a copy of the workspace without `target/`, `.zig-cache/` or `zig-out/`, which the agent built under `/work`;
|
||||
- report infrastructure failures distinctly from solution failures.
|
||||
|
||||
The evaluator's full output is stored in the run directory as `evaluator.log`; the record keeps only the verdict. To debug an evaluator without an agent run, call it exactly as the harness does:
|
||||
|
||||
```sh
|
||||
python3 -m ajieval evaluate --task TASK_DIR --language rust --workspace DIR --evaluator CMD --log evaluator.log
|
||||
``` The evaluator runs untrusted code, so it must sandbox that code itself. The record stores the hash of the evaluator, or of `--evaluator-hash-path`, and the full verdict.
|
||||
|
||||
## Run record (`RUN/run.json`, protocol §28)
|
||||
|
||||
|
||||
@@ -94,6 +94,17 @@ def cmd_matrix(a):
|
||||
report.print_report([out])
|
||||
|
||||
|
||||
def cmd_evaluate(a):
|
||||
"""Runs an evaluator on a workspace exactly as the harness does (same
|
||||
arguments and environment), to debug evaluator integration without an
|
||||
agent run."""
|
||||
from . import task as task_mod
|
||||
t = task_mod.Task(a.task)
|
||||
lim = t.limits
|
||||
verdict = record.evaluate(shlex.split(a.evaluator), os.path.realpath(a.workspace), a.language, t.dir, lim["command_timeout"] * 4, a.log)
|
||||
print(json.dumps(verdict, indent=2))
|
||||
|
||||
|
||||
def cmd_freeze(a):
|
||||
path, frozen = freeze.write(a.plan, a.order_seed)
|
||||
print(json.dumps({"freeze": path, "cells": len(frozen["order"]), "order_seed": frozen["order_seed"], "aji_commit": frozen["state"]["aji_commit"]}))
|
||||
@@ -161,6 +172,14 @@ def main(argv=None):
|
||||
m.add_argument("plan")
|
||||
m.set_defaults(fn=cmd_matrix)
|
||||
|
||||
ev = sub.add_parser("evaluate", help="run an evaluator on a workspace exactly as the harness does")
|
||||
ev.add_argument("--task", required=True)
|
||||
ev.add_argument("--language", required=True, choices=languages.available())
|
||||
ev.add_argument("--workspace", required=True)
|
||||
ev.add_argument("--evaluator", required=True)
|
||||
ev.add_argument("--log", help="write the evaluator's full stdout/stderr here")
|
||||
ev.set_defaults(fn=cmd_evaluate)
|
||||
|
||||
fz = sub.add_parser("freeze", help="freeze a plan: record its state and a random cell order")
|
||||
fz.add_argument("plan")
|
||||
fz.add_argument("--order-seed", type=int)
|
||||
|
||||
@@ -455,7 +455,7 @@ def run_native(task_dir, lang_name, agent_name, model, out_dir, effort=None, see
|
||||
cyc = cycles(profile, lang.get("test"), command_events(agent_name, transcript))
|
||||
with open(os.path.join(run_dir, "patch.diff"), "w") as f:
|
||||
f.write(diff_tree(pristine, workspace))
|
||||
verdict = record.evaluate(evaluator, workspace, lang_name, task.dir, lim["command_timeout"] * 4) if evaluator else None
|
||||
verdict = record.evaluate(evaluator, workspace, lang_name, task.dir, lim["command_timeout"] * 4, os.path.join(run_dir, "evaluator.log")) if evaluator else None
|
||||
|
||||
rec = {
|
||||
"schema": "aji-eval-native/1",
|
||||
|
||||
@@ -47,12 +47,36 @@ def file_hashes(root):
|
||||
return out
|
||||
|
||||
|
||||
def evaluate(evaluator, workspace, lang, task_dir, timeout):
|
||||
"""Runs the (external, hidden) evaluator; returns its JSON verdict."""
|
||||
def evaluator_env(lang):
|
||||
"""Environment for the evaluator: the caller's environment plus the
|
||||
language toolchain exactly as the agent's sandbox had it, so an
|
||||
evaluator that sandboxes the code it runs can bind the same directories.
|
||||
|
||||
AJIEVAL_LANGUAGE language id (aji_air, rust, zig)
|
||||
AJIEVAL_TOOLCHAIN_PATH PATH entries of the toolchain (`:`-separated)
|
||||
AJIEVAL_TOOLCHAIN_DIRS directories to bind read-only (newline-separated)
|
||||
"""
|
||||
env = dict(os.environ)
|
||||
try:
|
||||
p = subprocess.run(evaluator + [workspace, lang, task_dir], capture_output=True, text=True, timeout=timeout)
|
||||
_, binds = languages.resolve_binaries(languages.load(lang))
|
||||
except SystemExit:
|
||||
binds = []
|
||||
env["AJIEVAL_LANGUAGE"] = lang
|
||||
env["AJIEVAL_TOOLCHAIN_PATH"] = ":".join(languages.sandbox_path(binds))
|
||||
env["AJIEVAL_TOOLCHAIN_DIRS"] = "\n".join(binds)
|
||||
return env
|
||||
|
||||
|
||||
def evaluate(evaluator, workspace, lang, task_dir, timeout, log_path=None):
|
||||
"""Runs the (external, hidden) evaluator; returns its JSON verdict. Its
|
||||
full output goes to `log_path` (the run directory), not to the record."""
|
||||
try:
|
||||
p = subprocess.run(evaluator + [workspace, lang, task_dir], capture_output=True, text=True, timeout=timeout, env=evaluator_env(lang))
|
||||
except subprocess.TimeoutExpired:
|
||||
return {"accepted": False, "error": "evaluator timed out"}
|
||||
if log_path:
|
||||
with open(log_path, "w") as f:
|
||||
f.write(f"$ {' '.join(evaluator)} WORKSPACE {lang} TASK_DIR\nexit {p.returncode}\n--- stdout ---\n{p.stdout}\n--- stderr ---\n{p.stderr}")
|
||||
try:
|
||||
verdict = json.loads(p.stdout)
|
||||
except json.JSONDecodeError:
|
||||
@@ -110,9 +134,9 @@ def run_one(task_dir, lang_name, provider_name, model, out_dir, model_class=None
|
||||
|
||||
verdict = first_verdict = None
|
||||
if evaluator:
|
||||
verdict = evaluate(evaluator, workspace, lang_name, task.dir, lim["command_timeout"] * 4)
|
||||
verdict = evaluate(evaluator, workspace, lang_name, task.dir, lim["command_timeout"] * 4, os.path.join(run_dir, "evaluator.log"))
|
||||
if a.first_snapshot:
|
||||
first_verdict = evaluate(evaluator, a.first_snapshot, lang_name, task.dir, lim["command_timeout"] * 4)
|
||||
first_verdict = evaluate(evaluator, a.first_snapshot, lang_name, task.dir, lim["command_timeout"] * 4, os.path.join(run_dir, "evaluator.first.log"))
|
||||
metrics["first_hidden_test_passed"] = None if first_verdict is None else first_verdict["accepted"]
|
||||
|
||||
record = {
|
||||
|
||||
Reference in new issue
Block a user