Files
aji/docs/rfcs/0004-air-instruction-set.md
T
dev 03dda1245a spec: single normative source, accept RFC 0004, freeze AIR format 0, fuel
Owner decisions after the Phase 0 review:

- precedence: docs/spec/ is the single normative source; RFCs are
  decision records whose accepted rules are integrated into the spec in
  the same change (AGENTS.md, docs/README.md, rfcs/README.md, DD-011)
- RFC 0004 Accepted (scope: AIR format 0, language 0.1)
- AIR format 0 frozen as the semantic baseline; spec 07 §8.7 defines the
  only permitted additive changes, everything else needs `air 1` (DD-012)
- Q-019 resolved: deterministic instruction fuel (spec 11 §7). Outcome
  `limit_exceeded` is a runner outcome, not a trap; `aji run --fuel N`,
  exit code 5; conformance runs always use fuel (default 1 000 000,
  `fuel:` header); fuel/schedule budget/quantum kept separate for P3
  (DD-013)
2026-10-04 12:40:32 +03:00

2.7 KiB

RFC 0004: AIR Instruction Set

Status: Accepted
Scope: AIR format 0
Language version: 0.1
Integrated into: spec 07 §8, spec 07a, reference/air-text.ebnf

Goal

AIR should be small enough for complete semantic definitions to fit in an agent context while remaining expressive enough for systems software.

Principle

Do not add instructions because they make source syntax convenient. Add an AIR instruction only when it represents a distinct semantic/verifier operation.

Initial instruction families

Pure values

const copy move
integer arithmetic
bitwise operations
comparisons
casts with explicit failure/semantics

Control

br cbr switch ret trap guard assert

Memory

borrow.ref borrow.mut borrow.end
load store
slice.make slice.sub
mem.copy mem.zero

Ownership

own.alloc own.free
region.create region.alloc region.reset region.destroy
island.create island.alloc island.freeze
arc.clone arc.release

Resources and calls

call call.indirect intrinsic.call
resource.consume

Concurrency

task.scope.begin task.scope.end
task.spawn task.join task.cancel
thread.spawn thread.join
channel.send channel.recv
mutex.lock mutex.unlock
rwlock.read rwlock.write
atomic.load atomic.store atomic.rmw atomic.cmpxchg atomic.fence

Required metadata

Each opcode definition must declare:

syntax
operand types
result types
ownership transfer
borrow transfer
memory read/write set
sync relation
required effect
required capability
trap cases
verifier transfer function
interpreter behavior

Binary stability

AIR opcodes should receive stable numeric IDs only after the semantics of v0.1 freeze. Before then, text AIR is the safer canonical interchange for development.

Amendment 1 — format version 0 (Phase 0)

Status: Accepted with the RFC; implemented in the reference implementation.

Format version 0 (spec 07 §8, spec 07a) realizes the "pure values" and "control" families and adds the following, each a distinct verifier operation rather than syntax sugar:

Addition Why it is a distinct operation
cast.widen / cast.checked / cast.wrap the three cast semantics differ in verifier obligations (static losslessness, runtime trap, none)
struct.make, struct.get nominal aggregate construction and projection need their own typing rules
enum.make, enum.switch tagged unions: exhaustiveness is checked by the CFG pass and payloads bind to block parameters, so no separate "get payload" instruction can observe an inactive variant

Not yet realized: memory, ownership, resources, calls through values (call.indirect) and concurrency families; they arrive with their phases and are specified in spec 07a first.