- docs/agent/bundle.txt: minimal AIR reference by file and section (grammar, instructions, types, traps, verifier rules, resources, effects, capabilities, intrinsics, heap/regions, unsafe, runtime contract, diagnostics and registries); syntax-example.air verifies and runs - zig build agent-reference: deterministic bundle and report (files, sections, bytes, lines, words); section extraction ignores fenced code - tools/agent_bundle_tokens.py: cl100k_base, o200k_base and Qwen2.5 BPE counts; growth warnings >10 % and review >20 % against history.json - baseline after Phase 2: 104 250 bytes, 16 197 words, ~27.3k tokens - CI builds the bundle and counts tokens (non-blocking) - evaluation protocol 0.2: benchmark families, Aji/AIR and Aji/source conditions, 36-run engineering smoke test, order of work - RFC template and AGENTS.md: report bundle growth
39 lines
1.5 KiB
LLVM
39 lines
1.5 KiB
LLVM
; Minimal syntax reference for text AIR format 0 (part of the Agent Reference Bundle).
|
|
; Run: aji run --grant out=io.write --grant heap=mem.alloc:64 docs/agent/syntax-example.air
|
|
module example.syntax
|
|
air 0
|
|
lang 0.1
|
|
features [arrays, capabilities, effects, heap, ownership, resources]
|
|
|
|
type @Pair = struct { a: u8, b: u8 }
|
|
|
|
; Entry point: capabilities arrive as named parameters.
|
|
fn @main(%out: cap<io.write>, %heap: cap<mem.alloc>) -> u8
|
|
effects [io.write, mem.alloc]
|
|
entry:
|
|
%msg = local.alloc array<u8, 3> ; frame storage, only in entry
|
|
%c = const.u8 104 ; 'h'
|
|
%arr = array.splat array<u8, 3> %c
|
|
local.store %msg, %arr ; initializes the local
|
|
%r = borrow.ref %msg ; second-class borrow
|
|
%s = slice.make %r
|
|
intrinsic io.stdout_write(%out, %s), ok -> @written, err -> @io_failed
|
|
written:
|
|
borrow.end %s ; every borrow ends on every path
|
|
borrow.end %r
|
|
%one = const.u8 1
|
|
%two = const.u8 2
|
|
%p = struct.make @Pair(%one, %two)
|
|
own.new %p, %heap, ok -> @owned, err -> @no_memory
|
|
owned(%o: own<@Pair>): ; results arrive as block parameters
|
|
%v = own.take %o ; linear owner consumed
|
|
%b = struct.get @Pair.b, %v
|
|
%sum = add.checked.u8 %b, %one ; traps T0003 on overflow
|
|
br @done(%sum)
|
|
done(%result: u8):
|
|
ret %result
|
|
io_failed(%e: io_error):
|
|
trap
|
|
no_memory(%a: alloc_error):
|
|
trap
|