spec 04 §20: Q-024 resolved (RMW events, initialization write, object orders, channel FIFO and capacity, C++20 release sequence); litmus corpus normative; P5-0 PASS; Phase 5 implementation GO

This commit is contained in:
dev committed 2026-10-06 07:26:47 +03:00
1 parent f8d2a99249
commit ce9ef03bc0
6 files changed
+89 -18

No files matched your search

+14 -1
View File
@@ -26,7 +26,7 @@ Status values: `open`, `resolved`.
| Q-018 | resolved | P2 | Runtime diagnostics (traps) vs verifier diagnostics |
| Q-019 | resolved | P3 | Non-terminating programs in test tooling |
| Q-020 | resolved | P2 | Size bound for SSA array values |
| Q-024 | open | P5 | Memory-model clarifications found by the independent oracle |
| Q-024 | resolved | P5 | Memory-model clarifications found by the independent oracle |
## Q-001 — Text AIR grammar
@@ -184,3 +184,16 @@ The independent author of `tools/litmus/enumerate.py` (P5-1a) worked from spec 0
Points 1–3 and 5 are editorial. Point 4 fixes FIFO, which spec 04 §38 already implies for the interpreter, but leaves capacity synchronization open.
**Resolved (owner, 2026-10-06; spec 04 §20.1–§20.3).**
1. A successful RMW or compare-exchange is a read event plus a write event plus an `rmw` edge. A failed compare-exchange is a read only.
2. A distinguished initialization write. It precedes every other write in `mo`, happens-before every program access, and is a service event of the model, not a source-level access or a race.
3. An object order is consistent with `hb`: if `a hb→ b`, then `a` precedes `b`.
4. Channels:
- buffered channels are FIFO in one enqueue order chosen by the execution;
- rendezvous pairs are chosen by the scheduler;
- a send synchronizes with the receive that obtains its value;
- capacity affects blocking and scheduling, not memory ordering;
- capacity-based synchronization would be a separate feature by RFC.
5. The C++20 release sequence, stated explicitly.
+7 -6
View File
@@ -80,11 +80,12 @@ The Quick Reference grew by about 550 tokens with §7 Graphs (`quick_reference_u
- `ajieval checkpoint` lowers both sides with the current toolchain. The P6A-9 programs were re-lowered here with `p4-frozen`, so their ratios differ from the values recorded in the P6A-9 results.
- The operator's first report named the two private task ids. The names were not copied anywhere in this repository.
## Verdict
## Verdict (owner, 2026-10-06)
To be decided by the owner. On the facts:
**PASS. No rerun.**
- R1, R2 and R5 are met.
- R3 found one frontend regression class, now fixed with a regression test.
- R4 is a model error.
- R6 shows no toolchain growth.
> Regression passed; one latent frontend defect was discovered and subsequently fixed.
- No evaluator or toolchain problem invalidated a cell.
- The fix comes with its own regression test.
- For a scientific comparison, metrics of this frozen run must not be mixed with a later commit. For the go/no-go gate this result is sufficient.
+1 -1
View File
@@ -156,5 +156,5 @@ Targets for Phase 6A, measured on dev tasks:
| P3 | done (exit review in the phase file); P3-10, P3-11 moved to P7 |
| P6A | done (exit review in `phase-6-source-language.md`; P6A-9 [results](../evaluation/results/2026-10-05-p6a-9.md)): the agent-facing source language over AIR is the architecture |
| P4 | done (exit review in the phase file) |
| P5 | started with the RFC (owner decision, 2026-10-05): implementation on hold until the RFC is accepted, the M/C regression on `p4-frozen` passes and the litmus corpus is ready |
| P5 | implementation in progress (GO 2026-10-06): RFC 0015 accepted, M/C regression PASS, normative litmus corpus 20/20 against the independent oracle |
| P7, P8 | not started |
+24 -2
View File
@@ -10,6 +10,28 @@ Non-normative. Part of the [implementation plan](README.md).
**Blocking questions:** none. Q-015 was resolved by RFC 0015; Q-017 moved to Phase 8 with record/replay.
**Implementation GO (owner, 2026-10-06).** All three gates are closed:
| Gate | Result |
|---|---|
| M/C regression | PASS |
| RFC 0015 | Accepted |
| oracle self-tests | 21/21 |
| normative litmus corpus | 20/20 |
| Q-024 | resolved |
Order, strictly vertical:
```text
AIR types and instructions → verifier → interpreter weak-memory exploration
→ .aji → Quick Reference → litmus conformance → reference program
```
The first thing the interpreter must show:
- all 20 litmus tests give exactly the oracle's sets;
- programs without `atomic.weak` keep their interleaving behavior, with unchanged run records.
**Owner decision (2026-10-05, after the Phase 4 exit review).** Phase 5 starts with the RFC. Implementation is on hold until all three of these are done:
1. the RFC is reviewed and accepted;
@@ -53,9 +75,9 @@ Phase 4 commit frozen (tag p4-frozen)
| ID | Status | Task | Depends | Output | Done when |
|---|---|---|---|---|---|
| P5-0 | done (gate: owner verdict pending) | M/C regression on the frozen Phase 4 commit (tag `p4-frozen`): M, C × Aji/source × N1–N3, 6 cells, same agents, tasks, evaluators and procedure as P6A-9 | — | [`docs/evaluation/results/2026-10-06-p5-0.md`](../evaluation/results/2026-10-06-p5-0.md) | see "Regression gate" below; 6/6 PASS; R3 found frontend defect A (`ref` through `mut`), fixed with a regression test |
| P5-0 | done (PASS, owner 2026-10-06) | M/C regression on the frozen Phase 4 commit (tag `p4-frozen`): M, C × Aji/source × N1–N3, 6 cells, same agents, tasks, evaluators and procedure as P6A-9 | — | [`docs/evaluation/results/2026-10-06-p5-0.md`](../evaluation/results/2026-10-06-p5-0.md) | see "Regression gate" below; 6/6 PASS; R3 found frontend defect A (`ref` through `mut`), fixed with a regression test |
| P5-1 | done | RFC 0015: scalar atomics and the Aji memory model (supersedes RFC 0003); closes the owner's question list; resolves Q-015; scope of Q-017 | — | `docs/rfcs/0015-…` | Accepted by the owner and integrated into spec 04, 05, 07a, 11, 15 |
| P5-1a | done (owner review pending) | Litmus enumerator `tools/litmus` (an executable oracle derived from spec 04 §20, not the definition) and the normative corpus: the classes MP, SB, LB, release/acquire publication, `seq_cst` ordering (IRIW, SB with `seq_cst`), relaxed counter, CAS success/failure, fence publication, forbidden non-atomic race, atomic/non-atomic mixing, plus the handoffs (mutex, channel, spawn/join). Each test has allowed and forbidden outcome sets | P5-1 | `tools/litmus/`, `reference/concurrency-litmus.md`, `tests/litmus/` | the enumerator's allowed set equals every stated set, disagreements diagnosed (spec 04 §20.5); owner review |
| P5-1a | done (corpus normative, owner 2026-10-06) | Litmus enumerator `tools/litmus` (an executable oracle derived from spec 04 §20, not the definition) and the normative corpus: the classes MP, SB, LB, release/acquire publication, `seq_cst` ordering (IRIW, SB with `seq_cst`), relaxed counter, CAS success/failure, fence publication, forbidden non-atomic race, atomic/non-atomic mixing, plus the handoffs (mutex, channel, spawn/join). Each test has allowed and forbidden outcome sets | P5-1 | `tools/litmus/`, `reference/concurrency-litmus.md`, `tests/litmus/` | the enumerator's allowed set equals every stated set, disagreements diagnosed (spec 04 §20.5); owner review |
| P5-2 | done | Contract tables: `atomic.new`, `atomic.take`, `atomic.load`, `atomic.store`, RMW, `atomic.cmpxchg`, `atomic.fence` | P5-1 | spec 04 §42, spec 07a | all spec 07 §4 fields present, with the ordering tables of spec 04 §24 (integrated with RFC 0015) |
| P5-2a | todo | Publish feature `atomics` (depends on `effects`, `ownership`) | P5-3 | `reference/air-features.md`, `src/air/features.zig` | feature_not_declared / missing_dependency tests |
| P5-3 | todo | AIR parse/print, types (linear `atomic<T>`, AtomicScalar, not IslandSafe), ordering tables, `E4202` | P5-1a | `src/air/`, `src/verifier/` | `E4201` accept/reject for every operation and every cmpxchg success/failure pair; `E4202`; `E1001`, `E2111`, `E0006` cases |
+1 -1
View File
@@ -4,7 +4,7 @@ Litmus tests for the memory model of spec 04 §20–§30 (RFC 0015). They are se
The tests do not define the model; spec 04 §20 does. They are its consequences, and the normative conformance corpus for the interpreter (spec 04 §20.5).
**Status:** confirmed by the independent oracle (P5-1a, 2026-10-06): the oracle's allowed set equals the stated set for all 20 tests (`python3 tools/litmus/check.py`). It becomes normative on the owner's review. Earlier status: draft corpus. The sets below were derived by hand from the axioms. The test files are `tests/litmus/*.lit` (format: `tests/litmus/README.md`), where every allowed set is written out in full. P5-1a makes the corpus normative: `tools/litmus/check.py` confirms every set against the independent oracle `tools/litmus/enumerate.py`, and the owner reviews the result. When the enumerator, the interpreter and a stated set disagree, the cause is diagnosed (spec 04 §20.5). A set is never edited to match a tool without a diagnosis.
**Status:** normative conformance corpus of the Aji 0.1 atomic model (owner, 2026-10-06; spec 04 §20.5). The independent oracle's allowed set equals the stated set for all 20 tests (`python3 tools/litmus/check.py`). Changing a published test's sets changes the memory model and requires an RFC. New tests that only cover existing axioms may be added. The sets below were derived by hand from the axioms. The test files are `tests/litmus/*.lit` (format: `tests/litmus/README.md`), where every allowed set is written out in full. P5-1a makes the corpus normative: `tools/litmus/check.py` confirms every set against the independent oracle `tools/litmus/enumerate.py`, and the owner reviews the result. When the enumerator, the interpreter and a stated set disagree, the cause is diagnosed (spec 04 §20.5). A set is never edited to match a tool without a diagnosis.
## Rules
+42 -7
View File
@@ -233,12 +233,26 @@ A weaker model MAY later be added only as a separate feature. Published semantic
An execution consists of events:
- atomic reads `R`, writes `W` and read-modify-writes `U` (both a read and a write), each with a location, values and an ordering;
- atomic reads `R` and writes `W`, each with a location, a value and an ordering;
- fences `F`;
- ordinary reads and writes;
- the synchronization events of the built-in primitives (§20.3).
The cell created by `atomic.new` has an initializing write, first in the modification order of its location. `atomic.take` is an ordinary read of the cell.
**Read-modify-write.** A successful read-modify-write, including a successful compare-exchange, consists of two events:
- a read event and a write event of the same location, related by `rmw`;
- the read is immediately `sb`-before the write;
- both carry the operation's ordering.
A failed compare-exchange is a single read event with the failure ordering. It writes nothing and is not in `rmw`.
**Distinguished initialization write.** Every atomic cell has one initialization write, the value given to `atomic.new`. It is a service event of the model, not a source-level access:
- it precedes every other write of the cell in `mo`;
- it happens-before every program access to the cell;
- it starts no `sw`, and is never part of a data race.
**Taking the cell.** `atomic.take` is an ordinary read of the cell. It is happens-before-ordered after every atomic access by §28.
### 20.2 Relations
@@ -247,31 +261,43 @@ An execution has:
- `sb` (sequenced-before): the program order of the events of one task;
- `rf` (reads-from): relates each read to exactly one write to the same location, whose value it reads;
- `mo` (modification order): a strict total order on the writes to each location;
- `rmw`: relates the read part of each `U` to its write part.
- `rmw`: relates the read event of each successful read-modify-write to its write event (§20.1).
Derived:
```text
fr = rf⁻¹ ; mo from-read
eco = (rf ∪ mo ∪ fr)⁺ extended coherence
rs = [W] ; (rf ; rmw)* release sequence
rs = [W] ; (rf ; rmw)* release sequence (C++20 form)
sw = [E ⊒ rel] ; ([F] ; sb)? ; rs ; rf ; [R] ; (sb ; [F])? ; [E ⊒ acq] ∪ sw_prim
hb = (sb ∪ sw)⁺ happens-before
```
`E ⊒ rel` is a write, RMW or fence whose ordering is `release`, `acq_rel` or `seq_cst`. `E ⊒ acq` is a read, RMW or fence whose ordering is `acquire`, `acq_rel` or `seq_cst`. `[X]` restricts a relation to events in `X`.
`E ⊒ rel` is a write or fence whose ordering is `release`, `acq_rel` or `seq_cst`. `E ⊒ acq` is a read or fence whose ordering is `acquire`, `acq_rel` or `seq_cst`. A read-modify-write's two events carry its ordering, so its write event is `⊒ rel` and its read event `⊒ acq` as the ordering says. `[X]` restricts a relation to events in `X`.
The release sequence is deliberately the C++20 form. It continues only through read-modify-writes that read from it, not through later plain stores of the releasing task (as C11 and the original RC11 do).
### 20.3 Synchronization of built-in primitives
Each task, channel and mutex has a total order of its operations, consistent with `hb`. It is not part of the `seq_cst` order: these are lock semantics, as for C++ mutexes. `sw_prim` contains:
**Object orders.** Each task, channel and mutex has a total order of its operations. These orders are not part of the `seq_cst` order: they are lock semantics, as for C++ mutexes. Each order is **consistent with `hb`**: for any `a` and `b` in the domain of the order, if `a hb→ b` then `a` precedes `b` in the order. No `hb` edge points backwards in it.
**`sw_prim`** contains:
- `task.spawn` → the first event of the spawned task;
- the last event of a task → the `task.join` (or `task.join.cancel`) that returns its result;
- a successful `channel.send` → the `channel.recv` (or `select` arm) that receives that message;
- a successful `channel.send` of a value → the `channel.recv` (or `select` arm) that obtains that exact value;
- `channel.close_sender` of the last sender → the `closed` outcome it causes;
- `mutex.unlock` → the next `mutex.lock` of the same mutex;
- `task.cancel` → the `cancelled` outcome it causes.
**Channels.**
- A buffered channel is FIFO. Successful sends enter one enqueue order of the channel, and receives remove values in that order. With several senders, the execution (the scheduler) determines the enqueue order. Once it exists, receivers observe it.
- A rendezvous channel (capacity 0) has no buffer. The scheduler chooses which waiting send is matched with a receive.
- Each value is received at most once.
- **Capacity affects blocking and scheduling, not memory ordering, in Aji 0.1.** A receive that frees a slot, and the send it unblocks, are related by nothing beyond the edges listed above.
- A semantics in which capacity itself creates synchronization (as in Go) may only be introduced as a separate feature by an RFC. The published model is never strengthened silently.
### 20.4 Consistency
An execution is consistent iff:
@@ -298,6 +324,15 @@ The **outcomes** of a program are the observable behaviors of its consistent exe
There are two distinct obligations:
- **Axiomatic oracle.** `tools/litmus` holds an enumerator derived from §20.1–§20.4. For a small program it enumerates exactly the consistent executions, and hence the allowed outcomes. It is an executable oracle, not the definition. When it, the interpreter and a stated outcome set disagree, the disagreement is diagnosed as a defect of a tool or of the stated set. The model changes only through an RFC.
**Status of the corpus.** The 20 tests of `tests/litmus/` are the normative conformance corpus of the Aji 0.1 atomic model. They are normative consequences of §20.1–§20.4, not its definition. For each test:
```text
oracle allowed set == stated allowed set
interpreter exhaustive outcomes == stated allowed set
```
Changing the allowed or forbidden set of a published test changes the memory model and requires an RFC. New tests that only cover the existing axioms may be added as extensions of the corpus.
- **Interpreter exploration.**
- For every program, every outcome the interpreter produces is allowed (`observed ⊆ allowed`).
- For each test of the finite normative litmus corpus (`reference/concurrency-litmus.md`), exhaustive exploration produces every allowed outcome (`observed_exhaustive = allowed`).