harness: ajieval checkpoint (M checkpoint / P6A-9 rows; n/a for fields a record lacks)
This commit is contained in:
1 parent
c1391eb3c5
commit
4aa9183e78
4 files changed
+151
No files matched your search
@@ -238,6 +238,15 @@ A first-generation snapshot is not available in Track B. There is no cost in dol
|
||||
|
||||
A line is *distinctive* when no other file of the mount contains it. A line seen in a tool output counts toward a group only if every file containing it belongs to that group. This keeps table rules, fences and sections copied into several files out of the attribution: the error-code table, for instance, is in both `diagnostics/` and `air/`.
|
||||
|
||||
**Checkpoint rows (`ajieval checkpoint`).** One row per run with the fields of the M checkpoint and P6A-9 (plan, P6A-9), shareable as numbers, codes and documentation file names:
|
||||
|
||||
- result, `first_public_check`, `repair_cycles`, `tool_calls`, `wall_seconds`, provider input (total, uncached), output tokens;
|
||||
- `docs`: unique tokens read per group, `files_opened`, `coverage_by_section`;
|
||||
- `diagnostics`: `E0001-E0006`, `E5001`, `E5002`, `E1001`, `E7005`, `other_E7xxx`, then `ownership`, `borrow` (including `memory.*`), `resource`, `concurrency`, `runtime_traps` by the code's kind in `reference/error-codes.md`, and `other` for every remaining code (effects, capabilities, unsafe…), so nothing is dropped; `ir_form_total` is the sum of the first three;
|
||||
- `program`: source bytes, and for `aji_source` the lowered AIR bytes and both `mechanical_air_eliminated` metrics.
|
||||
|
||||
A field the record did not collect is `n/a`, never reconstructed. For an older `aji_air` run with the single-file bundle, `air_docs_unique` is the recorded `unique_reference_tokens` and `coverage_by_section` is the recorded `reference_coverage`; the source groups are `n/a`. Diagnostic codes come from the stored command outputs, as for `profile`. The lowered sizes use the current `zig-out/bin/aji`, so take them while the frontend is the one the runs used.
|
||||
|
||||
**Task variants for `aji_source`.** A task supports the condition through a `languages.aji_source` entry: a starter workspace whose README names `main.aji` and the `main` signature, and a public test. `in` is a keyword in `.aji`, so a source entry point names that capability `input`, and the grant becomes `--grant input=io.read`. Example: [`dev-tasks/dev-echo/lang/aji_source/`](dev-tasks/dev-echo/lang/aji_source/). The evaluator gets `AJIEVAL_LANGUAGE=aji_source` and runs `aji check`/`aji run` on `main.aji`.
|
||||
|
||||
The gap between provider input and cumulative context is history resending, mostly cached. The gap between cumulative context and unique reference is rereading and verbose output. The tokenizer is `cl100k_base` if tiktoken is installed, otherwise bytes / 4. Each record names the one it used.
|
||||
@@ -249,6 +258,7 @@ python3 -m ajieval freeze PLAN.json # PLAN.freeze.json: frozen state + rand
|
||||
python3 -m ajieval matrix PLAN.json # verifies the freeze, runs cells sequentially in frozen order
|
||||
python3 -m ajieval journal PLAN.json "observation" [--run RUN_ID]
|
||||
python3 -m ajieval summary RUNS_DIR # shareable: PASS/FAIL matrix, per-cell metrics, aggregates
|
||||
python3 -m ajieval checkpoint RUNS_DIR... [--json] # M checkpoint / P6A-9 rows (below)
|
||||
python3 -m ajieval profile RUNS_DIR # shareable: termination, output tokens, tool calls, solution size, lowered AIR size (aji_source), docs files read, IR-form and type-mismatch diagnostic counts, diagnostic-code occurrences
|
||||
```
|
||||
|
||||
|
||||
@@ -203,6 +203,10 @@ def main(argv=None):
|
||||
pf = sub.add_parser("profile", help="per-run cost profile: termination, output tokens, solution size, diagnostic codes")
|
||||
pf.add_argument("paths", nargs="+")
|
||||
pf.set_defaults(fn=lambda a: print(report.profile(a.paths)))
|
||||
cp = sub.add_parser("checkpoint", help="per-run rows for the M checkpoint and P6A-9: results, cost, docs by group, diagnostic buckets, program size; n/a where a record lacks a field")
|
||||
cp.add_argument("paths", nargs="+")
|
||||
cp.add_argument("--json", action="store_true")
|
||||
cp.set_defaults(fn=lambda a: print(report.checkpoint(a.paths, a.json)))
|
||||
|
||||
c = sub.add_parser("classify", help="record the primary failure category of a run (protocol §27)")
|
||||
c.add_argument("run")
|
||||
|
||||
@@ -232,3 +232,129 @@ def profile(paths):
|
||||
f"{files} / {lines} / {nbytes} | {f'{lowered[0]} / {lowered[1]}' if lowered else '-'} | "
|
||||
f"{docs.get('unique_docs_read', '-')} | {ir} | {ty} | {', '.join(f'{k} {v}' for k, v in codes.items()) or '-'} |")
|
||||
return "\n".join(out)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- M checkpoint / P6A-9 rows
|
||||
|
||||
def _code_kinds():
|
||||
"""code -> kind from docs/reference/error-codes.md (`ownership.use_after_move`, …)."""
|
||||
import re
|
||||
|
||||
kinds = {}
|
||||
with open(os.path.join(util.REPO, "docs", "reference", "error-codes.md"), encoding="utf-8") as f:
|
||||
for line in f:
|
||||
m = re.match(r"\| ([ET]\d{4}) \| ([a-z_]+)\.", line)
|
||||
if m:
|
||||
kinds[m.group(1)] = m.group(2)
|
||||
return kinds
|
||||
|
||||
|
||||
def _diagnostic_buckets(codes):
|
||||
"""The checkpoint's diagnostic fields. Every code lands in exactly one
|
||||
bucket; codes in none of the named ones are counted in `other`, never
|
||||
dropped."""
|
||||
kinds = _code_kinds()
|
||||
b = {k: 0 for k in ("E0001-E0006", "E5001", "E5002", "E1001", "E7005", "other_E7xxx", "ownership", "borrow",
|
||||
"resource", "concurrency", "runtime_traps", "other")}
|
||||
for code, n in codes.items():
|
||||
kind = kinds.get(code, "")
|
||||
if code in ("E0001", "E0002", "E0003", "E0004", "E0005", "E0006"):
|
||||
b["E0001-E0006"] += n
|
||||
elif code in ("E5001", "E5002", "E1001", "E7005"):
|
||||
b[code] += n
|
||||
elif code.startswith("E7"):
|
||||
b["other_E7xxx"] += n
|
||||
elif code.startswith("T"):
|
||||
b["runtime_traps"] += n
|
||||
elif kind == "ownership":
|
||||
b["ownership"] += n
|
||||
elif kind in ("borrow", "memory", "island"):
|
||||
b["borrow"] += n
|
||||
elif kind == "resource":
|
||||
b["resource"] += n
|
||||
elif kind in ("concurrency", "atomic", "task", "sync", "io"):
|
||||
b["concurrency"] += n
|
||||
else:
|
||||
b["other"] += n
|
||||
b["ir_form_total"] = b["E0001-E0006"] + b["E5001"] + b["E5002"]
|
||||
return b
|
||||
|
||||
|
||||
def checkpoint_rows(paths):
|
||||
"""One row per run with the fields of the M checkpoint and P6A-9 (plan,
|
||||
P6A-9). Only what the record holds: a field the run did not collect is
|
||||
"n/a", never reconstructed. Shareable: numbers, codes and documentation
|
||||
file names only."""
|
||||
from . import languages
|
||||
|
||||
na = "n/a"
|
||||
rows = []
|
||||
for p in paths:
|
||||
for f in sorted(glob.glob(os.path.join(p, "**", "run.json"), recursive=True)):
|
||||
if "/superseded/" in f:
|
||||
continue
|
||||
r = util.read_json(f)
|
||||
d = os.path.dirname(f)
|
||||
lang = r["language"]["name"]
|
||||
m = r["metrics"]
|
||||
ctx = m.get("context") or {}
|
||||
pin = ctx.get("provider_input_tokens") or {}
|
||||
docs = ctx.get("docs")
|
||||
cyc = None if m.get("failed_verifier_cycles") is None else m["failed_verifier_cycles"] + (m.get("failed_test_cycles") or 0)
|
||||
if docs is not None:
|
||||
rb = docs.get("read_tokens_by_group") or {}
|
||||
doc_fields = {"quick_reference_unique": rb.get("quick_reference", na), "source_docs_unique": rb.get("source_docs", na),
|
||||
"air_docs_unique": rb.get("air_docs", na), "files_opened": docs.get("files_opened", na),
|
||||
"coverage_by_section": docs.get("coverage_by_section", na)}
|
||||
elif lang == "aji_air":
|
||||
# Single-file AIR bundle: everything read was AIR documentation,
|
||||
# as recorded at the time (unique_reference_tokens, reference_coverage).
|
||||
doc_fields = {"quick_reference_unique": na, "source_docs_unique": na,
|
||||
"air_docs_unique": ctx.get("unique_reference_tokens", na), "files_opened": na,
|
||||
"coverage_by_section": {"reference-bundle.md": ctx["reference_coverage"]} if ctx.get("reference_coverage") is not None else na}
|
||||
else:
|
||||
doc_fields = {k: na for k in ("quick_reference_unique", "source_docs_unique", "air_docs_unique", "files_opened", "coverage_by_section")}
|
||||
exts = set(languages.load(lang).get("source_extensions", []))
|
||||
_, _, nbytes = _source_size(d, exts)
|
||||
program = {"source_bytes": nbytes, "lowered_air_bytes": na, "mechanical_air_eliminated_raw": na, "mechanical_air_eliminated_normalized": na}
|
||||
if lang == "aji_source":
|
||||
low = _lowered_size(d)
|
||||
if low:
|
||||
program.update({"lowered_air_bytes": low[0], "lowered_air_bytes_normalized": low[1],
|
||||
"mechanical_air_eliminated_raw": round(1 - nbytes / low[0], 4) if low[0] else na,
|
||||
"mechanical_air_eliminated_normalized": round(1 - nbytes / low[1], 4) if low[1] else na})
|
||||
|
||||
def v(x):
|
||||
return na if x is None else x
|
||||
|
||||
rows.append({
|
||||
"task": r["task"]["id"], "agent": _agent_key(r),
|
||||
"condition": {"aji_air": "air", "aji_source": "source"}.get(lang, lang),
|
||||
"result": "PASS" if r.get("accepted") else ("FAIL" if r.get("accepted") is False else na),
|
||||
"first_public_check": v(m.get("first_public_test_passed")), "repair_cycles": v(cyc),
|
||||
"tool_calls": v(m.get("tool_calls")), "wall_seconds": v(m.get("elapsed_seconds")),
|
||||
"provider_input_total": v(pin.get("total")), "provider_input_uncached": v(pin.get("uncached")),
|
||||
"output_tokens": v(m.get("output_tokens")),
|
||||
"docs": doc_fields,
|
||||
"diagnostics": _diagnostic_buckets(_diagnostic_codes(r, d)),
|
||||
"program": program,
|
||||
})
|
||||
return rows
|
||||
|
||||
|
||||
def checkpoint(paths, as_json=False):
|
||||
rows = checkpoint_rows(paths)
|
||||
if as_json:
|
||||
return json.dumps(rows, indent=2)
|
||||
out = []
|
||||
for r in sorted(rows, key=lambda r: (r["task"], r["agent"], r["condition"])):
|
||||
out.append(f"## {r['task']} · {r['agent']} · {r['condition']}\n")
|
||||
for k in ("result", "first_public_check", "repair_cycles", "tool_calls", "wall_seconds",
|
||||
"provider_input_total", "provider_input_uncached", "output_tokens"):
|
||||
out.append(f"- {k}: {r[k]}")
|
||||
for group in ("docs", "diagnostics", "program"):
|
||||
out.append(f"- {group}:")
|
||||
for k, x in r[group].items():
|
||||
out.append(f" - {k}: {json.dumps(x) if isinstance(x, (dict, list)) else x}")
|
||||
out.append("")
|
||||
return "\n".join(out)
|
||||
@@ -264,6 +264,17 @@ class NativeTest(unittest.TestCase):
|
||||
self.assertEqual(native.normalize_usage({"input": 40, "cache_read": 60, "cache_creation": 0, "output": 5})["input"], 100)
|
||||
|
||||
|
||||
class CheckpointTest(unittest.TestCase):
|
||||
def test_diagnostic_buckets(self):
|
||||
b = report._diagnostic_buckets({"E0001": 2, "E0006": 1, "E5001": 3, "E5002": 1, "E1001": 4, "E7005": 2, "E7003": 1,
|
||||
"E2001": 1, "E2101": 2, "E2104": 1, "E3002": 1, "E4304": 1, "T0001": 1, "E3101": 5})
|
||||
self.assertEqual(b["E0001-E0006"], 3)
|
||||
self.assertEqual(b["ir_form_total"], 7)
|
||||
self.assertEqual((b["E1001"], b["E7005"], b["other_E7xxx"]), (4, 2, 1))
|
||||
self.assertEqual((b["ownership"], b["borrow"], b["resource"], b["concurrency"], b["runtime_traps"]), (1, 3, 1, 1, 1))
|
||||
self.assertEqual(b["other"], 5) # effects and capabilities are not dropped
|
||||
|
||||
|
||||
class CyclesTest(unittest.TestCase):
|
||||
def test_repair_cycles_from_commands(self):
|
||||
from ajieval import native
|
||||
|
||||
Reference in new issue
Block a user