diag: add stable source reasons and diagnostic incidence reporting

This commit is contained in:
dev committed 2026-10-07 18:52:36 +03:00
1 parent 911982dd1c
commit dbd9763713
21 files changed
+571 -156

No files matched your search

+6
View File
@@ -95,3 +95,9 @@ Spec 15 §4 and the grammar resolve Q-040 syntactically: leading bare `if`, `mat
Reason: `if true { *p = 2u64; } *p = 3u64;` must denote two statements regardless of spacing. Greedy expression parsing consumed multiplication instead. Merely splitting would silently change `{2i64} -3i64` from −1 to −3; rejecting the undiscarded value avoids that change. Neither line-sensitive syntax nor assignment lookahead is needed. This is a small grammar decision, not a new AIR facility.
Compatibility: formerly accepted bare continuations in statement/tail position require parentheses around the initial construct. Formerly accepted value-producing bare block statements require explicit `;`, including mixed branches such as `if c { return 1u64; } else { 2u64 }` before another statement. Existing tails, explicit discards and initializer/return/argument/condition/expression-arm continuations retain their meanings. Ownership, lexical borrow ends, verifier transfers and deterministic runtime rules are unchanged. A borrow bound inside a preceding block remains inaccessible afterwards (E7002); aliasing and task rules still come from the existing verifier. No new diagnostic code, source syntax form, feature or verifier/runtime state is added. One frontend statement marker enforces the value guard and gives the formatter an explicit boundary; it never changes tokens or inserts separators. No empirical Model Capability Compression benefit is claimed; source documentation growth is measured in docs/agent/README.md.
## DD-017 — Stable E7006 reasons before repair-frequency analysis
Spec 15 §10 requires a registered reason on each E7006. Frontend rejection sites select an enum category explicitly; `move_copy` excludes borrowed and non-materializable operands. ajieval groups observed codes/reasons per run and reports unknown historical reasons separately, without reading message prose. Existing code counts remain compatible; missing logs are unavailable evidence. Counts describe observed command outputs, not the true frequency of all errors.
Reason: a shared code cannot establish whether Copy moves occur often enough to justify RFC 0038. Structured categories also let an agent choose the appropriate rule without classifying prose. This small diagnostic schema extension uses a decision record and a P6-7 plan increment; no new rejection, code, source/AIR syntax, verifier/runtime state or repair application is introduced. Existing locations, payloads, interpreter records, resource/borrow invariants and frozen evaluation inputs remain intact. Enum/registry and CLI/report tests cover serialization, generic/package propagation and historical uncertainty. Bundle growth is recorded in docs/agent/README.md. RFC 0038 remains Proposed with its existing recommendation to defer pending frequency and application-usability data.
+7
View File
@@ -33,6 +33,7 @@ Status values: `open`, `resolved`.
| Q-036 | resolved | STD-6a | Dynamic initialized linear buffer storage and drain |
| Q-038 | resolved | STD-6d.2 | Pure construction of built-in errors |
| Q-039 | resolved | STD-6d | Explicit static function parameters |
| Q-041 | open | P6-2 task block forms | Source scope-handle value bindings |
## Q-001 — Text AIR grammar
@@ -297,3 +298,9 @@ General collections and algorithms need explicit typed hash/equality/order opera
P6-8 review found an existing parser ambiguity: `if true { *p = 2u64; } *p = *p + 1u64;` is consumed as an expression continued by multiplication and then rejects E7006 at the assignment. The same failure is reproduced after a standalone block or `match`; `while` dispatches separately and is not affected. Source whitespace is insignificant; spec 15 §4 and the grammar admit both block statements and expressions beginning with block/control-flow forms. The intended disambiguation must be specified before changing which previously parsed expressions are accepted. Decide how a standalone block statement ends before a dereference/other unary-leading statement while preserving block-valued expressions in explicit expression contexts. Add positive/rejected parser and lowering cases for the chosen rule. The formatter preserves the current tokens/AST and MUST NOT insert semicolons or infer the intended statement boundary. This question is separate from P6-8.
**Resolved (DD-016, spec 15 §4):** leading bare `if`, `match` and `{…}` in statement/tail position stop before outer expression operations. The next `}` selects a tail, `;` an explicit discard, otherwise a block statement must yield `void` or diverge (E7006). Parentheses permit continuation; nested expression contexts retain ordinary parsing. The value guard prevents silent reinterpretation of former expressions such as `{2i64} -3i64`. Parser, lowering, formatter and source conformance cover the boundary and compatibility rules. This resolves one P6-1/P6-2 ambiguity, not the complete grammar tasks.
## Q-041 — Source scope-handle value bindings
Independent E7006 review found that `module scope_move fn main()->u64 effects [] { scope sc { let alias = move sc; } 42u64 }` checks and returns 42 with fuel 10,000. Its AIR contains only `task.scope.begin` and `task.scope.end` on the same SSA value; the unused alias introduces no instruction. This observation alone establishes no memory/concurrency safety defect. Spec 15 §3 excludes `scope` from source type spellings, §7 ties scope completion to the block, and spec 04 §33 permits function-local scope flow while preserving linear completion. They do not explicitly say which ordinary source value-binding forms may name that internal handle or how an explicit transfer interacts with the block's retained completion obligation.
Clarify whether `let`/`move` aliases and rebinding of a scope name are permitted, how their availability relates to the originating block, and which existing diagnostic applies to rejected forms. Keep AIR scope identity, live-child/loan checks, deterministic completion and the no-escape invariant intact; add source acceptance/rejection tests for the chosen contract before changing lowering. This is separate from DD-017's reason field and RFC 0038's proposed repairs; neither adopts a new scope rule.
+3 -3
View File
@@ -182,16 +182,16 @@ Updated count after RFC review: **1 concrete RFC candidate** (C5), **1 deferred
RFC 0038 is therefore retained with a recommendation to defer work, preserving formal Proposed status. Its byte offsets and file hash identify an exact edit for a programmatic applicator, but `expected: "[]"` does not identify a unique string replacement. Context plus edit line/column, or an explicitly invoked application command, remain design alternatives rather than adopted fixes. Resume review only after aggregate eligible per-run incidence with a defined denominator, evidence of material repair cost, and validation of the actual application workflow. No arbitrary N% is set from these reports; any owner-selected threshold and minimum sample size must precede a new cohort's evaluation. M/C may only check regression and cannot select or tune the feature. Frozen evaluation inputs remain untouched.
**Independent measurement prerequisite: stable E7006 reasons.** Current frontend E7006 diagnostics do not provide a stable `reason` discriminator. The move rejection in [lower.zig](../../src/frontend/lower.zig) exposes `name`/`type`, but the same rejection site can cover Copy values and other non-linear forms, and E7006 also covers unrelated constructs across frontend stages. Parsing `message` would violate the machine-readable intent of spec 14 §3.5 and cannot supply a reliable Copy-move incidence metric.
**Independent measurement prerequisite: stable E7006 reasons.** At the review baseline, frontend E7006 diagnostics did not provide a stable `reason` discriminator. The move rejection in [lower.zig](../../src/frontend/lower.zig) exposes `name`/`type`, but the same rejection site can cover Copy values and other non-linear forms, and E7006 also covers unrelated constructs across frontend stages. Parsing `message` would violate the machine-readable intent of spec 14 §3.5 and cannot supply a reliable Copy-move incidence metric.
Record a separate diagnostic-schema task, independent of RFC 0038's edits or application workflow, for owner routing to a plan task or RFC. Its proposed completion conditions are:
The review proposed a separate diagnostic-schema task, independent of RFC 0038's edits or application workflow, with these completion conditions:
- Specify stable `reason` values and coverage in spec/reference, distinguishing Copy-move rejection from borrowed/non-Copy moves and other covered invalid constructs. Keep E7006's code/kind and the language's accepted/rejected sets unchanged.
- Emit reasons from explicit frontend error classification, not message parsing or simply assigning one reason to every use of the shared code. Check JSON serialization, original source provenance and positive/negative examples for each specified reason; valid generic Copy transfer remains accepted.
- Keep missing/unclassified reasons explicitly unknown in measurements. Do not relabel historical records or infer their reasons from prose; adding fields to future runs does not recover old data.
- Separately extend evaluation reporting to aggregate affected source runs by `(code, reason)`, alongside existing code counts, with the agreed denominator/cutoff. Merely adding `reason` does not change `_diagnostic_codes`, which currently counts codes only. Both changes must precede the relevant future experiment's freeze.
The reason field improves machine repairability on its own; the reporting follow-up enables the Copy-move branch of 0038's evidence condition. E3101's code-level incidence can already be counted without this prerequisite. No task ID, implementation, new reason name or diagnostic-schema adoption is assigned by this assessment; the owner decides routing and scope.
The reason field improves machine repairability on its own; the reporting follow-up enables the Copy-move branch of 0038's evidence condition. E3101's code-level incidence can already be counted without this prerequisite. The assessment itself assigned no implementation or adoption. Subsequent language work implements the independent schema/reporting increment under [DD-017](decisions.md#dd-017--stable-e7006-reasons-before-repair-frequency-analysis) and [P6-7](../plan/phase-6-source-language.md): every E7006 has a registered reason, and ajieval reports observed occurrences and affected runs with unknown reasons/log availability retained. Code totals are unchanged. The reporting covers the entire recorded transcript; a future cohort must still specify its pre-acceptance cutoff, agent/toolchain strata and missing-data policy. No new experiment, repair-cost evidence or application-usability result is supplied; RFC 0038 remains Proposed with the deferral recommendation.
### C2 — Diagnostic statistics