Files
aji/docs/rfcs/0001-memory-regions-islands-frozen.md
T
dev 17a55a7fef Initial import: Aji 0.1 draft spec and Zig scaffolding
Draft specification, RFCs, reference registries and examples, plus the
reference-implementation skeleton: build.zig, diagnostic envelope with
error-code registry synced to docs, aji CLI, conformance runner with seed
tests, CI and contributor docs.
2026-10-04 11:59:13 +03:00

2.7 KiB

RFC 0001: Regions, Islands and Frozen Graphs

Status: Proposed
Target: Aji 0.1

Summary

Aji uses four complementary ownership mechanisms:

Own<T>     single object ownership
Region     bulk lifetime
Island<T>  closed uniquely owned mutable graph
Frozen<T>  deeply immutable shared graph

The intent is to avoid forcing all systems programming into one ownership abstraction.

Motivation

Traditional per-object ownership works well for trees and many local structures, but becomes awkward for:

  • cyclic graphs;
  • object arenas;
  • parsers with many related nodes;
  • message graphs transferred between tasks;
  • storage-engine request contexts;
  • actor-like state.

A tracing GC solves graph lifetime at runtime but introduces runtime tracing and weakens explicit lifetime control.

Regions solve bulk lifetime but by themselves do not solve safe concurrent transfer of arbitrary mutable graphs.

Island<T> combines region-owned storage with unique graph ownership.

Invariant

For a live island I:

outside mutable aliases into I = 0
mutable references from I into ordinary foreign mutable memory = 0

Internal iref<T> edges may be cyclic but are scoped to the island.

Transfer

Ownership of Island<T> may move between tasks, channels and threads if the contained external resources satisfy transfer requirements.

Transfer invalidates sender ownership.

No deep copy is required.

Freeze

island.freeze consumes the mutable island and produces Frozen<T>.

The conversion is irreversible in safe Aji.

This allows a large graph to move from:

single-writer mutable state

into:

concurrently shared immutable state

without copying.

Rejected alternatives

Everything is Own

Rejected because cyclic/arena-style graphs become unnecessarily complex.

Garbage collection

Rejected as a core requirement because Aji targets kernels, runtimes and storage systems where deterministic lifetime and bounded runtime behavior are important.

Implicit reference counting

Rejected because hidden atomic increments/decrements are poor fits for transparent cost and agent reasoning.

Shared mutable regions

Rejected as a default model because it makes the verifier's alias and race problem substantially harder.

Verifier rules

The verifier must track:

  • island owner;
  • internal allocation membership;
  • escaping references;
  • iref island identity;
  • mutable borrow exclusivity;
  • freeze transition;
  • transfer transition.

Open questions

  • whether islands may contain multiple physical regions;
  • exact representation of iref<T>;
  • whether sub-islands can be detached in O(1);
  • interaction with memory-mapped files.