Files
aji/docs/evaluation/protocol.md
T
dev 72192c2331 spec: agent efficiency objectives and evaluation protocol
- spec 14: Model Capability Compression, design objectives (correctness
  externalization, small semantic surface, explicit semantics, local
  reasoning, machine repairability, deterministic feedback, bounded
  context / Agent Reference Bundle), economic objective, design review
  requirement, hypotheses H1-H6, non-goals, anti-overfitting rule
- docs/evaluation/protocol.md: Agent Language Evaluation Protocol 0.1
  (tasks T01-T10, maintenance and seeded-bug benchmarks, metrics,
  statistics, stages A-E, success and falsification criteria)
- docs/evaluation/README.md: integrity rules, stage readiness
- RFC process: mandatory Agent complexity impact section
- AGENTS.md: overarching objective and anti-overfitting rule
- plan: evaluation track E0-1..E-1; P8-7 integrates ajid with the
  scaffold; conformance plan points to the protocol
2026-10-04 15:36:32 +03:00

23 KiB
Raw Blame History

Aji Agent Language Evaluation Protocol

Version: 0.1
Status: Proposed
Purpose: empirical validation of the Aji language hypothesis (spec 14)

1. Goal

The benchmark answers five primary questions:

Does Aji increase correctness?

Does Aji reduce repair work?

Does Aji allow weaker models to perform like stronger models?

Does the advantage survive maintenance and refactoring?

Does this reduce the economic cost of correct software?

Performance of generated binaries is measured separately.

The benchmark is not intended to show that Aji can merely implement the test programs.


2. Experimental variables

Three dimensions are varied independently.

Language

Primary comparison:

Aji
Rust
Zig

Secondary comparison:

C

C is useful as a low-level baseline but is not required for every experiment.

Model capability

At least four capability classes:

F — frontier
S — strong
M — mid
L — small/local

Model classes are assigned before Aji evaluation.

Parameter count alone MUST NOT determine capability class.

At least one locally runnable model SHOULD be included.

Task

Tasks cover:

memory safety
binary parsing
resource ownership
persistent storage
networking
regions
concurrency
synchronization
atomics
maintenance

3. Experimental unit

One experimental run is:

one model
+
one language
+
one task
+
one fresh repository
+
one fresh agent context

Runs share no conversation state.

The model cannot inspect another run.


4. Agent environment

All languages receive equivalent facilities:

repository access
editor
compiler
test runner
local language documentation
shell
benchmark runner

The agent may not:

access hidden tests
access another language's reference implementation
modify the evaluator
access previous benchmark runs
use the public internet during the run

Aji receives its released Agent Reference Bundle.

Rust and Zig receive pinned local official/reference documentation appropriate to the tested version.


5. Agent scaffold

The same agent loop SHOULD be used wherever technically possible.

The scaffold controls:

repository inspection
file editing
compiler execution
test execution
termination
token budget
tool-call budget

Language-specific instructions may explain how to invoke the toolchain but MUST NOT contain solution hints.

Scaffold tuning occurs only on the development set.

The test set is not used for scaffold tuning.


6. Repetition

Development experiments:

3 runs per cell

Full evaluation:

>= 6 independent runs per
model × language × task

Headline comparisons SHOULD be repeated:

>= 12 runs per cell

when cost permits.


7. Benchmark corpus

The benchmark has three sets.

dev
validation
test

dev

Visible to Aji developers.

Used for:

tooling development
scaffold tuning
benchmark debugging

validation

Used before releases.

Tasks are visible, hidden tests are not.

test

Private held-out corpus.

Neither task solutions nor hidden tests are used during language design.

A task is retired from the hidden set after public disclosure.


8. Task acceptance review

Every benchmark task must pass human review before entering the test set.

Reviewers verify:

  • requirements are unambiguous;
  • more than one valid implementation is possible;
  • hidden tests test the stated requirements;
  • tests do not require unspecified behavior;
  • one language is not given an accidental structural advantage;
  • acceptance criteria are deterministic;
  • baseline solutions exist in all compared languages.

Broken tasks are removed before results are examined.


9. Task classes

T01 — Binary Frame Decoder

Purpose:

bounds
initialization
integer handling
slices
malformed input

Task

Implement a streaming decoder for this binary frame:

