Commit Graph
21 Commits
Author SHA1 Message Date
dev c96199e7ec cli: add explicit package source modules
Link manifest-selected source graphs with module-local names, qualified
structs/enums/functions and task workers through ordinary AIR verification.
Keep source inputs bounded, reject source symlinks and preserve explicit
grants, diagnostics and deterministic canonical lowering.

Integrate spec 12/15, RFC 0021, source reference budgets, roadmap, examples
and CI coverage. Validate 579 conformance tests, unit tests, 76 source
constructs, hosted smoke, 36 package CLI checks and task schedule stress.
2026-10-06 18:51:54 +03:00
dev 618b4b95c1 cli: add supplied-buffer decimal integer formatting to std 2026-10-06 17:18:33 +03:00
dev 3bb11e03b2 cli: add safe UTF-8 and supplied-buffer hex/base64 std modules 2026-10-06 17:06:39 +03:00
dev 6397a317e2 cli: add bounded std copy/search and checked arithmetic 2026-10-06 15:40:57 +03:00
dev a2ca293506 cli: add recoverable endian APIs and qualified std enums 2026-10-06 15:12:55 +03:00
dev 10a370471b cli: bootstrap verified std bytes and math with source imports 2026-10-06 14:51:10 +03:00
dev 0879b9497b Phase 5: race detector (P5-6) and the atomic_stats reference program (P5-9b)
Dynamic data-race detector for ordinary memory: vector clocks are the
task-keyed part of the weak-memory views, so happens-before follows every
synchronization edge already modelled; per-cell shadows with path
granularity. Enabled for every conformance run test (433, no false
positive); a unit test shows an unverified racy program caught on every
schedule. Reference program atomic_stats in .aji and hand-written AIR by an
independent author (equivalent:, 30 schedule seeds). Author feedback:
07a clarifications; Q-025 (no array construction) logged.
2026-10-06 08:11:25 +03:00
dev 4242132b2a Phase 5: atomics through every layer (RFC 0015)
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.
2026-10-06 08:05:01 +03:00
dev cfee89ff19 P5-0: M/C regression on p4-frozen (6/6 PASS); fix frontend defect A found by gate R3
A `ref` of a place reached through a `mut` borrow (`ref s.buf`, `ref s.n`
with `s: mut<S>`) is now a shared reborrow (borrow.ref). Before, an array
field lowered to slice_mut and reached the verifier as E1001, and a scalar
field was rejected with E7005. Regression test ref_through_mut.aji.
2026-10-06 00:35:22 +03:00
dev c699529fec Phase 4: islands, frozen graphs and arc through every layer (RFC 0014)
AIR: types island<T>, frozen<T>, arc<T>, iref<T>; 16 instructions
(island.create/alloc/root/borrow/freeze/destroy, frozen.root/borrow/
release, arc.from_frozen/new/clone/release/root/borrow, iref.eq); features
islands (depends on heap) and arc (depends on islands) published.
Verifier: IslandSafe/ArcSafe (E2111 at the owner type), container child
borrows (one mut access per island), Send/Share rows (island not Share),
linear owners, mem.alloc effect, element rules (recursion through iref).
Interpreter: graphs with never-reused identities, T0010 for a foreign
iref, O(1) freeze/conversion/transfer, arc counts in a trace hook
(Options.arc_events), budgets per the quota table, collector support.
.aji layer 9: types, operations, island.at/frozen.at/arc.at as borrow
places with explicit container borrows, iref ==/!=.
Frontend fix: joins carry only variables the construct assigns (and that
are read again), so an unchanged linear value is never a block argument
while borrowed.

Tests: 10 AIR (phase4), 6 .aji run + 12 rejects (layer9), the reference
program island-pipeline in .aji, equivalent to an independently
hand-written AIR program (36 on 30 schedule seeds); unit tests for the
arc count trace and O(1) transfer. Quick Reference §7 graphs (checked
excerpt of quickref/graphs.aji); coverage 61/61. Bundle growth: AIR
+7.0%, Quick Reference +0.6k, source docs +4.2k (recorded).
Spec: quota rows match the header-reserved count; idioms and iref
recursion in spec 03 §22; P4-11 (air-text.ebnf gaps) recorded.
2026-10-05 22:14:05 +03:00
dev 591f0aea19 P6A-7 for the freeze: three reference programs in source; source construct coverage
- programs/parallel_map, channel_transfer, tcp_echo_tasks: the Phase 3 exit
  programs in .aji, with AIR equivalence on every schedule seed
