Files
aji/docs/design/open-questions.md
T

21 KiB
Raw Blame History

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 resolved P0 Text AIR grammar
Q-002 open P0 Instruction contract tables
Q-003 resolved P0 Diagnostic codes for parse errors
Q-004 resolved P0 Observable trap semantics
Q-005 resolved P0 Verifier resource budget values
Q-006 resolved P0 Target description for usize and layout in the interpreter
Q-007 resolved P0 Integer edge cases besides overflow
Q-008 resolved P0 How hello writes output before capabilities exist
Q-009 resolved P1 Borrow lifetimes in AIR
Q-010 resolved P1 Region generation checks: static, dynamic, or both
Q-011 resolved P2 Effect hierarchy and discharge
Q-012 resolved P2 Capability representation and host instantiation
Q-013 resolved P3 Deterministic select rule and scheduler seed
Q-014 resolved P3 Send/Share derivation for aggregates holding capabilities
Q-015 resolved P5 Operational weak-memory model for the interpreter
Q-016 open P0 Floating-point determinism
Q-017 open P8 Replay file format
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 resolved P5 Memory-model clarifications found by the independent oracle
Q-025 open — No array construction from element values in AIR

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.

Resolved (P0-1): docs/reference/air-text.ebnf and spec 07 §8. Comments use ;; opcodes carry the type suffix (add.checked.u64, const.u64 5); the module header is four lines (module, air, lang, features).

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.

Partially resolved (P0-3): format-version-0 instructions are specified in spec 07a. Stays open for the instructions of later phases.

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.

Resolved (P0-1): new range E0xxx (E0001–E0006) for text and module errors. Undefined values and unknown block labels use the semantic codes E5001 and E5002.

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.

Resolved (P0-2): spec 01 §6. Traps terminate the program and produce a record with a stable T0xxx code, function, block and instruction index.

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.

Resolved (P0-2): fixed, non-configurable limits in spec 08 §7.

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").

Resolved (P0-2): spec 09 §9. Target description with pointer_bits; the interpreter defaults to air64. usize/isize are never widen operands, so verification is target-independent.

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).

Resolved (P0-2): spec 02 §2.1 and spec 07a.

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.

Resolved (P0-2): Phase 0 hello is a @main that returns a value which aji run reports (spec 07a "Run result"). A hello that writes to stdout moves to P2-11, after slices (P1) and capabilities (P2).

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.

Resolved (RFC 0005): second-class borrows; returns use from %param; explicit borrow.end with path linearity (spec 07 §8.8, spec 08 §11).

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.

Resolved (owner decision, RFC 0005): static checks only; no runtime generation checks in safe code (spec 03 §8.1). Specified in detail with regions in Phase 2.

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.

Resolved (RFC 0006): effects are flat atoms from a closed registry; no implication and no discharge in format 0; function pointer types must carry effect sets (spec 05 §9).

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.

Resolved (RFC 0006): cap<K> is an opaque, copyable reference to a shared host authority object; it enters only as a named @main parameter bound by --grant name=kind[:scope]; cap.narrow is the only, fallible, transformation; failed instantiation is not_instantiated (exit 6) (spec 05 §10).

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.

Resolved (RFC 0012, spec 04 §39): ready arms chosen by a draw from the schedule generator (not textual order); task choices and arm choices share one stream and one choices count. The schedule seed was settled by RFC 0011.

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.

Resolved (RFC 0011): Send/Share are structural; every capability kind is Send and Share, so an aggregate holding capabilities is Send/Share exactly when its other members are (spec 04 §35).

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.

Resolved (RFC 0015):

  • The normative model is axiomatic: the Aji RC11 profile of spec 04 §20, including NO-THIN-AIR (sb ∪ rf acyclic).
  • An enumerator derived from the axioms is the executable oracle (spec 04 §20.5).
  • The interpreter is an operational machine. For every program, observed ⊆ allowed. For the finite normative litmus corpus only, observed_exhaustive = allowed (spec 04 §20.5, §42).
  • Weak choices are draws from the schedule stream.
  • Promises are not needed, because NO-THIN-AIR forbids the cyclic load-buffering outcome.

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.

Moved to Phase 8 by RFC 0015 (D13). The deterministic profile already reproduces runs from seeds and quantum. A replay file for hosted or native runs must record scheduler choices, reads-from choices, modification orders and the SC order.

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.

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.

