Files
aji/docs/agent/README.md
T
dev 4242132b2a Phase 5: atomics through every layer (RFC 0015)
AIR: linear atomic<T> (AtomicScalar), atomic.new/take/load/store/RMW/
cmpxchg (two results)/fence with explicit orderings; feature atomics
published. Verifier: ordering tables (E4201), ordinary access (E4202),
effects [atomic] / [atomic, atomic.weak], linearity, take while lent
(E4101, also for mutex.take). Interpreter: timestamped message machine
(src/interp/weak.zig); views travel through spawn/join, channels, mutexes,
close and cancel; seq_cst reads the latest message and programs without
weak reads make no extra draw (existing records unchanged). aji explore:
exhaustive exploration that branches only before visible operations.
Litmus: 20/20 tests give exactly the oracle's sets; differential test
(1500 random programs) found no unsound outcome. .aji layer 10, Quick
Reference atomics, source coverage 67/67, audit report atomic_operations.
AIR bundle +5.9 %, QUICK.md +0.5k.
2026-10-06 08:05:01 +03:00

89 lines
6.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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 "<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`](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.