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.
This commit is contained in:
dev committed 2026-10-04 11:59:13 +03:00
commit 17a55a7fef
67 files changed
+4197

No files matched your search

@@ -0,0 +1,110 @@
# RFC 0001: Regions, Islands and Frozen Graphs
Status: Proposed
Target: Aji 0.1
## Summary
Aji uses four complementary ownership mechanisms:
```text
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`:
```text
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:
```text
single-writer mutable state
```
into:
```text
concurrently shared immutable state
```
without copying.
## Rejected alternatives
### Everything is Own<T>
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.