Files
aji/docs/reference/air-features.md
T
dev c699529fec Phase 4: islands, frozen graphs and arc through every layer (RFC 0014)
AIR: types island<T>, frozen<T>, arc<T>, iref<T>; 16 instructions
(island.create/alloc/root/borrow/freeze/destroy, frozen.root/borrow/
release, arc.from_frozen/new/clone/release/root/borrow, iref.eq); features
islands (depends on heap) and arc (depends on islands) published.
Verifier: IslandSafe/ArcSafe (E2111 at the owner type), container child
borrows (one mut access per island), Send/Share rows (island not Share),
linear owners, mem.alloc effect, element rules (recursion through iref).
Interpreter: graphs with never-reused identities, T0010 for a foreign
iref, O(1) freeze/conversion/transfer, arc counts in a trace hook
(Options.arc_events), budgets per the quota table, collector support.
.aji layer 9: types, operations, island.at/frozen.at/arc.at as borrow
places with explicit container borrows, iref ==/!=.
Frontend fix: joins carry only variables the construct assigns (and that
are read again), so an unchanged linear value is never a block argument
while borrowed.

Tests: 10 AIR (phase4), 6 .aji run + 12 rejects (layer9), the reference
program island-pipeline in .aji, equivalent to an independently
hand-written AIR program (36 on 30 schedule seeds); unit tests for the
arc count trace and O(1) transfer. Quick Reference §7 graphs (checked
excerpt of quickref/graphs.aji); coverage 61/61. Bundle growth: AIR
+7.0%, Quick Reference +0.6k, source docs +4.2k (recorded).
Spec: quota rows match the header-reserved count; idioms and iref
recursion in spec 03 §22; P4-11 (air-text.ebnf gaps) recorded.
2026-10-05 22:14:05 +03:00

80 lines
7.6 KiB
Markdown

