cli: parse control flow with shared continuations

This commit is contained in:
dev committed 2026-10-11 22:18:21 +03:00
1 parent 9534359595
commit b2c551047c
5 files changed
+1442 -345

No files matched your search

+40
View File
@@ -34,6 +34,7 @@ Status values: `open`, `resolved`.
| Q-038 | resolved | STD-6d.2 | Pure construction of built-in errors |
| Q-039 | resolved | STD-6d | Explicit static function parameters |
| Q-041 | resolved | P6-2 task block forms | Source scope-handle value bindings |
| Q-062 | open | P6-2 | Parenthesized block constructs without a statement terminator |
## Q-001 — Text AIR grammar
@@ -574,3 +575,42 @@ The [mutex make/take increment](source-expression-depth-audit.md#mutex-maketake-
The [scalar index operand increment](source-expression-depth-audit.md#scalar-index-operand-continuations) preserves base/type/operand priority, usize hints, bounds facts, unchecked state, loans, load/end order, spans and host OOM. Build/units/format and store-mode/array-argument/lifetime/CFG suites pass; exact ordinary conformance (1,793), public frozen parity (1,423/506), the original focused run passes 318 CLI checks (check through 32,768 then existing E5101 at 65,536; lower/fmt through 65,536; runtime/fuel through 1,024), and separate overlapping 30-call fuel/28-call CFG/deref/proven-context subsets pass. Read-only Claude core/final reviews found no production defect and their fixture/wording suggestions are covered. At that scalar-operand checkpoint the recorded nested-array base-index probe still aborted at 1,024 before/after; its subsequent repair is recorded below. Other place/control/liveness callbacks, Q-060 and Phase 6 remain open. No semantic or new depth-limit change.
The [raw-place base increment](source-expression-depth-audit.md#raw-place-base-continuations) repairs the recorded 1,024-level nested-array base failure using iterative field/index projections and one ancestor-name list. Borrow modes, parents, child-first ends, range ordering, facts, unchecked selection, spans and host OOM separation are preserved. Exact ordinary conformance coverage, public check/lower parity and 159 focused CLI calls pass; expanded units pass, and scoped read-only Claude core/final reviews found no production defect. Follow-up block/if probes confirm remaining parser aborts at 1,024 before/after. Q-061, Q-060 full GC validation and Phase 6 remain open; no semantic or depth-limit change.
The [shared control-parser increment](source-expression-depth-audit.md#shared-control-parser-continuations)
removes native expression/control re-entry through blocks/statements, conditions,
if/else-if, match/arms, select, loops, scopes, shield and lock. Deep mixed,
ungrouped-condition and wide ASTs, token EOF/deletion sweeps, scope/advice,
scratch and recovering/persistent OOM tests pass. All 1,793 ordinary conformance
files have exact successful coverage; public check/lower parity (1,423/506),
grammar/format/error/advice suites and 127 focused CLI calls pass. Scoped
read-only Claude reviews found no production defect. Arena backing/RSS figures
are informational, not an efficiency gate. Full block/if checks still abort at
1,024 in lowering; control/liveness and remaining callbacks, Q-060 full GC and
Phase 6 stay open. Q-062 separately logs a preserved grouped-statement gap.
## Q-062 — Parenthesized block constructs without a statement terminator
**Open; existing source-parser behavior, not a new rule.** Spec 15 §4 makes
unparenthesized block constructs self-delimiting and requires semicolons for
ordinary expression statements; the reference grammar includes `expr ";"` in
`statement`. The parser also accepts a parenthesized block/if/match followed by another
statement without `;`, through the ordinary expression path's block-kind
fallback. Claude identified this during the Q-061 control-parser review.
A frozen HEAD `9534359` binary and the shared-control-parser candidate both
accept this complete source with exit 0 and no diagnostics:
```aji
module grouped
fn g() -> void effects [] {}
fn main() -> u64 effects [] {
(if true {} else {}) g();
return 0u64;
}
```
The Q-061 traversal repair deliberately preserves this behavior. A separate
spec/parser decision and positive/negative boundary tests are needed before
changing acceptance. This does not add a semantic rule or close Q-061.
+82 -2
View File
@@ -1162,6 +1162,86 @@ Control parsing/lowering, multi-result/graph callbacks and liveness/read/
assignment scans keep Q-061 open. Q-060's full GC validation and Phase 6 exit
review remain independent open gates.
## Shared control parser continuations
At HEAD `9534359`, nested block/if expressions parse and check at 16/256
levels but abort in the parser at 1,024; a separate else-if chain formats at
1,024 but aborts at 16,384. The shared parser driver now queues block,
statement, condition, if/else-if, match/arm, select, loop, scope, shield and
lock children alongside expression continuations. All use one stable result
frame; the expression-returning entry API cannot select control-only outputs.
Unused recursive-entry wrappers and multi-frame machinery are removed.
This is a traversal repair: tokens, AST/spans, statement/tail/discard boundaries,
`block_statement`, arm-kind selection, error priority and borrow advice retain
their existing rules. Conditions/call advice restore on all exits; for/lock
prefix and group/index restoration remains success-only, as before. Host OOM
propagates without diagnostic conversion or a public partial AST. Work buffers
and AST allocation retain caller-arena lifetime; `deinit` does not promise
physical early release of arena storage. Spec/reference, AIR, verifier,
ownership/concurrency/runtime, diagnostic codes, bundles and acceptance limits
are unchanged. The existing grouped-statement discrepancy is logged separately
as Q-062, with old/new accepted CLI evidence.
An independent copy of the former mutually recursive control/expression
parser compares shallow ASTs, mutated token buffers, position/end/failure and
scope state. Token/type/pattern helpers remain shared, an explicit oracle
limitation. Added checks cover per-token EOF/deletion sweeps with outer borrow
advice; every control child form's invalid leaf; 32,768 mixed/block and
ungrouped-condition levels; 32,768 statements, match/select arms and else-if
links; control-heavy scratch poisoning; recovering and sticky per-call OOM
above the arena, including grown queues and late failures. A physical backing
tracker measures scalar, block and mixed parsing and verifies complete backing
release after arena teardown. Expanded and final follow-up units pass,
including both OOM modes with resize/remap disabled to inject every growth.
The fixed failure-sweep guards are test bounds, not language limits.
At 32,768 levels, measured live arena backing allocations peak at:
| Input | Source bytes | Peak backing bytes |
|---|---:|---:|
| Scalar `not` chain | 131,126 | 89,887,292 |
| Nested blocks | 131,127 | 139,565,186 |
| Mixed 17-form tree | 805,722 | 692,273,454 |
Work items are 448 bytes, compared with the reconstructed former
expression-only union's 424 bytes; the single frame is 1,992 bytes. The former
payload layouts were checked unchanged, but this is not a before/after peak
measurement. The 24-byte item growth does not justify boxing control payloads
and adding allocation/aliasing paths in this repair. The large stress peaks
are informational, not evidence of efficient memory use or a portable bound.
They include tokenization, owned token duplication, AST, retained work buffers
and arena slack; they exclude source text, allocator overhead and downstream
passes. Backing allocation lengths are distinct from resident process memory.
The separate 12-form, 32,768-depth hosted rejection source is 857,464 bytes;
one Linux/Debug `check` measured 350,804 KiB max child RSS. Its six-command
comparisons run sequentially. This does not bound other environments.
The focused standalone CLI block passes 127 calls: block/if formatting and
fixed points through 1,024; else-if through 65,536; bounded check/lower through
256 and source/AIR runtime through 16; syntax-only control contexts at 256;
and exact E7001/boolean-negation records for six public commands through
32,768 with CRLF/UTF-8 source. It is an exact extraction of the new block in
`tests/hosted/source_expression_depth.py`, not a run of that whole accumulating
suite. Build/format, frozen public check/lower byte parity (1,423/506), grammar
(312), formatter (6,078), independent-error (234) and repair-advice (299)
checks pass. All 1,793 ordinary conformance files pass with exact unique
coverage; no file is omitted or counted twice.
Claude's core read-only review found no demonstrated production divergence;
its API/dead-path, mutation, deep/wide, scratch and OOM suggestions are addressed
above. Read-only follow-up/final reviews also found no production defect
within their recorded scope; they ran no tests. Final review clarifications:
peak measurements are informational and the historical work-size reconstruction
is explicit; the hosted memory-heavy scope is documented. Its counter concern
does not reproduce: `cli` increments the global counter and the standalone
extraction records all 127 calls. Current frame/queue poisoning does not cover
abandoned arena buffers, a retained test limitation.
The new parser exposes the next confirmed failure: full checking still aborts
at 1,024 nested block/if levels in `blockBodyWant`/`ifExpr`, with empty stdout.
Lowering/control/liveness, Q-060 full GC validation and Phase 6 exit gates stay
open.
## Remaining work
Follow-up checks accept 16 parenthesized/mixed-call levels but abort
@@ -1171,11 +1251,11 @@ components but aborts in Parser.exprPath at 16,384. Raw evidence is
Generic transformation, its path callback, Parser.exprPath and the shared
expression parser above are now repaired. The preceding follow-up records are
historical checkpoints, not current parser failures. The remaining inventory
includes a confirmed lowerer failure and inspection-only risks:
includes confirmed block/if lowerer failures and inspection-only risks:
| Production path | Evidence and next scope |
|---|---|
| Parser `ifExpr`, block/statement and match/arm expression entry | Finite block/if probes above confirm parser aborts at 1,024 before/after the raw-place repair; 16/256 accept. Alternating control/statement combinations still need audit. |
| Parser block/statement/condition and if/match/select expression entry | Shared control/expression continuations are repaired above. Historical parser aborts no longer describe the candidate; parser-only deep coverage does not prove downstream AST traversal. |
| Lowerer non-scalar `expr` callbacks: builtin/variant calls, fields/indices/places, arrays/structs, if/match/arms and blocks/statements | Ordinary calls, struct/value-field, array and enum-payload descent are repaired above. Boolean, consuming own/region, atomic, task.join and spawn operands are repaired above. Mutex make/take operands are repaired above. Scalar index operands use continuations above; the recorded nested-array base-index failure is repaired by the raw-place increment above. Dereference/bound expression callbacks and graph/control combinations still need audit. Multi-result task.join_cancel inputs and other graph/place/control callbacks retain native entry. Other callback depth remains unverified; include alternating scalar/non-scalar expressions. |
| Lowerer use-after-region/liveness and assignment scans (`After`, first-use/read scans, `blockAssigns`/`stmtAssigns`/`exprAssigns`, match/select helpers) | Recursive AST walks inspected; audit their callers and finite deep inputs separately. |
+24
View File
@@ -832,3 +832,27 @@ production defect. Documentation scope corrections are recorded in the audit. Th
claimed. Block/if parsing still aborts at 1,024 before/after; other callbacks
and liveness/read/assignment scans, Q-060 full GC validation and Phase 6 exit
review remain open. No normative, feature, bundle or accepted-depth change.
### Shared control parser depth increment
The [shared control parser](../design/source-expression-depth-audit.md#shared-control-parser-continuations)
uses one expression/control driver for block/statement, if/else-if, match/arms,
select, loops, scopes, shield and lock. Grammar, AST/spans, error/repair advice,
statement/tail boundaries and scoped state retain their former behavior; OOM
propagates without diagnostics or public partial AST. Unused entry wrappers and
multi-frame machinery are removed. No semantic/feature/bundle/depth-limit change.
Build/format, frozen public check/lower parity (1,423/506), grammar (312),
formatter (6,078), independent-error (234), repair-advice (299) and 127 new
focused CLI calls pass. Final expanded/follow-up units and all 1,793 ordinary
conformance cases with exact unique coverage pass. Arena backing measurements
are informational, include tokens/AST/work/slack, and do not assert efficiency
or a memory bound; the audit records the large mixed stress peak and separate
hosted RSS measurement. Read-only Claude core/follow-up/final reviews found no
production defect within their scoped inspections; they ran no tests. Parser-only coverage is distinguished from bounded lower/runtime
coverage and from the unrun whole accumulating expression-depth suite.
Full block/if checking at 1,024 now reaches a confirmed lowerer stack failure.
Q-062 logs the independently reproduced existing parenthesized-statement
boundary discrepancy. Q-061 lowering/control/liveness, Q-060 full per-step GC
validation and Phase 6 exit gates remain open.