magic        u32 little-endian
version      u8
flags        u8
payload_len  u32 little-endian
payload      payload_len bytes
checksum     u32

Requirements:

  • maximum payload: 1 MiB;
  • truncated input returns an error;
  • invalid magic returns an error;
  • unsupported version returns an error;
  • payload length must never cause out-of-bounds access;
  • arbitrary input must never crash or trap;
  • decoder may receive a frame in arbitrary chunks;
  • successful decoding must reproduce the exact payload.

Hidden evaluation:

valid corpus
truncation at every byte boundary
oversized lengths
integer edge cases
100k+ generated malformed inputs
round-trip tests

Mutation tasks:

add optional extension field
support two protocol versions
reduce allowed scratch memory

T02 — Region-Bound Tree Processor

Requires Aji regions/heap milestone.

Purpose:

Own<T>
Region
allocation budget
borrowing
lifetime

Task

Read a sequence of tree-building commands and construct an in-memory tree.

Operations:

NODE parent value
RESET
SUM node
DEPTH node

Requirements:

  • nodes between RESET operations must use region storage;
  • RESET releases the entire current tree;
  • no reference from an old tree may survive RESET;
  • memory grant: 4 MiB;
  • allocation failure must be handled;
  • processing continues after a reset.

Hidden evaluation:

deep trees
wide trees
repeated resets
near-budget allocation
budget exhaustion
invalid parent identifiers

Mutations:

add subtree deletion
return a computed immutable snapshot
change value from scalar to structure

T03 — Durable Append Log

Purpose:

resources
I/O
failure paths
bounded memory
recovery

Task

Implement an append-only record log.

Record:

sequence
length
checksum
payload

Requirements:

  • monotonically increasing sequence;
  • max payload 64 KiB;
  • append;
  • sync;
  • reopen;
  • recovery;
  • torn final record must not make previous records unreadable;
  • corrupted completed record must be reported;
  • working memory <= 2 MiB.

Hidden evaluator injects interruption after selected write boundaries.

Mutations:

add log rotation
add record type
add batch append
change checksum algorithm

T04 — Framed TCP Relay

Purpose:

network resources
partial I/O
resource closing
capabilities
protocol parsing

Task

Implement a TCP service using a length-prefixed request protocol.

For every request:

u32 length
payload

server returns:

u32 length
transformed payload

Requirements:

  • fragmented receives;
  • fragmented sends;
  • maximum frame size;
  • clean disconnect;
  • malformed client isolation;
  • every listener and stream consumed exactly once.

Deterministic loopback network is used in the primary evaluation.

Mutations:

add request identifier
add connection limit
add graceful shutdown

T05 — Bounded Processing Pipeline

Requires structured concurrency.

Purpose:

tasks
channels
backpressure
cancellation
linear resources

Task

Create three stages:

reader
  ↓
parser
  ↓
writer

All queues are bounded.

Requirements:

  • no unbounded allocation;
  • configurable queue capacity;
  • downstream failure cancels upstream work;
  • all tasks terminate;
  • no resource leaks;
  • output ordering is defined by the task specification.

Hidden evaluator varies:

queue capacity
producer speed
consumer speed
failure point
cancellation point
schedule

Mutations:

add fourth stage
change ordering requirement
add retryable failure

T06 — Parallel Histogram

Purpose:

safe parallelism
disjoint memory
structured tasks
determinism

Task

Compute a 256-bin histogram over a large byte buffer using N worker tasks.

Requirements:

  • N is configurable;
  • input is immutable;
  • mutable state may not be unsafely shared;
  • result must equal sequential reference implementation;
  • task completion must be structured;
  • output must be identical for every scheduler interleaving.

Mutations:

support u16 symbols
dynamic worker count
process data in chunks

T07 — Concurrent Sharded KV Store

Purpose:

shared mutable state
mutexes
lock ordering
resource lifetime
concurrent APIs

Operations:

GET
PUT
DELETE
COMPARE_AND_SWAP

Requirements:

  • configurable shard count;
  • concurrent clients;
  • operations on the same key behave linearly;
  • no data races;
  • no deadlocks in tested schedules;
  • bounded memory.

Hidden evaluation includes concurrent operation histories.

Mutations:

add TTL
change shard function
add snapshot
reduce memory budget