# AIR Feature Registry
Normative registry for the `features [...]` header of AIR format 0 (spec 07 §8.1, §8.7). `src/air/features.zig` mirrors this table; a unit test fails if they drift.
## What a feature is
A feature is a coherent block of AIR semantics added to format 0 after the Phase 0 baseline: its types, instructions, verifier rules, diagnostics and interpreter behavior. A module that declares a feature tells the implementation: *to verify and execute this module you must understand these semantics.*
Features are not build options. Three concepts stay separate:
| Concept | Question it answers | Where |
|---|---|---|
| feature | what the AIR implementation must understand | module header `features [...]` |
| effect | what a function does | function `effects [...]` (spec 05) |
| capability | what an invocation is allowed to do | `cap<…>` values (spec 05) |
Declaring `features [capabilities, effects, ownership]` grants no authority. It only states that the module uses capability semantics.
## Rules
- `features []` is the Phase 0 baseline.
- Every post-baseline construct belongs to exactly one feature. A feature is a whole semantic block, not one instruction.
- A module MUST declare every feature whose constructs it uses, plus the full dependency closure; nothing is implied.
- Canonical form: names sorted lexicographically, no duplicates.
- Status `reserved`: the name is fixed, semantics are not yet specified; modules MUST NOT use it (`unsupported_feature`). Because no valid module can use a reserved feature, its dependency set MAY change until it is published (DD-014, RFC 0012); from publication on the dependencies are part of the frozen semantics.
- Status `published`: semantics are specified in spec 07a and the relevant spec files, and are immutable. Incompatible evolution needs a new feature name or a new AIR format version.
- A dependency is listed only when the feature's semantics cannot be stated without it.
## Registry
| Feature | Status | Phase | Depends on | Semantic block |
|---|---|---|---|---|
| `arc` | published | 4 | `capabilities`, `effects`, `heap`, `islands`, `ownership`, `resources` | `arc<T>`, `arc.*`, `ArcSafe` (spec 03 §24) |
| `arrays` | published | 1 | `ownership` | `array<T, N>`, `slice<T>`, `slice_mut<T>`, `array.splat`, `borrow.index[.proven]`, `slice.*`, `guard`, bounds facts (spec 07a, spec 08 §12) |
| `atomics` | reserved | 5 | `ownership` | atomic types, the five orderings, fences, `atomic.*` instructions |
| `borrow_joins` | reserved | — | `ownership` | borrow-typed block parameters (spec 08 §11.6); unscheduled |
| `cancellation` | published | 3 | `effects`, `ownership`, `tasks` | effect `task.wait` (required by suspending operations, `task.join` included), waiting-operation rule, `shield`, `task.shield.*`, `task.check_cancel`, `task.join.cancel` (spec 04 §37) |
| `capabilities` | published | 2 | `effects`, `ownership` | `cap<K>`, built-in `cap_error`, `cap.narrow`, `intrinsic`, instantiation of `@main` (spec 05 §10–§12) |
| `channel_transfer` | reserved | — | `cancellation`, `capabilities`, `channels`, `effects`, `heap`, `ownership`, `resources`, `tasks` | endpoints inside channel elements or mutex contents; unscheduled |
| `channels` | published | 3 | `cancellation`, `capabilities`, `effects`, `heap`, `ownership`, `resources`, `tasks` | `sender<T>`, `receiver<T>`, `channel.*`, `select` (spec 04 §38–§39) |
| `effects` | published | 2 | — | flat effect checking of `effects [...]` for `call` and `intrinsic` (E3101, spec 05 §9) |
| `guard_transfer` | reserved | — | `cancellation`, `effects`, `ownership`, `sync`, `tasks` | `guard<T>` as parameter, return type or aggregate member; unscheduled |
| `heap` | published | 2 | `capabilities`, `effects`, `ownership`, `resources` | `own<T>`, `own_array<T>`, `own.*`, built-in `alloc_error`, `mem.alloc` budgets and `budget` narrowing (spec 03 §18–§19) |
| `islands` | published | 4 | `capabilities`, `effects`, `heap`, `ownership`, `resources` | `island<T>`, `frozen<T>`, `iref<T>`, `island.*`, `frozen.*`, `iref.eq`, `IslandSafe`, `T0010` (spec 03 §22–§23) |
| `linear_aggregates` | reserved | — | `capabilities`, `effects`, `ownership`, `resources` | resource types as struct fields, enum payloads and array elements; unscheduled |
| `ownership` | published | 1 | — | frame storage `local<T>`, second-class borrows `ref<T>`/`mut<T>`, `from` returns, initialization (spec 07 §8.8, spec 07a, spec 08 §11, §13) |
| `receiver_dup` | reserved | — | `cancellation`, `capabilities`, `channels`, `effects`, `heap`, `ownership`, `resources`, `tasks` | several receivers of one channel (MPMC); unscheduled |
| `regions` | published | 2 | `capabilities`, `effects`, `heap`, `ownership`, `resources` | `region`, `region.*`, static generations (spec 03 §20) |
| `resource_joins` | reserved | — | `capabilities`, `effects`, `ownership`, `resources` | joins whose incoming edges carry different resource states (spec 06 §6.3); unscheduled |
| `resources` | published | 2 | `capabilities`, `effects`, `ownership` | linear resources `file<read>`, `file<write>`, `file<append>`, `listener`, `stream`; built-in `io_error`; I/O intrinsics (spec 06 §6–§7, `reference/intrinsics.md`) |
| `rwlock` | reserved | — | `cancellation`, `effects`, `ownership`, `sync`, `tasks` | `rwlock<T>`, read and write guards, no upgrade/downgrade; unscheduled |
| `sync` | published | 3 | `cancellation`, `effects`, `ownership`, `tasks` | `mutex<T>`, `guard<T>`, `mutex.*`, critical-section rule (spec 04 §40–§41) |
| `task_borrow_returns` | reserved | — | `ownership`, `tasks` | spawned functions returning borrows; unscheduled |
| `task_transfer` | reserved | — | `ownership`, `tasks` | `scope` and `task<T>` as parameters, return types, aggregate members or heap contents; unscheduled |
| `tasks` | published | 3 | `ownership` | `scope`, `task<T>`, `task.*`, loans, `Send`/`Share`, deterministic scheduler (spec 04 §33–§36) |
| `unsafe` | published | 2 | `arrays`, `effects`, `ownership` | `assume`, `borrow.index.unchecked`, the `trusted` boundary, the effect `unsafe` (spec 13 §6–§8) |
`capabilities` depends on `effects` so that every module that can perform an external operation is also effect-checked.
`effects` in the baseline: format-0 modules already carry `effects [...]` lines. Without the `effects` feature these lists are recorded but not checked; there is no effectful operation in the baseline, so nothing can escape checking.
## Diagnostics
Feature problems are reported as `E0006` (`module.unsupported_feature`) with a `reason` field, before the module body is examined:
| `reason` | Meaning | Extra fields |
|---|---|---|
| `unknown_feature` | name not in this registry | `feature` |
| `unsupported_feature` | registered but reserved, or not implemented by this toolchain | `feature` |
| `missing_dependency` | a dependency of a declared feature is not declared | `feature`, `requires`, `canonical_header` |
| `duplicate_feature` | the same name is declared twice | `feature` |
| `feature_not_declared` | the body uses a construct of an undeclared feature | `feature`, `construct`, `closure`, `canonical_header` |
| `reserved_type` | the body uses a reserved type such as `f32` (spec 07 §8.4) | `type` |
`canonical_header` is the complete header line the module needs, sorted, with the full dependency closure. Replacing the module's `features` line with it repairs every `missing_dependency` and `feature_not_declared` reported so far. `closure` lists the named feature and everything it depends on.
## Discovery
`aji features` prints the toolchain's AIR format, language version and supported features as one JSON object, e.g. `{"air":0,"lang":"0.1","features":[]}`. Agents query it before generating AIR.