Files
aji/docs/agent

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 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<T>, 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: 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.

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 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.

RFC 0020 supplied-buffer decimal formatting (cl100k, relative to text): Quick Reference 6,163 → 6,220 (+0.9%); other source docs 36,042 → 37,128 (+3.0%); full source docs excluding AIR 42,205 → 43,348 (+2.7%). The library page is 7,730 tokens. AIR remains unchanged. Four scalar writers reuse ordinary source and one Copy enum; full contracts and explicit record composition stay on demand. Cumulative source growth from the pre-stdlib baseline is +27.6%, with the existing owner-review justification recorded in RFC 0020. No compression benefit is inferred from documentation or fixtures.

RFC 0021 package modules (cl100k, relative to formatting): Quick Reference 6,220 → 6,501 (+4.5%); other source docs 37,128 → 38,822 (+4.6%); full source docs excluding AIR 43,348 → 45,323 (+4.6%). New on-demand language/modules.md is 1,566 tokens, library/std.md and AIR remain unchanged. The front door has one checked module example; package input/name/loader contracts stay on demand. Cumulative source growth is +33.4%, documented for owner review; no compression benefit is claimed. Pure modules need no new AIR feature or verifier state.

RFC 0022 explicit generics (cl100k, relative to modules): Quick Reference 6,501 → 6,948 (+6.9%); other source docs 38,822 → 41,086 (+5.8%); full source docs excluding AIR 45,323 → 48,034 (+6.0%). New on-demand language/generics.md is 1,324 tokens; library/std.md is 8,380 tokens. AIR remains 160,797 bytes. Cumulative source growth is +41.3%, and Quick Reference exceeds its 4–6k target; the RFC explains the cost for owner review and calls for separate front-door consolidation/selective API reading. Explicit specialization adds no AIR instruction or verifier transfer state; documentation growth alone does not establish a compression benefit.

RFC 0023 whole-value linear aggregates (cl100k, relative to generics): Quick Reference 6,948 → 7,225 (+4.0%); other source docs 41,086 → 42,364 (+3.1%); full source docs excluding AIR 48,034 → 49,589 (+3.2%). New on-demand language/linear-aggregates.md is 1,133 tokens; library/std.md is 8,398. AIR grows to 168,336 bytes (+4.7%). Whole unpack/exhaustive match/explicit swap/allocation failure expose ownership without per-field holes, cleanup or new transfer state. Cumulative source growth is approximately +45.9%; Quick Reference remains beyond its 4–6k target. RFC 0023 justifies the added contracts; consolidation remains separate work and no MCC improvement is claimed.

RFC 0024 initialized buffers and safe Vec (cl100k, relative to linear aggregates): Quick Reference 7,225 → 7,667 (+6.1%); other source docs 42,364 → 44,717 (+5.6%); full source excluding AIR 49,589 → 52,384 (+5.6%). New on-demand language/buffers.md is 1,175 tokens; library/std.md is 9,432. AIR grows to 175,736 bytes (+4.4%). Initialized prefixes, explicit reserve, returned failure ownership and empty-only free permit safe resource containers without per-slot verifier state. Cumulative full source growth is +54.2%, with the RFC's owner-review justification; Quick Reference consolidation remains separate work and no empirical MCC improvement is claimed.

RFC 0025 safe owning Deque (cl100k, relative to buffer/Vec): Quick Reference 7,667 → 7,747 (+1.0%); other source docs 44,717 → 46,246 (+3.4%); full source excluding AIR 52,384 → 53,993 (+3.1%). library/std.md is 10,961 tokens; AIR remains 175,736 bytes. Eleven generic safe functions reuse buffer/Option/exchange and existing ownership/borrow rules without semantic or verifier-state growth. Full ring invariants and accounting stay on demand; cumulative full-source growth is +58.9%, with the RFC's owner-review justification and no empirical MCC claim.

RFC 0026 std.hash (cl100k, relative to Deque): Quick Reference 7,747 → 7,806 (+0.8%); other source docs 46,246 → 47,475; full source excluding AIR 53,993 → 55,281 (+2.4%). library/std.md is 12,190 tokens; AIR remains 175,736 bytes. Four pure functions expose exact FNV/CRC continuation with no semantic, verifier or authority growth. Cumulative full-source growth is +62.7%, justified in the RFC for owner review without an empirical MCC claim. The proposed map contract stays outside the bundles.

RFC 0027 explicit error values (cl100k, relative to hashes): Quick Reference 7,806 → 7,863; other source docs 47,475 → 48,061; full source excluding AIR 55,281 → 55,924 (+1.2%). AIR is 179,282 bytes / 51 sections, and its source-bundle copy is 46,300 tokens. The measurement excludes the developing map contract. Existing variant syntax gains pure built-in error values; no authority, resource or ownership state is added. Cumulative source growth is +64.6%; the RFC records the complexity justification, without claiming MCC improvement.

RFC 0028 numeric-key owning map (cl100k, relative to error_values; includes the separate integer-pattern clarification): Quick Reference stays 7,863, other source docs 48,061 → 50,079, full source excluding AIR 55,924 → 57,942 (+3.6%). The on-demand library page is 14,167 tokens. AIR remains 179,282 bytes / 51 sections. No map-specific instruction, source form, verifier state or diagnostic is added; general keys remain Q-037. Cumulative source growth is +70.5%, with review justification in the RFC and no claimed MCC benefit.