- tools/source_coverage.py: every .aji construct (56) has a run/accept test
  and, where it rejects, a reject test; CI step
- gaps filled: wrapping arithmetic run test, break outside a loop (E7006),
  close_receiver without pending (E7004)
- plan: P6A-7 freeze criterion (owner decision); further twins gradually
2026-10-05 18:15:48 +03:00
dev 748eddf4e5 P6A-11, P6A-12: malformed lowering is an internal compiler error; source type-check completeness
P6A-11: when a .aji module passed the frontend but its AIR does not parse
(E0001-E0005) or has invalid SSA/CFG (E5001, E5002), the result is one
E7900 source.internal_compiler_error at the source construct, with the
AIR code in air_code; semantic codes (E0006 included) are unaffected.
Unit test injects the checkpoint's `ret %` defect.

P6A-12: source-decidable type errors are E7005 at the source:
- `as` checks lossless widening with the verifier's own rule (shared
  function), and that both sides are integers
- slice.copy element types; own.free / region.destroy operand types
- element rules of channel.make<T> and mutex.make (no borrow, scope,
  task, shield or guard, at any depth)
Probing every source position found no other E1001/E1002 leak. The old
test encoding the previous rule (verifier_widen, E1002) is replaced by
typecheck/lossy_widen (E7005); 9 typecheck tests. Spec 15 §10 states the
frontend/verifier boundary.
2026-10-05 18:10:53 +03:00
dev 154c39865f Phase 6A: .aji layer 8 (lock and mutexes, select, shields, cancellation)
- lock ref m as x { … } cancelled { … }: mutex.lock on a ref<mutex<T>>
  (a mutex is borrowed for the lock, a ref binding used as is); ok edge:
  mutex.borrow bound as x; at every normal exit borrow.end x then
  mutex.unlock; the guard is never a source value
- mutex.make/mutex.take; mutex<T> type; ref mr = m lends a mutex
- shield { … }: task.shield.begin/end at every exit (nesting by construction)
- task.check_cancel and task.join_cancel as outcome matches
- select: one borrow per endpoint, send values evaluated first and
  deduplicated, every edge binds its own value then the unsent values;
  bind count E7005, missing outcome E7004
- linear values never get frame storage (borrowed in place)
- liveness: select handled in the read and after walks
- Quick Reference: select edges bind `job` back (ok(x, job), closed(job));
  every Quick Reference example now passes (no PENDING)
- tests: 6 run tests with AIR equivalence (mutex counter, select draw,
  select same value, shield, join_cancel forwarding, cancelled recv), 10
  rejects (E4304 x3, E3001, E2101, E7005 x2, E7004, E3101 x2, E4101)
- spec 15 §7/§9, quick reference, bundle notes, plan
2026-10-05 18:02:11 +03:00
dev 179dee3c3a Phase 6A: .aji layer 7 (task scopes, spawn/join, channels)
- scope s { … }: task.scope.begin, task.scope.end at every normal exit
  (scope ends generalized: borrow.end or task.scope.end, innermost first)
- task.spawn(s, f, args): call-like; named linear values moved (E7003);
  lent borrows are bound first (inline borrow E7006); scope operand E7005
- task.join/cancel/cancelled; task<T>, sender<T>, receiver<T>, scope types
- channels: make<T>, dup, send, recv, close_sender, close_receiver; send,
  recv and close_receiver are outcome matches; endpoints by name, borrowed
  for the operation and ended on every edge (written `mut tx`: E7006)
- outcome rebinding: a value coming back under the name of a variable of
  its type becomes the variable's value (pending(r))
- joins carry live variables only (pruned SSA): a linear value consumed
  before a join does not travel to it; ordered after-walk over the
  enclosing statement or tail, sibling arms not counted
- parser: a keyword after `.` is a member name (task.cancelled)
- conformance equivalence ignores schedule.choices (quantum counts AIR
  instructions)
