docs: reorganize documentation layout
- docs/roadmap/ -> docs/plan/ (implementation-plan.md becomes plan/README.md) - docs/reference/design-decisions.md -> docs/design/decisions.md (+ DD-008..010) - SPEC.md and docs/spec/INDEX.md merged into docs/spec/README.md - new docs/design/open-questions.md: spec gaps found so far (Q-001..Q-018) - new docs/dev/architecture.md and docs/dev/testing.md - docs/README.md: layout, precedence, where new documents go - update links in README, AGENTS, CONTRIBUTING, sources and test docs
This commit is contained in:
1 parent
17a55a7fef
commit
4e4d753090
17 files changed
+384
-95
No files matched your search
@@ -128,7 +128,7 @@ zig build conformance # tests/conformance; add `-- --json` for machine-re
|
||||
zig fmt --check build.zig build.zig.zon src tools
|
||||
```
|
||||
|
||||
Toolchain: Zig 0.17.0. Workflow, layout and definition of done: `CONTRIBUTING.md`. Current phase task list: `docs/roadmap/phase-0.md`.
|
||||
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, 1 rejected, 2 usage/I/O error, 3 not yet implemented.
|
||||
|
||||
|
||||
+4
-2
@@ -24,7 +24,9 @@ CI runs `zig fmt --check`, `zig build test` and `zig build conformance` on every
|
||||
docs/spec/ normative specification
|
||||
docs/rfcs/ design RFCs (template: 0000-template.md)
|
||||
docs/reference/ grammar, error codes, intrinsics, glossary
|
||||
docs/roadmap/ implementation plan, phase task breakdowns
|
||||
docs/design/ design decisions log, open questions
|
||||
docs/plan/ implementation plan, phase task breakdowns
|
||||
docs/dev/ implementation architecture, testing guide
|
||||
src/ reference implementation (Zig)
|
||||
root.zig library root
|
||||
diag.zig diagnostic envelope + error-code registry
|
||||
@@ -42,7 +44,7 @@ Everything under `src/` except `main.zig` is part of the trusted computing base
|
||||
|
||||
## Workflow for a change
|
||||
|
||||
1. **Find the governing text.** Precedence: accepted RFCs → `docs/spec/` → `docs/reference/` → examples → README.
|
||||
1. **Find the governing text.** Precedence: accepted RFCs → `docs/spec/` → `docs/reference/` → examples → README. If the spec does not answer the question, add a `Q-NNN` entry to `docs/design/open-questions.md` and resolve it in the spec before relying on an answer.
|
||||
2. **Spec first.** If the behavior is not specified, change the spec (or write an RFC for major changes) before code. Never let the implementation define semantics silently.
|
||||
3. **Tests first.** Add conformance tests (`accept` and `reject`) for every verifier rule touched.
|
||||
4. **Implement.**
|
||||
|
||||
@@ -49,7 +49,9 @@ The central language ideas are:
|
||||
docs/spec/ Normative language specification
|
||||
docs/rfcs/ Major design RFCs and rationale
|
||||
docs/reference/ Grammar, error codes, intrinsics, glossary
|
||||
docs/roadmap/ Implementation and conformance plans
|
||||
docs/design/ Design decisions log, open questions
|
||||
docs/plan/ Implementation plan and per-phase task breakdowns
|
||||
docs/dev/ Reference implementation architecture and testing
|
||||
src/ Reference implementation (Zig): diagnostics, AIR, verifier, interpreter
|
||||
tools/ Conformance runner
|
||||
tests/ Conformance suite (.air accept/reject tests)
|
||||
@@ -68,16 +70,13 @@ zig build test # unit tests
|
||||
zig build conformance # conformance suite
|
||||
```
|
||||
|
||||
Current state: Phase 0 has not started. `aji check` reports every input as not yet decidable; see [`docs/roadmap/phase-0.md`](docs/roadmap/phase-0.md) for the task breakdown.
|
||||
Current state: Phase 0 has not started. `aji check` reports every input as not yet decidable. The plan is in [`docs/plan/README.md`](docs/plan/README.md).
|
||||
|
||||
Start with [`SPEC.md`](SPEC.md), then:
|
||||
## Where to start
|
||||
|
||||
1. `docs/spec/00-status-and-conformance.md`
|
||||
2. `docs/spec/01-language-overview.md`
|
||||
3. `docs/spec/03-memory-model.md`
|
||||
4. `docs/spec/04-concurrency-and-atomics.md`
|
||||
5. `docs/spec/07-air.md`
|
||||
6. `docs/spec/08-verifier.md`
|
||||
- The language: [`docs/spec/README.md`](docs/spec/README.md), then spec 00, 01, 03, 04, 07, 08.
|
||||
- All documentation and where new documents go: [`docs/README.md`](docs/README.md).
|
||||
- Implementation work: [`docs/plan/README.md`](docs/plan/README.md) and [`CONTRIBUTING.md`](CONTRIBUTING.md).
|
||||
|
||||
## Design thesis
|
||||
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
# Aji Specification 0.1 — Entry Point
|
||||
|
||||
This repository intentionally splits the language specification by semantic domain.
|
||||
|
||||
Normative specification: [`docs/spec/INDEX.md`](docs/spec/INDEX.md).
|
||||
|
||||
The most important documents are:
|
||||
|
||||
1. [`03-memory-model.md`](docs/spec/03-memory-model.md)
|
||||
2. [`04-concurrency-and-atomics.md`](docs/spec/04-concurrency-and-atomics.md)
|
||||
3. [`05-effects-and-capabilities.md`](docs/spec/05-effects-and-capabilities.md)
|
||||
4. [`07-air.md`](docs/spec/07-air.md)
|
||||
5. [`08-verifier.md`](docs/spec/08-verifier.md)
|
||||
6. [`11-determinism-and-replay.md`](docs/spec/11-determinism-and-replay.md)
|
||||
7. [`13-contracts-and-unsafe.md`](docs/spec/13-contracts-and-unsafe.md)
|
||||
|
||||
Major rationale documents are under [`docs/rfcs/`](docs/rfcs/).
|
||||
|
||||
The current draft's central semantic model is:
|
||||
|
||||
```text
|
||||
local value
|
||||
│
|
||||
├── ref<T> / mut<T> borrows
|
||||
│
|
||||
├── Own<T> per-object ownership
|
||||
│
|
||||
├── Region bulk lifetime
|
||||
│ │
|
||||
│ └── Island<T> closed movable mutable graph
|
||||
│ │
|
||||
│ └── freeze → Frozen<T>
|
||||
│
|
||||
└── synchronized sharing → Mutex/RwLock/Atomic/Channel
|
||||
```
|
||||
|
||||
Concurrency is deliberately ordered by preference:
|
||||
|
||||
```text
|
||||
ownership transfer
|
||||
→ shared immutable data
|
||||
→ synchronized shared state
|
||||
→ atomics
|
||||
→ unsafe raw concurrency
|
||||
```
|
||||
+38
-15
@@ -1,19 +1,42 @@
|
||||
# Documentation
|
||||
|
||||
- `spec/` contains the normative draft specification.
|
||||
- `rfcs/` contains proposed major design decisions and rationale.
|
||||
- `reference/` contains compact registries and lookup material.
|
||||
- `roadmap/` contains implementation and conformance plans, including per-phase task breakdowns (`roadmap/phase-0.md`).
|
||||
- `rfcs/0000-template.md` is the template for new RFCs.
|
||||
## Layout
|
||||
|
||||
Suggested reading order:
|
||||
| Directory | Kind | Purpose |
|
||||
|---|---|---|
|
||||
| [`spec/`](spec/) | **Normative** | What a conforming implementation MUST do |
|
||||
| [`rfcs/`](rfcs/) | Normative once Accepted | Major design proposals with rationale |
|
||||
| [`reference/`](reference/) | Normative registries | Grammar, error codes, intrinsics, type properties, litmus tests, glossary |
|
||||
| [`design/`](design/) | Non-normative | Short design decisions and the open-questions log |
|
||||
| [`plan/`](plan/) | Non-normative | Implementation plan, per-phase task breakdowns, conformance plan |
|
||||
| [`dev/`](dev/) | Non-normative | How the reference implementation is built and tested |
|
||||
|
||||
```text
|
||||
spec/00-status-and-conformance.md
|
||||
spec/01-language-overview.md
|
||||
spec/03-memory-model.md
|
||||
spec/04-concurrency-and-atomics.md
|
||||
spec/07-air.md
|
||||
spec/08-verifier.md
|
||||
spec/13-contracts-and-unsafe.md
|
||||
```
|
||||
## Precedence
|
||||
|
||||
When documents disagree (from `AGENTS.md`):
|
||||
|
||||
1. accepted RFCs;
|
||||
2. `spec/`;
|
||||
3. `reference/`;
|
||||
4. examples;
|
||||
5. README prose.
|
||||
|
||||
`design/`, `plan/` and `dev/` never override the above. If a plan or dev document contradicts the spec, the plan or dev document is wrong.
|
||||
|
||||
## Where to put a new document
|
||||
|
||||
| You are writing… | Put it in |
|
||||
|---|---|
|
||||
| a MUST/SHOULD rule | the matching `spec/NN-*.md` |
|
||||
| a major change to memory, concurrency, effects, AIR or unsafe | `rfcs/NNNN-title.md` from `rfcs/0000-template.md` |
|
||||
| a new error code, intrinsic or grammar rule | `reference/` (and `src/diag.zig` for codes) |
|
||||
| a small decision with a one-paragraph reason | `design/decisions.md` as the next `DD-NNN` |
|
||||
| a gap or ambiguity you found but cannot resolve now | `design/open-questions.md` as the next `Q-NNN` |
|
||||
| tasks, milestones, sequencing | `plan/` |
|
||||
| implementation architecture, conventions, test how-to | `dev/` |
|
||||
|
||||
## Reading order
|
||||
|
||||
New to Aji: [`../README.md`](../README.md) → [`spec/README.md`](spec/README.md) → spec 00, 01, 03, 04, 07, 08, 13.
|
||||
|
||||
Starting implementation work: [`plan/README.md`](plan/README.md) → the current phase file → [`dev/architecture.md`](dev/architecture.md) → [`dev/testing.md`](dev/testing.md).
|
||||
@@ -39,3 +39,21 @@ 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, 1 rejected, 2 usage/I/O, 3 not yet implemented).
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,102 @@
|
||||
# Open Questions
|
||||
|
||||
Non-normative log of gaps and ambiguities in the draft spec. Each entry names the phase that is blocked until it is answered. Close an entry by changing the spec (or accepting an RFC) and recording the resolution here; do not delete entries.
|
||||
|
||||
Status values: `open`, `resolved`.
|
||||
|
||||
| ID | Status | Blocks | Question |
|
||||
|---|---|---|---|
|
||||
| Q-001 | open | P0 | Text AIR grammar |
|
||||
| Q-002 | open | P0 | Instruction contract tables |
|
||||
| Q-003 | open | P0 | Diagnostic codes for parse errors |
|
||||
| Q-004 | open | P0 | Observable trap semantics |
|
||||
| Q-005 | open | P0 | Verifier resource budget values |
|
||||
| Q-006 | open | P0 | Target description for `usize` and layout in the interpreter |
|
||||
| Q-007 | open | P0 | Integer edge cases besides overflow |
|
||||
| Q-008 | open | P0 | How `hello` writes output before capabilities exist |
|
||||
| Q-009 | open | P1 | Borrow lifetimes in AIR |
|
||||
| Q-010 | open | P1 | Region generation checks: static, dynamic, or both |
|
||||
| Q-011 | open | P2 | Effect hierarchy and discharge |
|
||||
| Q-012 | open | P2 | Capability representation and host instantiation |
|
||||
| Q-013 | open | P3 | Deterministic `select` rule and scheduler seed |
|
||||
| Q-014 | open | P3 | `Send`/`Share` derivation for aggregates holding capabilities |
|
||||
| Q-015 | open | P5 | Operational weak-memory model for the interpreter |
|
||||
| Q-016 | open | P0 | Floating-point determinism |
|
||||
| Q-017 | open | P5 | Replay file format |
|
||||
| Q-018 | open | P2 | Runtime diagnostics (traps) vs verifier diagnostics |
|
||||
|
||||
## Q-001 — Text AIR grammar
|
||||
|
||||
Spec 07 shows illustrative AIR but no grammar. Undecided: comment syntax; constant spelling (`const.u64 0`?); type suffix convention on opcodes (`add.checked.u64` vs typed operands); module header and version/feature-bit declaration (spec 00 §5 requires them); how types, structs and enums are declared; canonical whitespace for the serializer.
|
||||
|
||||
Proposed home: `docs/reference/air-text.ebnf` plus normative text in spec 07.
|
||||
|
||||
## Q-002 — Instruction contract tables
|
||||
|
||||
Spec 07 §4 and RFC 0004 require per-opcode contracts (operands, results, ownership/borrow transition, memory set, sync, effects, capabilities, traps, transfer function, interpreter behavior). None are written. Each phase must write the contracts for the opcodes it introduces before implementing them.
|
||||
|
||||
Proposed home: a normative `docs/spec/07-air.md` appendix or `docs/spec/air/` per instruction family.
|
||||
|
||||
## Q-003 — Diagnostic codes for parse errors
|
||||
|
||||
The registry has no codes for malformed AIR text. Options: a new `E0xxx` range for syntax, or `E50xx` under AIR/verifier.
|
||||
|
||||
## Q-004 — Observable trap semantics
|
||||
|
||||
Spec 01 §6 defines a trap as termination "according to runtime policy". The interpreter needs: trap kinds (overflow, assert, bounds, explicit, …), how a trap is reported (exit status, structured record), and whether the trap location is observable.
|
||||
|
||||
## Q-005 — Verifier resource budget values
|
||||
|
||||
Spec 08 §7 says budgets are "configured/spec-defined". A user-configurable budget would let a flag change which programs are accepted, which conflicts with "no compiler flags that change language semantics". Proposal: fixed spec-defined budgets per profile, reported in `E5101`.
|
||||
|
||||
## Q-006 — Target description in the interpreter
|
||||
|
||||
`usize`/`isize` match the target pointer width (spec 02 §1) and struct layout is implementation-defined (spec 02 §7). For determinism the interpreter must run against an explicit target description. Undecided: format, default, and whether it is part of the AIR module (spec 00 §5 "optional target requirements").
|
||||
|
||||
## Q-007 — Integer edge cases besides overflow
|
||||
|
||||
Unspecified: division and remainder by zero; signed `MIN / -1`; shift amounts ≥ bit width; signed right shift; casts between widths and signedness (spec 01 §2 forbids implicit conversion but explicit cast semantics are absent).
|
||||
|
||||
## Q-008 — `hello` before capabilities
|
||||
|
||||
Phase 0's exit criterion runs AIR `hello`, but `io.stdout_write` needs `cap<io.write>` (Phase 2). Options: bring a minimal `io.write` capability and intrinsic into Phase 0, or define Phase 0 `hello` as a function whose return value the test harness checks.
|
||||
|
||||
## Q-009 — Borrow lifetimes in AIR
|
||||
|
||||
Spec 03 §4 shows `'a` lifetimes in source; AIR has `borrow.ref`/`borrow.end` but no notation for lifetime relationships across function signatures. Undecided: explicit lifetime parameters in AIR signatures vs scope-based borrows only.
|
||||
|
||||
## Q-010 — Region generation checks
|
||||
|
||||
Spec 03 §8.1 allows removing generation checks "when statically proven unnecessary", implying a dynamic check otherwise; `E2104` implies static rejection. Undecided: which cases are static errors, which compile to runtime checks, and what the runtime failure is.
|
||||
|
||||
## Q-011 — Effect hierarchy and discharge
|
||||
|
||||
Spec 05 §2 lists effects such as `atomic` and `atomic.weak`, `io.write` and `fs.write`. Undecided: whether effects form a hierarchy (does `atomic` cover `atomic.weak`?), and what a "verifier-recognized boundary" that discharges an effect is.
|
||||
|
||||
## Q-012 — Capability representation and host instantiation
|
||||
|
||||
Binary AIR has a `CAPABILITY_TABLE` (spec 07 §6). Undecided: how capabilities appear in text AIR, how an entry point declares the capabilities it needs, how the host/interpreter grants them, and how narrowing (spec 05 §4) is expressed.
|
||||
|
||||
## Q-013 — Deterministic `select` and scheduler seed
|
||||
|
||||
Spec 04 §14 and spec 11 §6 require a stable rule in deterministic mode but do not define it. Also undecided: scheduler seed format and which choice points are recorded.
|
||||
|
||||
## Q-014 — `Send`/`Share` for aggregates holding capabilities
|
||||
|
||||
Spec 02 §6 derives properties structurally; spec 05 §5 says capability types define their own transfer rules. Undecided: the derivation for a struct mixing ordinary fields with `Local` or move-only capabilities.
|
||||
|
||||
## Q-015 — Operational weak-memory model
|
||||
|
||||
The SB litmus test requires the interpreter not to forbid `r1=0, r2=0` under relaxed ordering. Undecided: which executable model to use (store buffers, a promising-style semantics, or an axiomatic checker over recorded executions) and how much of C11's model to adopt.
|
||||
|
||||
## Q-016 — Floating-point determinism
|
||||
|
||||
`f32`/`f64` exist (spec 02 §1) with no rules on NaN payloads, fused operations, rounding mode or denormals. Deterministic replay requires these to be fixed.
|
||||
|
||||
## Q-017 — Replay file format
|
||||
|
||||
Spec 11 §4 mentions `.ajr` files without a format or compatibility rule.
|
||||
|
||||
## Q-018 — Runtime diagnostics
|
||||
|
||||
The error registry covers verifier/compiler errors. Traps and runtime check failures (bounds, generation, overflow) need stable machine-readable records too, either in the same registry (e.g. `R` codes) or a separate one.
|
||||
@@ -0,0 +1,101 @@
|
||||
# Reference Implementation Architecture
|
||||
|
||||
Non-normative. Describes how the Zig reference implementation is organised. The spec defines behavior; this file defines where code goes.
|
||||
|
||||
## Pipeline
|
||||
|
||||
```text
|
||||
.aji source text AIR (.air)
|
||||
│ │
|
||||
frontend: lex → parse → lower (P6) │
|
||||
│ │
|
||||
└──────────────► AIR module ◄────────┘
|
||||
│ air: parse / print / (binary, later)
|
||||
▼
|
||||
verifier passes in spec 08 order
|
||||
│
|
||||
┌───────────────┼───────────────┐
|
||||
▼ ▼ ▼
|
||||
interpreter audit reports LLVM backend (P7)
|
||||
(+ det. scheduler, (unsafe, effects,
|
||||
trace, replay) capabilities)
|
||||
```
|
||||
|
||||
Nothing executes or lowers unverified safe AIR (spec 07 §7). `check.zig` is the single front door used by the CLI, the conformance runner and later `ajid`.
|
||||
|
||||
## Source layout
|
||||
|
||||
Current files are marked ✓; the rest is the planned layout. Split a file into a directory when it passes roughly 1 000 lines or gains a second responsibility.
|
||||
|
||||
```text
|
||||
src/
|
||||
root.zig ✓ library root, re-exports
|
||||
main.zig ✓ `aji` CLI
|
||||
check.zig ✓ parse → verify front door
|
||||
diag.zig ✓ diagnostic envelope, error-code registry
|
||||
air.zig ✓ (stub) → air/
|
||||
air/
|
||||
types.zig type table, primitive and composite types
|
||||
module.zig module, function, block, instruction, value ids
|
||||
ops.zig opcode enum + per-opcode metadata (from contract tables)
|
||||
parse.zig text AIR lexer and parser
|
||||
print.zig canonical text serializer
|
||||
binary.zig binary AIR (after opcode freeze, RFC 0004)
|
||||
verifier.zig ✓ (stub) → verifier/
|
||||
verifier/
|
||||
cfg.zig ssa.zig types.zig init.zig
|
||||
ownership.zig borrow.zig region.zig island.zig
|
||||
resource.zig effects.zig caps.zig
|
||||
send_share.zig tasks.zig atomics.zig
|
||||
bounds.zig unsafe.zig
|
||||
budget.zig deterministic resource budget (E5101)
|
||||
interp.zig ✓ (stub) → interp/
|
||||
interp/
|
||||
machine.zig values, frames, instruction dispatch
|
||||
memory.zig heap, regions, islands, provenance, generations
|
||||
sched.zig deterministic scheduler, seeds, choice recording
|
||||
weak.zig weak-memory model for atomics (P5)
|
||||
trace.zig replay.zig
|
||||
runtime/ intrinsics: io, fs, net, clock, random (capability-gated)
|
||||
frontend/ .aji lexer, parser, lowering, formatter (P6)
|
||||
backend/llvm/ AIR → LLVM IR (P7)
|
||||
report/ audit artifacts: unsafe, effects, capabilities, contracts
|
||||
ajid/ long-running agent protocol server (P8)
|
||||
tools/
|
||||
conformance.zig ✓ conformance runner
|
||||
tests/
|
||||
conformance/ ✓ .air accept/reject (and later run) tests
|
||||
```
|
||||
|
||||
## Trusted computing base
|
||||
|
||||
From `AGENTS.md`: verifier, AIR interpreter semantics, backend, unsafe runtime modules, ABI/platform descriptions. In this tree that is `air/`, `verifier/`, `interp/`, `runtime/`, `backend/`. The frontend, CLI, `ajid` and report generators are outside the TCB: a frontend bug can produce wrong AIR, but the verifier still rejects unsafe AIR.
|
||||
|
||||
Rules for TCB code:
|
||||
|
||||
- no heuristics in the verifier: every rejection maps to a spec rule and a registry code;
|
||||
- no dependency outside the Zig standard library;
|
||||
- every verifier pass is a pure function of the AIR module and the target description;
|
||||
- the interpreter never relies on host undefined behavior to implement Aji semantics.
|
||||
|
||||
## Determinism rules
|
||||
|
||||
These hold for the whole toolchain, not only deterministic mode:
|
||||
|
||||
- iteration over hash maps never affects output; sort before emitting;
|
||||
- diagnostics are emitted in a defined order (by source position, then code);
|
||||
- no wall-clock time, randomness or environment variables influence verification or diagnostics;
|
||||
- the interpreter's sources of nondeterminism (scheduling, clock, random, I/O ordering) go through `interp/sched.zig` so they can be seeded and recorded.
|
||||
|
||||
## Memory management in the implementation
|
||||
|
||||
- Per-compilation arena for AIR and verifier state; free it as a whole.
|
||||
- `std.testing.allocator` in unit tests to catch leaks.
|
||||
- No global mutable state; pass allocators and `std.Io` explicitly.
|
||||
|
||||
## Zig conventions
|
||||
|
||||
- Zig 0.17.0, formatted with `zig fmt`.
|
||||
- Errors that are Aji diagnostics are values (`diag.Diagnostic`), not Zig errors. Zig errors are reserved for I/O failure and out-of-memory.
|
||||
- Unit tests live next to the code (`test` blocks); behavior visible to users is tested through `tests/conformance`.
|
||||
- Doc comments (`//!`, `///`) cite the spec section they implement, e.g. `// spec 03 §8.2`.
|
||||
@@ -0,0 +1,45 @@
|
||||
# Testing
|
||||
|
||||
Non-normative. How the reference implementation is tested. Policy (what must be tested) is in `AGENTS.md`; this file covers the mechanics.
|
||||
|
||||
## Test levels
|
||||
|
||||
| Level | Where | Run | Purpose |
|
||||
|---|---|---|---|
|
||||
| Unit | `test` blocks in `src/`, `tools/` | `zig build test` | internal data structures, helpers, registry ↔ docs sync |
|
||||
| Conformance | `tests/conformance/` | `zig build conformance` | spec behavior: accept/reject, later run output and traps |
|
||||
| Reference programs | `tests/programs/` (from P2) | `zig build conformance` | the six programs in `plan/conformance-suite.md` |
|
||||
| Litmus | `tests/litmus/` (from P5) | `zig build litmus` | memory-model outcomes allowed/forbidden |
|
||||
| Schedule stress | via runner flags (from P3) | `zig build conformance -- --schedules=N` | randomized and systematic interleavings |
|
||||
| Native parity | (from P7) | `zig build parity` | interpreter and native backend agree on the whole corpus |
|
||||
|
||||
Only unit and conformance exist today.
|
||||
|
||||
## Conformance tests
|
||||
|
||||
Format and outcomes: [`tests/conformance/README.md`](../../tests/conformance/README.md).
|
||||
|
||||
Adding a verifier rule:
|
||||
|
||||
1. Write the rule in the spec, with its code in `docs/reference/error-codes.md` and `src/diag.zig`.
|
||||
2. Add the smallest `reject` test that violates only that rule.
|
||||
3. Add an `accept` test that is as close as possible to the reject test but legal. The pair documents exactly where the boundary is.
|
||||
4. Implement until both pass.
|
||||
|
||||
Planned header extensions (added by the phase that needs them):
|
||||
|
||||
| Key | Phase | Meaning |
|
||||
|---|---|---|
|
||||
| `expect: run` | P0 | module must verify and run |
|
||||
| `stdout:` | P0 | expected output, `\n`-escaped |
|
||||
| `trap:` | P0 | expected trap kind (Q-004) |
|
||||
| `seed:` / `schedules:` | P3 | deterministic scheduler seed / number of randomized schedules |
|
||||
| `profile:` | P2 | runtime profile (`hosted`, `deterministic`, …) |
|
||||
|
||||
## Determinism checks
|
||||
|
||||
Every run test is executed twice by the runner from P0-10 onward and the outputs (stdout, trap record, trace hash) compared byte-for-byte. Concurrency tests additionally run under the stress modes listed in `plan/conformance-suite.md`.
|
||||
|
||||
## Diagnostics as API
|
||||
|
||||
Diagnostic JSON is a stable interface. Snapshot tests on the full JSON (not only the code) belong in unit tests next to the pass that emits them, so field renames are caught.
|
||||
File renamed without changes.
File renamed without changes.
@@ -1,6 +1,6 @@
|
||||
# Phase 0 — Semantic skeleton: task breakdown
|
||||
|
||||
Non-normative. Breaks Phase 0 of `implementation-plan.md` into tasks small enough for one agent session each.
|
||||
Non-normative. Breaks Phase 0 of [`README.md`](README.md) into tasks small enough for one agent session each.
|
||||
|
||||
Exit criterion (from the plan): AIR `hello` and arithmetic tests execute identically across runs.
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
# Aji Specification Index
|
||||
|
||||
| File | Status | Topic |
|
||||
|---|---|---|
|
||||
| 00-status-and-conformance.md | Normative draft | Conformance, safety, profiles |
|
||||
| 01-language-overview.md | Normative draft | Language shape and control flow |
|
||||
| 02-types-and-values.md | Normative draft | Primitive/composite types, properties |
|
||||
| 03-memory-model.md | Normative draft | Ownership, regions, islands, frozen graphs |
|
||||
| 04-concurrency-and-atomics.md | Normative draft | Tasks, synchronization, memory model, atomics |
|
||||
| 05-effects-and-capabilities.md | Normative draft | Authority and effect tracking |
|
||||
| 06-resources-and-errors.md | Normative draft | Linear resources and error handling |
|
||||
| 07-air.md | Normative draft | Canonical IR |
|
||||
| 08-verifier.md | Normative draft | Verification rules |
|
||||
| 09-runtime-and-abi.md | Normative draft | Runtime, FFI, MMIO/DMA |
|
||||
| 10-diagnostics-and-agent-protocol.md | Normative draft | Stable diagnostics and ajid |
|
||||
| 11-determinism-and-replay.md | Normative draft | Deterministic testing/replay |
|
||||
| 12-packages-and-build.md | Normative draft | Manifest/build model |
|
||||
| 13-contracts-and-unsafe.md | Normative draft | Contracts, proof status and unsafe boundaries |
|
||||
@@ -0,0 +1,62 @@
|
||||
# Aji Specification 0.1
|
||||
|
||||
Status: **Draft 0.1**. Normative unless an accepted RFC says otherwise (see precedence in [`../README.md`](../README.md)).
|
||||
|
||||
The specification is split by semantic domain. Rationale for major decisions lives in [`../rfcs/`](../rfcs/); short decisions in [`../design/decisions.md`](../design/decisions.md).
|
||||
|
||||
## Files
|
||||
|
||||
| File | Status | Topic |
|
||||
|---|---|---|
|
||||
| [00-status-and-conformance.md](00-status-and-conformance.md) | Normative draft | Conformance, safety, profiles |
|
||||
| [01-language-overview.md](01-language-overview.md) | Normative draft | Language shape and control flow |
|
||||
| [02-types-and-values.md](02-types-and-values.md) | Normative draft | Primitive/composite types, properties |
|
||||
| [03-memory-model.md](03-memory-model.md) | Normative draft | Ownership, regions, islands, frozen graphs |
|
||||
| [04-concurrency-and-atomics.md](04-concurrency-and-atomics.md) | Normative draft | Tasks, synchronization, memory model, atomics |
|
||||
| [05-effects-and-capabilities.md](05-effects-and-capabilities.md) | Normative draft | Authority and effect tracking |
|
||||
| [06-resources-and-errors.md](06-resources-and-errors.md) | Normative draft | Linear resources and error handling |
|
||||
| [07-air.md](07-air.md) | Normative draft | Canonical IR |
|
||||
| [08-verifier.md](08-verifier.md) | Normative draft | Verification rules |
|
||||
| [09-runtime-and-abi.md](09-runtime-and-abi.md) | Normative draft | Runtime, FFI, MMIO/DMA |
|
||||
| [10-diagnostics-and-agent-protocol.md](10-diagnostics-and-agent-protocol.md) | Normative draft | Stable diagnostics and `ajid` |
|
||||
| [11-determinism-and-replay.md](11-determinism-and-replay.md) | Normative draft | Deterministic testing/replay |
|
||||
| [12-packages-and-build.md](12-packages-and-build.md) | Normative draft | Manifest/build model |
|
||||
| [13-contracts-and-unsafe.md](13-contracts-and-unsafe.md) | Normative draft | Contracts, proof status and unsafe boundaries |
|
||||
|
||||
## Reading order
|
||||
|
||||
Implementers: 00 → 01 → 03 → 04 → 07 → 08 → 13. The most consequential files are 03, 04, 05, 07, 08, 11 and 13.
|
||||
|
||||
## Central semantic model
|
||||
|
||||
```text
|
||||
local value
|
||||
│
|
||||
├── ref<T> / mut<T> borrows
|
||||
│
|
||||
├── Own<T> per-object ownership
|
||||
│
|
||||
├── Region bulk lifetime
|
||||
│ │
|
||||
│ └── Island<T> closed movable mutable graph
|
||||
│ │
|
||||
│ └── freeze → Frozen<T>
|
||||
│
|
||||
└── synchronized sharing → Mutex/RwLock/Atomic/Channel
|
||||
```
|
||||
|
||||
Concurrency is deliberately ordered by preference:
|
||||
|
||||
```text
|
||||
ownership transfer
|
||||
→ shared immutable data
|
||||
→ synchronized shared state
|
||||
→ atomics
|
||||
→ unsafe raw concurrency
|
||||
```
|
||||
|
||||
## Changing the spec
|
||||
|
||||
- Small clarifications and gap fills: edit the file directly, in the same change as the tests that exercise them.
|
||||
- Changes to memory safety, concurrency, effects/capabilities, AIR or unsafe semantics: write an RFC first ([`../rfcs/0000-template.md`](../rfcs/0000-template.md)).
|
||||
- Known gaps are tracked in [`../design/open-questions.md`](../design/open-questions.md). Close the entry when the spec answers it.
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
//! AIR — Aji Intermediate Representation (spec 07, RFC 0004).
|
||||
//!
|
||||
//! Phase 0 deliverables (docs/roadmap/phase-0.md):
|
||||
//! Phase 0 deliverables (docs/plan/phase-0-semantic-skeleton.md):
|
||||
//! - type and value model;
|
||||
//! - text AIR lexer, parser and canonical serializer;
|
||||
//! - functions, basic blocks with block parameters, terminators.
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
//! AIR verifier (spec 08). Part of the language semantics, not a lint.
|
||||
//!
|
||||
//! Passes are added in roadmap order. Each normative rejection MUST map to a
|
||||
//! Passes are added in plan order (docs/plan/README.md). Each normative rejection MUST map to a
|
||||
//! code in `diag.registry` and MUST have positive and negative conformance
|
||||
//! tests under tests/conformance/.
|
||||
//!
|
||||
|
||||
@@ -10,7 +10,7 @@ tests/conformance/
|
||||
phase<N>/reject/*.air modules a conforming verifier MUST reject
|
||||
```
|
||||
|
||||
`phase<N>` is the roadmap phase (`docs/roadmap/implementation-plan.md`) that first requires the test to pass.
|
||||
`phase<N>` is the implementation phase (`docs/plan/README.md`) that first requires the test to pass.
|
||||
|
||||
## Test header
|
||||
|
||||
@@ -19,7 +19,7 @@ Every test starts with a block of `;` lines. Keys:
|
||||
| Key | Required | Value |
|
||||
|---|---|---|
|
||||
| `expect` | yes | `accept`, or `reject` followed by one or more codes from `docs/reference/error-codes.md` |
|
||||
| `phase` | yes | roadmap phase number |
|
||||
| `phase` | yes | implementation phase number |
|
||||
| `spec` | yes | spec section that justifies the expectation |
|
||||
|
||||
Header lines without a `key:` are free-form description. The runner blanks the header before handing the module to the pipeline, so line numbers in diagnostics are unchanged and the AIR grammar does not need to know about test metadata.
|
||||
|
||||
Reference in new issue
Block a user