T08 — Atomic SPSC Ring Buffer

Purpose:

atomics
memory ordering
weak-memory reasoning

Task

Implement a bounded single-producer/single-consumer ring buffer.

Restrictions:

no mutex
no channel
fixed capacity

Requirements:

  • no lost values;
  • no duplicated values;
  • FIFO ordering;
  • wrap-around correctness;
  • deterministic interleaving exploration must find no invalid history.

The task intentionally tests whether Aji's atomic model and verifier reduce reasoning errors.

Mutations:

batch push
batch pop
64-bit sequence counters

MPMC is NOT part of the initial task.


T09 — Mini Message Broker

Purpose:

networking
tasks
bounded queues
backpressure
resource ownership
cancellation

Features:

publish
subscribe
bounded topic queue
multiple clients
disconnect cleanup

Requirements:

  • bounded memory;
  • slow consumers create backpressure according to specification;
  • disconnect cannot leak resources;
  • one failed client cannot terminate unrelated clients;
  • deterministic execution must be replayable.

Mutations:

multiple topics
consumer groups
queue retention limit

T10 — Mini Storage Engine

This is the final integration benchmark.

Components:

TCP protocol
KV API
memtable
WAL
immutable segments
recovery
concurrent clients

Required operations:

GET
PUT
DELETE
SYNC

Requirements:

  • bounded memory;
  • recovery after interruption;
  • concurrent clients;
  • deterministic test execution;
  • valid resource ownership;
  • no unsafe code unless explicitly permitted by the track.

Later variants add:

compaction
snapshots
background maintenance

This task is not used until the required Aji features are stable.


10. Maintenance benchmark

Generation from scratch is insufficient.

Every core program receives modification tasks.

Primary modification categories:

M1 — Feature addition

Add externally visible functionality without breaking previous behavior.

M2 — API migration

Change an internal interface used by multiple modules.

M3 — Memory constraint

Reduce allowed memory without changing observable behavior.

M4 — Concurrency conversion

Convert sequential processing to parallel/concurrent processing.

M5 — Capability reduction

Reduce authority granted to one component while preserving functionality.

M6 — Fault handling

Introduce a new failure mode and ensure complete cleanup.

M7 — Bug repair

Provide a failing public reproduction but keep regression tests hidden.

M8 — Structural refactor

Change storage/layout/ownership representation while preserving behavior.


11. Independent vs cumulative maintenance

Two modes are measured.

Independent

Every mutation begins from the same known-good baseline.

Measures:

ability to perform one change

Cumulative

Mutations are applied sequentially:

v1
↓
M1
↓
M2
↓
M3
↓
...

Measures:

architectural degradation
context growth
regression accumulation
long-term maintainability

12. Seeded bug benchmark

Canonical implementations receive deliberately inserted defects.

Bug classes:

out-of-bounds access
use-after-move
resource leak
double close
lifetime escape
allocation budget bypass
authority misuse
missing error edge
deadlock
incorrect atomic ordering

The agent receives only:

repository
bug report
observable failure when appropriate

Metrics measure whether the defect is:

caught before execution
correctly diagnosed
correctly repaired
repaired without regression

Aji verifier-detected bugs and test-detected bugs are reported separately.


13. Primary correctness metric

A run is accepted only if all mandatory gates pass:

compiler/verifier accepts
public tests pass
hidden functional tests pass
hidden regression tests pass
fuzz corpus passes
resource checks pass
required deterministic runs agree

For concurrency tasks:

schedule exploration passes

For tasks with resource limits:

memory/fuel limits pass

There is no partial success in the primary metric.

Primary result:

Verified Success Rate
=
accepted runs / all runs

14. First-generation metric

Record the state before the first compiler-driven repair.

Metrics:

first check accepted
first build accepted
first public test pass
first hidden test pass

This separates:

generation quality

from:

repair-loop quality

15. Repair metrics

For every run record:

compiler/verifier invocations
failed verifier cycles
failed test cycles
number of patches
total generated tokens
total context tokens
tool calls
elapsed agent time

Key metric:

Repair Cycles to Accepted Solution

16. Context efficiency

For maintenance tasks measure:

repository tokens inspected
documentation tokens inspected
files opened
functions inspected

Aji's context hypothesis is supported if correct modifications require materially less context.


17. Economic metrics