- tests: 10 run tests with AIR equivalence (Phase 3 programs), 12 rejects
  (E4301, E4101 x2, E4002, E2001, E3101, E3002, E7006 x2, E7003, E0006,
  E7005); Quick Reference tasks/channels programs now pass
- spec 15 §4/§6/§7, grammar, quick reference, bundle notes, plan
2026-10-05 17:55:30 +03:00
dev 222c0c884c Fix two toolchain defects found by the M checkpoint
A. Interpreter memory grew with the number of executed steps (one arena,
never reclaimed): block and call arguments, frames, frame storage, value
copies, place paths, channel buffers and per-step scratch now live in a
collectable execution heap. Between instructions, past a threshold, the
live state is copied into a fresh heap (sharing preserved) and the old one
released. Long-lived state (module, world, authority, task, channel and
region tables, the result) stays in the caller's arena. The guarded value
of a mutex is a separate cell (no interior pointers). Nothing observable
changes: fuel, schedule, PRNG, values, traps and run records are the same.
- test: five loop shapes x 100k/1M/4M iterations, measured with the
  interpreter's own heap counters: live state after a collection does not
  grow with the iteration count; the heap stays under a fixed bound
- conformance --collect-every-step: the second run of every run test
  collects before every instruction; records must be byte-identical
  (passes, also with --stress 20)

B. A void function whose body ends in an if/if-else/match/block/void call
lowered to `ret %` (malformed AIR, reported as E0001): it now lowers to
`ret`. Seven fall-through tests (six failed before).

Also: files_opened counts reads by relative path and file name; P6A-11
(malformed generated AIR as an internal compiler diagnostic) and Q-023
(ref of a whole array as an argument) recorded.
2026-10-05 15:34:12 +03:00
dev 3e2d9b63a7 P6A-8: Source Reference Bundle and harness profile aji_source
- source bundle: a /docs directory with QUICK.md (Quick Reference plus a
  where-to-read table), language/*.md, diagnostics/errors.md and the AIR
  bundle only under air/; built from docs/agent/source-bundle.txt
  (> output files, @manifest includes) by zig build agent-reference
- Quick Reference examples are checked: every aji block must be an
  excerpt of a conformance program in tests/conformance/source/quickref
  (zig build test fails otherwise); QR fixes found by the check
  (mut d = data, region not auto-borrowed, statement/borrow blocks that
  could not verify, io_error match)
- frontend: task.*/channel.*/mutex.* are not-yet-implemented, not E7006
- aji lower --stats: mechanical_air_eliminated_raw and _normalized (each
  byte-string materialization counted as one constant; spec 15 §11)
- harness: profile aji_source (doc_groups), per-file and per-group docs
  metrics on distinctive lines, profile columns (tool calls, lowered AIR
  raw/normalized, docs files read, IR-form and type-mismatch counts),
  dev-echo aji_source variant, scripted run and test, source token report
- plan: P6A-8 done, P6A-9 criteria; Q-021/Q-022 resolved; unsafe block
  deferred
2026-10-05 13:16:51 +03:00
dev c18fb7acc1 Phase 6A: .aji layer 6 (intrinsics, resources, narrowing, unsafe operations)
- intrinsics from the registry as plain calls: fallible ones are outcome
  matches or `or trap` (E7006 otherwise), infallible ones plain calls
- resource operands by name, borrowed mut for the one operation and ended
  on every edge; a mut binding/parameter passes as is; `mut f` is E7006
- closes consume with `move` (E7003); no inserted closes (E3002/E3001)
- data operands explicit (ref/mut/byte string, E7005 otherwise)
- file<…>, stream, listener types; cap.narrow.prefix with cap_error edges
- ref/mut unchecked s[i] (also as a binding) and assume(c) under
  effects [unsafe]; boundary left to the verifier (E6001)
- trusted is reserved and rejected (E7006)
- parameter names preserved; generated names avoid them (normative)
- parser: >> closes two type arguments
- conformance: `equivalent:` compares the run record with a reference
  AIR program (hello, file_copy, tcp_echo, narrow ok/not_subset/invalid,
  random)
