Files
aji/docs/agent
dev c18fb7acc1 Phase 6A: .aji layer 6 (intrinsics, resources, narrowing, unsafe operations)
- intrinsics from the registry as plain calls: fallible ones are outcome
  matches or `or trap` (E7006 otherwise), infallible ones plain calls
- resource operands by name, borrowed mut for the one operation and ended
  on every edge; a mut binding/parameter passes as is; `mut f` is E7006
- closes consume with `move` (E7003); no inserted closes (E3002/E3001)
- data operands explicit (ref/mut/byte string, E7005 otherwise)
- file<…>, stream, listener types; cap.narrow.prefix with cap_error edges
- ref/mut unchecked s[i] (also as a binding) and assume(c) under
  effects [unsafe]; boundary left to the verifier (E6001)
- trusted is reserved and rejected (E7006)
- parameter names preserved; generated names avoid them (normative)
- parser: >> closes two type arguments
- conformance: `equivalent:` compares the run record with a reference
  AIR program (hello, file_copy, tcp_echo, narrow ok/not_subset/invalid,
  random)
- spec 15, grammar, quick reference (io_error match fixed), plan, examples
2026-10-05 12:16:54 +03:00
..

Agent Reference Bundle

Non-normative tooling for spec 14 §3.7. The bundle is the minimal material a model must receive to write correct AIR without access to the rest of the repository. Its size is a language complexity metric.

File Purpose
bundle.txt manifest: files and sections in bundle order
syntax-example.air the one example in the bundle: a minimal syntax reference that verifies and runs
history.json recorded measurements, one entry per milestone

Contents

Included: AIR text grammar and format rules, instruction set, type and integer semantics, traps, verifier rules (limits, borrows, facts, initialization, stage order), resources, effects, capabilities, intrinsics, heap and regions, unsafe boundaries, the deterministic runtime contract, the diagnostic format and all registries (codes, features, effects, capabilities, intrinsics).

Excluded: RFC rationale, plans and roadmap, design history, README prose, benchmark descriptions, examples other than the syntax reference.

A section enters the bundle through bundle.txt only. When a semantic RFC adds normative text an agent needs, the RFC adds the corresponding entry.

Measuring

zig build agent-reference                     # zig-out/agent/reference-bundle.md, report.json
uv run --with tiktoken --with tokenizers tools/agent_bundle_tokens.py
uv run --with tiktoken --with tokenizers tools/agent_bundle_tokens.py --record "<milestone>"

Counted: files, sections, bytes, lines, words, and tokens with OpenAI cl100k_base and o200k_base and the independent byte-level BPE of Qwen2.5. The trend matters more than any single tokenizer.

Growth policy

Compared with the last recorded milestone:

Growth per semantic RFC Consequence
≤ 10 % none
> 10 % CI warning
> 20 % review required: the RFC explains the growth in its Agent complexity impact section

Growth never blocks a merge automatically; a complex feature can be justified, but not silently.

Milestones

Milestone Files Sections Bytes Words cl100k o200k Qwen2.5
Phase 2 baseline (AIR format 0) 18 29 104 250 16 197 27 347 27 445 28 230
RFC 0011 tasks (Phase 3, part 1) 19 33 116 126 18 082 30 333 (+10.9 %) 30 433 (+10.9 %) 31 316 (+10.9 %)

| RFC 0012 waits, channels, select, mutex | 19 | 38 | 133 781 | 20 748 | 35 119 (+15.8 %) | 35 219 (+15.7 %) | 36 238 (+15.7 %) | | Phase 3 implementation | 19 | 38 | 134 576 | 20 884 | 35 324 (+0.6 %) | 35 424 (+0.6 %) | 36 453 (+0.6 %) |

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.

Quick Reference (.aji)

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.