For API models:

input cost
output cost
cached-input cost
tool/model cost

For local models:

GPU-seconds
energy if available
wall time
generated tokens

Primary economic measure:

Expected Cost per Correct Solution
=
total cost of all runs
/
number of accepted runs

Failed attempts therefore contribute to cost.

This prevents cheap but unreliable models from appearing artificially inexpensive.


18. Model Capability Compression metric

Primary evidence is direct cross-tier comparison.

Example:

M + Aji
versus
S + Rust

M + Aji
versus
S + Zig

A one-tier compression result occurs when the lower-tier Aji configuration is non-inferior in Verified Success Rate to the higher-tier baseline configuration.

Recommended non-inferiority margin:

5 percentage points

Stronger evidence:

M + Aji >= F + baseline

or:

L + Aji >= S + baseline

19. Capability curves

For each language, fit:

P(success)
=
f(model capability, task difficulty)

The important observation is horizontal shift.

Conceptually:

success
1.0 |                Aji
    |              /
    |            /
    |       Rust/
    |      /   /
    | Zig /   /
0.0 +-----------------
       model capability

If Aji's curve is consistently shifted toward weaker models, the Model Capability Compression hypothesis is supported.


20. Statistical analysis

Report at minimum:

success proportion
95% confidence interval
median repair cycles
median cost
cost per accepted solution

Task-level bootstrap SHOULD be used for aggregate confidence intervals.

A mixed-effects logistic model MAY be used:

success
~
language
* model
+ task-family random effect

No headline metric should rely on one task family.


21. Fixed-budget track

Each configuration receives the same execution envelope:

maximum agent turns
maximum tool calls
maximum wall-clock duration

This measures engineering capability under comparable operational constraints.


22. Economic track

Each configuration instead receives the same maximum monetary or compute budget.

Example:

$1
$5
$20

or equivalent local-compute budget.

Question:

Which language/model pair produces the highest probability of a correct solution per unit cost?

This is the main track for testing Aji's economic hypothesis.


23. Unconstrained diagnostic track

A smaller experiment allows the agent to continue until:

success
or
hard safety limit

This is used to understand failure modes and repair convergence.

It is not the main leaderboard.


24. Runtime performance

Correct implementations are subsequently benchmarked for:

throughput
latency
peak memory
binary size
startup time

Runtime performance is secondary to correctness during early Aji development.

An incorrect program receives no performance score.


25. Unsafe code

Report separately:

unsafe blocks
unsafe instructions
FFI boundaries
raw memory operations

A baseline solution using unsafe facilities is not automatically invalid, but the amount of unsafe code is recorded.

Aji tasks MAY define:

unsafe forbidden

when testing safe-language guarantees.


26. Negative controls

Include tasks where Aji should have little structural advantage:

pure arithmetic
simple transformation
straightforward sorting
small deterministic algorithms

If Aji appears dramatically superior on every negative-control task, investigate benchmark or scaffold bias.


27. Failure classification

Every failed run receives one primary category:

SPEC_UNDERSTANDING
SYNTAX
TYPE
OWNERSHIP
BORROW
RESOURCE
BOUNDS
FUNCTIONAL
CONCURRENCY
DEADLOCK
ATOMIC_ORDERING
PERFORMANCE
BUDGET
TIMEOUT
AGENT_GAVE_UP
TOOL_FAILURE

For Aji additionally record:

caught_by_verifier
caught_by_runtime
caught_by_test

This measures where reasoning was externalized.


28. Reproducibility record

Every run stores:

task id/version
hidden evaluator hash
language
compiler version/commit
model exact identifier
provider
model parameters
agent scaffold commit
system prompt hash
task prompt hash
token limits
tool limits
hardware
seed
all tool calls
all patches
all compiler diagnostics
all test results
final repository
cost

29. Benchmark integrity

The hidden test corpus must not be committed into the public Aji repository.

Store:

task spec
evaluator
reference implementation
hidden tests

in a separate private benchmark repository.

Published results include evaluator hashes.

When a test set is disclosed, it is retired and replaced.


30. Stage A — Phase 2 validation

Run after:

heap
regions
resources
capabilities
effects
deterministic I/O

Tasks:

T01 Binary Frame Decoder
T02 Region-Bound Tree
T03 Durable Append Log
T04 Framed TCP Relay

