M checkpoints recorded; harness statuses; memory test split; P6A-12

- results note docs/evaluation/results/2026-10-06-m-checkpoints.md:
  both checkpoints, owner's assessment (IR-tax closed at the engineering
  level, layer 7 GO; cost hypothesis open); plan status and order
- P6A-12: source type-check completeness (E1001 reached the verifier
  from a source run); not a layer 7 blocker
- harness: metrics.agent_status (max_tokens for a reply cut at its
  length limit, provider_rate_limited for 429/usage limits) and
  metrics.evaluation_status (accepted/rejected/evaluator_error/
  infrastructure_failure/not_evaluated), kept apart; termination records
  max_tokens; checkpoint rows show both; evaluator contract: an
  infrastructure failure sets "infrastructure": true
- interpreter memory test: fast form (20k-320k iterations, 256 KiB
  threshold via Options.collect_threshold) in zig build test; full form
  (100k/1M/4M) in zig build test-extended; CI job 'extended' also runs
  conformance with --collect-every-step
This commit is contained in:
dev committed 2026-10-05 17:43:55 +03:00
1 parent 222c0c884c
commit c2c238d9b1
13 files changed
+251 -19

No files matched your search

+13 -1
View File
@@ -15,7 +15,7 @@ jobs:
- uses: mlugg/setup-zig@v2
with:
version: 0.17.0
- run: zig fmt --check build.zig build.zig.zon src tools
- run: zig fmt --check build.zig build.zig.zon src tools tests/extended
- run: zig build test --summary all
- run: zig build conformance
- run: zig build conformance -- --stress 200
@@ -28,3 +28,15 @@ jobs:
continue-on-error: true
run: pip install --quiet tiktoken tokenizers && python3 tools/agent_bundle_tokens.py
- run: zig-out/bin/aji run --manifest examples/packages/hello/aji.toml | grep -q '"stdout":"hello, aji\\n"'
# Long-running tests, kept out of the main job.
extended:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: mlugg/setup-zig@v2
with:
version: 0.17.0
- run: zig build test-extended --summary all
- run: zig build conformance -- --collect-every-step
- run: zig build conformance -- --stress 20 --collect-every-step
+2 -1
View File
@@ -133,8 +133,9 @@ Do not add an AIR instruction solely as syntax sugar.
```sh
zig build # build ./zig-out/bin/aji
zig build test # unit tests; fails if src/diag.zig drifts from docs/reference/error-codes.md
zig build test-extended # long-running tests (interpreter memory at millions of steps); CI runs it in a separate job
zig build conformance # tests/conformance; add `-- --json` for machine-readable results
zig fmt --check build.zig build.zig.zon src tools
zig fmt --check build.zig build.zig.zon src tools tests/extended
```
Toolchain: Zig 0.17.0. Workflow, layout and definition of done: `CONTRIBUTING.md`. Implementation plan and current phase: `docs/plan/README.md`. Documentation layout and where new documents go: `docs/README.md`. Unresolved spec gaps: `docs/design/open-questions.md` — log new ones there instead of guessing.
+2 -1
View File
@@ -11,6 +11,7 @@ Read `AGENTS.md` first. It holds the non-negotiable principles and the checklist
```sh
zig build # build ./zig-out/bin/aji
zig build test # unit tests (includes registry ↔ docs sync check)
zig build test-extended # long-running tests; also `zig build conformance -- --collect-every-step`
zig build conformance # conformance suite, see tests/conformance/README.md
zig build run -- check f.air # verify a text AIR module
zig build run -- run f.air # verify and execute @main (deterministic profile)
@@ -19,7 +20,7 @@ python3 tests/hosted/smoke.py # hosted profile against the real OS
zig fmt --check build.zig src tools
```
CI runs `zig fmt --check`, `zig build test`, `zig build conformance` and the hosted smoke tests on every push and pull request.
CI runs `zig fmt --check`, `zig build test`, `zig build conformance` and the hosted smoke tests on every push and pull request. A separate job runs `zig build test-extended` and conformance with collection before every instruction (`--collect-every-step`).
## Repository layout
+9
View File
@@ -48,6 +48,15 @@ pub fn build(b: *std.Build) void {
// Unit tests.
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = mod })).step);
// Long-running tests kept out of `zig build test` (CI: a separate job).
const extended = b.addTest(.{ .root_module = b.createModule(.{
.root_source_file = b.path("tests/extended/memory.zig"),
.target = target,
.optimize = optimize,
.imports = &.{.{ .name = "aji", .module = mod }},
}) });
b.step("test-extended", "Run long-running tests (interpreter memory at millions of steps)").dependOn(&b.addRunArtifact(extended).step);
test_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = exe.root_module })).step);
// Conformance suite runner (tests/conformance).
+12 -1
View File
@@ -93,7 +93,7 @@ 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.
`accepted` follows protocol §13: all mandatory gates pass, with no partial success. An evaluator that could not judge the solution because of its own environment (sandbox, toolchain, missing dependency) adds `"infrastructure": true`; the record then says `evaluation_status: infrastructure_failure` instead of a solution failure.
**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:
@@ -216,6 +216,17 @@ Per agent:
A first-generation snapshot is not available in Track B. There is no cost in dollars either: on subscriptions there is no honest cost per solution, so Track B reports success, time, tool calls and context. Economics stays with Track A.
## Agent and evaluation status (Track B, `metrics`)
How the agent's session ended and what the evaluator says about the repository are recorded separately, so that a transport problem after a finished solution is not read as a failure of the solution, and a cut-off reply is not read as a normal exit.
| Field | Values |
|---|---|
| `agent_status` | `exited`, `max_tokens` (the last model reply stopped at its length limit: `finish_reason`/`stop_reason` `length` or `max_tokens`), `provider_rate_limited` (HTTP 429 or a usage limit, then an error exit), `error_exit`, `wall_time` |
| `evaluation_status` | `accepted`, `rejected`, `evaluator_error` (no verdict: timeout, no JSON), `infrastructure_failure` (`"infrastructure": true`), `not_evaluated` |
`termination` keeps the process-level outcome, except that a cut-off final reply is recorded as `max_tokens` there too. `accepted` and the VSR come only from the evaluator.
## Context metrics (both tracks, `metrics.context`)
| Metric | Measures |
@@ -0,0 +1,70 @@
# 2026-10-06 — M checkpoints: Aji/AIR vs Aji/source (Phase 6A)
Non-normative. Diagnostic dev runs on task **M** (the memory-safety-heavy streaming task of the native smoke; private, not named here), one run per cell. **Not evidence** for any hypothesis in the protocol's sense (protocol §39a). Negative findings are kept (protocol §37). The private-side work was done by a clean-context operator; this repository received only numbers, diagnostic codes and documentation file names.
## Setup
- Agents as in the native smoke: N1 Codex + `gpt-6.1-sol` (high), N2 Claude Code + `claude-opus-5-5` (high), N3 OpenCode + `zai-coding-plan/glm-5.3-flash`.
- Aji/source: the Source Reference Bundle (`QUICK.md` front door, `docs/agent/README.md`), sha256 `24cca814…a2843` in both checkpoints.
- Each checkpoint ran from a frozen tag, with cells in a shuffled order, one at a time, each with a fresh workspace and HOME.
## Checkpoint 1 (tag `p6a-m-checkpoint`)
Aji/source × 3 agents, compared with the frozen Aji/AIR smoke runs.
| Agent | AIR | source | IR-form AIR → source | output tokens AIR → source |
|---|---|---|---|---|
| N1 | PASS | PASS | 0 → 1 | 13.3k → 15.4k |
| N2 | PASS | FAIL | 6 → 0 | 30.6k → 12.3k |
| N3 | PASS | FAIL | 50 → 7 | 156k → 55.8k |
Both source failures were classified with `toolchain_bug = yes`. The programs were correct on all evaluator cases. Two toolchain defects caused the failures and the diagnostics.
| Defect | Cause | Effect |
|---|---|---|
| A | The interpreter's memory grew with the number of executed steps. | Under the evaluator's 1 GiB limit the host process ran out of memory: N2 failed 4 cases, N3 failed 5. |
| B | A void function ending in an `if` (or `if`/`else`, `match`, block or void call) was lowered to `ret %`. | Malformed AIR. Every `E0001` counted in the source runs came from this. |
Both were fixed in `222c0c8`, with a memory-invariant test, a collect-every-step conformance mode and fall-through tests.
## Checkpoint 2 (tag `p6a-m-checkpoint-2`)
Both conditions on the same fixed toolchain: M × {AIR, source} × 3 agents = 6 cells.
| | N1 AIR → source | N2 AIR → source | N3 AIR → source |
|---|---|---|---|
| result | PASS → PASS | PASS → PASS | FAIL → PASS |
| IR-form diagnostics | 0 → 0 | 4 (`E0006`) → 0 | 0 → 0 |
| repair cycles | 2 → 6 | 1 → 3 | 0 → 1 |
| tool calls | 22 → 32 | 29 → 37 | 15 → 38 |
| output tokens | 16.2k → 13.9k | 55.3k → 32.4k | 32.4k → 46.7k |
| uncached input | 54.0k → 67.4k | 130.7k → 77.7k | 62.9k → 87.8k |
| seconds | 658 → 600 | 763 → 702 | 797 → 1 491 |
| AIR docs read | 33.0k → 0 | 35.9k → 1.5k | 33.7k → 2.1k |
| source docs read | — → 3.6k + 6.2k | — → 3.6k + 6.6k | — → 3.6k + 7.9k |
| program bytes | 19.0k → 7.5k | 17.1k → 7.8k | 0 → 17.0k |
In source, "docs read" counts the Quick Reference plus the language and diagnostics files.
**The one failure.** N3 on AIR produced no program. It made 15 reads, then its last reply hit the output length limit, with about 32k reasoning tokens. The CLI exited without writing a file. Classification: toolchain no, evaluator integration no, model logic not applicable. The same pattern as N3 on task C in the native smoke.
**Memory.** Peak RSS of the source programs on the largest cases was 12–38 MB. Run on the fixed toolchain, the checkpoint-1 workspaces need 20–26 MB; they needed 700–1 360 MB before the fix.
## Owner's assessment (2026-10-06)
| Hypothesis | Status |
|---|---|
| H_representation: direct AIR imposes a large representation overhead that the frontend removes | confirmed for design |
| H_documentation | strongly supported |
| H_source_correctness | checkpoint passed |
| H_model_capability_compression | preliminary positive signal (N3: AIR no program, source accepted) |
| H_cost_reduction | unresolved (N1 more expensive in source, N2 cheaper, N3 not comparable; one run per cell is too noisy) |
The diagnosis "direct AIR is the main cost of Aji/AIR" is closed at the engineering level, and layer 7 is unblocked. The criterion "AIR 3/3, source 3/3" was not applied literally. Its purpose was to show that source does not regress, and checkpoint 2 gave AIR 2/3 against source 3/3.
> Phase 6A checkpoints demonstrate that direct AIR imposes substantial representation and documentation overhead. The `.aji` frontend eliminates observed manual IR-form failures while preserving verifier-enforced semantics. Evidence for model-capability compression is promising but not yet statistically established.
## Follow-ups
- **P6A-12 (source type-check completeness).** N1's source run in checkpoint 2 got `E1001` ×4: a source type error that the frontend let through and the verifier reported on the lowered AIR.
- **Harness: termination labels.** A reply that ended with `finish_reason=length` was recorded as `exited`. An HTTP 429 after an accepted solution was recorded as `error_exit`. The agent's transport status and the evaluation status are to be kept apart.
+11
View File
@@ -33,6 +33,7 @@ Targets and the evaluation order are in `README.md`. Phase 6A is specified by RF
| P6A-8 | done | Source Reference Bundle (directory, `QUICK.md` front door, AIR reference only under `air/`), harness profile `aji_source` with per-group documentation metrics, Quick Reference examples checked against conformance programs, raw and normalized size metrics | P6A-6 | `docs/agent/source-bundle.txt`, `tools/eval/languages/aji_source.json` | bundle measured; every Quick Reference example is an excerpt of a checked program |
| P6A-9 | todo | Dev regression on tasks M and C: the frozen `Aji/AIR` runs vs new `Aji/source` runs, same agents (all three native agents) | P6A-8 | results note | criteria below reported |
| P6A-10 | todo | Phase 6A exit review | all | plan status | targets reported |
| P6A-12 | todo | Source type-check completeness: errors fully determined by the source type system are reported by the frontend as `E7xxx` at the source construct, never left to the verifier on the lowered AIR (checkpoint 2: `E1001` ×4 in a source run). Not a layer 7 blocker; to be closed before the Phase 6A freeze | P6A-4 | `src/frontend/lower.zig` | for each verifier type rule reachable from source, a source test expecting the `E7xxx` |
| P6A-11 | todo | Malformed generated AIR is a compiler bug: when a `.aji` module passed the frontend but its AIR fails to parse or is structurally invalid, report an internal compiler diagnostic (with the source construct), not the AIR parse error mapped back (found by the M checkpoint: void fall-through lowered to `ret %`) | P6A-4 | `src/check.zig`, error registry | a test that injects malformed lowering gets the internal diagnostic |
### P6A-9 criteria (owner decision, fixed before the runs)
@@ -68,6 +69,16 @@ Order (owner decision, after P6A-8):
Type mismatches (`E1001`, `E7005`) stay a separate category from the IR-form diagnostics.
**Status (2026-10-06).** Steps 1–2 are done in two checkpoints ([results](../evaluation/results/2026-10-06-m-checkpoints.md)). Checkpoint 1 found two toolchain defects, fixed in `222c0c8`. Checkpoint 2 gave AIR 2/3 and source 3/3, with IR-form diagnostics at 0 in source. The owner closed the IR-tax diagnosis at the engineering level: **layer 7 GO**. Remaining order:
1. layer 7 (tasks, channels);
2. layer 8 (`lock`, `select`, cancellation);
3. every concurrency example of the Quick Reference passes;
4. Phase 6A candidate freeze;
5. official P6A-9: M + C × 3 agents.
The cost hypothesis stays open: it needs repetitions.
Lowering layers (P6A-3/4), each with accepted (golden AIR), rejected (`E7xxx`) and verifier-caught tests in `tests/conformance/source/`:
| Layer | Content | Status |
+9
View File
@@ -13,6 +13,15 @@ pub const run = machine.run;
pub const writeOutcome = machine.writeOutcome;
pub const writeValue = machine.writeValue;
pub const call_depth_limit = machine.call_depth_limit;
pub const MemoryStats = machine.MemoryStats;
/// For `tests/extended/memory.zig`: the loop shapes of the memory invariant
/// test and the function that measures one.
pub const memory_test = struct {
pub const loop_shapes = machine.loop_shapes;
pub const memoryOf = machine.memoryOf;
pub const min_threshold = machine.Heap.min_threshold;
};
test {
_ = machine;
+24 -13
View File
@@ -155,6 +155,9 @@ pub const Options = struct {
memory: ?*MemoryStats = null,
/// Collect before every instruction (tests: a missed root then fails).
collect_every_step: bool = false,
/// Smallest heap size that triggers a collection (default 4 MiB); a
/// small value makes short test programs collect often.
collect_threshold: ?usize = null,
/// Maximum number of instructions to execute (spec 11 §7.1); null means unlimited.
fuel: ?u64 = null,
/// Capability grants for the parameters of the entry function.
@@ -234,6 +237,10 @@ pub fn run(arena: std.mem.Allocator, module: air.Module, entry: []const u8, opti
}
m.exec_heap.every_step = options.collect_every_step;
if (options.collect_threshold) |t| {
m.exec_heap.floor = t;
m.exec_heap.threshold = t;
}
const outcome = try m.runProgram(idx, args);
// The result outlives the execution heap.
var result = outcome;
@@ -401,13 +408,15 @@ const Task = struct {
};
/// Execution heap: collected between instructions (see the file comment).
const Heap = struct {
pub const Heap = struct {
space: std.heap.ArenaAllocator = .init(std.heap.page_allocator),
threshold: usize = min_threshold,
/// Smallest collection threshold (`Options.collect_threshold`).
floor: usize = min_threshold,
every_step: bool = false,
stats: MemoryStats = .{},
const min_threshold = 4 << 20;
pub const min_threshold = 4 << 20;
};
const Machine = struct {
@@ -562,7 +571,7 @@ const Machine = struct {
st.collections += 1;
st.peak_heap = @max(st.peak_heap, before);
st.peak_live = @max(st.peak_live, live);
m.exec_heap.threshold = @max(Heap.min_threshold, 2 * live);
m.exec_heap.threshold = @max(m.exec_heap.floor, 2 * live);
}
fn pushFrame(m: *Machine, task: u32, fn_index: u32, args: []const Value) !void {
@@ -2047,7 +2056,7 @@ test "schedule seed: explicit value is used as is, default derives from the prog
// not host RSS: for each loop shape, the live execution state after a
// collection must not grow with the iteration count, and the heap stays
// under a fixed bound.
fn memoryOf(comptime body: []const u8, n: u64) !MemoryStats {
pub fn memoryOf(comptime body: []const u8, n: u64, threshold: ?usize) !MemoryStats {
var arena_state: std.heap.ArenaAllocator = .init(std.testing.allocator);
defer arena_state.deinit();
const arena = arena_state.allocator();
@@ -2058,12 +2067,12 @@ fn memoryOf(comptime body: []const u8, n: u64) !MemoryStats {
return error.NotAccepted;
}
var stats: MemoryStats = .{};
const outcome = try run(arena, report.module.?, "main", .{ .grants = &.{.{ .parameter = "heap", .kind = "mem.alloc", .scope = "4096" }}, .memory = &stats });
const outcome = try run(arena, report.module.?, "main", .{ .grants = &.{.{ .parameter = "heap", .kind = "mem.alloc", .scope = "4096" }}, .memory = &stats, .collect_threshold = threshold });
try std.testing.expect(outcome == .returned);
return stats;
}
const loop_shapes = [_][]const u8{
pub const loop_shapes = [_][]const u8{
// scalar state carried in block arguments
\\module t
\\fn main(heap: cap<mem.alloc>) -> u64
@@ -2133,18 +2142,20 @@ const loop_shapes = [_][]const u8{
};
test "execution memory is bounded by live state, not by the iteration count" {
// Fast form: a 256 KiB threshold makes 20k-320k iterations collect many
// times. The full form (100k/1M/4M iterations, default threshold) is
// tests/extended/memory.zig, run by `zig build test-extended`.
const floor = 256 << 10;
inline for (loop_shapes, 0..) |shape, k| {
const small = try memoryOf(shape, 100_000);
const mid = try memoryOf(shape, 1_000_000);
const large = try memoryOf(shape, 4_000_000);
const small = try memoryOf(shape, 20_000, floor);
const mid = try memoryOf(shape, 80_000, floor);
const large = try memoryOf(shape, 320_000, floor);
errdefer std.debug.print("shape {d}: live {d}/{d}/{d} heap {d}/{d}/{d} collections {d}/{d}/{d}\n", .{
k, small.peak_live, mid.peak_live, large.peak_live, small.peak_heap, mid.peak_heap, large.peak_heap,
small.collections, mid.collections, large.collections,
});
try std.testing.expect(large.collections > 0);
// Steady state: the live state of 4M iterations is the live state of 1M.
try std.testing.expect(large.collections > mid.collections);
try std.testing.expect(large.peak_live <= mid.peak_live + 64 * 1024);
// The heap is bounded by a constant (collection threshold plus one growth step).
try std.testing.expect(large.peak_heap <= 3 * Heap.min_threshold);
try std.testing.expect(large.peak_heap <= 3 * floor + 64 * 1024);
}
}
+25
View File
@@ -0,0 +1,25 @@
//! Extended test (`zig build test-extended`): the interpreter's execution
//! memory is bounded by live state, not by the iteration count, at full
//! scale with the default collection threshold. The fast form runs in
//! `zig build test` (src/interp/machine.zig).
const std = @import("std");
const aji = @import("aji");
const mt = aji.interp.memory_test;
test "execution memory at 100k / 1M / 4M iterations" {
inline for (mt.loop_shapes, 0..) |shape, k| {
const small = try mt.memoryOf(shape, 100_000, null);
const mid = try mt.memoryOf(shape, 1_000_000, null);
const large = try mt.memoryOf(shape, 4_000_000, null);
errdefer std.debug.print("shape {d}: live {d}/{d}/{d} heap {d}/{d}/{d} collections {d}/{d}/{d}\n", .{
k, small.peak_live, mid.peak_live, large.peak_live, small.peak_heap, mid.peak_heap, large.peak_heap,
small.collections, mid.collections, large.collections,
});
try std.testing.expect(large.collections > 0);
// Steady state: the live state of 4M iterations is the live state of 1M.
try std.testing.expect(large.peak_live <= mid.peak_live + 64 * 1024);
// The heap is bounded by a constant (collection threshold plus one growth step).
try std.testing.expect(large.peak_heap <= 3 * mt.min_threshold);
}
}
+50 -1
View File
@@ -358,6 +358,51 @@ def cycles(profile, test_command, commands):
return m
_FINISH = re.compile(r'"(?:finish_reason|stop_reason|finish|reason)"\s*:\s*"([a-z_]+)"')
_RATE_LIMIT = re.compile(r"\b429\b|rate[ _-]?limit|usage limit|too many requests", re.IGNORECASE)
def agent_status(termination, transcript_path, stderr_path):
"""How the agent's session ended, apart from what the evaluator says
about the repository (protocol §28):
finished / exited the CLI ended normally
max_tokens the last model reply stopped at its length
limit (finish_reason length / max_tokens)
provider_rate_limited the provider refused further requests (429,
usage limit); the CLI then exited with an error
error_exit, wall_time otherwise as recorded in `termination`
"""
def tail(path, n=200_000):
try:
with open(path, encoding="utf-8", errors="replace") as f:
return f.read()[-n:]
except OSError:
return ""
t = tail(transcript_path)
reasons = _FINISH.findall(t)
if reasons and reasons[-1] in ("length", "max_tokens"):
return "max_tokens"
if termination == "error_exit" and _RATE_LIMIT.search(tail(stderr_path) + t[-20_000:]):
return "provider_rate_limited"
return termination
def evaluation_status(verdict):
"""accepted / rejected / evaluator_error / infrastructure_failure /
not_evaluated. An evaluator reports an infrastructure failure with
`"infrastructure": true` in its verdict (harness.md, evaluator contract)."""
if verdict is None:
return "not_evaluated"
if verdict.get("infrastructure"):
return "infrastructure_failure"
if verdict.get("accepted"):
return "accepted"
if "gates" not in verdict and verdict.get("error"):
return "evaluator_error"
return "rejected"
def normalize_usage(u):
"""Input (including cached), output and cached-input tokens from the
differently named usage fields of the CLIs; None when not reported."""
@@ -456,6 +501,9 @@ def run_native(task_dir, lang_name, agent_name, model, out_dir, effort=None, see
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, os.path.join(run_dir, "evaluator.log")) if evaluator else None
status = agent_status(termination, transcript, os.path.join(run_dir, "stderr.log"))
if status == "max_tokens":
termination = "max_tokens"
rec = {
"schema": "aji-eval-native/1",
@@ -476,7 +524,8 @@ def run_native(task_dir, lang_name, agent_name, model, out_dir, effort=None, see
"limits": lim,
"hardware": util.hardware(),
"seed": seed,
"metrics": {"elapsed_seconds": elapsed, "exit_code": code, "termination": termination, "tool_calls": facts.get("tool_calls"),
"metrics": {"elapsed_seconds": elapsed, "exit_code": code, "termination": termination,
"agent_status": status, "evaluation_status": evaluation_status(verdict), "tool_calls": facts.get("tool_calls"),
"usage": facts.get("usage"), "agent_facts": {k: v for k, v in facts.items() if k not in ("usage", "tool_calls", "model")},
"input_tokens": tokens["input"], "output_tokens": tokens["output"], "cached_input_tokens": tokens["cached_input"], "context": ctx,
"toolchain_invocations": cyc["toolchain_invocations"],
+2 -1
View File
@@ -331,6 +331,7 @@ def checkpoint_rows(paths):
"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),
"agent_status": v(m.get("agent_status")), "evaluation_status": v(m.get("evaluation_status")),
"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")),
@@ -349,7 +350,7 @@ def checkpoint(paths, as_json=False):
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",
for k in ("result", "agent_status", "evaluation_status", "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"):
+22
View File
@@ -293,6 +293,28 @@ class DocsReadTest(unittest.TestCase):
self.assertEqual(m["coverage_by_section"]["language/memory.md"], 0.0)
class StatusTest(unittest.TestCase):
def test_agent_and_evaluation_status(self):
from ajieval import native
with tempfile.TemporaryDirectory() as d:
tr, err = os.path.join(d, "t.jsonl"), os.path.join(d, "e.log")
def write(t, e=""):
open(tr, "w").write(t)
open(err, "w").write(e)
write('{"part":{"reason":"tool-calls"}}\n{"part":{"reason":"length"}}\n')
self.assertEqual(native.agent_status("exited", tr, err), "max_tokens")
write('{"stop_reason":"max_tokens"}\n{"stop_reason":"end_turn"}\n')
self.assertEqual(native.agent_status("exited", tr, err), "exited")
write('{"part":{"reason":"stop"}}\n', "Error: 429 Too Many Requests: usage limit reached")
self.assertEqual(native.agent_status("error_exit", tr, err), "provider_rate_limited")
self.assertEqual(native.agent_status("exited", tr, err), "exited")
self.assertEqual(native.evaluation_status(None), "not_evaluated")
self.assertEqual(native.evaluation_status({"accepted": True, "gates": {}}), "accepted")
self.assertEqual(native.evaluation_status({"accepted": False, "gates": {"builds": False}, "error": "build_failed"}), "rejected")
self.assertEqual(native.evaluation_status({"accepted": False, "error": "evaluator timed out"}), "evaluator_error")
self.assertEqual(native.evaluation_status({"accepted": False, "infrastructure": True}), "infrastructure_failure")
class CyclesTest(unittest.TestCase):
def test_repair_cycles_from_commands(self):
from ajieval import native