Owner decisions after the Phase 0 review: - precedence: docs/spec/ is the single normative source; RFCs are decision records whose accepted rules are integrated into the spec in the same change (AGENTS.md, docs/README.md, rfcs/README.md, DD-011) - RFC 0004 Accepted (scope: AIR format 0, language 0.1) - AIR format 0 frozen as the semantic baseline; spec 07 §8.7 defines the only permitted additive changes, everything else needs `air 1` (DD-012) - Q-019 resolved: deterministic instruction fuel (spec 11 §7). Outcome `limit_exceeded` is a runner outcome, not a trap; `aji run --fuel N`, exit code 5; conformance runs always use fuel (default 1 000 000, `fuel:` header); fuel/schedule budget/quantum kept separate for P3 (DD-013)
2.7 KiB
Phase 5 — Atomics and memory model
Non-normative. Part of the implementation plan.
Goal: atomic types with all five orderings and fences, an interpreter that exhibits exactly the outcomes the memory model allows, systematic schedule exploration, and record/replay.
Exit criterion: the litmus suite (reference/concurrency-litmus.md) and atomic-publication conformance tests pass, including allowed weak outcomes.
Spec inputs: spec 04 §20–32, 11; reference/concurrency-litmus.md. RFC 0003 is proposed for acceptance (owner decision); acceptance integrates it into the spec.
Blocking questions: Q-015 operational weak-memory model, Q-017 replay format.
Invariants
- no atomic operation without an explicit, valid ordering;
- safe code never accesses atomic storage as ordinary storage;
- DRF-SC holds for programs without ordinary-memory races;
- the interpreter neither forbids allowed outcomes (SB
r1=0,r2=0) nor produces forbidden ones (MP).
Tasks
| ID | Status | Task | Depends | Output | Done when |
|---|---|---|---|---|---|
| P5-1 | todo | Resolve Q-015, Q-017; propose RFC 0003 for acceptance | — | spec 04, 11 | questions resolved |
| P5-2 | todo | Contract tables: atomic.load, atomic.store, atomic.rmw, atomic.cmpxchg, atomic.fence |
P5-1 | spec 07 appendix | all fields present, including allowed orderings per op |
| P5-3 | todo | Atomic types and ordering validation | P5-2 | src/verifier/atomics.zig |
E4201 accept/reject for every op, including cmpxchg failure order |
| P5-4 | todo | atomic / atomic.weak effect marking |
P5-3 | verifier + report | relaxed use without atomic.weak rejected per Q-011 outcome; weak sites listed in report |
| P5-5 | todo | Weak-memory model in the interpreter | P5-1 | src/interp/weak.zig |
SB weak outcome reachable; MP forbidden outcome unreachable |
| P5-6 | todo | Happens-before tracking and dynamic race detector (validates the verifier) | P5-5 | src/interp/ |
any race the verifier missed aborts the test run with a diagnostic |
| P5-7 | todo | Systematic schedule exploration with bounded budget | P5-5 | src/interp/sched.zig |
aji test --interleavings=N explores distinct schedules deterministically |
| P5-8 | todo | Record and replay | P5-1 | src/interp/replay.zig |
aji run --record / aji replay reproduce a failing concurrent run byte-for-byte |
| P5-9 | todo | Litmus suite runner | P5-5 | tests/litmus/, zig build litmus |
each litmus test states allowed and forbidden outcomes; all pass |
| P5-10 | todo | Phase exit review | all | plan status | exit criterion passes |
Conformance tests to add
Negative corpus entry owned by this phase: invalid atomic ordering. Litmus: MP, SB, mutex handoff, channel handoff, spawn/join, invalid ordinary race.