Primary hypotheses:

H1 correctness
H2 repair
H4 early model compression

No claims about concurrency yet.


31. Stage B — Phase 3 validation

After structured concurrency:

T05 Pipeline
T06 Parallel Histogram
T07 Concurrent KV

Add:

schedule exploration
cancellation tests
deadlock analysis

This is the first serious test of Aji's concurrency thesis.


32. Stage C — Atomic validation

After the atomic memory model is stable:

T08 SPSC Ring

Also run small litmus-test repair tasks.

Do not add complex lock-free reclamation until Aji has explicit support for it.


33. Stage D — Systems integration

Run:

T09 Message Broker
T10 Mini Storage Engine

These become the primary end-to-end language benchmark.


34. Stage E — Maintenance campaign

For T03, T07, T09 and T10 run all M1–M8 mutation classes.

This stage is more important than additional greenfield examples.

A language for AI development must remain effective when an agent changes code it did not create in the current context.


35. Initial success criteria

Before running the private test set, freeze these thresholds.

Evidence for H1

For mid and small models:

Aji Verified Success Rate
>=
best Rust/Zig baseline + 15 percentage points

on safety-heavy tasks.

Evidence for H2

Median repair cycles:

Aji <= 70% of best baseline

Evidence for H3

For successful maintenance runs:

median context consumed by Aji
<= 70% of best baseline

Evidence for H4

At least one lower model tier using Aji is non-inferior within 5 percentage points to the next higher model tier using Rust or Zig across the aggregate test set.

Strong evidence requires this to hold across multiple task families.

Evidence for H5

Expected Cost per Correct Solution:

Aji lower-tier model
<= 50%

of the higher-tier baseline model it matches in correctness.

Evidence for H6

Aji's correctness advantage remains positive on the independent and cumulative maintenance tracks.


36. Strong confirmation criterion

The core Aji thesis is strongly supported if all are observed:

Mid + Aji
>=
Strong + Rust/Zig

for correctness,

while:

cost(Mid + Aji)
<
cost(Strong + Rust/Zig)

and the advantage persists on:

greenfield
maintenance
concurrency
fault repair

tasks.


37. Falsification criteria

The hypothesis should be considered weakened if:

  • Aji only helps frontier models;
  • weaker models repeatedly fail to understand Aji-specific semantics;
  • verifier errors cause long repair loops;
  • Aji advantage disappears on maintenance tasks;
  • benefits only occur on examples already present in the specification;
  • correctness gains require substantially more inference cost;
  • language complexity grows until the Agent Reference Bundle approaches conventional language complexity.

A negative result must be retained and reported.


38. Decision rules for language development

Benchmark failures SHOULD be classified before changing the language.

Possible causes:

model limitation
documentation problem
diagnostic problem
tooling problem
language semantic complexity
missing abstraction
benchmark defect

A language feature should be added only when repeated failures show that the semantic model itself is responsible.

Do not add syntax or instructions merely because one model struggled with one task.


39. First concrete experiment

As soon as RFC 0008 is implemented, run a pilot:

tasks:
T01
T02
T03
T04

languages:
Aji
Zig
Rust

models:
1 frontier
1 mid
1 small/local

runs:
3 per cell

Total:

4 × 3 × 3 × 3
=
108 runs

Purpose:

debug benchmark
estimate effect size
identify impossible/ambiguous tasks
measure cost
validate instrumentation

Do not use this pilot as headline evidence.


40. First confirmatory experiment

After fixing the benchmark based only on the pilot:

8 held-out tasks
3 languages
4 model classes
6 independent runs

Total:

576 runs

This should be the first meaningful published Aji language evaluation.


41. Central benchmark question

The most important table produced by the project should eventually look like:

Model class Zig Rust Aji
Frontier success % success % success %
Strong success % success % success %
Mid success % success % success %
Small/local success % success % success %

Immediately beside it:

Model + language Cost / correct solution Repair cycles Context consumed
Frontier + Rust … … …
Mid + Aji … … …
Small + Aji … … …

That comparison directly tests the Aji thesis.


42. Final principle

The benchmark does not ask:

Can an AI write Aji?

It asks:

How much model intelligence does Aji make unnecessary while preserving correctness?

That is the primary experimental question of the project.