air: feature negotiation for AIR format 0 (DD-014)

- reference/air-features.md: normative feature registry (arrays,
  atomics, capabilities, channels, effects, islands, ownership, regions,
  sync, tasks; all reserved), dependency closures, reasons for E0006
- spec 07 §8.1/§8.5/§8.7: features are mandatory, validated before the
  body, full dependency closure declared, sorted canonically; every
  extension belongs to a feature; published feature semantics immutable
- spec 05 §8: features vs effects vs capabilities
- src/air/features.zig: registry, validation, sync test with the docs
- parser validates features first; E0006 carries `reason`
- `aji features` prints supported AIR format, language and features
- conformance: unknown, reserved and duplicate feature tests
- plan: feature publication tasks in phases 1-5
This commit is contained in:
dev committed 2026-10-04 12:49:29 +03:00
1 parent 03dda1245a
commit 19dff5dd52
24 files changed
+366 -17

No files matched your search

+4
View File
@@ -99,3 +99,7 @@ The toolchain should be able to emit:
- capability requirements per entry point;
- effective transitive authority;
- unsafe/FFI authority boundaries.
## 8. Relation to AIR features
AIR features (spec 07 §8.1) are a third, separate concept. A feature says which semantics the implementation must understand; it grants no authority and adds no effect. Declaring `features [capabilities, effects, ownership]` does not let a program read a file: the function still needs `effects [fs.read]` and a `cap<fs.read>` value.
+16 -4
View File
@@ -198,7 +198,17 @@ lang 0.1
features []
```
An implementation MUST reject a module whose `air` format version or `lang` version it does not implement (`E0005`), and a module that lists a feature it does not implement (`E0006`). Format version 0 defines no features.
An implementation MUST reject a module whose `air` format version or `lang` version it does not implement (`E0005`).
The `features` line is the semantic compatibility contract of the module: it lists the feature bundles ([`../reference/air-features.md`](../reference/air-features.md)) an implementation MUST understand to verify and execute the module. `features []` is the Phase 0 baseline.
- A module MUST declare every feature whose constructs it uses, together with the full dependency closure of those features; a feature never implies another.
- The same name MUST NOT appear twice.
- An implementation MUST validate the feature list before examining the module body, and MUST NOT examine the body if any feature is unknown, unsupported, duplicated or missing a declared dependency.
- A construct belonging to a feature that the module does not declare is rejected.
- All of these are reported as `E0006` with a `reason` field (`unknown_feature`, `unsupported_feature`, `duplicate_feature`, `missing_dependency`, `feature_not_declared`); see the registry for the fields of each reason.
Features describe what the implementation must understand. They grant no authority and declare no effects: effects (spec 05 §2) say what a function does and capabilities (spec 05 §3) say what an invocation may do.
### 8.2 Functions and blocks
@@ -217,11 +227,11 @@ An implementation MUST reject a module whose `air` format version or `lang` vers
### 8.4 Reserved
`f32` and `f64` are reserved until floating-point determinism is specified (open question Q-016). A module that uses them MUST be rejected with `E0006`.
`f32` and `f64` are reserved until floating-point determinism is specified (open question Q-016). A module that uses them MUST be rejected with `E0006`, reason `reserved_type`.
### 8.5 Canonical form
The canonical serialization of a module is: the four header lines; one blank line; type declarations in declaration order, one per line; for each function, a blank line, the signature line, the `effects` line, then each block label at column 0 followed by its instructions indented by four spaces. Separators are `", "` between list items and single spaces elsewhere. Comments are not preserved. Value, block, function and type names are preserved.
The canonical serialization of a module is: the four header lines, with feature names sorted lexicographically; one blank line; type declarations in declaration order, one per line; for each function, a blank line, the signature line, the `effects` line, then each block label at column 0 followed by its instructions indented by four spaces. Separators are `", "` between list items and single spaces elsewhere. Comments are not preserved. Value, block, function and type names are preserved.
Serializing a parsed module and parsing the result MUST yield an equal module.
@@ -237,7 +247,9 @@ A change is permitted under `air 0` only if all of the following hold:
1. every module accepted before the change is still accepted and produces the same run record (spec 07a "Run result") or the same trap record;
2. every module rejected before the change is still rejected with the same codes, **except** where the rejection was `E0004` (unknown opcode or type name) or `E0006` (reserved type or unsupported feature) and the change gives that name a meaning;
3. the change adds instructions, types, header features, diagnostic codes or trap codes, and specifies each new instruction in spec 07a before it is implemented;
3. the change adds instructions, types, diagnostic codes or trap codes; every added construct belongs to a feature registered in [`../reference/air-features.md`](../reference/air-features.md), and the feature's semantics are specified (spec 07a and the relevant spec files) before the feature is published and implemented;
4. the canonical form (§8.5) of existing constructs is unchanged.
A published feature's semantics are immutable. Extending a feature with new semantics is not permitted; register a new feature instead.
Any other change to format 0 — a different meaning, typing rule, trap behavior, diagnostic code or canonical spelling for an existing construct — requires a new format version (`air 1`) introduced by an RFC. An implementation that supports several format versions selects the semantics by the module's `air` line; it never mixes them.