diff --git a/docs/agent/README.md b/docs/agent/README.md index b52f10a..4681602 100644 --- a/docs/agent/README.md +++ b/docs/agent/README.md @@ -174,3 +174,5 @@ Q-051 source effect names (DD-023, cl100k): Quick Reference 8,948 → 8,955 (+7) Q-052 CFG resource provenance (DD-024): Quick Reference and other/full source docs remain 8,955 / 68,323 / 77,278 cl100k (o200k 8,991 / 68,526 / 77,517; Qwen2.5 9,233 / 69,994 / 79,227); std is unchanged. Canonical AIR grows 184,678 → 185,220 bytes and 47,385 → 47,476 cl100k (+91), 47,540 → 47,631 o200k (+91), 48,917 → 49,009 Qwen2.5 (+92). The separately wrapped source-bundle AIR copy grows 47,458 → 47,549 cl100k. The added sentences clarify preservation of existing task/scope, guard and shield obligations through block arguments. No new agent concept, syntax, feature or diagnostic is introduced. Sparse implementation relations replace incomplete SSA metadata; verifier acceptance now enforces existing safety rules. No empirical MCC benefit is claimed. P6-7 factual source E4202 fields (cl100k): Quick Reference stays 8,955; other source docs 68,323 → 68,353 (+30), full source 77,278 → 77,308 (+0.04%). o200k groups are 8,991 / 68,556 / 77,547; Qwen2.5 9,233 / 70,024 / 79,257. Only language/concurrency.md grows; AIR and library/std.md are unchanged. Concrete `found` and `use` fields distinguish ordinary atomic reads without message parsing. No new syntax, code, feature or verifier/runtime state is introduced; no empirical MCC benefit is claimed. + +Spec 15 scope corrections (cl100k): Quick Reference stays 8,955 tokens despite the E1002 → E7005 correction; other source docs 68,353 → 68,403 (+50), full source 77,308 → 77,358 (+0.06%). o200k full source grows 77,547 → 77,594 (+47); Qwen2.5 79,257 → 79,315 (+58). AIR and std are unchanged. Existing source diagnostics, unpacking, escapes, buffers and borrow returns replace obsolete baseline descriptions; no semantic or implementation change. diff --git a/docs/agent/quick-reference.md b/docs/agent/quick-reference.md index 5636369..479a855 100644 --- a/docs/agent/quick-reference.md +++ b/docs/agent/quick-reference.md @@ -71,7 +71,7 @@ return x + y + w; // also: `trap;` | `+% -% *%` | wrapping | | `& \| ^ << >>` | bitwise; shift ≥ width traps `T0005` | | `== != < <= > >=`, `and or not` | comparisons, booleans | -| `x as T` | lossless widening only (else `E1002`) | +| `x as T` | lossless widening only (else `E7005`) | | `x as! T` | checked conversion, traps `T0006` | | `x as% T` | wrapping conversion | | `42`, `42u8`, `0xff`, `1_000` | literals; type from context or suffix (else `E7007`) | diff --git a/docs/plan/phase-6-source-language.md b/docs/plan/phase-6-source-language.md index edcf32c..f20ad64 100644 --- a/docs/plan/phase-6-source-language.md +++ b/docs/plan/phase-6-source-language.md @@ -327,3 +327,7 @@ The [checker documentation](../../tests/conformance/README.md) records the diagn Validation: full conformance is 1,713/1,713; unit tests, Zig formatting, all 62 checker regressions and the 91-case source/AIR position check pass. All 66 source reject_twins fixtures and five atomic_access fixtures pass collection before every instruction; source coverage remains 121/121. The completion gate still rejects partial same-code coverage. Claude independently reviewed the feature/CFG witnesses, all remaining classifications and the atomic operand checks. New probes reject another scalar or borrow mode, an unrelated borrow reported as the operand, and inconsistent raw/source identities. Existing Git attributes force LF for pinned artifacts. The frontend ordinary-dereference E4202 now adds concrete found and use fields, retaining the code, message, primary position and early failure. CLI tests pass 33 checks; comparison with the previous compiler passes 52, including generic/package provenance, first-error selection, untouched alternative errors and identical valid AIR. No SSA identity or AIR location is fabricated for a frontend rejection. Atomic access invariants, verifier/runtime rules and deterministic execution remain unchanged; valid reads use explicit atomic.load orderings. The schema is additive; the source bundle grows by 30 tokens (docs/agent/README.md). Q-053 remains the owner decision on the literal criterion; there are no unaudited public rows. + +## P6-1 source specification consistency (2026-10-09) + +Spec 15's initial Phase 6A limits now point to its existing extensions. Its introductory diagnostic rule follows §10 and construct-specific codes; widening reports source E7005 while AIR retains E1002, including the corrected Quick Reference entry. Multi-result bindings include complete unpacking, byte escapes agree with the later exact list, and grammar comments locate graph access in §8. Old incremental limits link buffers/borrow returns to §17/§19. No grammar production, semantic rule or implementation changes. Six existing public fixtures confirm the reported code and deterministic successful AIR; Claude independently audited the corrections. The reference bundle rebuilds; source growth is +50/+47/+58 tokens across the three tokenizers, with unchanged Quick Reference token counts, AIR and std (docs/agent/README.md). P6-1/P6-5 remain open for their unimplemented surfaces. diff --git a/docs/reference/grammar.ebnf b/docs/reference/grammar.ebnf index d27c954..096e2e9 100644 --- a/docs/reference/grammar.ebnf +++ b/docs/reference/grammar.ebnf @@ -1,5 +1,5 @@ -(* Aji source language `.aji` 0.1 (Phase 6A). Normative together with - docs/spec/15-source-language.md. Decision record: RFC 0013. +(* Aji source language `.aji` 0.1. Normative together with + docs/spec/15-source-language.md. Initial decision record: RFC 0013. Lexical conventions ------------------- @@ -81,7 +81,7 @@ int_type = "u8" | "u16" | "u32" | "u64" | "u128" | "usize" block = "{" { statement } [ expr ] "}" ; (* optional tail expression: the block's value *) statement = "let" binding [ ":" type ] "=" expr ";" | "var" ident ":" type "=" ( expr | "zero" ) ";" - | ( "ref" | "mut" ) [ "unchecked" ] ident "=" ( place | borrow_call ) ";" (* borrow binding; buffer.view(b) / graph access also bind child borrows, spec 15 §17 *) + | ( "ref" | "mut" ) [ "unchecked" ] ident "=" ( place | borrow_call ) ";" (* borrow binding; buffer.view(b) (§17) / graph access (§8) also bind child borrows *) | place "=" expr ";" | "break" ";" | "continue" ";" | "return" [ expr ] ";" | "trap" ";" | expr ";" @@ -138,7 +138,7 @@ primary = int_lit | "true" | "false" | string | "(" expr ")" | if_expr | match_expr | block ; field_init = ident ":" expr ; -borrow_call = name_path [ application ] call_args ; (* only declared `from` calls (§19), buffer.view and graph .at (§17) *) +borrow_call = name_path [ application ] call_args ; (* only declared `from` calls (§19), buffer.view (§17) and graph .at (§8) *) place = ( ident | "(" place ")" ) { "." member | "[" expr [ ".." expr ] "]" } | "*" unary ; int_lit = digit { digit | "_" } [ int_type ] diff --git a/docs/spec/15-source-language.md b/docs/spec/15-source-language.md index fcece61..9835bea 100644 --- a/docs/spec/15-source-language.md +++ b/docs/spec/15-source-language.md @@ -1,6 +1,6 @@ -# 15. Source Language `.aji` 0.1 (Phase 6A) +# 15. Source Language `.aji` 0.1 -This file is normative for `.aji` source 0.1. Decision record: RFC 0013. Grammar: [`../reference/grammar.ebnf`](../reference/grammar.ebnf). +This file is normative for `.aji` source 0.1. Initial decision record: RFC 0013; subsequent extensions are specified below. Grammar: [`../reference/grammar.ebnf`](../reference/grammar.ebnf). ## 1. Principle @@ -30,8 +30,8 @@ It MUST NOT hide: Rules: 1. Lowering is a pure function of its explicit source inputs: the same module graph gives byte-identical canonical AIR (spec 07 §8.5). -2. No source construct admits a program whose AIR the verifier rejects. Errors the verifier would find are reported with the verifier's code (§9). -3. `.aji` 0.1 covers the published features of Phases 0–3 and nothing else. +2. No source construct admits a program whose AIR the verifier rejects. Diagnostics follow §10 and the construct-specific rules below. +3. `.aji` 0.1 covers the constructs specified here and nothing else, including the extensions to the initial Phases 0–3 baseline. 4. Every construct has **one canonical spelling**. There are no alternative forms of the same operation. Parentheses for expression grouping and the optional list delimiters of §2 do not introduce operations. ## 2. Modules and declarations @@ -146,7 +146,7 @@ Lowering: structured control flow becomes blocks and terminators. A variable ass | Source | AIR | |---|---| -| `x as T` | `cast.widen`; only where every value is representable, otherwise `E1002` | +| `x as T` | `cast.widen`; only where every value is representable, otherwise source `E7005` (§10; AIR `E1002`) | | `x as! T` | `cast.checked` (`T0006`) | | `x as% T` | `cast.wrap` | @@ -154,7 +154,7 @@ Lowering: structured control flow becomes blocks and terminators. A variable ass - integers (`42`, `0xff`, `0b101`, `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`. +- `b"…"`: a byte string, of type `[u8; N]`, with escapes `\n`, `\r`, `\t`, `\\`, `\"`, `\0`, `\xHH`. **Aggregates.** @@ -163,7 +163,7 @@ Lowering: structured control flow becomes blocks and terminators. A variable ass - **Arrays.** `[e; N]` is `array.splat`. - **Field access.** `v.f` on a struct value is `struct.get`. -6A has no destructuring: no `let Point { x, y } = p`, no nested patterns, guards or or-patterns. +There is no pattern destructuring: no `let Point { x, y } = p`, no nested patterns, guards or or-patterns. Complete aggregate unpacking is specified in §16. **Calls.** `f(args)` calls a local function; a directly imported function uses its full path (§13–§14). Built-in operations are called by their AIR names (§7, §8). Arguments are evaluated left to right. @@ -185,7 +185,7 @@ Lowering: structured control flow becomes blocks and terminators. A variable ass | `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`. Besides `atomic.compare_exchange` (§12), the only multi-result binding. There is no general tuple destructuring. | +| `let (left, right) = s.split_at(k);` | `slice.split`: two disjoint borrows of `s`. Multi-result bindings also cover `atomic.compare_exchange` (§12) and complete aggregate unpacking (§16). There is no general tuple destructuring. | | `slice.copy(mut dst, ref src)` | primitive `slice.copy`; insufficient capacity traps. Recoverable byte copy is `std.bytes.copy` (spec 16 §2.4). | **Whole-array arguments.** In an ordinary function call, `ref place` / `mut place` MUST preserve a whole-array referent when the known parameter is `ref<[T; N]>` / `mut<[T; N]>`; otherwise the existing whole-array-to-slice rule applies. Element type, length and explicit borrow mode MUST match (`E7005`); a slice MUST NOT be converted back to an array borrow. This also applies after explicit generic/static-function specialization and to array fields, elements and dereferenced array borrows (`ref (*a)`). Shared reborrowing of an exclusive parent follows the existing AIR rule. All temporary ancestors end after the call, child first. Borrow bindings still produce slices; bare byte-string arguments still produce `slice`. The named-origin requirement of §19 and the named-loan requirement of `task.spawn` (§7) remain mandatory. @@ -485,7 +485,7 @@ Spec 04 §20–§30, §42; layer 10, RFC 0015. Implemented with the publication | `atomic.swap(c, v, o)` | `atomic.xchg.` | | `atomic.add.wrap(c, v, o)`, `atomic.sub.wrap(c, v, o)` | `atomic.add.wrap.`, `atomic.sub.wrap.` | | `atomic.and(c, v, o)`, `atomic.or(c, v, o)`, `atomic.xor(c, v, o)` | `atomic.and.`, `atomic.or.`, `atomic.xor.` | -| `let (old, exchanged) = atomic.compare_exchange(c, expected, desired, s, f);` | `atomic.cmpxchg..`, the second multi-result binding | +| `let (old, exchanged) = atomic.compare_exchange(c, expected, desired, s, f);` | `atomic.cmpxchg..`, a multi-result binding | | `atomic.fence(o);` | `atomic.fence.` | The cell operand `c`: @@ -581,7 +581,7 @@ Structs, enums and fixed arrays with linear members MUST obey spec 03 §25. Cons `value.swap(mut place, move replacement)` returns the previous complete value and stores the replacement; it lowers to value.swap with the existing borrow scope. The same spelling accepts Copy replacements without move. The caller MUST explicitly consume a returned linear value. `match own.pack(move value, heap) { ok(owner) => …, err(error, value) => … }` makes allocation authority/failure explicit and preserves ownership on both outcomes; `or trap` retains ordinary abnormal-path semantics. own.new/own.array/region storage and local storage remain Copy-only; own.take extracts whole linear content and own.free cannot destroy it. -The frontend MUST declare linear_aggregates plus its dependencies whenever any emitted aggregate has linear members or any of the new operations is emitted. Existing Source/AIR diagnostics and deterministic behavior apply. This phase does not implement partial moves, borrowed aggregates, dynamic linear buffers or source from-returns. +The frontend MUST declare linear_aggregates plus its dependencies whenever any emitted aggregate has linear members or any of the new operations is emitted. Existing Source/AIR diagnostics and deterministic behavior apply. Partial moves and borrowed aggregates remain outside this surface; dynamic buffers and borrow returns are specified in §17 and §19. ## 17. Source dynamic buffers @@ -592,7 +592,7 @@ Outcomes: new has ok(buffer)/err(alloc_error); reserve has ok()/err(alloc_error) A specialized generic body MAY use `move name` to express complete value transfer for a type parameter. If its concrete binding is Copy, lowering passes the existing Copy value and it remains available; if linear, ordinary transfer/availability applies. This rule applies to complete Copy bindings inside a specialized generic body, not borrows or internal storage/scope/guard/shield handles. A Copy value bound in frame storage remains a Copy value and is loaded normally when transferred. Outside a specialized generic body, move of a Copy value remains E7006. No AIR ownership rule changes and no implicit destructor/allocation is added. This makes one generic container body correct for both Copy and linear contents; ordinary borrow/effect/type constraints still apply to every specialization. -The frontend MUST emit linear_buffers and its full dependencies for buffer types/operations. Existing syntax suffices apart from admitting the buffer wrapper and the typed built-in allocator with the existing channel.make type-argument form. General methods, borrowed aggregate storage, recursive ownership and from-return calls are not added. +The frontend MUST emit linear_buffers and its full dependencies for buffer types/operations. Existing syntax suffices apart from admitting the buffer wrapper and the typed built-in allocator with the existing channel.make type-argument form. General methods, borrowed aggregate storage and recursive ownership remain outside this surface; borrow-returning calls are specified in §19. ## 18. Static function parameters diff --git a/docs/spec/README.md b/docs/spec/README.md index 1c97eb1..6d0db5b 100644 --- a/docs/spec/README.md +++ b/docs/spec/README.md @@ -24,7 +24,7 @@ The specification is split by semantic domain. Rationale for major decisions liv | [12-packages-and-build.md](12-packages-and-build.md) | Normative draft | Manifest/build model | | [13-contracts-and-unsafe.md](13-contracts-and-unsafe.md) | Normative draft | Contracts, proof status and unsafe boundaries | | [14-agent-efficiency.md](14-agent-efficiency.md) | Normative draft (design objectives) | Agent efficiency, Model Capability Compression, design review requirement | -| [15-source-language.md](15-source-language.md) | Normative draft | The agent-facing source language `.aji` 0.1 (Phase 6A), lowering to AIR | +| [15-source-language.md](15-source-language.md) | Normative draft | The agent-facing source language `.aji` 0.1, lowering to AIR | | [16-standard-library.md](16-standard-library.md) | Normative draft | Standard library contracts and built-in pure modules | ## Reading order