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
@@ -4,6 +4,7 @@ Non-normative. Empirical validation of the Aji hypothesis stated in [spec 14](..
|
||||
|
||||
| Document | Purpose |
|
||||
|---|---|
|
||||
| [harness.md](harness.md) | Agent scaffold and run recorder (E0-3): task format, evaluator contract, run record, commands |
|
||||
| [protocol.md](protocol.md) | Agent Language Evaluation Protocol 0.2: variables, benchmark families T01–T10, conditions `Aji/AIR` and `Aji/source`, maintenance and seeded-bug benchmarks, metrics, statistics, stages A–E, success and falsification criteria |
|
||||
| [../agent/README.md](../agent/README.md) | Agent Reference Bundle: contents, measurement, growth policy, milestones |
|
||||
|
||||
@@ -18,8 +19,8 @@ Non-normative. Empirical validation of the Aji hypothesis stated in [spec 14](..
|
||||
|
||||
| Stage | Tasks | Requires | Status |
|
||||
|---|---|---|---|
|
||||
| A — Phase 2 validation | T01–T04 | Phase 2 (heap, regions, resources, capabilities, effects, deterministic I/O) | language ready; infrastructure pending (plan E0) |
|
||||
| B — Phase 3 validation | T05–T07 | Phase 3 (structured concurrency, schedule exploration) | blocked on Phase 3 |
|
||||
| A — Phase 2 validation | T01–T04 | Phase 2 (heap, regions, resources, capabilities, effects, deterministic I/O) | language ready; harness done (E0-3); tasks and baselines pending (E0-2, E0-4) |
|
||||
| B — Phase 3 validation | T05–T07 | Phase 3 (structured concurrency, schedule exploration) | language ready; infrastructure: harness done (E0-3), tasks pending (E0-2) |
|
||||
| C — Atomic validation | T08, litmus repair | Phase 5 (atomics, memory model) | blocked on Phase 5 |
|
||||
| D — Systems integration | T09, T10 | Phases 3–5; stable features | blocked |
|
||||
| E — Maintenance campaign | M1–M8 on T03, T07, T09, T10 | D | blocked |
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Dev evaluator for dev-echo (public because the task is dev-set; real
|
||||
evaluators live in the private benchmark repository and sandbox the code
|
||||
they run).
|
||||
|
||||
usage: evaluator.py WORKSPACE LANGUAGE TASK_DIR -> JSON verdict on stdout
|
||||
"""
|
||||
import json, os, subprocess, sys
|
||||
|
||||
ws, lang = sys.argv[1], sys.argv[2]
|
||||
REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))))
|
||||
AJI = os.path.join(REPO, "zig-out", "bin", "aji")
|
||||
cases = ["", "hello", "x" * 64, "line one\nline two\n"]
|
||||
gates = {}
|
||||
|
||||
def build():
|
||||
if lang == "rust":
|
||||
return subprocess.run(["cargo", "build", "-q", "--offline"], cwd=ws, capture_output=True).returncode == 0
|
||||
if lang == "zig":
|
||||
return subprocess.run(["zig", "build-exe", "main.zig"], cwd=ws, capture_output=True).returncode == 0
|
||||
return subprocess.run([AJI, "check", "main.air"], cwd=ws, capture_output=True).returncode == 0
|
||||
|
||||
def run(inp):
|
||||
if lang == "aji_air":
|
||||
p = subprocess.run([AJI, "run", "--grant", "in=io.read", "--grant", "out=io.write", "--stdin", inp, "main.air"], cwd=ws, capture_output=True, text=True, timeout=60)
|
||||
try:
|
||||
rec = json.loads(p.stdout)
|
||||
except json.JSONDecodeError:
|
||||
return None
|
||||
return rec.get("stdout") if rec.get("status") == "returned" else None
|
||||
exe = "./target/debug/echo" if lang == "rust" else "./main"
|
||||
p = subprocess.run([exe], cwd=ws, input=inp, capture_output=True, text=True, timeout=60)
|
||||
return p.stdout if p.returncode == 0 else None
|
||||
|
||||
gates["builds"] = build()
|
||||
gates["functional"] = gates["builds"] and all(run(c) == c for c in cases)
|
||||
print(json.dumps({"accepted": all(gates.values()), "gates": gates}))
|
||||
@@ -0,0 +1,5 @@
|
||||
# Interface
|
||||
|
||||
- Source: `main.air`, a text AIR module.
|
||||
- Entry point: `@main(%in: cap<io.read>, %out: cap<io.write>)`; any return type.
|
||||
- The program is run as `aji run --grant in=io.read --grant out=io.write --stdin TEXT main.air`; the bytes written to standard output appear in the run record's `stdout` field.
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
# Public test: one input.
|
||||
out=$(aji run --grant in=io.read --grant out=io.write --stdin 'hello' main.air) || { echo "FAIL: aji run failed"; echo "$out"; exit 1; }
|
||||
case "$out" in
|
||||
*'"stdout":"hello"'*) echo "PASS";;
|
||||
*) echo "FAIL: unexpected run record: $out"; exit 1;;
|
||||
esac
|
||||
@@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "echo"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
@@ -0,0 +1,4 @@
|
||||
# Interface
|
||||
|
||||
- Cargo package `echo` in this directory; the binary is `target/debug/echo`.
|
||||
- The program reads standard input and writes standard output.
|
||||
@@ -0,0 +1 @@
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Public test: one input.
|
||||
cargo build -q --offline || { echo "FAIL: build"; exit 1; }
|
||||
out=$(printf 'hello' | ./target/debug/echo)
|
||||
[ "$out" = "hello" ] && echo PASS || { echo "FAIL: got '$out'"; exit 1; }
|
||||
@@ -0,0 +1,4 @@
|
||||
# Interface
|
||||
|
||||
- Source: `main.zig`, built with `zig build-exe main.zig` into `./main`.
|
||||
- The program reads standard input and writes standard output.
|
||||
@@ -0,0 +1 @@
|
||||
pub fn main() void {}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Public test: one input.
|
||||
zig build-exe main.zig 2>&1 || { echo "FAIL: build"; exit 1; }
|
||||
out=$(printf 'hello' | ./main)
|
||||
[ "$out" = "hello" ] && echo PASS || { echo "FAIL: got '$out'"; exit 1; }
|
||||
@@ -0,0 +1,7 @@
|
||||
# Task: echo
|
||||
|
||||
Harness development task (dev set; not a benchmark family). Do not use it to evaluate anything.
|
||||
|
||||
Write a program that reads all of its standard input and writes exactly the same bytes to its standard output. The input is at most 64 bytes long and may be empty.
|
||||
|
||||
The repository contains a README with the program's interface for this language and a public test script, `sh test.sh`, which must pass.
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"id": "dev-echo",
|
||||
"version": "1",
|
||||
"set": "dev",
|
||||
"family": "harness-dev",
|
||||
"prompt": "prompt.md",
|
||||
"languages": {
|
||||
"aji_air": {"workspace": "lang/aji_air", "test": "sh test.sh"},
|
||||
"rust": {"workspace": "lang/rust", "test": "sh test.sh"},
|
||||
"zig": {"workspace": "lang/zig", "test": "sh test.sh"}
|
||||
},
|
||||
"limits": {"tool_calls": 40, "total_tokens": 400000, "wall_seconds": 900, "command_timeout": 120},
|
||||
"concurrency": false
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
# Evaluation Harness
|
||||
|
||||
Non-normative. The language-neutral agent scaffold and run recorder of plan item E0-3 (protocol §3–§5, §13–§17, §27–§29). Code: [`tools/eval/`](../../tools/eval/). Python standard library only.
|
||||
|
||||
```sh
|
||||
cd tools/eval
|
||||
python3 -m ajieval run --task DIR --language aji_air --provider anthropic --model MODEL --class frontier \
|
||||
--evaluator CMD --out runs/
|
||||
python3 -m ajieval matrix PLAN.json # every cell of a plan; resumable
|
||||
python3 -m ajieval report runs/ [--json] # VSR, repair cycles, context, cost per correct solution
|
||||
python3 -m ajieval classify RUN_DIR CATEGORY [--caught-by verifier|runtime|test] [--cause CAUSE]
|
||||
python3 -m unittest discover tests # harness self-tests (needs `zig build`, Rust, Zig)
|
||||
```
|
||||
|
||||
## One run
|
||||
|
||||
One model + one language + one task + one fresh workspace + one fresh agent context (protocol §3). The task's starter workspace for the language is copied into `RUN/workspace`, and the agent loop runs until the model calls `finish`, ends its turn without a tool call, or a budget runs out. Then the evaluator judges the final workspace and the first-generation snapshot.
|
||||
|
||||
**One loop for every language.** The system prompt, the tools and the termination rules are the same for Aji, Rust and Zig. A language contributes only its profile ([`tools/eval/languages/`](../../tools/eval/languages/)): how to invoke the toolchain, where its pinned documentation is, and which commands count as verifier, compiler or test runs. Profiles carry no solution hints (protocol §5).
|
||||
|
||||
**Tools.** `list_files`, `read_file`, `write_file`, `edit_file`, `run` (a shell command in the workspace) and `finish`. Paths are confined to `/work` (the repository, writable) and `/docs` (documentation, read-only).
|
||||
|
||||
**Sandbox.** `bwrap` (bubblewrap) is the default:
|
||||
|
||||
- no network (protocol §4);
|
||||
- read-only system and toolchain;
|
||||
- the workspace at `/work`;
|
||||
- documentation at `/docs`;
|
||||
- a fresh `/tmp` and `HOME`;
|
||||
- a clean environment.
|
||||
|
||||
`--sandbox none` is for harness development only and is recorded.
|
||||
|
||||
**Termination.** One of:
|
||||
|
||||
| Reason | Meaning |
|
||||
|---|---|
|
||||
| `finished` | the model called `finish` |
|
||||
| `model_end` | the model ended its turn without a tool call; the scaffold does not nudge, so stopping early is part of the measurement |
|
||||
| `max_tokens` | the reply hit the output-token limit |
|
||||
| `budget_tool_calls`, `budget_tokens`, `wall_time` | a task limit ran out |
|
||||
| `provider_error` | the model provider failed |
|
||||
|
||||
**Providers.** Each provider has a fixed role:
|
||||
|
||||
| Provider | Use |
|
||||
|---|---|
|
||||
| `anthropic` | Anthropic Messages API (`ANTHROPIC_API_KEY`) |
|
||||
| `openai` | OpenAI-compatible chat completions (`OPENAI_API_KEY`); also local servers such as vLLM, llama.cpp or Ollama via `base_url` |
|
||||
| `scripted` | replays fixed turns (self-tests) |
|
||||
|
||||
## Task directory (the interface to the private benchmark repository)
|
||||
|
||||
```text
|
||||
<task>/task.json id, version, set (dev|validation|test), family, prompt,
|
||||
languages {lang: {workspace, test}}, limits, concurrency
|
||||
<task>/prompt.md language-neutral statement
|
||||
<task>/<workspace>/ starter repository per language: README with the
|
||||
interface, public tests, build files
|
||||
```
|
||||
|
||||
`limits` may set:
|
||||
|
||||
| Limit | Default |
|
||||
|---|---|
|
||||
| `tool_calls` | 150 |
|
||||
| `total_tokens` | 3 000 000 |
|
||||
| `wall_seconds` | 3 600 |
|
||||
| `command_timeout` | 300 |
|
||||
| `output_chars` | 20 000 |
|
||||
|
||||
The `test` command is the public test. Invoking it counts as a test run.
|
||||
|
||||
Hidden tests, evaluators and reference implementations never enter this repository (protocol §29). The only task kept here is the harness development task [`dev-tasks/dev-echo`](dev-tasks/dev-echo/), which belongs to no benchmark family.
|
||||
|
||||
## Evaluator contract
|
||||
|
||||
The harness calls `CMD WORKSPACE LANGUAGE TASK_DIR` outside the agent's sandbox. The evaluator must print one JSON object:
|
||||
|
||||
```json
|
||||
{"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.
|
||||
|
||||
## Run record (`RUN/run.json`, protocol §28)
|
||||
|
||||
Every run directory contains:
|
||||
|
||||
| Path | Contents |
|
||||
|---|---|
|
||||
| `run.json` | the record below |
|
||||
| `events.jsonl` | every model reply (content and token usage), tool call and result, patch (unified diff), and command (exit code, output) |
|
||||
| `workspace/` | the final repository |
|
||||
| `first_generation/` | the workspace before the first toolchain invocation (protocol §14) |
|
||||
|
||||
`run.json` holds:
|
||||
|
||||
- **Identity:**
|
||||
- task id, version, set and hash;
|
||||
- evaluator command and hash;
|
||||
- language, profile hash, toolchain versions, docs path and hash;
|
||||
- model provider, id, class and parameters;
|
||||
- scaffold version, commit and sandbox;
|
||||
- system prompt hash and task prompt hash;
|
||||
- limits, hardware, seed.
|
||||
- **Metrics:**
|
||||
- model and tool calls;
|
||||
- input, output and cached tokens;
|
||||
- patches, commands, check/build/test runs;
|
||||
- failed verifier cycles and failed test cycles (§15);
|
||||
- first check, build, public test and hidden test results (§14);
|
||||
- files opened, repository and documentation bytes read (§16);
|
||||
- elapsed time, termination.
|
||||
- **Outcome:** `cost_usd` from an optional pricing table (USD per million tokens, §17), `verdict`, `first_generation_verdict`, `accepted`, the hashes of the final repository, and `classification`.
|
||||
|
||||
## Failure classification
|
||||
|
||||
`ajieval classify` records the primary category of a failed run (protocol §27). For Aji runs it also records where the failure was caught: verifier, runtime or test.
|
||||
|
||||
For the smoke test it also records the cause, decided before any language change is considered (protocol §38):
|
||||
|
||||
- `language`
|
||||
- `documentation`
|
||||
- `agent_bundle`
|
||||
- `diagnostics`
|
||||
- `harness`
|
||||
- `model_capability`
|
||||
- `task_ambiguity`
|
||||
|
||||
## Smoke test (E-S)
|
||||
|
||||
[`smoke-plan.example.json`](smoke-plan.example.json) is the shape of the 36-run plan (owner decision):
|
||||
|
||||
- families: a binary/stream parser and a concurrent bounded pipeline;
|
||||
- languages: Aji/AIR, Rust and Zig;
|
||||
- model classes: frontier, mid and small/local;
|
||||
- runs: 2 independent runs per cell.
|
||||
|
||||
The tasks, evaluators and baselines come from E0-2 and E0-4. The smoke test checks infrastructure, not the hypothesis. Its headline numbers are still read: Verified Success Rate, repair cycles, context consumed and cost per correct solution.
|
||||
@@ -1534,7 +1534,7 @@ Do not add syntax or instructions merely because one model struggled with one ta
|
||||
Before the pilot, a small run checks the infrastructure, not the hypothesis:
|
||||
|
||||
```text
|
||||
2 families (e.g. binary frame decoding, append log)
|
||||
2 families (binary/stream parsing; concurrent bounded pipeline — owner decision after Phase 3)
|
||||
× 3 languages (Aji/AIR, Rust, Zig)
|
||||
× 3 model classes
|
||||
× 2 runs
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"comment": "E-S engineering smoke test (protocol §39a): 2 tasks x 3 languages x 3 model classes x 2 runs = 36 runs. Copy next to the private task checkout, fill in task paths, models and the evaluator, then: python3 -m ajieval matrix plan.json (from tools/eval, with PYTHONPATH or cwd there). Infrastructure check only; no result is evidence.",
|
||||
"tasks": ["../aji-bench/tasks/<binary-frame-decoder>", "../aji-bench/tasks/<bounded-pipeline>"],
|
||||
"languages": ["aji_air", "rust", "zig"],
|
||||
"models": [
|
||||
{"class": "frontier", "provider": "anthropic", "model": "<frontier model id>"},
|
||||
{"class": "mid", "provider": "openai", "model": "<mid model id>", "base_url": "<OpenAI-compatible endpoint>"},
|
||||
{"class": "small", "provider": "openai", "model": "<small/local model id>", "base_url": "http://127.0.0.1:8000/v1"}
|
||||
],
|
||||
"runs": 2,
|
||||
"sandbox": "bwrap",
|
||||
"evaluator": "../aji-bench/evaluate",
|
||||
"evaluator_hash_path": "../aji-bench/evaluators",
|
||||
"pricing": "pricing.json",
|
||||
"out": "runs-smoke"
|
||||
}
|
||||
Reference in new issue
Block a user