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
This commit is contained in:
dev committed 2026-10-05 13:16:51 +03:00
1 parent 61be766634
commit 3e2d9b63a7
35 files changed
+1170 -106

No files matched your search

+4
View File
@@ -149,6 +149,10 @@ Frame storage is bounded (`max_local_frame`, spec 08 §11.5), but an SSA value o
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).