P6A-11: when a .aji module passed the frontend but its AIR does not parse (E0001-E0005) or has invalid SSA/CFG (E5001, E5002), the result is one E7900 source.internal_compiler_error at the source construct, with the AIR code in air_code; semantic codes (E0006 included) are unaffected. Unit test injects the checkpoint's `ret %` defect. P6A-12: source-decidable type errors are E7005 at the source: - `as` checks lossless widening with the verifier's own rule (shared function), and that both sides are integers - slice.copy element types; own.free / region.destroy operand types - element rules of channel.make<T> and mutex.make (no borrow, scope, task, shield or guard, at any depth) Probing every source position found no other E1001/E1002 leak. The old test encoding the previous rule (verifier_widen, E1002) is replaced by typecheck/lossy_widen (E7005); 9 typecheck tests. Spec 15 §10 states the frontend/verifier boundary.
29 KiB
15. Source Language .aji 0.1 (Phase 6A)
This file is normative for .aji source 0.1. Decision record: RFC 0013. Grammar: ../reference/grammar.ebnf.
1. Principle
.aji is the agent-facing language. AIR (spec 07) remains the normative execution format. A .aji module means exactly the AIR it lowers to, and that AIR is checked by the normative verifier (spec 08). The frontend is outside the trusted computing base.
Boundary rule. Source syntax MAY hide representation mechanics:
- SSA values;
- the CFG and block parameters;
borrow.end;local.alloc;- the
features [...]header; - intermediate values.
It MUST NOT hide:
- authority (capabilities);
- allocation (
own.*,region.*,channel.make); - ownership transfer (
move); - resource consumption (close, free, take);
- synchronization (
lock,send,recv,join); - external effects (
effects [...], intrinsics); - task structure (
scope,task.spawn); - cancellation;
- recoverable failure (every outcome of a fallible operation).
Rules:
- Lowering is a pure function of the source: the same module gives byte-identical canonical AIR (spec 07 §8.5).
- No source construct admits a program whose AIR the verifier rejects. Errors the verifier would find are reported with the verifier's code (§9).
.aji0.1 covers the published features of Phases 0–3 and nothing else.- Every construct has one canonical spelling. There are no alternative forms of the same operation.
2. Modules and declarations
module demo.echo
struct Pair {
a: u8,
b: u8,
}
enum Shape {
Empty,
Square(u64),
Rect(u64, u64),
}
fn main(input: cap<io.read>, out: cap<io.write>) -> void
effects [io.read, io.write]
{
...
}
- A file holds one module:
module <dotted.path>, then type and function declarations in any order. //starts a line comment.- Function
flowers to@f; typeTto@T. - Signature.
fn name(params) -> type, then optionallyfrom pfor a borrow return (spec 08 §11.3), then the lineeffects [...], then the body block. - Parameter names are preserved. A parameter
plowers to%p. Names the compiler generates are chosen so that they never equal a parameter name of the function. The names of@main's parameters are part of the instantiation contract. - The entry point is
main. Its parameters are capabilitiescap<K>, bound by name (spec 05 §10.2). Startup values of other types (command-line arguments, for example) are not part of.aji0.1. - Grants are not source semantics. A program only declares
main's capability parameters. Granting them is instantiation after the module is lowered and verified (aji run --grant …,aji.toml, spec 12 §1). A missing grant isnot_instantiatedat run time, never a source or verifier diagnostic. - One source for every profile. The frontend does not know the execution profile. The same
.ajiruns in the deterministic and the hosted profile (spec 11). trustedis not available. It is the boundary of runtime, std and toolchain modules (spec 13 §6.3), not something a program declares about its own code. The word is reserved and atrustedclause isE7006.- Unsafe operations are the format-0 ones and nothing else:
ref unchecked s[i]/mut unchecked s[i](also bound:ref unchecked e = s[i];) lower toborrow.index.unchecked, andassume(c)toassume. Their boundary is the AIR one: the function declareseffects [unsafe], which propagates to its callers. Outside it the verifier reportsE6001. There is nounsafe { … }block, because AIR has no block-level unsafe boundary (owner decision: deferred; localizing unsafe inside a function would be an AIR change through its own RFC). There is no FFI, raw address or syscall surface in format 0, so none exists in source.
3. Types
The AIR spellings are used (spec 07 §8):
- integers
u8…u128,usize,i8…i128,isize;bool,void,never; - named types;
ref<T>,mut<T>,slice<T>,slice_mut<T>;own<T>,own_array<T>,region;cap<K>;file<read|write|append>,listener,stream;task<T>,sender<T>,receiver<T>,mutex<T>;- the built-in enums
io_error,alloc_error,cap_error.
Arrays are written [T; N]. scope, shield and guard<T> are not source types: they exist only inside the block forms of §7.
4. Statements and control flow
Statements end with ;. Block constructs (if, while, for, loop, match, select, scope, shield, lock, { … }) do not take one.
| Source | Meaning |
|---|---|
let x = e; / let x: T = e; |
immutable binding |
var x: T = e; / var x: T = zero; |
variable; zero is local.zero (zeroable types only) |
x = e; |
assignment to a variable |
*r = e; |
store through mut<T> |
r.f = e; |
store into a field through mut<Struct> |
if c { … } else { … } |
else if chains allowed |
while c { … } |
|
for i in a..b { … } |
a ≤ i < b, integer type of a and b; b evaluated once |
loop { … } |
|
break; / continue; |
innermost loop |
return; / return e; |
|
trap; |
|
assert(c); |
traps T0002 |
match e { … } |
§6 |
if and match are expressions when every branch yields a value of the same type through a tail expression (an expression without ; at the end of a block) or diverges (return, break, continue, trap).
Joins carry live variables only. A variable is passed to a join (the block after an if or match, a loop header, a loop exit) only if it may be read after that join: on a later path, or, for a loop header, anywhere in the loop. A variable that is not read again is not passed on. This is ordinary pruned SSA construction, not tracking of moves. A linear value consumed before a join (channel.close_receiver(move r) before break) does not travel to it. A linear value that is read after it was consumed is still the verifier's E2001. The analysis is conservative: any read on a later path counts, and only a whole-variable assignment in straight-line code ends a variable's life.
Type inference is deliberately small. It works within one function, it is monomorphic, and it does no overload resolution or search among several admissible types. An expression's type comes from:
- its own form: a literal suffix, a name, a call's declared return type, a cast, a struct or enum constructor;
- otherwise its context: an annotation, the other operand, the parameter type of the function called, the function's return type.
An untyped let x = <literal> takes the type its first later use in the same function determines in that way. If nothing determines a type, the result is E7007: the frontend never picks a default.
Lowering: structured control flow becomes blocks and terminators. A variable assigned on several paths becomes a block parameter at the join.
5. Expressions
Arithmetic, comparison and logic:
| Source | AIR |
|---|---|
a + b, a - b, a * b, a / b, a % b |
checked (T0003, T0004) |
a +% b, a -% b, a *% b |
wrapping |
a & b, a | b, a ^ b, a << b, a >> b |
bitwise and shifts (T0005) |
==, !=, <, <=, >, >= |
comparisons |
and, or, not |
boolean operations |
-a |
0 - a, checked |
Casts:
| Source | AIR |
|---|---|
x as T |
cast.widen; only where every value is representable, otherwise E1002 |
x as! T |
cast.checked (T0006) |
x as% T |
cast.wrap |
Literals:
- integers (
42,0xff,1_000) take their type from context, or a suffix (42u8); true,false;b"…": a byte string, of type[u8; N], with escapes\n,\t,\\,\",\xHH.
Aggregates.
- Struct values.
Pair { a: 1, b: 2 }is the only way to build one: every field exactly once, in any order. A missing or repeated field isE7006, an unknown oneE7002. The initializers are evaluated, and lowered, in declaration order, so the AIR does not depend on the order the fields are written in. There is no positional constructor. - Enum values.
Shape::Square(4), orShape::Emptyfor a variant without payload, is the only form. - Arrays.
[e; N]isarray.splat. - Field access.
v.fon a struct value isstruct.get.
6A has no destructuring: no let Point { x, y } = p, no nested patterns, guards or or-patterns.
Calls. f(args) calls a function of the module. Built-in operations are called by their AIR names (§7, §8). Arguments are evaluated left to right.
Borrows and places. A place is:
- a variable;
place.f;place[i];place[a..b];*r.
| Source | Meaning |
|---|---|
ref r = place; / mut r = place; |
the only way to bind a borrow: a statement, valid to the end of the enclosing block. let r = mut x; is E7006. An active borrow cannot be shadowed by the same name in the same scope (E7006). Borrowing a whole array binds a slice (slice<T> / slice_mut<T>). Borrowing a borrow binding reborrows it. |
ref place / mut place as an argument |
a temporary borrow for that call (ended right after it); allowed only as an argument |
*r |
load through ref<T>/mut<T> of a scalar or struct; slices and arrays use s[i] (E7006) |
r.f |
field through a borrow of a struct (borrow, load, end) |
s[i] |
element value (borrow, load, end) |
s.len |
slice.len, or the static length of an array |
s[a..b] |
a sub-slice (slice.sub with start a, length b - a); a borrow, so it is bound or passed, never a value |
let (left, right) = s.split_at(k); |
slice.split: two disjoint borrows of s; the only multi-result binding. There is no general tuple destructuring. |
slice.copy(mut dst, ref src) |
slice.copy, the only copy form |
Writes.
*r = v;for a scalar or struct referent;r.f = v;,x.f = v;;s[i] = v;,x[i] = v;.
The value is evaluated first, then the place is borrowed for the store and the borrow ends. So s[i] = s[i] + 1; reads before it writes.
Bounds. These follow AIR exactly:
s[i]is a checkedborrow.index(T0008);- inside the true branch of
if i < s.len, withiandsthe unchanged SSA values, the frontend emitsborrow.index.proven. This is the fact the verifier proves (spec 08 §12, "fact on the same slice"); - in every other case the index stays checked. The frontend never knows more about bounds than the verifier.
Unsafe indexing. ref unchecked s[i] and mut unchecked s[i] are borrow.index.unchecked, and assume(c) is assume. Both are allowed only under spec 13 §6.
Arrays and byte strings.
[e; N]evaluateseonce and copies the value N times (array.splat). The element must be copyable; a linear element isE7006.b"…"is an immutable[u8; N]value held in frame storage, written there byte by byte, with no heap. The escapes are exactly\n \r \t \\ \" \0 \xNN.- Used where a
slice<u8>is expected, it is borrowed for the operation.
Moves.
- A named linear value (
own<T>,own_array<T>,region, and the resources and endpoints of later layers) is consumed only bymove x. Using a named linear value as a consuming operand withoutmoveisE7003; the diagnostic carriessuggestion: "move x". Consuming operands are: call arguments,let/varinitializers, assignments,return, the value operand of an allocation, andown.take,own.free,region.destroy. moveof a copyable value isE7006.- The frontend does not track moved state. Use after move (
E2001), double consumption (E2002), use after consume (E3001) and leaks (E3002) are found by the verifier on the lowered AIR and reported at the source location. - A linear value used as a borrow place (
ref x,mut x,ref r = x;) is borrowed in place:own<T>asref<T>/mut<T>,own_array<T>asslice<T>/slice_mut<T>,regionasref<region>. There is no implicit dereference of an owner. - A temporary, that is the result of a call or operation used directly as an operand, needs no
move: it has no other owner in the source. - Copyable values are copied by plain use.
6. Fallible operations and match
Every AIR terminator with outcome edges is written as a match over its outcomes. The arms are named after the edge roles and the match MUST be exhaustive (E7004):
| Operation | Outcomes |
|---|---|
fallible intrinsics, own.new, own.array, region.create, region.new, region.array, cap.narrow.* |
ok(…), err(e) |
channel.make<T>(n, mem) |
ok(tx, rx), err(e) |
channel.send(tx, v) |
ok, closed(v), cancelled(v) |
channel.recv(rx) |
ok(v), closed, cancelled |
channel.close_receiver(move rx) |
ok, pending(rx) |
task.check_cancel() |
ok, cancelled |
task.join_cancel(move t) |
ok(v), cancelled(t) |
match io.stdin_read(input, mut buf) {
ok(n) => { … }
err(e) => { trap; }
}
- Match kinds. The parser decides the kind of a
matchfrom its arms:Enum::Variantarms make an enum match, integer literals and_an integer match, and bare outcome names (ok,err,closed,cancelled,pending) an outcome match. Outcome names are not enum patterns. In an outcome match the scrutinee MUST be a fallible operation (E7006otherwise). Each outcome is matched exactly once: a repeated one isE7006, an unknown oneE7002, a wrong number of bound namesE7005. A fallible operation outside an outcome match oror trapisE7006. - Outcome values.
err(e)binds the real error value (alloc_error,cap_error,io_error). These built-in enums are matched like declared ones:alloc_error::out_of_memory, exhaustive, no_. A borrow bound by an outcome (theok(item)ofregion.new) ends at the end of its arm. A borrow bound bylet item = region.new(arena, v) or trap;ends at the end of the enclosing block. - Rebinding. A value that comes back on an edge is rebound by the name in its arm:
closed(v),pending(rx),cancelled(t). If that name is a variable (var) of the value's type, the value becomes the variable's new value. A receiver kept invar ris closed withmatch channel.close_receiver(move r) { ok => …, pending(r) => … }and received from again. or trap.op(args) or trapis the expression of theokvalue, or ofvoid. Every other outcome traps (T0001). It is the only shorthand.- Enums. A
matchover a value of an enum type has exactly one arm per variant, each writtenEnum::Variant(names…)(Enum::Variantwithout payload). It must be exhaustive (E7004lists the missing variants), and_is not allowed (E7006), so a new variant cannot slip through silently. Payload names are bound only inside their arm (they are the arm block's parameters in AIR). It lowers toenum.switch. - Integers. A
matchover an integer has literal arms and exactly one_arm, which is required (E7004). It lowers toswitch. - Booleans use
if. - As expressions.
matchandifare expressions when their arms yield values (§4). Every arm must have the type of the others, or diverge. - Source map. The switch maps to the
match; each arm's code and its branch to the join map to that arm.
7. Tasks, cancellation, channels, select and mutex
scope s {
let a = task.spawn(s, square, mut left);
let r = task.join(move a);
}
scope s { … } is task.scope.begin and task.scope.end, at every normal exit of the block. Inside it:
task.spawn(s, f, args)spawnsf(a function of the module) into the scopes. Arguments are passed like call arguments: a named linear value ismoved (E7003). A borrow argument is lent until the join (spec 04 §34), so it is a borrow binding passed by name (mut part = buf;…task.spawn(s, f, part)). A borrow or byte string written inline isE7006, because a temporary would have to end right after the spawn. The first operand must be the scope (E7005);task.join(move t)joins; its value is the task's result (task<T>givesT);- a task that is not joined at an exit is
E4301.
Task operations elsewhere:
task.cancel(t)(not consuming);task.cancelled();task.check_cancel()andtask.join_cancel(move t), which are matches (§6).
shield { … } is task.shield.begin and task.shield.end, at every normal exit. Shields nest by construction.
Channels:
channel.make<T>(n, mem): a match, §6;channel.dup(tx):channel.sender.dupon a shared borrow oftx, made for the operation;channel.send(tx, v)(move vfor a linearv);channel.recv(rx); forsendandrecvthe endpoint is borrowedmutfor the operation and the borrow ends on every edge;channel.close_sender(move tx);channel.close_receiver(move rx).
select { … } has one form:
select {
recv(rx_a) { ok(x) => …, closed => … }
send(tx_b, move job) { ok => …, closed(job) => … }
cancelled(job) => …
}
Every edge binds its own value (the received T of a recv arm's ok) and then the send values not sent on it, distinct values in the order of first appearance (spec 04 §39). With send(tx_b, move job) in the select, the recv arm's edges are ok(x, job) and closed(job), the send arm's are ok and closed(job), and the select's own is cancelled(job). A wrong number of names is E7005, a missing outcome E7004. Each endpoint is borrowed mut once for the select, even when several arms name it, and the borrow ends on every edge.
Mutex:
mutex.make(v); to share a mutex with tasks, bindref mr = m;and passmr(aref<mutex<T>>);mutex.take(move m), which needs no live borrow ofm;lock ref m as x { … } cancelled { … }.
The lock block lowers to:
mutex.lockon the borrowref m:mis amutex<T>(borrowed for the lock, the borrow ending after the unlock and on thecancellededge) or aref<mutex<T>>binding (used as it is);- on the
okedge:mutex.borrowof the guard, bound asx: mut<T>; - the block;
borrow.end xandmutex.unlockof the guard.
Step 4 happens at every normal exit from the block: fall-through, and every return, break and continue that leaves it. The cancelled { … } block is the lock's cancelled edge. On a trap nothing is unlocked: the execution terminates (spec 04 §33.2). The guard is never a source value. The critical-section rule (spec 04 §41) applies to the block's contents.
Resource and endpoint operands. An operation whose AIR operand is a borrow of a resource or endpoint accepts the resource by name and borrows it for the duration of the operation (§8):
file<…>,stream,listener;sender<T>,receiver<T>;task<T>fortask.cancel.
For example net.accept(l), fs.read(f, mut buf), channel.send(tx, move v). Data borrows (ref/mut of values, arrays and slices) are always written. A mutex is borrowed explicitly: lock ref m. A region is borrowed explicitly too (§8).
8. Allocation, resources and intrinsics
Allocation and resource operations keep their AIR names and operand order:
own.new(v, mem)andown.array(n, v, mem)(outcome matches, §6):ok(o)bindsown<T>/own_array<T>,err(e)analloc_error;let v = own.take(move o);,own.free(move o);(own<T>orown_array<T>; there is no take for arrays);region.create(mem):ok(r)binds aregion;region.new(rb, v),region.array(rb, n, v):rbMUST be aref/mutborrow binding of the region;ok(item)bindsmut<T>/slice_mut<T>;region.reset(r),region.destroy(move r);cap.narrow.budget(c, n)andcap.narrow.prefix(c, path):ok(c2)binds acap<K>,err(e)acap_error(invalid_restriction,not_subset,unsupported_restriction). Narrowing is always fallible and never yields an empty capability;- capabilities are values of type
cap<K>, received as parameters and copied by plain use (nomove); - intrinsics under their registered names and operand order (
reference/intrinsics.md), as plain calls:io.stdout_write(out, ref buf[0..n]),fs.open_read(c, b"/in/data.txt"),fs.close(move f),net.listen(c, b"127.0.0.1:7"). There are no methods, noFile.open()and no implicit I/O.
Intrinsics.
- Failure. A fallible intrinsic is an outcome match (
ok(results…),err(e)withe: io_error) orop(…) or trap(§6). Used as a plain value or statement it isE7006. An infallible one (clock.monotonic,random.fill) is a plain call; matching it isE7006. - Authority. A capability is needed only to acquire authority:
fs.open_read(c, path)returns afile<read>that carries it, andfs.read(f, mut buf)takes no capability. The capability kind is checked by the verifier (E3201), and the effect too (E3101). - Resource operands. An operand the registry marks as borrowed is the resource by name. The frontend borrows it
mutfor that one operation and ends the borrow on every outcome edge. Amutborrow binding or parameter of the resource (f: mut<file<write>>) is passed as is. Writingmut fthere isE7006(one spelling); a resource of the wrong type or mode isE7005. - Consumed operands (
fs.close,net.close_stream,net.close_listener) takemove f(E7003without it). The frontend never inserts a close: an unclosed resource is the verifier'sE3002, use after closeE3001. - Data operands are always written:
ref bytes/ref buf[a..b]/ a byte string for read bytes,mut buf/mut buf[a..b]for a buffer the operation fills (E7005otherwise). - Paths and addresses are byte strings or borrowed bytes, passed as they are. There is no
Pathtype and the frontend does not normalize. Whether a path is absolute, free of./..and inside the capability's scope is decided by the intrinsic at run time (invalid_input,permission_denied; for narrowing,invalid_restriction,not_subset). - Source map. The intrinsic's terminator maps to the call. The borrow ends on each edge map to the call, and each arm's code to its arm. A runtime trap under
or trappoints at the call (source_locationin the run record). A verifier diagnostic on an operand points at that operand's construct.
Region borrows are explicit. The borrow of a region that region.new/region.array take is written by the programmer and lexically outlives the allocation borrows derived from it:
{
ref arena = r;
match region.new(arena, 1u64) {
ok(item) => { *item = *item + 1; }
err(e) => { trap; }
}
}
region.reset(r);
Passing the region itself is E7005; the frontend never creates a temporary region borrow. region.reset and region.destroy end no borrow: a live allocation borrow at a reset or destroy is the verifier's E2104. The programmer narrows the scope.
Linear aggregates. A struct or enum with a linear field (own<T>, region, a resource) needs the reserved feature linear_aggregates. The frontend lowers it as written and the AIR is rejected (E0006) until that feature is published.
A byte string or array used where a slice<u8> is expected is materialized in frame storage and borrowed for the operation.
9. Frame storage, borrow scopes and features
- Frame storage. Addressability is a property of lowering, not of source types. Linear values (owners, regions, resources, endpoints, tasks, mutexes) never get frame storage: they are borrowed in place. A variable whose name is borrowed, indexed, or written through a field or element anywhere in the function lowers to
local<T>storage, allocated in the entry block (spec 08 §11.5). Every other variable is an SSA value. The decision is by name, so the same source always gives the same placement. The frame-size limit applies to the lowered AIR. There is no implicit heap allocation. - Borrow scopes. A borrow bound by
ref/mutends at the end of the block that contains the binding. Because a borrow's name is not visible after its scope, a use after the borrow ended (E2106) cannot be written in source. A temporary borrow, used directly as an operand, ends at the end of its statement. Both end at every normal exit from their scope. The frontend emitsborrow.endin reverse order of creation. A borrow that must end earlier is placed in an inner block. Borrows lent to tasks end at the join (spec 04 §34). - Features. The frontend emits the
features [...]header as the dependency closure of the constructs used, always includingeffects. - Effects. They are declared by the programmer.
E3101names the missing effect and suggests the complete effect list (suggested_effects).
10. Diagnostics
| Problem | Code |
|---|---|
| found by the verifier on the lowered AIR | the AIR code; the diagnostic's file, line and col are the source location of the construct the instruction came from, and air_line/air_col locate it in the lowered AIR (aji lower); the verifier's own fields (function, block, inst) are kept |
| syntax, name resolution, lowering and invalid source constructs | E7xxx, below |
| several AIR instructions of one construct reporting the same code | one diagnostic (the first) per code and source location |
the lowered AIR is malformed: a parse error (E0001–E0005) or invalid SSA or CFG (E5001, E5002) |
E7900 (source.internal_compiler_error) at the source construct, with the AIR code in air_code. It is a compiler bug, never an error in the program, and replaces every other diagnostic of the module. Semantic codes (ownership, borrows, resources, effects, capabilities, concurrency, E0006) are not affected |
| trap at run time | the trap record also carries source_location (file, line, col) |
Which errors the frontend reports. An error that is fully decided by source types is E7005 (or another E7xxx) at the source construct, and never reaches the verifier as E1001/E1002. The frontend checks:
- the types of expressions, operands and results;
- arity and argument types of functions and built-in operations;
- the existence of fields and variants;
ref/mutcompatibility;- lossless widening by
as(the verifier's own rule); - slice element types of
slice.copy; - the element rules of channels and mutexes (no borrow, scope, task, shield or guard).
The verifier remains the authority for:
- ownership state, linearity and moves;
- borrow conflicts and lifetimes;
- resource state;
- effects and capabilities;
- concurrency (loans,
Send/Share, the critical-section rule); - reserved features;
- every other verifier invariant.
Its diagnostics keep their AIR codes, reported at the source location.
| Code | Kind | Meaning |
|---|---|---|
| E7001 | source.syntax | Malformed .aji source |
| E7002 | source.unknown_name | Undefined variable, function, type, field or variant |
| E7003 | source.missing_move | Named linear value consumed without move |
| E7004 | source.not_exhaustive | match misses an outcome, variant or default |
| E7005 | source.type_mismatch | Expression has the wrong type in a source position |
| E7006 | source.invalid_construct | Construct not allowed here (e.g. break outside a loop, move of a non-linear value, zero for a non-zeroable type) |
| E7007 | source.ambiguous | Source meaning cannot be determined (e.g. an integer literal with no type from context) |
| E7900 | source.internal_compiler_error | The frontend produced invalid AIR for this construct (a compiler bug, not a program error) |
11. Tooling
| Command | Does |
|---|---|
aji check file.aji |
parse, lower, verify |
aji run file.aji |
the same, then run (same flags and run record as for .air) |
aji lower file.aji |
print the canonical AIR |
aji lower --stats file.aji |
source and AIR size, expansion ratios and the two mechanical_air_eliminated metrics below |
aji lower --annotate file.aji |
the same with ; line:col-line:col source spans before each instruction (not canonical; for debugging) |
Lowering is deterministic: the same source and compiler give byte-identical AIR, and the lowered AIR is canonical (parse → print reproduces it). The conformance runner checks both for every accepted .aji test.
Size metrics (--stats, non-normative tooling with a fixed definition):
- Sizes count code only: non-empty lines that are not comments (
//in source,;in AIR), each with its newline. mechanical_air_eliminated_raw= 1 −source_bytes/air_bytes: how much of the AIR text the author did not write. This is the main engineering metric.mechanical_air_eliminated_normalized= 1 −source_bytes/air_bytes_normalized: the same against AIR in which every byte-string materialization counts as one logical constant operation. Such a materialization is the instructions from the string'slocal.zeroto its finalborrow.end, a store per non-zero byte, because format 0 has no byte-array constant. It is replaced by the single notional lineconst.bytes %<storage>, <literal>, where<literal>is the canonical spelling: printable ASCII as is, otherwise the escapes\n \r \t \0 \\ \" \xNN. The storage'slocal.allocis real frame storage and stays. No other instruction is normalized. The rule is the same for every program, andbyte_string_constantsreports how many were replaced.