- air: cap<K> and built-in enums (cap_error) as types; enum.switch over built-in enums; cap.narrow terminator with ok/err targets; intrinsic syntax (registry still empty: E0004); registries for effects, capability kinds and built-in enums, synced with reference docs - verifier: effect stage (E3101, flat, direct callees); cap.narrow form check (E3202) and ok/err parameter rules (E5002, E1001); capabilities are copyable, not zeroable, not comparable; sizes cap 8, built-in tag - interp: host authority table; @main instantiation from grants by parameter name with not_instantiated reasons; capabilities render as opaque - CLI: --grant P=KIND[:SCOPE], exit code 6; runner: grant: and not_instantiated: headers, pending only for unsupported features - conformance: 18 Phase 2 tests; 4000 mutants without a crash
5.2 KiB
AGENTS.md
This repository defines the Aji programming language.
Mission
Aji is a small, typed, verifiable systems language intended primarily for AI-generated software. Any design or implementation change should improve at least one of:
- semantic explicitness;
- verifier strength;
- deterministic behavior;
- machine repairability;
- memory/concurrency safety;
- implementation simplicity;
- auditability.
Human ergonomics matter, but they are secondary to verifier clarity and agent reliability.
Non-negotiable principles
Do not introduce:
- implicit heap allocation;
- implicit reference counting;
- exceptions or stack unwinding;
- hidden destructors;
- unrestricted detached tasks;
- raw-pointer operations in safe code;
- default atomic memory orderings;
- compiler flags that change language semantics;
- arbitrary build scripts with host authority;
- effects or capabilities that are inferred away from the public contract.
Safe Aji must not permit use-after-free, double-free, out-of-bounds reads/writes, uninitialized reads, invalid mutable aliasing, dangling borrows or unsynchronized data races.
Central abstractions
Memory:
Own<T> individually owned allocation
Region bulk lifetime and bulk deallocation
Island<T> uniquely owned closed mutable object graph
Frozen<T> deeply immutable graph
Arc<T> explicit shared ownership for Share values
ref<T> immutable borrow
mut<T> exclusive mutable borrow
Concurrency preference:
ownership transfer
→ shared immutable data
→ synchronized shared state
→ atomics
→ unsafe raw concurrency
Source of truth
The specification is the single normative source. When documents disagree, use this precedence order:
- files in
docs/spec/; - files in
docs/reference/; - examples;
- README prose.
RFCs are architectural decision records with rationale, not a normative layer. Accepting an RFC means its rule changes are integrated into docs/spec/ (and docs/reference/) in the same change; from then on the spec, not the RFC, is authoritative. If an accepted RFC and the spec disagree, the spec wins and the RFC is out of date.
AIR format 0 is a frozen semantic baseline (spec 07 §8.7): do not change the meaning of existing format-0 constructs; extend only as §8.7 allows, otherwise introduce a new format version through an RFC. Every extension belongs to a registered feature (docs/reference/air-features.md); modules declare features and their full dependency closure in the features [...] header. Keep three concepts apart: features (what the implementation must understand), effects (what code does), capabilities (what code may do).
Normative language
Use RFC-style terminology:
- MUST / MUST NOT: mandatory for conformance;
- SHOULD / SHOULD NOT: strong recommendation with documented exceptions;
- MAY: optional behavior.
Implementation constraints
Reference implementation target: Zig.
Keep the trusted computing base small:
- verifier;
- AIR interpreter semantics;
- backend;
- unsafe runtime modules;
- ABI/platform descriptions.
Prefer verifier-visible primitives over opaque library magic.
Changes to memory or concurrency
Any change involving ownership, aliasing, atomics, tasks, cancellation, resource lifetime, FFI or unsafe code MUST include:
- invariant being preserved;
- verifier rule;
- runtime rule if any;
- at least one valid example;
- at least one rejected example;
- diagnostic/error code impact;
- deterministic interpreter behavior;
- backward-compatibility impact.
Changes to AIR
AIR instructions must have explicit:
- operand types;
- result types;
- ownership effects;
- memory effects;
- concurrency effects;
- capability/effect requirements;
- trap behavior;
- verifier transfer function.
Do not add an AIR instruction solely as syntax sugar.
Commands
zig build # build ./zig-out/bin/aji
zig build test # unit tests; fails if src/diag.zig drifts from docs/reference/error-codes.md
zig build conformance # tests/conformance; add `-- --json` for machine-readable results
zig fmt --check build.zig build.zig.zon src tools
Toolchain: Zig 0.17.0. Workflow, layout and definition of done: CONTRIBUTING.md. Implementation plan and current phase: docs/plan/README.md. Documentation layout and where new documents go: docs/README.md. Unresolved spec gaps: docs/design/open-questions.md — log new ones there instead of guessing.
aji CLI output contract: diagnostics are JSON Lines on stdout, human notes on stderr; exit codes 0 accepted/returned, 1 rejected, 2 usage/I/O error, 3 not yet implemented, 4 trapped, 5 execution limit exceeded, 6 not instantiated. aji run [--fuel N] [--grant P=KIND[:SCOPE]]… prints one JSON run record; capabilities reach a program only as named @main parameters. aji features reports the supported AIR format, language version and features; query it before generating AIR. Never use wall-clock timeouts to end runs or tests; use fuel (spec 11 §7).
Testing policy
Every verifier rule should have:
- positive conformance test;
- negative conformance test;
- stable diagnostic code;
- interpreter test if observable at runtime.
Concurrency features additionally need deterministic scheduler tests and randomized schedule stress tests.