Resolved: deterministic instruction fuel (spec 11 §7). Wall-clock time is never used to determine semantic test termination. Fuel exhaustion is an execution-runner outcome (limit_exceeded, CLI exit code 5), not an Aji trap.

Q-020 — Size bound for SSA array values

Frame storage is bounded (max_local_frame, spec 08 §11.5), but an SSA value of type array<T, N> (for example from array.splat) is bounded only by N ≤ 2^32. A module can therefore ask the interpreter for gigabytes in one instruction, and the outcome then depends on host memory. Options: apply the same accounted-size limit to every type in the module (E5101), or a separate max_value_bytes. Needs an owner decision; changing it later would turn accepted modules into rejected ones, so it should be settled before format 0 is released.

Resolved (owner decision, DD-015): max_value_size = 1 048 576 bytes bounds the accounted size of every materializable type in a module (spec 08 §7.1); max_local_frame stays a separate limit. Both are normative, deterministic, independent of host memory and reported as E5101. Accounted sizes use checked arithmetic; overflow is E5101. Total allocation is a Phase 2 concern (allocation capabilities and runtime limits).

Q-021 — @main parameter names that are .aji keywords

Parameter names are preserved by lowering and are the binding points for grants (spec 15 §2). An AIR program whose @main has a parameter named after a .aji keyword (%in in tests/conformance/phase2/run/echo_stdin.air) has no source equivalent with the same instantiation contract, so a grant in=io.read cannot target a .aji program. Options: accept the restriction (keywords are not parameter names; AIR programs meant to have a source twin avoid them), or a raw-identifier spelling for this position. Not urgent; noted when the source/AIR equivalence test for echo_stdin had to drop its equivalent: reference.

Resolved (owner decision): no language change. For runtime grants the source parameter name is what matters, not identity with a hand-written AIR program: the source program names the parameter input and is run with --grant input=…, and that AIR test simply has no equivalent: twin. Escaped identifiers (`in`) are deferred until there is a real need, because they grow the grammar for a rare case.

Q-022 — Byte strings dominate the source/AIR size metric

A byte string lowers to one local.zero, then a borrow, index, store and end per non-zero byte, because format 0 has no byte-array constant. In the Layer 6 programs this makes up most of the AIR (hello: mechanical_air_eliminated 0.94). The metric then measures a representation cost of format 0 more than the mechanics an agent would otherwise write. Options for P6A-9: report the metric both with and without byte-string materialization, or count each byte string as one AIR construct. A byte-array constant in AIR would be a format change (spec 07 §8.7) and is out of scope for 6A.

Resolved (owner decision): report both. mechanical_air_eliminated_raw counts all AIR actually generated and stays the main engineering metric. mechanical_air_eliminated_normalized counts each byte-string materialization as one logical constant operation, under one fixed rule for every program (spec 15 §11).

Q-023 — ref of a whole array passed to a ref<[T; N]> parameter

In .aji a borrow of a whole array written as an argument (f(ref a), a: [u64; 4]) is always lowered as a slice (slice<u64>), so a function declared with a parameter ref<[u64; 4]> cannot be called with ref a (E7005). Spec 15 §5 says that binding a borrow of a whole array (ref r = a;) gives a slice. It does not say what an argument borrow gives, so the frontend's choice is not specified. Options: the argument borrow follows the parameter type (array borrow for ref<[T; N]>, slice for slice<T>), which is a small amount of inference from a known signature; or keep slices only and state it in spec 15. Found while writing the interpreter memory test; not urgent.

Q-024 — Memory-model clarifications found by the independent oracle

The independent author of tools/litmus/enumerate.py (P5-1a) worked from spec 04 §20 only. It reported five points the text leaves implicit. For each, the author chose the RC11 reading, and all 20 corpus tests agree with the stated sets under it. Proposed clarifying text for spec 04 §20, for owner approval:

  1. RMW events (§20.1–§20.2). An RMW consists of a read event and a write event of the same location, related by rmw, with the read immediately sb-before the write. Both carry the RMW's ordering. A failed compare-exchange is a single read with the failure ordering and is not in rmw.
  2. Initial writes (§20.1). The initializing write of a cell is non-atomic (it starts no sw), first in mo, and hb-before every event of every task that can reach the cell.
  3. Primitive orders (§20.3). "A total order consistent with hb" means that no hb edge between two operations of one object points backwards in that order.
  4. Channels (§20.3). A channel's messages are received in send order (FIFO), and each message is received at most once. Capacity is not yet modelled. For a bounded channel, a later RFC must say whether a receive that frees a slot synchronizes with the send that was waiting for it. The litmus format has no capacity.
  5. Release sequence (§20.2). rs = [W] ; (rf ; rmw)* is deliberately the C++20 form, without RC11's same-thread later stores. Spec 04 §20.2 says "C++20" in the comment; no change is needed beyond keeping it explicit.

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.

