P6A-8: Source Reference Bundle and harness profile aji_source

- source bundle: a /docs directory with QUICK.md (Quick Reference plus a
  where-to-read table), language/*.md, diagnostics/errors.md and the AIR
  bundle only under air/; built from docs/agent/source-bundle.txt
  (> output files, @manifest includes) by zig build agent-reference
- Quick Reference examples are checked: every aji block must be an
  excerpt of a conformance program in tests/conformance/source/quickref
  (zig build test fails otherwise); QR fixes found by the check
  (mut d = data, region not auto-borrowed, statement/borrow blocks that
  could not verify, io_error match)
- frontend: task.*/channel.*/mutex.* are not-yet-implemented, not E7006
- aji lower --stats: mechanical_air_eliminated_raw and _normalized (each
  byte-string materialization counted as one constant; spec 15 §11)
- harness: profile aji_source (doc_groups), per-file and per-group docs
  metrics on distinctive lines, profile columns (tool calls, lowered AIR
  raw/normalized, docs files read, IR-form and type-mismatch counts),
  dev-echo aji_source variant, scripted run and test, source token report
- plan: P6A-8 done, P6A-9 criteria; Q-021/Q-022 resolved; unsafe block
  deferred
This commit is contained in:
dev committed 2026-10-05 13:16:51 +03:00
1 parent 61be766634
commit 3e2d9b63a7
35 files changed
+1170 -106

No files matched your search

