# 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](bundle.txt) | manifest: files and sections in bundle order | | [syntax-example.air](syntax-example.air) | the one example in the bundle: a minimal syntax reference that verifies and runs | | [history.json](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 ```sh 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 "" ``` 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 0014 islands, frozen graphs, arc (Phase 4) | 19 | 41 | 142 918 | 22 212 | 37 785 (+7.0 %) | — | — | | P4-11 AIR text grammar for Phases 2–4 | 19 | 41 | 149 279 | 22 945 | 39 154 (+3.6 %) | 39 306 | 40 382 | | RFC 0015 spec integration (atomics reserved) | 19 | 41 | 151 929 | 23 311 | 39 904 (+1.9 %) | 40 049 | 41 186 | | Phase 5 atomics implemented (layer 10) | 19 | 48 | 160 428 | 24 607 | 42 275 (+5.9 %) | 42 422 | 43 644 | 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 | ~5.0k (Phase 4: +0.6k for §7 graphs) | | `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`, regions, islands, frozen graphs, arc, allocation authority (spec 03) | ~3.6k | | `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 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. ## Standard library bootstrap `language/syntax.md` includes the built-in import rules (spec 15 §13). The on-demand `library/std.md` includes spec 16 and the signature table in `reference/std.md`. The source profile counts `library/` with `source_docs`. Pure library source is verified through the ordinary pipeline; no AIR bundle addition is needed. RFC 0016 records bootstrap complexity growth; RFC 0017 records endian APIs and qualified standard enum types. The plan tracks the next APIs. RFC 0016 bootstrap measurement (cl100k): Quick Reference 5,511 → 5,777 (+4.8%); other source docs 28,470 → 30,461 (+7.0%); full source docs excluding AIR 33,981 → 36,238 (+6.6%). The on-demand library page is 1,346 tokens. The AIR bundle stays 160,797 bytes. The RFC also records o200k and Qwen2.5 counts. RFC 0017 endian increment (cl100k, relative to bootstrap): Quick Reference 5,777 → 6,000 (+3.9%); other source docs 30,461 → 31,918 (+4.8%); full source docs excluding AIR 36,238 → 37,918 (+4.6%). The library page is 2,533 tokens. AIR remains unchanged. The additional Quick Reference example shows explicit typed success/short-buffer handling; future API catalogs stay on demand. RFC 0018 bounded operations (cl100k, relative to endian): Quick Reference 6,000 → 6,082 (+1.4%); other source docs 31,918 → 33,628 (+5.4%); full source docs excluding AIR 37,918 → 39,710 (+4.7%). The library page is 4,223 tokens. AIR remains unchanged. Copy, substring lookup and recoverable arithmetic reuse existing verified primitives; detailed contracts and the checked sizing example stay on demand. RFC 0019 text/encodings (cl100k, relative to bounded): Quick Reference 6,082 → 6,163 (+1.3%); other source docs 33,628 → 36,042 (+7.2%); full source docs excluding AIR 39,710 → 42,205 (+6.3%). The library page is 6,644 tokens. AIR remains unchanged. UTF-8, hex and canonical Base64 use existing primitives and fixed frame tables. Cumulative full source growth since the pre-stdlib baseline is +24.2%, above the 20% review line; RFC 0019 records the justification and owner-review scope. Future API references should be split/read selectively instead of expanding the front-door catalog.