Files
aji/docs/design/decisions.md
T
dev 1f5008bb37 interp: deterministic interpreter, aji run, run tests (P0-11, P0-12)
- src/interp/machine.zig: format-0 interpreter on the air64 target;
  checked/wrapping arithmetic, shifts, casts, aggregates, calls with a
  1024-frame limit, traps as records with T0xxx codes
- aji run: prints one JSON run record; exit code 4 on trap
- conformance runner: `expect: run` with `result:`/`trap:`, every run
  executed twice and compared byte-for-byte; header keys must be single
  lowercase words
- Phase 0 corpus: 3 accept, 19 reject, 15 run tests (41 total)
2026-10-04 12:28:27 +03:00

2.3 KiB

Design Decisions

This file records short decisions whose rationale does not yet justify a standalone RFC.

DD-001 — Checked arithmetic by default

Normal integer arithmetic traps on overflow. Wrapping/saturating arithmetic is explicit.

Reason: release/debug behavior must not diverge, and arithmetic assumptions should remain visible to agents/verifier.

DD-002 — No exceptions

Errors are values. No stack unwinding.

Reason: explicit CFG and resource cleanup are easier to verify and replay.

DD-003 — No hidden destructors

Cleanup constructs lower to explicit AIR edges.

Reason: hidden control flow harms auditability and agent repair.

DD-004 — Bounded channels by default

Unbounded queues require explicit library choice.

Reason: memory growth must not be implicit.

DD-005 — No default atomic ordering

Every atomic operation states its order.

Reason: the compiler must not hide one of the most consequential concurrency choices.

DD-006 — No arbitrary safe atomic pointer type initially

Reason: reclamation cannot be separated from safe publication.

DD-007 — Interpreter before optimizer/backend

Reason: executable semantics and verifier behavior must stabilize before native-code complexity is introduced.

DD-008 — Reference implementation pins one exact Zig version

The toolchain version is pinned in build.zig.zon and mise.toml (currently 0.17.0) and upgraded deliberately in a dedicated change.

Reason: Zig's standard library changes between minor versions; an unpinned toolchain makes builds non-reproducible (spec 12 §2).

DD-009 — CLI diagnostics are JSON Lines on stdout

aji writes one JSON diagnostic per line on stdout, human notes on stderr, and uses fixed exit codes (0 accepted or returned, 1 rejected, 2 usage/I/O, 3 not yet implemented, 4 trapped).

Reason: agents consume diagnostics programmatically (spec 10); mixing prose into the machine channel breaks repair loops.

DD-010 — Conformance tests are text AIR with a metadata header

Tests live in tests/conformance/phase<N>/{accept,reject}/ with expect/phase/spec header lines that the runner strips before parsing.

Reason: AIR is the conformance format (spec 07 §1), and keeping metadata out of the AIR grammar lets the grammar evolve independently of the test harness.