Files
aji/docs/plan/phase-1-ownership-and-memory.md
T
dev 48bb50724f 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
2026-10-04 13:10:08 +03:00

3.1 KiB
Raw Blame History

Phase 1 — Frame storage, borrows and arrays

Non-normative. Part of the implementation plan.

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 — 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 03 §4, §6; spec 07 §8.8; spec 07a (features ownership, arrays); spec 08 §11–§14. Decision record: RFC 0005 (Accepted).

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: 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: heap, regions, move-only values, borrow-typed block parameters (borrow_joins).

Tasks

ID Status Task Depends Output Done when
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