Files
aji/docs/plan/phase-4-islands.md
T
dev c699529fec Phase 4: islands, frozen graphs and arc through every layer (RFC 0014)
AIR: types island<T>, frozen<T>, arc<T>, iref<T>; 16 instructions
(island.create/alloc/root/borrow/freeze/destroy, frozen.root/borrow/
release, arc.from_frozen/new/clone/release/root/borrow, iref.eq); features
islands (depends on heap) and arc (depends on islands) published.
Verifier: IslandSafe/ArcSafe (E2111 at the owner type), container child
borrows (one mut access per island), Send/Share rows (island not Share),
linear owners, mem.alloc effect, element rules (recursion through iref).
Interpreter: graphs with never-reused identities, T0010 for a foreign
iref, O(1) freeze/conversion/transfer, arc counts in a trace hook
(Options.arc_events), budgets per the quota table, collector support.
.aji layer 9: types, operations, island.at/frozen.at/arc.at as borrow
places with explicit container borrows, iref ==/!=.
Frontend fix: joins carry only variables the construct assigns (and that
are read again), so an unchanged linear value is never a block argument
while borrowed.

Tests: 10 AIR (phase4), 6 .aji run + 12 rejects (layer9), the reference
program island-pipeline in .aji, equivalent to an independently
hand-written AIR program (36 on 30 schedule seeds); unit tests for the
arc count trace and O(1) transfer. Quick Reference §7 graphs (checked
excerpt of quickref/graphs.aji); coverage 61/61. Bundle growth: AIR
+7.0%, Quick Reference +0.6k, source docs +4.2k (recorded).
Spec: quota rows match the header-reserved count; idioms and iref
recursion in spec 03 §22; P4-11 (air-text.ebnf gaps) recorded.
2026-10-05 22:14:05 +03:00

4.2 KiB
Raw Blame History

Phase 4 — Islands

Non-normative. Part of the implementation plan.

Goal: uniquely owned closed mutable graphs that move between tasks in O(1), and irreversible freezing into shareable immutable graphs.

Exit criterion: a cyclic graph moves between tasks with no deep copy and no shared mutation (island-pipeline reference program).

Spec inputs: spec 03 §12–15, 04 §13; RFC 0014 (Accepted, revision 2; integrated into spec 02 §6, 03 §12–§14 and §22–§24, 04 §13/§35/§38.1, 07a, 15 §8) makes RFC 0001's island sections concrete.

Vertical rule (owner decision after P6A-9): every feature goes through spec → AIR → verifier → interpreter → .aji lowering → Quick Reference → conformance (AIR and .aji) in this phase; nothing is left for a later frontend phase.

Blocking questions: none recorded; log new ones before starting.

Invariants

  • iref<T> points only inside its own island and is never dereferenced without access to the owning island;
  • an island has no edges into foreign mutable memory;
  • after transfer the sender holds nothing that reaches the island;
  • a Frozen<T> never yields a mutable reference in safe code;
  • reference counts change only through explicit arc.clone / arc.release.

Tasks

ID Status Task Depends Output Done when
P4-0 done RFC 0014: decisions D1–D10, owner review — docs/rfcs/0014-islands-frozen-arc.md Accepted (revision 2)
P4-1 done Spec integration: spec 03 §12–14, 04 §13/§35/§38.1, 07a contract tables, 15 (layer 9), error codes (T0010) P4-0 spec, reference contract tables complete (spec 07 §4 fields)
P4-1a done Publish islands (depends on heap) and add arc (depends on islands) P4-1 reference/air-features.md, src/air/features.zig feature_not_declared / missing_dependency tests
P4-2 done Interpreter: island tables, identities never reused, T0010, freeze, O(1) transfer; arc counts in the trace; collector support P4-1 src/interp/ transfer cost independent of graph size (unit test with an instruction-count bound); --collect-every-step passes
P4-3 done Verifier: types and classes, storability (E2111), container child borrows, arc rules (E4002/E1001), Send/Share rows P4-1 src/verifier/ accept/reject per rule
P4-4 done Transfer through channels and spawn; sender invalidation P4-3 verifier + interpreter use after send rejected (E2001); schedule stress
P4-5 done Freeze and frozen<T>; lending to tasks P4-3 verifier + interpreter concurrent reads accepted; mutable access rejected
P4-6 done arc<T>: arc.from_frozen, arc.new (ArcSafe), clone, release, root, borrow P4-5 verifier + interpreter non-ArcSafe rejected (E2111); count changes visible in the trace
P4-7 done .aji layer 9: types, operations, island.at/frozen.at/arc.at places, explicit container borrows; Quick Reference section; source coverage rows P4-3 src/frontend/, docs/agent/ .aji run/reject tests; Quick Reference examples checked; tools/source_coverage.py passes
P4-8 done Reference program island-pipeline in AIR and .aji with equivalence P4-4, P4-5, P4-6, P4-7 tests/conformance/ passes under all P3 stress modes
P4-9 done Complexity budget: AIR bundle, Quick Reference, Source Reference Bundle measured against the RFC estimate P4-7 docs/agent/README.md growth recorded and justified
P4-11 todo reference/air-text.ebnf covers the syntax of Phases 2–4: cap<K>, endpoint, task, graph and built-in types; own.*, task.*, channel.* (with the type operand of channel.make), island.*/frozen.*/arc.*/iref.eq; the multi-edge terminator forms (found by the independent author of program_island_pipeline.air) — docs/reference/air-text.ebnf every instruction of spec 07a and spec 03 §22–§24 has a production
P4-10 todo Phase exit review all plan status exit criterion passes

Conformance tests to add

Negative corpus entry owned by this phase: island internal reference escape. Plus E2111, freeze-then-mutate, Arc of non-Share.