- spec 15, grammar, quick reference (io_error match fixed), plan, examples
2026-10-05 12:16:54 +03:00
dev bdcf871e5d Phase 6A: .aji layer 5 (linear values, own, regions, outcome matches, or trap)
- explicit move for named linear values; E7003 with suggestion "move x";
  move of a copyable value is E7006; moved state left to the verifier
- own.new/own.array/region.create/region.new/region.array/cap.narrow.budget
  as outcome matches or with `or trap`; own.take/own.free/region.reset/
  region.destroy as AIR names in AIR operand order
- region.new/region.array take an explicit ref/mut region binding (E7005
  otherwise); reset/destroy end nothing (verifier E2104)
- match kind (enum/outcome/integer) decided by the parser; built-in error
  enums (alloc_error, cap_error, io_error) matched exhaustively
- cap<K> types; linear owners borrowed in place
- features header = registry closure of the features used
- parameters keep their source names (grants by @main parameter name)
- aji lower --stats: mechanical_air_eliminated = 1 - source/AIR bytes
- spec 15, grammar, quick reference, plan updated
2026-10-05 12:06:23 +03:00
dev eca30f817a Phase 6A: .aji layers 3-4 (addressable values, lexical borrows, slices)
Owner rules: addressability is decided by lowering (a variable that is
borrowed, indexed or written through a place gets frame storage in the
entry block; otherwise SSA; by name, deterministic); borrows are bound
only by 'ref r = place;' / 'mut r = place;' and live to the end of the
block (borrow.end at every normal exit, including break/continue/return);
no shadowing of an active borrow in the same scope; ref/mut as call
arguments are temporaries ended after the call; *r only for scalar and
struct referents, slices via s[i], s[a..b], s.len; writes *r = v,
r.f = v, s[i] = v with the value evaluated first; split_at as the only
multi-result binding; slice.copy(mut dst, ref src) as the only copy;
[e; N] evaluates e once; byte strings as [u8; N] in frame storage with
a fixed escape set; borrow.index.proven only for the verifier's own
fact form (if i < s.len, same SSA values), otherwise checked.

Diagnostics on lowered AIR are deduplicated per code and source
location. aji lower --stats counts code only (no comment lines).

Tests: 10 run (architecture goldens: value-only has no local.alloc,
borrowed has local.alloc, proven indexing), 6 rejects incl.
verifier-caught E2101 (aliasing; parent used after split_at).
Expansion on these programs: 4-9x bytes, 2.2-6.6x lines.
2026-10-05 11:51:04 +03:00
dev 0fdd04179b Phase 6A: .aji layer 2 (structs, enums, exhaustive match)
Owner rules: struct/enum declarations in Rust form; one construction
form each (named struct literal, Enum::Variant); struct fields lowered
in declaration order, so field order in the source does not change the
AIR (golden test with two orders, one AIR); match over enums exhaustive
with no '_' (E7004 lists missing variants, E7006 for '_'), integer
match needs '_'; payload names scoped to their arm (enum.switch block
parameters); match as an expression with a merge block; arm-level
source map; no destructuring, guards or nested patterns. Type inference
limits written into spec 15 (one function, monomorphic, no search,
E7007). aji lower --stats: source/AIR size and expansion ratio.

Tests: 4 run (one shared golden), 7 rejects incl. verifier-caught E1003.
2026-10-05 11:31:56 +03:00
dev ba3e9b3719 Phase 6A: .aji frontend, layer 1 (scalars, expressions, functions, control flow)
src/frontend: lexer, AST, parser for the full 6A grammar (first error
only: one E7001 with span, expected and found), lowering to canonical
text AIR with a line map. Variables become SSA with block parameters
carried across if/while/for/loop joins; short-circuit and/or; checked,
wrapping and cast forms; calls; untyped let literals typed from later
uses, never guessed (E7007). The frontend repairs nothing.

check.checkFile: .aji → frontend → existing AIR parser and verifier;
every diagnostic at its source location, AIR location kept as
air_line/air_col; trap records gain source_location. CLI: check/run on
.aji, aji lower [--annotate].

Runner: .aji tests with the same headers; every accepted module must
lower deterministically, be canonical (lower → parse → print
unchanged) and match <file>.expected if present. Layer-1 tests: 6 run,
6 E7xxx rejects, 2 verifier-caught (E1002, E3101).
2026-10-05 11:23:18 +03:00