RFC 0029 static function parameters (cl100k, relative to numeric maps): Quick Reference 7,863 → 8,051 (+2.4%); other source docs 50,079 → 51,002 (+1.8%); full source excluding AIR 57,942 → 59,053 (+1.9%). language/generics.md is 2,194 tokens; AIR remains 179,282 bytes / 51 sections. One explicit operation-selection concept adds two source forms and bounded frontend state, with no runtime/verifier state or new AIR construct/diagnostic. Cumulative growth is +73.8%; the RFC justifies the general hash/equality/order prerequisite, keeps general collections open and makes no empirical MCC claim.

RFC 0030 general owning HashMap (cl100k, relative to static operations): Quick Reference 8,051 → 8,124 (+0.9%), other source docs 51,002 → 53,363 (+4.6%), full source excluding AIR 59,053 → 61,487 (+4.1%). library/std.md is 16,504 tokens; AIR remains 179,282 bytes / 51 sections. Ten safe source functions use explicit static policies and complete key/value transfer, with no new language form, verifier/runtime state or diagnostic. Cumulative source growth is +80.9%, justified in the RFC without an empirical MCC claim; full policies/failure/dense-index invariants stay on demand.

RFC 0031 general owning HashSet (cl100k, relative to HashMap): Quick Reference 8,124 → 8,201 (+0.9%), other source docs 53,363 → 54,798 (+2.7%), full source excluding AIR 61,487 → 62,999 (+2.5%). library/std.md is 17,939 tokens; AIR remains 179,282 bytes / 51 sections. Nine safe wrappers return duplicate/full incoming keys and transfer stored keys through ordinary ownership rules. No new syntax, diagnostic or verifier/runtime state; cumulative source growth is +85.4%, justified by explicit ownership/accounting contracts without an empirical MCC claim.

RFC 0032 owning BinaryHeap (cl100k, relative to HashSet): Quick Reference 8,201 → 8,284 (+1.0%), other source docs 54,798 → 56,770 (+3.6%), full source excluding AIR 62,999 → 65,054 (+3.3%). library/std.md is 19,911 tokens; AIR remains 179,282 bytes / 51 sections. Eight safe source operations bind explicit pure order and sift Copy indices while complete owners remain in initialized storage. No new syntax, diagnostic or verifier/runtime state; cumulative source growth is +91.4%, justified by visible ordering/ownership/failure/accounting contracts without an empirical MCC claim.

RFC 0033 bounded I/O (cl100k, relative to BinaryHeap): Quick Reference 8,284 → 8,350 (+0.8%), other source docs 56,770 → 58,473 (+3.0%), full source excluding AIR 65,054 → 66,823 (+2.7%). library/std.md is 21,614 tokens; AIR remains 179,282 bytes / 51 sections. Six safe concrete compositions retain exact effects and caller resource loans, distinguishing EOF/limits from partial failure. No new syntax, diagnostic or verifier/runtime state; cumulative source growth is +96.6%, justified by progress/authority/cleanup contracts without an empirical MCC claim.

RFC 0034 owning buffered files (cl100k, relative to bounded I/O): Quick Reference 8,350 → 8,445 (+1.1%), other source docs 58,473 → 61,223 (+4.7%), full source excluding AIR 66,823 → 69,668 (+4.3%). library/std.md is 24,364 tokens; AIR remains 179,282 bytes / 51 sections. Ten safe concrete operations keep fixed allocation, file transfer, prefetch and first-error/partial-write cleanup visible. No new syntax, diagnostic or verifier/runtime state; cumulative source growth is +105.0%, justified by these contracts without an empirical MCC claim. Full representation/API details stay on demand; front-door consolidation remains separate work.

RFC 0035 caller-buffer paths (cl100k, relative to buffered files): Quick Reference 8,445 → 8,518 (+0.9%), other source docs 61,223 → 63,296 (+3.4%), full source excluding AIR 69,668 → 71,814 (+3.1%). library/std.md is 26,437 tokens; AIR remains 179,282 bytes / 51 sections. Six pure operations return raw Copy ranges or write a measured canonical prefix, keeping lifetime, byte syntax, capacity failure and authority visible. No new syntax, diagnostic or verifier/runtime state; cumulative source growth is +111.3%, justified by these contracts without an empirical MCC claim. API details stay on demand; front-door consolidation remains separate work.

RFC 0036 (Proposed), explicit source borrow returns (cl100k, relative to paths): Quick Reference 8,518 → 8,642 (+1.46%), other source docs 63,296 → 64,160 (+1.37%), full source excluding AIR 71,814 → 72,802 (+1.38%). language/ownership.md is 1,834 tokens; AIR remains 179,282 bytes / 51 sections. Existing from, ref/mut bindings and named returns reuse verifier/runtime primitives; frontend ancestry selects transferred lexical ends. No new keyword, AIR feature, verifier state or diagnostic. Cumulative full-source growth is +114.24%, justified in the proposed RFC without an empirical MCC claim. This measurement records the implementation for review, not owner adoption.

RFC 0036 review fixes clarify reserved task borrow returns and known array bounds in unused generic signatures. These rules add 54 cl100k tokens: other source docs 64,160 → 64,214, full source 72,848 → 72,902 (+0.07%); Quick Reference stays 8,688. o200k groups are 8,723 / 64,413 / 73,136; Qwen2.5 8,954 / 65,794 / 74,748. language/ownership.md is 1,873 cl100k tokens; AIR and library/std.md stay unchanged. The additions make source rejection predictable without adding a semantic feature.