frontend: collect independent source diagnostics without cascades

This commit is contained in:
dev committed 2026-10-09 16:01:18 +03:00
1 parent 2c6c7a3dcd
commit 4cda44823d
47 files changed
+697 -44

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
# Aji Quick Reference (`.aji` 0.1)
Read this first; it covers most programs. Where to find the full rules is at the end. Every example below is part of a program the conformance suite checks. `aji check file.aji` verifies, `aji run file.aji` verifies and runs, `aji lower file.aji` prints the AIR it becomes. `aji fmt file.aji` prints formatted source; `--check` checks formatting, `--write` replaces the file. Formatting preserves tokens and comments; it does not verify or repair code. Diagnostics are JSON lines; fix the first one first.
Read this first; it covers most programs. Where to find the full rules is at the end. Every example below is part of a program the conformance suite checks. `aji check file.aji` verifies, `aji run file.aji` verifies and runs, `aji lower file.aji` prints the AIR it becomes. `aji fmt file.aji` prints formatted source; `--check` checks formatting, `--write` replaces the file. Formatting preserves tokens and comments; it does not verify or repair code. Diagnostics are JSON lines; read the complete list and repair independent errors together. Frontend collection is capped at 32 and stops at uncertain boundaries.
Aji makes every significant action explicit — moves, borrows, allocation, closing, authority, effects, tasks, channel transfers, locking, cancellation, every failure outcome — and checks them all before running. The compiler writes the mechanics: SSA, control flow, borrow ends, frame storage, the feature header.
+13 -1
View File
@@ -45,6 +45,18 @@ Var inference remains an optional language-policy question. No change is adopted
Nine registered kinds now provide contextual E7001/E7005 advice through `repair_candidates`; argument and binding borrows are separate. Fixed hints and alternative units are specified in spec 10/15 and the registry. Enum variant payloads, `&&`, unsupported block comments, incomplete types and other nearby spellings have explicit exclusion tests. No syntax alias, var inference, inferred slice end or automatic cast selection was added.
Validation: 1735/1735 conformance, including exact `.advice` JSON goldens for all kinds; 161 CLI/package advice checks; unit/registry tests, grammar, formatter, hosted smoke and format checks. Independent Claude review caught the enum-payload context and confirmed the static candidate lifetime correction. Multi-error collection and the public dev measurement remain pending.
Validation: 1735/1735 conformance, including exact `.advice` JSON goldens for all kinds; 161 CLI/package advice checks; unit/registry tests, grammar, formatter, hosted smoke and format checks. Independent Claude review caught the enum-payload context and confirmed the static candidate lifetime correction. At this increment's boundary, multi-error collection was still pending; its delivery follows below. The public dev measurement remains pending.
Bundle growth versus the pre-increment generated bundle (whose Quick Reference matched HEAD): Quick Reference `cl100k_base` 8955 → 9237 (+282, 3.15%), `o200k_base` 8991 → 9272, Qwen2.5 9233 → 9515. Full Source Reference Bundle excluding AIR: 77358 → 78582 (+1224, 1.58%), 77594 → 78815 and 79315 → 80563 respectively. The table and machine advice registry account for this explicit cost; the proposed reduction in repair rounds has not been measured.
## Second increment delivered (2026-10-09)
Spec 15 §10 now defines delimiter-bounded parser recovery, first-error phase stops, collection across validated function bodies, deterministic order and the fixed 32-diagnostic limit. Every failed item/body contributes only its first error. A broken header/import or uncertain delimiter boundary stops collection; no partial AST/AIR reaches another stage. The first failing imported file carries its recovered list. Bodies start with fresh state; failed constants/features/linearity accumulations are restored. Calls read validated signatures, so a bad callee does not create a caller error. Later instances of a failed template are skipped. E7900 still replaces other diagnostics and carries no advice.
Check/lower/run/report/explore and syntax-only fmt now carry the applicable JSON Lines lists. The 12 original mini-probes preserve acceptance and every prior first-diagnostic field; the three-function syntax probe grows from one to three records, and the two-cast probe from one to two. These are compiler observations, not measurements of model repair rounds.
Validation: full conformance 1760/1760; all 25 independent-error fixtures; 234 CLI/package collection checks, 163 advice checks and 5975 formatter checks over 1442 files (770 accepted AIR outputs remain identical). Unit tests compare the next function's complete output/constant tags with fresh lowering after failed borrow/scope/loop bodies, pin constant/feature rollback and no output on error, and test std failure collapse to E7900. Remaining CI Python hosted/oracle checks passed (38 commands, including examples under 200 schedule seeds); source construct coverage remains 121/121. Evaluation harness self-tests also passed (41 tests, one skipped), using scripted/mocked providers rather than model runs. The reason suite's stale void-parameter expectation now pins the earlier E7005, its registry scan selects only the reason section, and the defensive void/never move guard is unit-tested. Claude found no remaining implementation defects after review.
Combined bundle cost for both increments: Quick Reference `cl100k_base` 8955 → 9255 (+300, 3.35%), `o200k_base` 8991 → 9290 and Qwen2.5 9233 → 9534. Full Source Reference Bundle excluding AIR: 77358 → 79072 (+1714, 2.22%), 77594 → 79306 and 79315 → 81059. The second increment adds 18 Quick Reference and 490 full-source tokens in `cl100k_base`; the cost documents recovery boundaries and the JSON Lines contract instead of adding language syntax.
The implementation is ready for a new pinned public dev condition. Gobang is not installed/exposed in this workspace, so no model runs or claimed threefold improvement are recorded here. The evaluation owner should confirm that its tool wrapper retains every diagnostic JSON line and freeze the new compiler commit, docs hashes, model/settings and tool behavior before rerunning the same four public dev tasks. Compare checks/turns and first-code/full-code counts separately; retain the earlier condition unchanged. Ajieval's inspected single-object readers are for documentation/Gobang tool envelopes, not raw compiler stdout; that does not verify the external Gobang wrapper. P6-12 remains open for this measurement, and P6-6 remains open in full.
+1 -1
View File
@@ -139,7 +139,7 @@ Lowering layers (P6A-3/4), each with accepted (golden AIR), rejected (`E7xxx`) a
| P6-8 | done | Formatter for implemented source syntax | P6-2 | `aji fmt`, spec 15 §11 | token/comment/declaration preservation; idempotence, identical AIR and CLI write/check tests |
| P6-9 | done | Port reference programs and examples to `.aji` | P6-5 | `tests/conformance/source/programs/`, `examples/` | all five source/AIR reference pairs and every example source/package pass |
| P6-11 | done (implementation; RFC 0036 Proposed) | Source functions/calls returning borrows with explicit `from` origin; Q-034 | P6-3/4 | spec 15, binding/call/return lowering, Quick Reference and source/AIR conformance | origin/lifetime and temporary-end rules specified; valid/rejected returned views use existing verifier/interpreter semantics |
| P6-12 | doing (advice delivered; collection/measurement pending) | Structured source repair advice and independent diagnostic collection; owner proposal 2026-10-09 | P6-2/4/7 | [repair plan](../design/source-diagnostic-repair.md), spec 15 §10, parser/lowering and CLI | advice applicability and additive fields specified/tested; independent item/body errors collected without partial AIR or cascades; bundle growth and public dev effect measured |
| P6-12 | doing (advice/collection delivered; dev measurement pending) | Structured source repair advice and independent diagnostic collection; owner proposal 2026-10-09 | P6-2/4/7 | [repair plan](../design/source-diagnostic-repair.md), spec 15 §10, parser/lowering and CLI | advice applicability and additive fields specified/tested; independent item/body errors collected without partial AIR or cascades; bundle growth and public dev effect measured |
| P6-10 | todo | Phase exit review | all | plan status | exit criterion passes |
The [standard-library track](standard-library.md) implements nineteen compiler-pinned modules and qualified standard enum names. STD-3/RFC 0021 completes P6-3 with explicit manifest source mapping, acyclic linking, direct qualified names, imported struct literals and task workers. Dependency fetching/resolution is separate package work; STD-4/RFC 0022 completes explicit generics and structural constraints. STD-5/RFC 0023 adds whole-value linear structs/enums/fixed arrays, complete unpack/match, explicit exchange and ownership-preserving allocation failure through all layers (spec 15 §16). STD-6a/b/RFC 0024 resolves Q-036 with initialized buffer<T> and safe std.vec, explicit growth, returned failure ownership and draining (spec 15 §17). STD-6c/RFC 0025 adds safe owning Deque with existing source primitives. STD-6d.1/RFC 0026 adds pure std.hash; STD-6d.2/RFC 0028 adds safe owning U64Map<V> after the explicit error_values prerequisite (RFC 0027). STD-6d.3/RFC 0029 adds explicit static function parameters for general hash/equality/order operations with existing AIR calls/workers. STD-6d.4/RFC 0030 implements the general owning-key std.hashmap contract; its full GC/stress validation passes and Q-037 is resolved. STD-6d.5/RFC 0031 implements general owning std.hashset with duplicate input return; its conformance, GC/schedule, CLI and documentation checks pass. STD-6d.6/RFC 0032 implements safe owning std.heap with explicit order; conformance, GC/schedule, CLI and documentation checks pass. STD-7a/RFC 0033 implements bounded std.io composition with explicit progress, resource loans and exact effects; conformance, GC/schedule, CLI and documentation checks pass. STD-7b/RFC 0034 implements safe owning buffered file adapters with explicit finish/discard and first-error/no-retry behavior; conformance, GC/schedule, CLI and documentation checks pass. STD-7c/RFC 0035 adds pure caller-buffer lexical paths and Copy component ranges; conformance, GC/schedule, CLI and documentation checks pass. The owner adopts STD-0..7 as an intermediate foundation and resumes language work (2026-10-07); remaining std system/service milestones stay in the backlog. P6-11 implements explicit borrowed returns over the existing AIR; RFC 0036 remains Proposed pending owner adoption (Q-034). These increments do not complete Phase 6.
@@ -43,6 +43,8 @@ Example:
}
```
A rejected source module MAY produce multiple diagnostic JSON lines under spec 15 §10. Each line retains the same envelope; consumers MUST read the complete diagnostic stream rather than treating stdout as one JSON object.
## 3. Repair candidates
The compiler MAY emit structured suggestions. The following kinds are illustrative:
+7 -1
View File
@@ -391,7 +391,13 @@ A byte string or array used where a `slice<u8>` is expected is materialized in f
## 10. Diagnostics
Recognized rejected spellings MUST carry the applicable source advice candidate registered in `reference/error-codes.md`, using spec 10 §3. These candidates describe existing syntax; they MUST NOT accept aliases, infer a missing `var` annotation, invent a slice end, duplicate a receiver expression or select a cast mode. `let` inference remains unchanged. Parser recovery and diagnostic collection are unaffected by this advice requirement.
Recognized rejected spellings MUST carry the applicable source advice candidate registered in `reference/error-codes.md`, using spec 10 §3. These candidates describe existing syntax; they MUST NOT accept aliases, infer a missing `var` annotation, invent a slice end, duplicate a receiver expression or select a cast mode. `let` inference remains unchanged.
**Independent source errors.** A rejected source compilation MUST expose at most 32 frontend diagnostics, in parser declaration order or concrete lowering order. Each failed top-level declaration/body contributes at most its first error. Module/import headers, linking failures, generic specialization, types, signatures and module requirements remain first-error phase stops. A syntax-error module MUST NOT reach linking/lowering; a module with body errors MUST NOT emit AIR or reach the verifier. No recovery placeholder may escape. Existing diagnostic fields and the first diagnostic MUST be preserved; later independent failures MAY add JSON lines. Check/lower/run/report/explore MUST expose the same list, including advice; fmt MUST expose the same syntax list and refuse formatting it.
Parser recovery MUST occur only after an independently bounded `fn`, `struct` or `enum` item: matching `()`, `[]` and `{}` tokens identify a complete outer body, the failure is within that item, and the next token is EOF or another declaration keyword. An unbalanced/mismatched delimiter, missing body, top-level junk or invalid lexical token other than the recognized lone `!` MUST stop recovery. A new function declaration before the first outer body MUST NOT supply the failed declaration's missing body; static `fn` selections/contracts are not declaration boundaries. Header/import failures stop before items. Parsing the next item MUST reset transient expression/advice state. Source import traversal retains its existing deterministic order: the first failing imported module exposes its own recovered list and then stops linking; a std syntax failure remains one E7900 without advice.
Body collection MUST begin only after complete declaration/signature/requirement validation. Bodies read other functions through those validated declarations, not through body outputs; a failed callee MUST NOT manufacture a caller error. Every body MUST start with fresh function state, and failure MUST discard its output and restore module accumulations before continuing. Later instantiations of a failed generic source declaration MUST be skipped, preserving one error per source function. Existing one-per-code/source-location deduplication remains mandatory. An unimplemented body encountered before any collected error retains the unimplemented result; after an error it is skipped and collection continues. At the fixed limit collection stops and the module remains rejected.
| Problem | Code |
|---|---|