spec: Phase 0 spec gate (P0-1, P0-2, P0-3)

- text AIR format 0: grammar (reference/air-text.ebnf) and module,
  block, SSA, type and canonical-form rules (spec 07 §8)
- instruction contracts for format 0 (new spec 07a)
- traps: stable T0xxx codes and trap records (spec 01 §6)
- integer edge cases and explicit casts (spec 02 §2.1)
- fixed verifier resource limits (spec 08 §7)
- target description with pointer_bits (spec 09 §9)
- new codes E0001-E0006, E1003, T0001-T0007
- resolves Q-001, Q-003..Q-008, Q-018; Q-002 resolved for format 0
This commit is contained in:
dev committed 2026-10-04 12:14:25 +03:00
1 parent 11ce6cb38c
commit 41b764ccfd
13 files changed
+425 -18

No files matched your search

+1 -1
View File
@@ -93,5 +93,5 @@ These run through all phases rather than belonging to one.
| Phase | Status |
|---|---|
| P0 | not started |
| P0 | in progress: spec gate (P0-1…P0-3) done |
| P1–P8 | not started |
+6 -6
View File
@@ -4,7 +4,7 @@ Non-normative. Part of the [implementation plan](README.md).
**Goal:** an executable core: AIR data model, text parser and serializer, CFG/SSA/type verification, and a deterministic interpreter for integer programs.
**Exit criterion:** AIR `hello` and arithmetic tests execute identically across runs.
**Exit criterion:** AIR `hello` and arithmetic tests execute identically across runs. Per Q-008, Phase 0 `hello` is a `@main` returning a value; output to stdout arrives in P2-11.
**Spec inputs:** spec 00 §5–6, 01 §6, 02 §1–3, 07, 08 §1–2, §7, 10 §2, 11 §1. RFC 0004 moves to Accepted at the end of this phase.
@@ -12,17 +12,17 @@ Non-normative. Part of the [implementation plan](README.md).
## Scope
In: integer types, `bool`, `void`, `never`; structs, enums, fixed arrays as values; functions and direct calls; `br`, `cbr`, `switch`, `ret`, `trap`, `assert`; checked and wrapping arithmetic, bitwise ops, comparisons, explicit casts.
In: integer types, `bool`, `void`, `never`; structs and enums as values; functions and direct calls; `br`, `cbr`, `switch`, `ret`, `trap`, `assert`; checked and wrapping arithmetic, bitwise ops, comparisons, explicit casts.
Out: floats (deferred until Q-016 is answered), borrows, memory, effects other than `[]`, concurrency.
Out: floats (reserved until Q-016 is answered), fixed arrays (moved to P1 with slices and bounds), borrows, memory, effect checking, concurrency.
## Tasks
| ID | Status | Task | Depends | Output | Done when |
|---|---|---|---|---|---|
| P0-1 | todo | Specify text AIR grammar (Q-001) and parse-error codes (Q-003) | — | `docs/reference/air-text.ebnf`, spec 07, error-codes.md | grammar covers module header with version/feature bits, type declarations, functions, `effects`, blocks with parameters, instructions, comments; seed tests in `tests/conformance/phase0` conform to it |
| P0-2 | todo | Specify traps (Q-004), integer edge cases and casts (Q-007), target description (Q-006), verifier budget (Q-005), `hello` strategy (Q-008) | — | spec 01, 02, 08, 11 | each question marked resolved in `open-questions.md` |
| P0-3 | todo | Write contract tables for Phase 0 opcodes; add aggregate opcodes (struct/enum construct and access) if needed, via RFC 0004 amendment | P0-1 | spec 07 appendix | every in-scope opcode has all fields required by spec 07 §4 |
| P0-1 | done | Specify text AIR grammar (Q-001) and parse-error codes (Q-003) | — | `docs/reference/air-text.ebnf`, spec 07, error-codes.md | grammar covers module header with version/feature bits, type declarations, functions, `effects`, blocks with parameters, instructions, comments; seed tests in `tests/conformance/phase0` conform to it |
| P0-2 | done | Specify traps (Q-004), integer edge cases and casts (Q-007), target description (Q-006), verifier budget (Q-005), `hello` strategy (Q-008) | — | spec 01, 02, 08, 11 | each question marked resolved in `open-questions.md` |
| P0-3 | done | Write contract tables for Phase 0 opcodes; add aggregate opcodes (struct/enum construct and access) if needed, via RFC 0004 amendment | P0-1 | spec 07 appendix | every in-scope opcode has all fields required by spec 07 §4 |
| P0-4 | todo | AIR data model | P0-1 | `src/air/{types,module,ops}.zig` | unit tests build the seed-test modules programmatically |
| P0-5 | todo | Text AIR lexer and parser | P0-4 | `src/air/parse.zig` | all seed tests parse; malformed input yields registered diagnostics with spans |
| P0-6 | todo | Canonical serializer | P0-4 | `src/air/print.zig` | `print(parse(x))` is a fixed point after one round; fuzz test on parser round-trip |
+1 -1
View File
@@ -12,7 +12,7 @@ Non-normative. Part of the [implementation plan](README.md).
## Scope
In: `move`, `copy`; `borrow.ref`, `borrow.mut`, `borrow.end`; `load`, `store`; `own.alloc`, `own.free`; `region.create`, `region.alloc`, `region.alloc_uninit`, `region.reset`, `region.destroy`; `slice.make`, `slice.sub`, split operations; `mem.copy`, `mem.zero`; `guard`; `Uninit<T>`; `Option<ref<T>>`.
In: `move`, `copy`; `borrow.ref`, `borrow.mut`, `borrow.end`; `load`, `store`; `own.alloc`, `own.free`; `region.create`, `region.alloc`, `region.alloc_uninit`, `region.reset`, `region.destroy`; `slice.make`, `slice.sub`, split operations; `mem.copy`, `mem.zero`; `guard`; fixed arrays `[T; N]` with checked indexing (moved from P0); `Uninit<T>`; `Option<ref<T>>`.
Out: islands, `Arc`, `Pin`, raw addresses (beyond rejecting them in safe code).