Q-025 — No array construction from element values in AIR

Found by the independent author of program_atomic_stats.air (P5-9b). AIR has array.splat but no way to build an array from distinct element values. A six-element constant array costs a mutable borrow, six borrow.index/store/borrow.end triples and six index constants. .aji has the same gap: it has [e; N] but no array literal. The options are an array.make T (%a, %b, …) instruction (a value constructor like struct.make) with an .aji literal [a, b, c], or no change. This is a convenience question, not a correctness one. It is not urgent, and any RFC for it must report its agent-complexity cost.

Q-026 — Standard library distribution and initial source imports

The source frontend had no import resolution and the package manifest no dependencies. A source-only std therefore needed either manual concatenation or a specified import path.

Resolved in the std bootstrap branch: spec 15 §13 defines a closed compiler-pinned registry, fully qualified calls, deterministic name mangling and library source locations. Spec 16 defines the initial pure API. General user modules and imported types remain STD-3/P6-3; no filesystem search is invented. RFC 0016 records the proposal; its status stays Proposed until the owner accepts it.

Q-027 — Empty byte strings in source

Found while testing std.bytes: the frontend rejects b"" with E7006 (“an empty byte string has no array type”), but spec 15 §5 does not state a nonempty restriction. Zero-length byte slices work as ref storage[0..0] and std tests use that existing form. Resolve the source literal rule separately; the std bootstrap does not change it or format-0 array semantics.

Q-028 — Recoverable endian reads need public standard result types

A plain integer cannot distinguish a decoded zero from a short input. A trap on malformed protocol input is not a recoverable API, and a boolean plus mutable out-parameter leaves an invalid/stale output for callers to track.

Resolved in the endian work branch: spec 16 §2.3 defines width-specific read result enums and one write result enum. Spec 15 §13 defines fully qualified standard enum type names, constructors and patterns using existing AIR enum semantics. RFC 0017 records the proposal. General modules, imported struct literals, generics and a must-use result rule remain outside this change.

Q-029 — Bounded byte copy/search/split and recoverable arithmetic surface

Short destination capacity needs explicit failure without partial mutation. A substring search's empty needle can match the end of empty data, so the existing single-byte length sentinel cannot unambiguously encode all outcomes. A returned split pair would hold borrows inside an aggregate before that source/lifetime surface is available. Arithmetic operators currently either trap or wrap; buffer sizing needs a recoverable overflow result.

Resolved in the STD-1b branch: spec 16 §2.4 reuses WriteResult for copy, adds FindResult for substring search, and composes splitting from explicit caller-owned slices. Spec 16 §2.1.1 adds checked add/sub/mul for u64 and target-width usize with ordinary result enums. Wrapping stays with existing operators. No new borrowed aggregate, generic type, AIR instruction or arithmetic mode is introduced. RFC 0018 records this API policy; its status remains Proposed until owner acceptance.

Q-030 — Strict text/encoding failures and destination state

UTF-8 needs a scalar-level iteration contract without an owning iterator. Hex/Base64 decoders need a choice between permissive input and one reproducible accepted encoding, plus a defined destination state when a bad byte appears after a valid prefix. Size calculations must not trap before reporting short capacity.

Resolved in STD-2a: spec 16 §2.5–§2.7 define UTF-8 next/validate with explicit offsets, lowercase hex output with case-insensitive ASCII decoding, and canonical padded standard Base64 with checked unused bits. Decoders validate all input before checking output capacity and before writing; invalid input wins over short output and both preserve the entire destination. Capacity guards avoid arithmetic overflow. RFC 0019 records the policy. No streaming state, URL-safe/permissive options, borrowed iterator or allocation is introduced. Formatting remains STD-2b.