plan: Phase 0 exit review (P0-13)

- all Phase 0 tasks done; exit criterion met (41 conformance tests,
  run records compared across two runs)
- RFC 0004 Amendment 1 documents format-0 additions; status stays
  Proposed pending owner acceptance
- open question Q-019: non-terminating programs in test tooling
- README/CONTRIBUTING: current state and `aji run`
This commit is contained in:
dev committed 2026-10-04 12:33:17 +03:00
1 parent 8ca93d0fa6
commit c7c5e4f521
6 files changed
+49 -14

No files matched your search

+2 -1
View File
@@ -12,7 +12,8 @@ Read `AGENTS.md` first. It holds the non-negotiable principles and the checklist
zig build # build ./zig-out/bin/aji
zig build test # unit tests (includes registry ↔ docs sync check)
zig build conformance # conformance suite, see tests/conformance/README.md
zig build run -- check f.air # run the CLI
zig build run -- check f.air # verify a text AIR module
zig build run -- run f.air # verify and execute @main
zig fmt --check build.zig src tools
```
+6 -1
View File
@@ -70,7 +70,12 @@ 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. The plan is in [`docs/plan/README.md`](docs/plan/README.md).
Current state: Phase 0 (semantic skeleton) is complete. `aji check` parses and verifies text AIR format 0, and `aji run` executes it deterministically. Phase 1 (ownership and memory) is next; see [`docs/plan/README.md`](docs/plan/README.md).
```sh
zig build run -- run tests/conformance/phase0/run/fibonacci.air
# {"status":"returned","value":2880067194370816120}
```
## Where to start
+5
View File
@@ -24,6 +24,7 @@ Status values: `open`, `resolved`.
| Q-016 | open | P0 | Floating-point determinism |
| Q-017 | open | P5 | Replay file format |
| Q-018 | resolved | P2 | Runtime diagnostics (traps) vs verifier diagnostics |
| Q-019 | open | P3 | Non-terminating programs in test tooling |
## Q-001 — Text AIR grammar
@@ -118,3 +119,7 @@ Spec 11 §4 mentions `.ajr` files without a format or compatibility rule.
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.
**Resolved (P0-2):** traps share the registry in a separate `T0xxx` range (`docs/reference/error-codes.md`).
## Q-019 — Non-terminating programs in test tooling
A program may legitimately loop forever, so the language cannot bound execution. The conformance runner and `ajid` still need a way to stop a run without making the outcome depend on wall-clock time. Options: a deterministic step budget that is a tooling parameter (reported as "budget exhausted", never as a language trap), or explicit `fuel:` in test headers. Must be decided before scheduler stress tests (P3), which multiply run counts.
+3 -2
View File
@@ -25,7 +25,7 @@ Non-normative. The order in which the Zig reference implementation is built, and
| Phase | File | Goal | Exit criterion | Blocking questions |
|---|---|---|---|---|
| P0 | [phase-0-semantic-skeleton.md](phase-0-semantic-skeleton.md) | AIR model, text parser, CFG/SSA/type verifier, interpreter | AIR `hello` and arithmetic tests execute identically across runs | Q-001…Q-008, Q-016 |
| P0 | done (exit review in phase file) | AIR model, text parser, CFG/SSA/type verifier, interpreter | AIR `hello` and arithmetic tests execute identically across runs | Q-001…Q-008, Q-016 |
| P1 | [phase-1-ownership-and-memory.md](phase-1-ownership-and-memory.md) | `Own`, borrows, slices, init tracking, regions, bounds | file-copy core implemented; UAF/alias/OOB rejected | Q-009, Q-010 |
| P2 | [phase-2-effects-capabilities-resources.md](phase-2-effects-capabilities-resources.md) | Effects, capabilities, linear resources, runtime intrinsics | safe file-copy and basic TCP echo | Q-011, Q-012, Q-018 |
| P3 | [phase-3-structured-concurrency.md](phase-3-structured-concurrency.md) | Task scopes, Send/Share, channels, mutex, cancellation, deterministic scheduler | parallel-map and channel ownership-transfer examples | Q-013, Q-014 |
@@ -94,4 +94,5 @@ These run through all phases rather than belonging to one.
| Phase | Status |
|---|---|
| P0 | in progress: spec gate (P0-1…P0-3) done |
| P1–P8 | not started |
| P1 | next |
| P2–P8 | not started |
+19 -10
View File
@@ -23,19 +23,28 @@ Out: floats (reserved until Q-016 is answered), fixed arrays (moved to P1 with s
| P0-1 | done | Specify text AIR grammar (Q-001) and parse-error codes (Q-003) | — | `docs/reference/air-text.ebnf`, spec 07, error-codes.md | grammar covers module header with version/feature bits, type declarations, functions, `effects`, blocks with parameters, instructions, comments; seed tests in `tests/conformance/phase0` conform to it |
| P0-2 | done | Specify traps (Q-004), integer edge cases and casts (Q-007), target description (Q-006), verifier budget (Q-005), `hello` strategy (Q-008) | — | spec 01, 02, 08, 11 | each question marked resolved in `open-questions.md` |
| P0-3 | done | Write contract tables for Phase 0 opcodes; add aggregate opcodes (struct/enum construct and access) if needed, via RFC 0004 amendment | P0-1 | spec 07 appendix | every in-scope opcode has all fields required by spec 07 §4 |
| P0-4 | todo | AIR data model | P0-1 | `src/air/{types,module,ops}.zig` | unit tests build the seed-test modules programmatically |
| P0-5 | todo | Text AIR lexer and parser | P0-4 | `src/air/parse.zig` | all seed tests parse; malformed input yields registered diagnostics with spans |
| P0-6 | todo | Canonical serializer | P0-4 | `src/air/print.zig` | `print(parse(x))` is a fixed point after one round; fuzz test on parser round-trip |
| P0-7 | todo | CFG verifier | P0-5 | `src/verifier/cfg.zig` | E5002 accept/reject tests pass (missing terminator, branch to unknown block, block-argument arity) |
| P0-8 | todo | SSA/dominance verifier | P0-7 | `src/verifier/ssa.zig` | E5001 accept/reject tests pass (undefined value, use not dominated, double definition) |
| P0-9 | todo | Type verifier | P0-5, P0-3 | `src/verifier/types.zig` | E1001 and E1002 accept/reject tests pass |
| P0-10 | todo | Deterministic verifier budget | P0-7 | `src/verifier/budget.zig` | E5101 test with an oversized module; budget value matches spec |
| P0-11 | todo | Interpreter core | P0-8, P0-9 | `src/interp/machine.zig` | arithmetic programs run; overflow, assert and explicit `trap` produce the trap records defined in P0-2 |
| P0-12 | todo | `aji run`; `expect: run` / `stdout:` / `trap:` in the conformance runner; double-run determinism check | P0-11 | `src/main.zig`, `tools/conformance.zig` | runner fails a test whose two runs differ |
| P0-13 | todo | Phase exit review | all | plan status, RFC 0004 status | `hello` and arithmetic suite pass; RFC 0004 marked Accepted; P0 status set to done |
| P0-4 | done | AIR data model | P0-1 | `src/air/{types,module,ops}.zig` | unit tests build the seed-test modules programmatically |
| P0-5 | done | Text AIR lexer and parser | P0-4 | `src/air/parse.zig` | all seed tests parse; malformed input yields registered diagnostics with spans |
| P0-6 | done | Canonical serializer | P0-4 | `src/air/print.zig` | `print(parse(x))` is a fixed point after one round; fuzz test on parser round-trip |
| P0-7 | done | CFG verifier | P0-5 | `src/verifier/cfg.zig` | E5002 accept/reject tests pass (missing terminator, branch to unknown block, block-argument arity) |
| P0-8 | done | SSA/dominance verifier | P0-7 | `src/verifier/ssa.zig` | E5001 accept/reject tests pass (undefined value, use not dominated, double definition) |
| P0-9 | done | Type verifier | P0-5, P0-3 | `src/verifier/types.zig` | E1001 and E1002 accept/reject tests pass |
| P0-10 | done | Deterministic verifier budget | P0-7 | `src/verifier/budget.zig` | E5101 test with an oversized module; budget value matches spec |
| P0-11 | done | Interpreter core | P0-8, P0-9 | `src/interp/machine.zig` | arithmetic programs run; overflow, assert and explicit `trap` produce the trap records defined in P0-2 |
| P0-12 | done | `aji run`; `expect: run` / `stdout:` / `trap:` in the conformance runner; double-run determinism check | P0-11 | `src/main.zig`, `tools/conformance.zig` | runner fails a test whose two runs differ |
| P0-13 | done | Phase exit review | all | plan status, RFC 0004 status | `hello` and arithmetic suite pass; RFC 0004 amended for format 0 (acceptance is an owner decision); P0 status set to done |
## Conformance tests to add
- accept: arithmetic on every integer width; loops via block parameters; `switch`; nested calls; recursion.
- reject: E5001 ×3, E5002 ×3, E1001 (operand, result, block argument, return), E1002.
- run: checked overflow traps; wrapping does not trap; division by zero (per Q-007); `hello`.
## Exit review
- Exit criterion met: `zig build conformance` runs 41 Phase 0 tests (3 accept, 19 reject, 15 run); every run test is executed twice and the run records compared byte-for-byte.
- Every code introduced in Phase 0 has a reject test: E0001–E0006, E1001–E1003, E5001, E5002, E5101; traps T0001–T0007 each have a run test.
- Parser and verifier survived 6 000 mutated corpus inputs through `aji check` and `aji run` without a crash (one crash found and fixed).
- RFC 0004 received Amendment 1 describing the format-0 additions; its status stays Proposed until the language owner accepts it.
- Deferred: interpreter memory grows with the number of calls and aggregates created, because everything lives in one arena per run. Acceptable for conformance tests; revisit with the Phase 1 memory model.
- New open question Q-019 (non-terminating programs in test tooling).
+14
View File
@@ -88,3 +88,17 @@ interpreter behavior
## Binary stability
AIR opcodes should receive stable numeric IDs only after the semantics of v0.1 freeze. Before then, text AIR is the safer canonical interchange for development.
## Amendment 1 — format version 0 (Phase 0)
Status: Proposed, implemented in the reference implementation.
Format version 0 (spec 07 §8, spec 07a) realizes the "pure values" and "control" families and adds the following, each a distinct verifier operation rather than syntax sugar:
| Addition | Why it is a distinct operation |
|---|---|
| `cast.widen` / `cast.checked` / `cast.wrap` | the three cast semantics differ in verifier obligations (static losslessness, runtime trap, none) |
| `struct.make`, `struct.get` | nominal aggregate construction and projection need their own typing rules |
| `enum.make`, `enum.switch` | tagged unions: exhaustiveness is checked by the CFG pass and payloads bind to block parameters, so no separate "get payload" instruction can observe an inactive variant |
Not yet realized: memory, ownership, resources, calls through values (`call.indirect`) and concurrency families; they arrive with their phases and are specified in spec 07a first.