spec: accept RFC 0013 and add spec 15, the .aji source language 0.1

Owner decisions D1-D7 and the boundary rule (source may hide
representation mechanics, never authority, allocation, ownership
transfer, synchronization, external effects or recoverable failure).
spec 15 normative: items, types, statements, expressions, places and
borrows, explicit move (named values), outcome matches and 'or trap',
scope/shield/lock blocks (lock lowering defined exactly), select,
channels, allocation, frame storage, lexical borrow scopes, inferred
features, one canonical spelling per construct. grammar.ebnf replaced;
E7001-E7007; E3101 gains suggested_effects; spec 01 examples updated.
This commit is contained in:
dev committed 2026-10-05 10:35:55 +03:00
1 parent 0e25a17e9d
commit 65b10e3fb5
9 files changed
+471 -56

No files matched your search

+32 -9
View File
@@ -1,6 +1,7 @@
# RFC 0013: The `.aji` Source Language, Phase 6A
Status: Proposed
Status: Accepted (owner decisions D1–D7 and the boundary rule; normative text in spec 15)
Integrated into: spec 15 (new); `reference/grammar.ebnf`; `reference/error-codes.md` (E7001–E7007); spec 05 / verifier (`E3101` `suggested_effects`); spec README
Scope: source language `.aji` 0.1 for the semantics of AIR format 0 features of Phases 0–3; no change to AIR, the verifier or the runtime
Language version: 0.1
Supersedes: the grammar sketch in `reference/grammar.ebnf`
@@ -325,15 +326,37 @@ The frontend lives in `src/frontend/`: `lex`, `parse`, `resolve`, `check`, `lowe
- **Inferring effects:** violates "effects are part of the public contract" (AGENTS.md).
- **A new surface unlike any known language:** wastes the agents' priors and makes the bundle bigger.
## Decisions requested
## Decisions (owner)
- **D1 — lock as a block** (`lock ref m as x { … } cancelled { … }`, unlock at block exit). The alternative is explicit `unlock(move g)` with guard values. Proposal: the block. It makes the guard lexical, which matches the critical-section rule, and removes a leak class.
- **D2 — lexical borrow scopes.** A borrow ends at the end of its block; earlier ends use an inner block. The alternative is an explicit `end(r)`. Proposal: lexical, with no explicit end in 6A.
- **D3 — `move` required for every consumption of a linear value.** Proposal: yes. Ownership transfer is the reasoning Aji externalizes.
- **D4 — frame storage chosen by the frontend for borrowed variables.** Proposal: yes. Frame storage is static and not an allocation in the sense of spec 01 §2.
- **D5 — effects stay explicit.** Proposal: yes, with `E3101` naming the full list the function needs.
- **D6 — Rust/Zig-like surface** to use model priors, with keywords where the meaning differs (`ref`, `mut`, `move`, `or trap`, `as!`, `as%`, `+%`). Proposal: yes.
- **D7 — the `E7xxx` range** for source-only diagnostics, and the AIR codes for everything the verifier decides. Proposal: yes.
All seven accepted, with these refinements (normative in spec 15):
- **Boundary rule.** Source syntax may hide representation mechanics:
- SSA;
- the CFG and block arguments;
- `borrow.end`;
- `local.alloc`;
- `features [...]`.
It must not hide authority, allocation, ownership transfer, synchronization, external effects or recoverable failure.
- **D1 — lock block, accepted.** `lock ref m as x { … } cancelled { … }` is a syntactic lowering:
1. `mutex.lock`;
2. `mutex.borrow` bound as `x: mut<T>`;
3. the body;
4. `borrow.end` and `mutex.unlock` at every normal exit, including `return`, `break` and `continue` that leave the block.
Nothing happens on a trap, because there is no unwinding. The guard is never a source value.
- **D2 — lexical borrows, accepted.** A borrow ends at the end of its block. An earlier end needs an inner block. There is no last-use inference: lexical source lifetime maps to an exact explicit lifetime in AIR. NLL may be discussed separately if benchmarks show its cost.
- **D3 — explicit `move`, accepted.** It is required when consuming a **named** linear value. A temporary needs none: `consume(make_value())`.
- **D4 — compiler-managed frame storage, accepted.** There is no hidden heap allocation, and the frame-size limit and address stability are preserved.
- **D5 — explicit effects, accepted.** "Explicit effects, assisted bookkeeping": `E3101` carries `suggested_effects`, the complete sorted list the function needs.
- **D6 — Rust/Zig familiarity, accepted.** A familiar operation gets a familiar form, and different semantics get their own word or operator. Every construct has **one canonical spelling**, with a minimum of alternatives. 6A has no compound assignment (`+=`): `x = x + 1;` is the only form.
- **D7 — `E7xxx` for frontend diagnostics only, accepted.** It covers syntax, names, lowering, invalid and ambiguous constructs (`E7001`–`E7007`). Verifier findings keep their AIR codes, with `source_location` (primary) and `air_location` (metadata).
Further spec-15 choices made while writing the normative text:
- built-in operations are called by their AIR names (`channel.send`, `own.new`, `task.spawn`), a one-to-one map to AIR;
- resource and endpoint operands are borrowed for the duration of an operation, while data borrows are always written;
- a mutex is borrowed explicitly (`lock ref m`).
## Open questions