+30 -1
View File
@@ -50,6 +50,35 @@ Growth never blocks a merge automatically; a complex feature can be justified, b
RFC 0011 crossed the 10 % warning line (its own estimate said "below 10 %"): four new sections in spec 04 (tasks, loans, `Send`/`Share` table, scheduler). Below the 20 % review threshold. RFC 0012 (+15.8 %, estimate 12–16 %): five sections in spec 04 (waits and cancellation, channels, select, mutex, critical-section rule). Implementation-time spec corrections (mutex linearity, `mutex.take` rules): +0.6 %. Phase 3 total since the Phase 2 baseline: +29.2 %. Next measurement: after the E-S smoke test, or with the next RFC.
## Source Reference Bundle (condition `Aji/source`)
The `.aji` condition does not get the AIR bundle as its documentation. It gets a directory mounted at `/docs` with a small front door, and the agent reads the rest only when it needs it. That tests a second hypothesis: a model can work from a small reference and selective reading.
| Path | Contents | cl100k tokens |
|---|---|---:|
| `QUICK.md` | the Quick Reference, then a table of which file to open for what | ~4.4k |
| `language/syntax.md` | grammar, spec 15 §1, §2, §4–§6 | ~5.4k |
| `language/types.md` | spec 15 §3, integer semantics, type properties, traps | ~1.0k |
| `language/ownership.md` | spec 15 §9, aliasing, borrow lifetime, stack storage, slices, initialization (spec 03) | ~1.0k |
| `language/memory.md` | `Own<T>`, regions, allocation authority (spec 03) | ~1.4k |
| `language/effects-capabilities.md` | spec 05 §2–§5, §9–§10, effect and capability registries | ~4.4k |
| `language/io-resources.md` | spec 15 §8, spec 06 §1–§3, §7, intrinsic registry | ~3.0k |
| `language/concurrency.md` | implementation status, spec 15 §7, `Send`/`Share`, scheduler | ~2.2k |
| `language/tooling.md` | spec 15 §11, execution limits and profiles (spec 11) | ~2.2k |
| `diagnostics/errors.md` | spec 15 §10, stable codes, repair loop, error-code registry | ~1.9k |
| `air/reference.md` | the whole AIR bundle, for reading `aji lower` output only | ~35.7k |
Without `air/` it comes to about 26.8k tokens. The manifest is [`source-bundle.txt`](source-bundle.txt): the `bundle.txt` syntax, plus `> path` to start an output file and `@manifest` to include another bundle. Text that exists only for this bundle (navigation, implementation status) is in [`source-notes.md`](source-notes.md).
```sh
zig build agent-reference # also writes zig-out/agent/source/ and source-report.json
uv run --with tiktoken --with tokenizers tools/agent_bundle_tokens.py --source
```
The groups `quick_reference`, `source_docs` and `air_docs` come from the `doc_groups` of the language profile `tools/eval/languages/aji_source.json`. The harness reports reading per group with the same definition (`docs/evaluation/harness.md`, context metrics). An agent writing `.aji` that reads much of `air/` is a signal: either the source documentation is not self-sufficient, or diagnostics are still too AIR-centric.
## Quick Reference (`.aji`)
[`quick-reference.md`](quick-reference.md) is the agent's first entry for the condition `Aji/source`. It is 4–6k tokens (currently about 3.6k, cl100k), covers most programs and has an index into the full reference (owner decision after the native smoke). It is kept consistent with spec 15. Its size and the `unique_reference_tokens` that agents actually read are measured alongside the bundle. The source-condition bundle, with the semantic rules restated in source terms, follows once the frontend exists.
[`quick-reference.md`](quick-reference.md) is the front door of the Source Reference Bundle (`QUICK.md`). It targets 4–6k tokens (about 4.4k with the navigation table, cl100k), covers most programs, and is kept consistent with spec 15.
**Its examples are checked.** Every ```aji block must be an excerpt of a program in `tests/conformance/source/quickref/`. Comments and whitespace are ignored, and `…` matches any text. Those programs are conformance tests, so each example is part of a program that verifies and runs. `zig build test` and `zig build agent-reference` fail on an example that is not. The concurrency programs (§7) are PENDING until layers 7–8 exist.
+28 -31
View File
@@ -1,6 +1,6 @@
# Aji Quick Reference (`.aji` 0.1)
Read this first; it covers most programs. The full rules live in the reference index at the end. `aji check file.aji` verifies, `aji run file.aji` verifies and runs, `aji lower file.aji` prints the AIR it becomes. Diagnostics are JSON lines; fix the first one first.
Read this first; it covers most programs. Where to find the full rules is at the end. Every example below is part of a program the conformance suite checks. `aji check file.aji` verifies, `aji run file.aji` verifies and runs, `aji lower file.aji` prints the AIR it becomes. Diagnostics are JSON lines; fix the first one first.
Aji makes every significant action explicit — moves, borrows, allocation, closing, authority, effects, tasks, channel transfers, locking, cancellation, every failure outcome — and checks them all before running. The compiler writes the mechanics: SSA, control flow, borrow ends, frame storage, the feature header.
@@ -50,15 +50,16 @@ var i: usize = 0; // variable; reassign with i = i + 1;
var buf: [u8; 16] = zero; // zero-initialized storage
if c { … } else if d { … } else { … }
while i < n { … }
for i in 0..n { … } // 0 ≤ i < n
for k in 0..n { … } // 0 ≤ k < n
loop { … break; … continue; … }
return v; trap; assert(c);
let y = if c { 1 } else { 2 }; // value-producing if/match: tail expression without `;`
let w: u64 = match m { // enum match: exhaustive, one arm per variant
Message::Stop => 0,
Message::Value(x) => x, // x exists only in this arm
Message::Value(v) => v, // v exists only in this arm
};
match d { 0 => { … } 1 => { … } _ => { … } } // integer match: `_` required
match t { 0 => { … } 1 => { … } _ => { … } } // integer match: `_` required
assert(c); // traps T0002 when false
return x + y + w; // also: `trap;`
```
| Operation | Meaning |
@@ -80,14 +81,19 @@ There is one spelling per construct: no `+=`, no alternative syntax.
```aji
var data: [u64; 8] = zero;
data[0] = 7; // element write (array variables get frame storage automatically)
mut s = data; // bind an exclusive borrow (an array is borrowed as slice_mut<u64>)
s[1] = s[0] + 1; // checked index; out of range traps T0008
let n = s.len;
if i < s.len { s[i] = 0; } // no runtime check here: the verifier proves i < s.len
let (l, r) = s.split_at(4); // two disjoint halves of s
{
mut s = data; // exclusive borrow to the end of this block (an array is borrowed as slice_mut<u64>)
s[1] = s[0] + 1; // checked index; out of range traps T0008
let n = s.len;
if i < s.len { s[i] = 0; } // no runtime check here: the verifier proves i < s.len
let (l, r) = s.split_at(4); // two disjoint halves of s
…
}
slice.copy(mut out[0..4], ref data[4..8]); // borrows as arguments end after the call
…
ref q = p; // shared borrow of a struct; q.a reads a field
*c = *c + 1; // through mut<u64>
…
*c = *c + 1; // through c: mut<u64>
```
Rules (checked by the verifier):
@@ -103,9 +109,10 @@ Rules (checked by the verifier):
```aji
match fs.open_read(c, b"/data/in.txt") {
ok(f) => { … use f … ; fs.close(move f) or trap; }
ok(f) => { …; fs.close(move f) or trap; }
err(e) => { return 1u8; }
}
…
let n = net.recv(conn, mut buf) or trap; // any non-ok outcome traps
```
@@ -134,6 +141,7 @@ A region allocation needs an explicit borrow of the region that outlives the all
ref arena = r;
let item = region.new(arena, 1u64) or trap; // item: mut<u64>, ends with this block
*item = *item + 1;
…
}
region.reset(r);
```
@@ -141,19 +149,22 @@ region.reset(r);
`err(e)` binds a real value: `match e { alloc_error::budget_exceeded => …, alloc_error::out_of_memory => … }`.
- **Narrowing:** `cap.narrow.prefix(c, b"/data")` and `cap.narrow.budget(heap, 4096)`, each giving `ok(c2) / err(e)`.
- Resource operands (`f`, `s`, `l`, `r`, endpoints) are borrowed automatically for an operation; data borrows (`mut buf`, `ref bytes`) are always written.
- Resource operands (`f`, `s`, `l`, endpoints) are borrowed automatically for an operation; a region is not (bind `ref arena = r;`); data borrows (`mut buf`, `ref bytes`) are always written.
- Memory budgets count live bytes, so freeing returns them. In the deterministic profile `mem.alloc` needs a grant with a budget: `--grant heap=mem.alloc:4096`.
## 7. Concurrency
Not implemented in the source frontend yet (layers 7–8): `aji check` reports these constructs as not implemented (exit code 3). They are shown as specified.
```aji
let d = mut data; // data: [u64; 8]
mut d = data; // data: [u64; 8]
scope s { // every task spawned in s must be joined before the block ends (E4301)
let (l, r) = d.split_at(4);
let a = task.spawn(s, square, l); // borrows are lent to the task until its join
let b = task.spawn(s, square, r);
let x = task.join(move a);
let y = task.join(move b);
…
}
```
@@ -174,11 +185,12 @@ scope s { // every task spawned in s must
```aji
match channel.make<u64>(2, heap) { // effect mem.alloc
ok(tx, rx) => {
let tx2 = channel.dup(tx);
let tx2 = channel.dup(tx); // another sender; close it too
…
match channel.send(tx, v) { ok => {} closed(v) => { … } cancelled(v) => { … } } // a linear v: `move v`
match channel.recv(rx) { ok(v) => { … } closed => { … } cancelled => { … } }
channel.close_sender(move tx);
match channel.close_receiver(move rx) { ok => {} pending(rx) => { … receive until closed, close again … } }
match channel.close_receiver(move rx) { ok => {} pending(rx) => { … } } // drain, then close again
}
err(e) => { trap; }
}
@@ -231,18 +243,3 @@ scope s { // every task spawned in s must
| E4301 | task not joined at scope end | `task.join(move t)` before the `scope` block ends |
| E4304 | wait inside `lock` | move the wait out of the `lock` block |
| T0001–T0009 | runtime trap | see `kind` and `source_location` |
## 9. Index into the full reference
| Topic | Section |
|---|---|
| source language, every construct | spec 15 |
| types, Send/Share | spec 02 §6; spec 04 §35 |
| borrows, frame storage | spec 08 §11; spec 15 §5, §9 |
| heap, regions, budgets | spec 03 §18–§20 |
| effects, capabilities, narrowing | spec 05 §9–§11; `reference/capabilities.md` |
| resources, I/O errors | spec 06 §6–§7; `reference/intrinsics.md` |
| tasks, loans, scheduler | spec 04 §33–§36 |
| waits, cancellation, channels, select, mutex | spec 04 §37–§41 |
| determinism, run records, profiles | spec 11 §7–§8 |
| all codes | `reference/error-codes.md` |
+78
View File
@@ -0,0 +1,78 @@
# Source Reference Bundle manifest (condition Aji/source, spec 14 §3.7).
#
# A directory mounted at /docs. QUICK.md is the front door: it covers most
# programs and says which file to open for the rest. The agent reads the
# other files only when it needs them; air/ is the AIR reference, for
# reading the output of `aji lower` only. Entry syntax: bundle.txt, plus
# > <path> starts the output file <path>
# @<manifest> the single output of another manifest
> QUICK.md
docs/agent/quick-reference.md
docs/agent/source-notes.md :: ## 9. Where to read more
> language/syntax.md
docs/reference/grammar.ebnf
docs/spec/15-source-language.md :: ## 1. Principle
docs/spec/15-source-language.md :: ## 2. Modules and declarations
docs/spec/15-source-language.md :: ## 4. Statements and control flow
docs/spec/15-source-language.md :: ## 5. Expressions
docs/spec/15-source-language.md :: ## 6. Fallible operations and `match`
> language/types.md
docs/spec/15-source-language.md :: ## 3. Types
docs/spec/02-types-and-values.md :: ## 2. Integer semantics
docs/reference/type-properties.md
docs/spec/01-language-overview.md :: ## 6. Trap
> language/ownership.md
docs/spec/15-source-language.md :: ## 9. Frame storage, borrow scopes and features
docs/spec/03-memory-model.md :: ## 3. Safe-reference aliasing rule
docs/spec/03-memory-model.md :: ## 4. Borrow lifetime
docs/spec/03-memory-model.md :: ## 6. Stack storage
docs/spec/03-memory-model.md :: ## 9. Slices
docs/spec/03-memory-model.md :: ## 10. Initialization policy
> language/memory.md
docs/spec/03-memory-model.md :: ## 7. Own<T>
docs/spec/03-memory-model.md :: ## 8. Regions
docs/spec/03-memory-model.md :: ## 18. Allocation authority in AIR
> language/effects-capabilities.md
docs/spec/05-effects-and-capabilities.md :: ## 2. Effects
docs/spec/05-effects-and-capabilities.md :: ## 3. Capabilities
docs/spec/05-effects-and-capabilities.md :: ## 4. Narrowing
docs/spec/05-effects-and-capabilities.md :: ## 5. Capability transfer
docs/spec/05-effects-and-capabilities.md :: ## 9. Effects in AIR
docs/spec/05-effects-and-capabilities.md :: ## 10. Capabilities in AIR
docs/reference/effects.md
docs/reference/capabilities.md
> language/io-resources.md
docs/spec/15-source-language.md :: ## 8. Allocation, resources and intrinsics
docs/spec/06-resources-and-errors.md :: ## 1. Linear resources
docs/spec/06-resources-and-errors.md :: ## 2. Typestate
docs/spec/06-resources-and-errors.md :: ## 3. Cleanup
docs/spec/06-resources-and-errors.md :: ## 7. I/O errors
docs/reference/intrinsics.md
> language/concurrency.md
docs/agent/source-notes.md :: ## Concurrency status
docs/spec/15-source-language.md :: ## 7. Tasks, cancellation, channels, select and mutex
docs/spec/04-concurrency-and-atomics.md :: ## 35. Send and Share in AIR
docs/spec/04-concurrency-and-atomics.md :: ## 36. The deterministic scheduler
> language/tooling.md
docs/spec/15-source-language.md :: ## 11. Tooling
docs/spec/11-determinism-and-replay.md :: ## 7. Execution limits
docs/spec/11-determinism-and-replay.md :: ## 8. Execution profiles
> diagnostics/errors.md
docs/spec/15-source-language.md :: ## 10. Diagnostics
docs/spec/10-diagnostics-and-agent-protocol.md :: ## 2. Stable codes
docs/spec/10-diagnostics-and-agent-protocol.md :: ## 5. Expected repair loop
docs/reference/error-codes.md
> air/reference.md
docs/agent/source-notes.md :: ## The AIR reference
@docs/agent/bundle.txt
+30
View File
@@ -0,0 +1,30 @@
# Source Reference Bundle notes
Text that exists only for the Source Reference Bundle (`source-bundle.txt`). Non-normative: it points at the normative files and states which source layers are implemented.
## 9. Where to read more
The other files in `/docs` hold the full rules. Open one only when this page is not enough.
| Need | Read |
|---|---|
| exact syntax, every construct, `match` and outcomes | `/docs/language/syntax.md` |
| integer semantics, conversions, Copy/Send/Share, traps | `/docs/language/types.md` |
| borrows, scopes, frame storage, slices, initialization | `/docs/language/ownership.md` |
| `own`, regions, allocation budgets | `/docs/language/memory.md` |
| effects, capabilities, grants, narrowing | `/docs/language/effects-capabilities.md` |
| files, streams, stdin/stdout, intrinsic operand tables, `io_error` | `/docs/language/io-resources.md` |
| tasks, channels, select, mutex, cancellation | `/docs/language/concurrency.md` |
| `aji` commands, run records, fuel, profiles | `/docs/language/tooling.md` |
| a diagnostic code (`E2101`, `T0008`, …) | `/docs/diagnostics/errors.md` |
| the AIR printed by `aji lower`, `air_line`/`air_col` in a diagnostic | `/docs/air/reference.md` |
You write `.aji`; you never need to write AIR. Diagnostics point at your source (`file`, `line`, `col`).
## Concurrency status
The source frontend implements layers 1–6 of spec 15. Layers 7 (tasks, channels) and 8 (`lock`, `select`, cancellation, shields) are not implemented yet: a program that uses `scope`, `task.*`, `channel.*`, `mutex.*`, `lock`, `select` or `shield` is reported as not implemented (exit code 3). The rules below describe the language as specified.
## The AIR reference
This file is the reference for text AIR format 0, the language `.aji` lowers to. You do not need it to write `.aji`. It explains what `aji lower` prints and the `air_line`/`air_col` fields of diagnostics.
+4
View File
@@ -149,6 +149,10 @@ Frame storage is bounded (`max_local_frame`, spec 08 §11.5), but an SSA value o
Parameter names are preserved by lowering and are the binding points for grants (spec 15 §2). An AIR program whose `@main` has a parameter named after a `.aji` keyword (`%in` in `tests/conformance/phase2/run/echo_stdin.air`) has no source equivalent with the same instantiation contract, so a grant `in=io.read` cannot target a `.aji` program. Options: accept the restriction (keywords are not parameter names; AIR programs meant to have a source twin avoid them), or a raw-identifier spelling for this position. Not urgent; noted when the source/AIR equivalence test for `echo_stdin` had to drop its `equivalent:` reference.
**Resolved (owner decision):** no language change. For runtime grants the source parameter name is what matters, not identity with a hand-written AIR program: the source program names the parameter `input` and is run with `--grant input=…`, and that AIR test simply has no `equivalent:` twin. Escaped identifiers (`` `in` ``) are deferred until there is a real need, because they grow the grammar for a rare case.
## Q-022 — Byte strings dominate the source/AIR size metric
A byte string lowers to one `local.zero`, then a borrow, index, store and end per non-zero byte, because format 0 has no byte-array constant. In the Layer 6 programs this makes up most of the AIR (`hello`: `mechanical_air_eliminated` 0.94). The metric then measures a representation cost of format 0 more than the mechanics an agent would otherwise write. Options for P6A-9: report the metric both with and without byte-string materialization, or count each byte string as one AIR construct. A byte-array constant in AIR would be a format change (spec 07 §8.7) and is out of scope for 6A.
**Resolved (owner decision):** report both. `mechanical_air_eliminated_raw` counts all AIR actually generated and stays the main engineering metric. `mechanical_air_eliminated_normalized` counts each byte-string materialization as one logical constant operation, under one fixed rule for every program (spec 15 §11).
@@ -18,11 +18,14 @@ def build():
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
src = "main.aji" if lang == "aji_source" else "main.air"
return subprocess.run([AJI, "check", src], 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)
if lang in ("aji_air", "aji_source"):
# `in` is a keyword in .aji, so the source entry point names it `input`.
argv = ["--grant", "in=io.read", "main.air"] if lang == "aji_air" else ["--grant", "input=io.read", "main.aji"]
p = subprocess.run([AJI, "run", argv[0], argv[1], "--grant", "out=io.write", "--stdin", inp, argv[2]], cwd=ws, capture_output=True, text=True, timeout=60)
try:
rec = json.loads(p.stdout)
except json.JSONDecodeError:
@@ -0,0 +1,5 @@
# Interface
- Source: `main.aji`, an `.aji` module.
- Entry point: `main(input: cap<io.read>, out: cap<io.write>)`; any return type.
- The program is run as `aji run --grant input=io.read --grant out=io.write --stdin TEXT main.aji`; 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 input=io.read --grant out=io.write --stdin 'hello' main.aji) || { 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
@@ -6,6 +6,7 @@
"prompt": "prompt.md",
"languages": {
"aji_air": {"workspace": "lang/aji_air", "test": "sh test.sh"},
"aji_source": {"workspace": "lang/aji_source", "test": "sh test.sh"},
"rust": {"workspace": "lang/rust", "test": "sh test.sh"},
"zig": {"workspace": "lang/zig", "test": "sh test.sh"}
},
+17 -2
View File
@@ -99,7 +99,7 @@ The harness calls `CMD WORKSPACE LANGUAGE TASK_DIR` outside the agent's sandbox.
| Variable | Contents |
|---|---|
| `AJIEVAL_LANGUAGE` | `aji_air`, `rust` or `zig` |
| `AJIEVAL_LANGUAGE` | `aji_air`, `aji_source`, `rust` or `zig` |
| `AJIEVAL_TOOLCHAIN_PATH` | the toolchain's PATH entries, `:`-separated |
| `AJIEVAL_TOOLCHAIN_DIRS` | the directories to bind read-only, one per line |
@@ -224,6 +224,21 @@ A first-generation snapshot is not available in Track B. There is no cost in dol
| `cumulative_context_tokens` | the text returned to the agent through its tool loop (every tool output, plus the task message), counted each time it was returned |
| `unique_reference_tokens` | the distinct documentation text the agent saw: distinct lines in the outputs of tool calls that touched `/docs` |
| `reference_coverage` | for a single-file reference (the Aji bundle), the fraction of its lines that the agent saw |
| `docs` | for a documentation directory (the Source Reference Bundle of `aji_source`), per file and per group of the profile's `doc_groups`; see below |
**Directory documentation (`metrics.context.docs`).**
| Field | Meaning |
|---|---|
| `quick_reference_tokens`, `source_docs_tokens`, `air_docs_tokens` | size of each group (`<group>_tokens`) |
| `full_source_docs_tokens` | every group except `air_docs` |
| `read_tokens_by_group` | tokens of the group's lines that the agent saw |
| `coverage_by_section` | per file: the fraction of its distinctive lines that the agent saw |
| `files_opened`, `unique_docs_read` | the files whose `/docs/…` path occurs in a tool input, and how many there are |
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/`.
**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.
@@ -234,7 +249,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 profile RUNS_DIR # shareable: termination, output tokens, solution size, diagnostic-code occurrences
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
```
In Track B the repair metrics are derived from the transcript's shell commands, with their exit codes and outputs:
@@ -0,0 +1,14 @@
{
"comment": "P6A-9 dev regression, Track B: the dev tasks M and C (former smoke tasks) in Aji/source x 3 native agents x 1 run = 6 runs, compared with the frozen Aji/AIR smoke runs of the same agents. Dev material only, never evidence for H4. The tasks need an `aji_source` variant first (harness.md, task variants). Run from tools/eval: python3 -m ajieval matrix plan.json; then python3 -m ajieval profile on both run directories.",
"tasks": ["../aji-bench/tasks/<task-M>", "../aji-bench/tasks/<task-C>"],
"languages": ["aji_source"],
"models": [
{"label": "N1", "agent": "codex", "model": "gpt-6.1-sol", "effort": "high"},
{"label": "N2", "agent": "claude", "model": "claude-opus-5-5", "effort": "high"},
{"label": "N3", "agent": "opencode", "model": "zai-coding-plan/glm-5.3-flash"}
],
"runs": 1,
"evaluator": "../aji-bench/evaluate",
"evaluator_hash_path": "../aji-bench/evaluators",
"out": "runs-source-regression"
}
+33 -2
View File
@@ -30,10 +30,41 @@ Targets and the evaluation order are in `README.md`. Phase 6A is specified by RF
| P6A-5 | done | Source spans on lowered AIR; verifier diagnostics and trap records carry `source_location` and `air_location` | P6A-4 | `src/frontend/spans.zig`, `src/diag.zig` | every diagnostic of a `.aji` file points at source |
| P6A-6 | done | CLI: `aji check/run/lower file.aji` | P6A-4 | `src/main.zig` | same flags and run record as for `.air` |
| P6A-7 | todo | `.aji` twins for the Phase 0–3 conformance tests (same outcome or code) and the reference programs | P6A-5 | `tests/conformance/*/source/` | twins pass; the reference programs in `.aji` pass `--stress` |
| P6A-8 | todo | Source bundle and harness profile `aji_source` (Quick Reference first, full material indexed) | P6A-6 | `docs/agent/`, `tools/eval/languages/aji_source.json` | bundle measured |
| P6A-9 | todo | Dev regression on tasks M and C: `Aji/AIR` vs `Aji/source` (size, output tokens, tool calls, bundle use, diagnostics) | P6A-8 | results note | targets checked (≤ 1.5× Rust size, ≤ 2× output tokens, no SSA/CFG or `E0006` diagnostics) |
| 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-9 criteria (owner decision, fixed before the runs)
Compared per agent with the frozen `Aji/AIR` run of the same task:
| Measure | Criterion |
|---|---|
| IR-form diagnostics (`E0001`–`E0006`, `E5001`, `E5002`; `ajieval profile`) | decrease ≥ 80 % |
| agent output tokens | decrease ≥ 50 % |
| tool calls | decrease materially |
| Aji semantic guarantees | unchanged (same verifier, same evaluator gates) |
| VSR | no regression |
| uncached provider input (strong agents) | substantial decrease |
| weakest agent (GLM) | an earlier `Aji/AIR` failure becomes a PASS, or repair cycles drop sharply |
Also reported:
- wall time;
- `unique_docs_read` and reading per group (`quick_reference`, `source_docs`, `air_docs`);
- diagnostic classes;
- source bytes, lowered AIR bytes (raw and normalized);
- type mismatches (`E1001` + `E7005`), counted apart from the IR-form classes so that relabeling cannot improve them.
Order:
1. source bundle and harness profile (P6A-8);
2. Quick Reference examples checked automatically (P6A-8);
3. M/C `Aji/source` dev runs;
4. comparison with the frozen AIR results;
5. Phase 6A review;
6. only then any decision about further frontend changes.
Lowering layers (P6A-3/4), each with accepted (golden AIR), rejected (`E7xxx`) and verifier-caught tests in `tests/conformance/source/`:
| Layer | Content | Status |
+8 -2
View File
@@ -66,7 +66,7 @@ effects [io.read, io.write]
- **Grants are not source semantics.** A program only declares `main`'s capability parameters. Granting them is instantiation after the module is lowered and verified (`aji run --grant …`, `aji.toml`, spec 12 §1). A missing grant is `not_instantiated` at run time, never a source or verifier diagnostic.
- **One source for every profile.** The frontend does not know the execution profile. The same `.aji` runs in the deterministic and the hosted profile (spec 11).
- **`trusted` is not available.** It is the boundary of runtime, std and toolchain modules (spec 13 §6.3), not something a program declares about its own code. The word is reserved and a `trusted` clause is `E7006`.
- **Unsafe operations** are the format-0 ones and nothing else: `ref unchecked s[i]` / `mut unchecked s[i]` (also bound: `ref unchecked e = s[i];`) lower to `borrow.index.unchecked`, and `assume(c)` to `assume`. Their boundary is the AIR one: the function declares `effects [unsafe]`, which propagates to its callers. Outside it the verifier reports `E6001`. There is no `unsafe { … }` block, because AIR has no block-level unsafe boundary. There is no FFI, raw address or syscall surface in format 0, so none exists in source.
- **Unsafe operations** are the format-0 ones and nothing else: `ref unchecked s[i]` / `mut unchecked s[i]` (also bound: `ref unchecked e = s[i];`) lower to `borrow.index.unchecked`, and `assume(c)` to `assume`. Their boundary is the AIR one: the function declares `effects [unsafe]`, which propagates to its callers. Outside it the verifier reports `E6001`. There is no `unsafe { … }` block, because AIR has no block-level unsafe boundary (owner decision: deferred; localizing unsafe inside a function would be an AIR change through its own RFC). There is no FFI, raw address or syscall surface in format 0, so none exists in source.
## 3. Types
@@ -377,7 +377,13 @@ A byte string or array used where a `slice<u8>` is expected is materialized in f
| `aji check file.aji` | parse, lower, verify |
| `aji run file.aji` | the same, then run (same flags and run record as for `.air`) |
| `aji lower file.aji` | print the canonical AIR |
| `aji lower --stats file.aji` | source and AIR size and the expansion ratio (bytes, non-empty lines): how much mechanical work the frontend took over |
| `aji lower --stats file.aji` | source and AIR size, expansion ratios and the two `mechanical_air_eliminated` metrics below |
| `aji lower --annotate file.aji` | the same with `; line:col-line:col` source spans before each instruction (not canonical; for debugging) |
Lowering is deterministic: the same source and compiler give byte-identical AIR, and the lowered AIR is canonical (parse → print reproduces it). The conformance runner checks both for every accepted `.aji` test.
**Size metrics** (`--stats`, non-normative tooling with a fixed definition):
- Sizes count code only: non-empty lines that are not comments (`//` in source, `;` in AIR), each with its newline.
- `mechanical_air_eliminated_raw` = 1 − `source_bytes` / `air_bytes`: how much of the AIR text the author did not write. This is the main engineering metric.
- `mechanical_air_eliminated_normalized` = 1 − `source_bytes` / `air_bytes_normalized`: the same against AIR in which every byte-string materialization counts as one logical constant operation. Such a materialization is the instructions from the string's `local.zero` to its final `borrow.end`, a store per non-zero byte, because format 0 has no byte-array constant. It is replaced by the single notional line ` const.bytes %<storage>, <literal>`, where `<literal>` is the canonical spelling: printable ASCII as is, otherwise the escapes `\n \r \t \0 \\ \" \xNN`. The storage's `local.alloc` is real frame storage and stays. No other instruction is normalized. The rule is the same for every program, and `byte_string_constants` reports how many were replaced.