AIR: linear atomic<T> (AtomicScalar), atomic.new/take/load/store/RMW/ cmpxchg (two results)/fence with explicit orderings; feature atomics published. Verifier: ordering tables (E4201), ordinary access (E4202), effects [atomic] / [atomic, atomic.weak], linearity, take while lent (E4101, also for mutex.take). Interpreter: timestamped message machine (src/interp/weak.zig); views travel through spawn/join, channels, mutexes, close and cancel; seq_cst reads the latest message and programs without weak reads make no extra draw (existing records unchanged). aji explore: exhaustive exploration that branches only before visible operations. Litmus: 20/20 tests give exactly the oracle's sets; differential test (1500 random programs) found no unsound outcome. .aji layer 10, Quick Reference atomics, source coverage 67/67, audit report atomic_operations. AIR bundle +5.9 %, QUICK.md +0.5k.
4.6 KiB
10. Diagnostics and Agent Protocol
1. Goal
Aji diagnostics are an API for automated repair, not only human-readable messages.
2. Stable codes
Every verifier/compiler error has:
- stable code;
- stable machine kind;
- structured fields;
- optional human explanation;
- optional non-binding repair candidates.
Example:
{
"code": "E2104",
"kind": "memory.region_generation",
"function": "decode",
"value": "%17",
"region": "%3",
"expected_generation": 5,
"found_generation": 4,
"reset_instruction": 84,
"use_instruction": 91
}
3. Repair candidates
The compiler may emit structured suggestions:
{
"repair_candidates": [
{"kind": "move_reset_after_use"},
{"kind": "copy_value_before_reset"}
]
}
Suggestions never modify semantics automatically.
4. ajid
ajid is the long-running machine interface.
Initial methods:
parse
typecheck
verify
compile
run
test
trace
inspect
explain
benchmark
5. Expected repair loop
agent patch
↓
ajid.verify
↓
structured errors
↓
agent repair
↓
ajid.test
↓
schedule exploration
↓
benchmark
6. Verification report
The toolchain should emit an audit artifact containing:
- unsafe sites;
- remaining runtime checks;
- eliminated bounds checks;
- ownership/borrow proof summaries;
- capability requirements;
- effect graph;
- weak atomic sites;
- lock-order findings;
- contract status.
6.1 Audit report, format 0
aji report FILE verifies the module and, if it is accepted, prints one canonical JSON document (spec 07a "Canonical record": UTF-8, no whitespace, fixed field order). A rejected module produces its diagnostics and no report. The report is derived from the verified AIR only; it never depends on a run.
{
"report": "audit",
"air": 0,
"module": "<name>",
"features": ["…"],
"entry": {"function": "main", "capabilities": [{"parameter": "out", "kind": "io.write"}]},
"functions": [
{
"name": "<function>",
"trusted": null,
"effects_declared": ["…"],
"effects_used": ["…"],
"effects_unused": ["…"],
"calls": ["<callee>", "…"],
"intrinsics": ["<intrinsic>", "…"],
"allocations": 0,
"runtime_checks": {"overflow": 0, "division": 0, "shift": 0, "cast": 0, "bounds": 0, "assert": 0, "guard": 0},
"proven_checks": {"bounds": 0},
"unsafe_operations": [{"block": "entry", "inst": 0, "op": "borrow.index.unchecked"}],
"atomic_operations": [{"block": "entry", "inst": 3, "op": "atomic.load", "ordering": "acquire", "weak": true}]
}
],
"capability_kinds": ["…"],
"unsafe": {"trusted_functions": ["…"], "unsafe_functions": ["…"], "operations": 0}
}
Fields:
entry:@mainand its capability parameters in order, ornullif there is no@main.effects_used: the effects the function can actually perform — its intrinsics' effects,mem.allocif it allocates,unsafeif it contains unsafe operations, and theeffects_usedof its callees — computed to a fixed point over the call graph. Atrustedfunction does not propagateunsafeto its callers (spec 13 §6.3); its owneffects_useddoes containunsafe, which it discharges.effects_unusediseffects_declaredminuseffects_used: declared authority the code never exercises, a candidate for removal.calls,intrinsics: distinct callees and intrinsic names in order of first occurrence; together witheffects_*this is the effect graph.runtime_checks: instructions whose safety condition is checked at runtime and may trap —overflow(checkedadd/sub/mul, anddiv/remfor signedMIN / -1),division(div/remby zero),shift(shl/shr),cast(cast.checked),bounds(borrow.index,slice.sub,slice.split,slice.copy),assert,guard.proven_checks.bounds:borrow.index.proveninstructions, whose check the verifier eliminated.atomic_operations(featureatomics, spec 04 §25): every atomic memory operation in order.orderingis the operation's ordering, orsuccess.failureforatomic.cmpxchg.weakis true for a non-seq_cstaccess: a site where interleaving reasoning is not enough.effects_usedcontainsatomicfor every such operation andatomic.weakfor every weak one.capability_kinds: distinct capability kinds appearing in any type of the module, sorted.- All lists of names are in order of first occurrence in the module unless stated otherwise; effect lists are sorted.
Ownership/borrow proof summaries, lock-order findings and contract status are added to this document by the phases that introduce them, as new fields; existing fields keep their meaning.