spec: accept RFC 0005 and integrate Phase 1 memory model (P1-1, P1-2)
- RFC 0005 Accepted (revision 2) - spec 07 §8.8 types and syntax; spec 07a contracts for features ownership and arrays; spec 08 §11-§14 borrows, facts, initialization, stage order; spec 03 frame storage, second-class borrows, static region generations - grammar: from-returns, multi-result, new types and opcodes - feature registry: ownership and arrays published; heap added and regions moved to Phase 2; borrow_joins reserved and unscheduled - codes E2105-E2108, T0008 - Q-009, Q-010 resolved; Phase 1 and Phase 2 plans updated; Own test moved to phase 2
This commit is contained in:
15 files changed
+269
-55
No files matched your search
+9
-6
@@ -26,8 +26,8 @@ Non-normative. The order in which the Zig reference implementation is built, and
|
||||
| Phase | File | Goal | Exit criterion | Blocking questions |
|
||||
|---|---|---|---|---|
|
||||
| P0 | [phase-0-semantic-skeleton.md](phase-0-semantic-skeleton.md) | AIR model, text parser, CFG/SSA/type verifier, interpreter | AIR `hello` and arithmetic tests execute identically across runs | resolved except Q-016 (floats reserved) |
|
||||
| P1 | [phase-1-ownership-and-memory.md](phase-1-ownership-and-memory.md) | `Own`, borrows, slices, init tracking, regions, bounds | file-copy core implemented; UAF/alias/OOB rejected | Q-009, Q-010 |
|
||||
| P2 | [phase-2-effects-capabilities-resources.md](phase-2-effects-capabilities-resources.md) | Effects, capabilities, linear resources, runtime intrinsics | safe file-copy and basic TCP echo | Q-011, Q-012, Q-018 |
|
||||
| P1 | [phase-1-ownership-and-memory.md](phase-1-ownership-and-memory.md) | Frame storage, second-class borrows, arrays/slices, init tracking, bounds (RFC 0005) | file-copy core on a local buffer; alias/dangling/escape/uninit/OOB rejected | resolved (Q-009, Q-010) |
|
||||
| P2 | [phase-2-effects-capabilities-resources.md](phase-2-effects-capabilities-resources.md) | Effects, capabilities, heap (`Own`), regions, linear resources, runtime intrinsics | safe file-copy and basic TCP echo | Q-011, Q-012, Q-018 |
|
||||
| P3 | [phase-3-structured-concurrency.md](phase-3-structured-concurrency.md) | Task scopes, Send/Share, channels, mutex, cancellation, deterministic scheduler | parallel-map and channel ownership-transfer examples | Q-013, Q-014 |
|
||||
| P4 | [phase-4-islands.md](phase-4-islands.md) | Islands, `iref`, transfer, freeze, `Frozen`, `Arc` | cyclic graph moves between tasks with no deep copy and no shared mutation | — |
|
||||
| P5 | [phase-5-atomics-and-memory-model.md](phase-5-atomics-and-memory-model.md) | Atomics, orderings, fences, weak-memory interpreter, schedule exploration, replay | atomic publication litmus/conformance tests | Q-015, Q-017 |
|
||||
@@ -58,17 +58,20 @@ Every registry code (`../reference/error-codes.md`) has a phase that must implem
|
||||
| E1001 type.mismatch | P0 | | E3101 effect.undeclared | P2 |
|
||||
| E1002 type.invalid_cast | P0 | | E3201 capability.missing | P2 |
|
||||
| E1010 init.read_uninitialized | P1 | | E3202 capability.widen | P2 |
|
||||
| E2001 ownership.use_after_move | P1 | | E4001 concurrency.not_send | P3 |
|
||||
| E2002 ownership.double_consume | P1 | | E4002 concurrency.not_share | P3 |
|
||||
| E2001 ownership.use_after_move | P2 | | E4001 concurrency.not_send | P3 |
|
||||
| E2002 ownership.double_consume | P2 | | E4002 concurrency.not_share | P3 |
|
||||
| E2101 borrow.mutable_alias | P1 | | E4101 concurrency.possible_data_race | P3 |
|
||||
| E2102 borrow.outlives_owner | P1 | | E4201 atomic.invalid_order | P5 |
|
||||
| E2103 memory.out_of_bounds | P1 | | E4301 task.live_child_escape | P3 |
|
||||
| E2104 memory.region_generation | P1 | | E4302 task.borrow_escape | P3 |
|
||||
| E2104 memory.region_generation | P2 | | E4302 task.borrow_escape | P3 |
|
||||
| E2110 island.escape | P4 | | E4303 io.buffer_in_flight | P3 |
|
||||
| E2111 island.foreign_mutable_edge | P4 | | E5001 air.invalid_ssa | P0 |
|
||||
| E3001 resource.use_after_consume | P2 | | E5002 air.invalid_cfg | P0 |
|
||||
| E3002 resource.leak | P2 | | E5101 verifier.resource_limit | P0 |
|
||||
| E6001 unsafe.required | P2 | | E6101 abi.unaligned_reference | P7 |
|
||||
| E2105 borrow.not_ended | P1 | | E2106 borrow.use_after_end | P1 |
|
||||
| E2107 borrow.not_owned | P1 | | E2108 borrow.escapes_frame | P1 |
|
||||
| E0001–E0006, E1003 | P0 | | T0001–T0007 P0, T0008 | P1 |
|
||||
|
||||
## Cross-cutting tracks
|
||||
|
||||
@@ -95,5 +98,5 @@ These run through all phases rather than belonging to one.
|
||||
| Phase | Status |
|
||||
|---|---|
|
||||
| P0 | done; AIR format 0 frozen as the semantic baseline (spec 07 §8.7) |
|
||||
| P1 | next |
|
||||
| P1 | in progress: RFC 0005 accepted and integrated (P1-1, P1-2) |
|
||||
| P2–P8 | not started |
|
||||
@@ -1,39 +1,33 @@
|
||||
# Phase 1 — Ownership and memory
|
||||
# Phase 1 — Frame storage, borrows and arrays
|
||||
|
||||
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.
|
||||
**Goal:** safe single-threaded memory without a heap: frame storage, initialization tracking, second-class borrows, arrays and slices, bounds checks and bounds proofs. Features `ownership` and `arrays` (RFC 0005).
|
||||
|
||||
**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.
|
||||
**Exit criterion:** the file-copy core — copying between slices of a local buffer in chunks — runs in the interpreter, and the verifier rejects representative aliasing (E2101), dangling and escaping borrows (E2102, E2108), uninitialized reads (E1010), unended borrows (E2105) and unproven element access (E2103).
|
||||
|
||||
**Spec inputs:** spec 02 §4–5, 03 §1–11, 08 §3–6, 13 §2. RFC 0001 memory sections are proposed for acceptance (owner decision; island sections may wait until P4); acceptance integrates them into the spec.
|
||||
**Spec inputs:** spec 03 §4, §6; spec 07 §8.8; spec 07a (features `ownership`, `arrays`); spec 08 §11–§14. Decision record: RFC 0005 (Accepted).
|
||||
|
||||
**Blocking questions:** Q-009 borrow lifetimes in AIR, Q-010 region generation checks.
|
||||
**Moved to Phase 2 (owner decision):** `Own<T>`, heap allocation and regions, together with E2001, E2002 and E2104 — they need allocation authority (`cap<mem.alloc>`).
|
||||
|
||||
## 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>>`.
|
||||
In: `local<T>`, `ref<T>`, `mut<T>`, `[T; N]`, `slice<T>`, `slice_mut<T>`; `local.alloc/store/zero/load`, `borrow.ref/mut/field/end`, `load`, `store`, `array.splat`, `borrow.index[.proven]`, `slice.make/len/sub/split/copy`, `guard`; `from` returns; multi-result syntax; feature gating (`feature_not_declared`).
|
||||
|
||||
Out: islands, `Arc`, `Pin`, raw addresses (beyond rejecting them in safe code).
|
||||
Out: heap, regions, move-only values, borrow-typed block parameters (`borrow_joins`).
|
||||
|
||||
## Tasks
|
||||
|
||||
| ID | Status | Task | Depends | Output | Done when |
|
||||
|---|---|---|---|---|---|
|
||||
| P1-1 | todo | Resolve Q-009 and Q-010; propose RFC 0001 memory sections for acceptance | — | spec 03, 07, RFC 0001 | questions resolved; RFC ready for the owner, rules integrated on acceptance |
|
||||
| P1-2 | todo | Contract tables for Phase 1 opcodes, grouped by feature (`arrays`, `ownership`, `regions`) | P1-1 | spec 07a | every in-scope opcode has all spec 07 §4 fields, including verifier transfer function, and names its feature |
|
||||
| P1-2a | todo | Feature gating in the parser: constructs of an undeclared feature report `E0006` reason `feature_not_declared`; publish `arrays`, `ownership`, `regions` in the registry and add them to `supported` once implemented | P1-2 | `src/air/features.zig`, `src/air/parse.zig`, `reference/air-features.md` | reject test per feature for `feature_not_declared` and `missing_dependency`; `aji features` lists the three |
|
||||
| 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.
|
||||
| P1-1 | done | Resolve Q-009 and Q-010; RFC 0005 accepted | — | RFC 0005 | owner accepted revision 2 |
|
||||
| P1-2 | done | Integrate RFC 0005 into the spec and registries | P1-1 | spec 03/07/07a/08, reference files | features `ownership`, `arrays` published |
|
||||
| P1-3 | todo | Data model, parser and printer: new types, `from`, multi-result, opcodes; feature gating | P1-2 | `src/air/` | round-trip fuzz covers new forms; `feature_not_declared` tests |
|
||||
| P1-4 | todo | Type rules: second-class rule, borrow/slice typing, zeroable types, `from` mode | P1-3 | `src/verifier/types.zig` | E1001 accept/reject pairs for each rule |
|
||||
| P1-5 | todo | Frame rules: `local.alloc` only in entry (E5002), frame size limit (E5101) | P1-3 | `cfg.zig`, `budget.zig` | reject tests for both |
|
||||
| P1-6 | todo | Initialization verifier | P1-4 | `src/verifier/init.zig` | E1010 accept/reject, including joins |
|
||||
| P1-7 | todo | Borrow verifier | P1-6 | `src/verifier/borrow.zig` | E2101, E2102, E2105–E2108 accept/reject; path linearity across branches; join state equality |
|
||||
| P1-8 | todo | Bounds facts for `borrow.index.proven` | P1-7 | `src/verifier/bounds.zig` | every row of the fact table accepted; `le i n` and other non-facts rejected (E2103) |
|
||||
| P1-9 | todo | Interpreter: frame storage, borrows, slices, bounds traps (T0008) | P1-4 | `src/interp/` | run tests for every instruction; T0008 for each checked operation |
|
||||
| P1-10 | todo | `aji features` lists `arrays`, `ownership`; conformance corpus for Phase 1 | P1-7…P1-9 | `tests/conformance/phase1/` | accept/reject/run tests for every new code and trap |
|
||||
| P1-11 | todo | Phase exit review | all | plan status | exit criterion passes |
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Non-normative. Part of the [implementation plan](README.md).
|
||||
|
||||
**Goal:** authority and external resources become verifiable: effect sets, unforgeable capabilities with narrowing, linear resources with typestate, capability-gated runtime intrinsics, unsafe boundaries.
|
||||
**Goal:** authority, allocation and external resources become verifiable: heap allocation (`Own<T>`) and regions (moved here from Phase 1, RFC 0005), effect sets, unforgeable capabilities with narrowing, linear resources with typestate, capability-gated runtime intrinsics, unsafe boundaries.
|
||||
|
||||
**Exit criterion:** safe file-copy and a basic (single-task) TCP echo run in the interpreter.
|
||||
|
||||
@@ -23,6 +23,10 @@ Out: tasks, threads, async I/O (P3); FFI to native code (P7).
|
||||
| P2-1 | todo | Resolve Q-011, Q-012, Q-018 | — | spec 05, 07, 10 | questions resolved; runtime record format defined |
|
||||
| P2-2 | todo | Formal signatures for fs, io, net, clock, random intrinsics | P2-1 | `reference/intrinsics.md` | each intrinsic lists types, effects, capabilities, ownership, failure, blocking (spec 09 §2) |
|
||||
| P2-2a | todo | Publish features `effects` and `capabilities` (spec text, registry status, `supported`); effect checking applies to modules declaring `effects` | P2-1 | `reference/air-features.md`, `src/air/features.zig` | feature_not_declared / missing_dependency tests; baseline modules unaffected |
|
||||
| P2-2b | todo | Specify and publish `heap` (`Own<T>`, `own.alloc`, `own.free`, move-only values) and `regions` (static generations per Q-010); contracts in spec 07a | P2-2a | spec 03, 07a, 08; registry | features published |
|
||||
| P2-2c | todo | Ownership verifier for move-only values: use after move, double consume | P2-2b | `src/verifier/ownership.zig` | E2001, E2002 accept/reject (incl. `phase2/reject/use_after_move.air`) |
|
||||
| P2-2d | todo | Region verifier: reset/destroy with live borrows, prior-generation use; region-derived borrows as an escapable `from` source | P2-2b | `src/verifier/region.zig` | E2104 accept/reject |
|
||||
| P2-2e | todo | Interpreter heap and regions | P2-2b | `src/interp/memory.zig` | run tests; file-copy with a heap-backed region buffer |
|
||||
| P2-3 | todo | Contract tables for `intrinsic.call`, `resource.consume`, `call.indirect` | P2-1 | spec 07 appendix | all spec 07 §4 fields present |
|
||||
| P2-4 | todo | Effect verifier | P2-1 | `src/verifier/effects.zig` | E3101 accept/reject, including transitive callees |
|
||||
| P2-5 | todo | Capability verifier: unforgeability, narrowing, transfer rules | P2-1 | `src/verifier/caps.zig` | E3201, E3202 accept/reject |
|
||||
|
||||
Reference in new issue
Block a user