- 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
39 lines
3.5 KiB
Markdown
39 lines
3.5 KiB
Markdown
# Phase 1 — Ownership and memory
|
||
|
||
Non-normative. Part of the [implementation plan](README.md).
|
||
|
||
**Goal:** safe single-threaded memory: `Own<T>`, `ref<T>`/`mut<T>`, slices, initialization tracking, regions with generations, bounds and range facts.
|
||
|
||
**Exit criterion:** the file-copy core (buffer handling, regions, slices) is implemented in AIR, and the verifier rejects representative use-after-move, aliasing and out-of-bounds cases.
|
||
|
||
**Spec inputs:** spec 02 §4–5, 03 §1–11, 08 §3–6, 13 §2. RFC 0001 moves to Accepted (island sections may stay Proposed until P4).
|
||
|
||
**Blocking questions:** Q-009 borrow lifetimes in AIR, Q-010 region generation checks.
|
||
|
||
## 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`; 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).
|
||
|
||
## Tasks
|
||
|
||
| ID | Status | Task | Depends | Output | Done when |
|
||
|---|---|---|---|---|---|
|
||
| P1-1 | todo | Resolve Q-009 and Q-010; review RFC 0001 memory sections to Accepted | — | spec 03, 07, RFC 0001 | questions resolved; RFC status updated |
|
||
| P1-2 | todo | Contract tables for Phase 1 opcodes | P1-1 | spec 07 appendix | every in-scope opcode has all spec 07 §4 fields, including verifier transfer function |
|
||
| P1-3 | todo | Interpreter memory: allocations, provenance, bounds, region generations, uninitialized bytes | P1-2 | `src/interp/memory.zig` | unit tests: every access checks provenance; reading uninitialized bytes is detected in interpreter debug checks |
|
||
| P1-4 | todo | Initialization verifier | P1-2 | `src/verifier/init.zig` | E1010 accept/reject (scalar, struct field, array prefix) |
|
||
| P1-5 | todo | Ownership state machine | P1-2 | `src/verifier/ownership.zig` | E2001, E2002 accept/reject, including across branches and loops |
|
||
| P1-6 | todo | Borrow/alias verifier | P1-5 | `src/verifier/borrow.zig` | E2101, E2102 accept/reject; borrow ending on all paths |
|
||
| P1-7 | todo | Region lifetime and generation verifier | P1-6 | `src/verifier/region.zig` | E2104 accept/reject; reset with live reference rejected (spec 03 §8.2) |
|
||
| P1-8 | todo | Bounds and range facts; path sensitivity; `guard` | P1-6 | `src/verifier/bounds.zig` | E2103 accept/reject; check elimination after `if i < len` and after `guard` |
|
||
| P1-9 | todo | Slices and disjoint partitioning facts (`split_mut`) | P1-8 | verifier + interpreter | two disjoint `slice_mut` usable simultaneously; overlapping ones rejected with E2101 |
|
||
| P1-10 | todo | Structured diagnostic fields and repair candidates for E2xxx | P1-5…P1-9 | `src/diag.zig`, spec 10 | snapshot tests on full JSON for each E2xxx code, matching the spec 10 §2 example shape |
|
||
| P1-11 | todo | Report: remaining runtime checks and eliminated bounds checks | P1-8 | `src/report/checks.zig` | `aji check --report` lists checks per function, deterministic order |
|
||
| P1-12 | todo | Phase exit review | all | `tests/programs/file-copy-core/` | file-copy core runs; negative corpus for use-after-move, overlapping borrows, region reset with live reference, prior generation use, OOB all pass |
|
||
|
||
## Conformance tests to add
|
||
|
||
Negative corpus entries from `conformance-suite.md` owned by this phase: use after move, overlapping mutable borrows, region reset with live reference, use of prior region generation. Plus E1010, E2002, E2102, E2103.
|