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
@@ -0,0 +1,59 @@
|
||||
# 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, 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.
|
||||
Reference in new issue
Block a user