cli: query SSA liveness with iterative continuations

This commit is contained in:
dev committed 2026-10-11 23:44:20 +03:00
1 parent b2c551047c
commit 5c883ace54
7 files changed
+1427 -339

No files matched your search

+11
View File
@@ -590,6 +590,17 @@ are informational, not an efficiency gate. Full block/if checks still abort at
Phase 6 stay open. Q-062 separately logs a preserved grouped-statement gap.
The [pruned-SSA liveness increment](source-expression-depth-audit.md#pruned-ssa-liveness-continuations)
removes confirmed read/assignment/After native recursion, preserving first-use
kills, loop steps, sibling gates, rest-frame order and pruned join sets. Host
OOM now propagates instead of the former select fallback's silent read fact.
Exact ordinary conformance coverage, frozen public parity and the full 418-call
source liveness CLI suite pass through 65,536 scalar wrappers; nested blocks
still abort later in `blockBodyWant`/`expr`. Final expanded units pass (332/332).
Direct AST tests and scoped Claude reviews do not establish arbitrary control
lowering or the performance of repeated nested-loop rescans. Q-061, Q-060 full
GC validation and Phase 6 remain open; no semantic or accepted-depth change.
## Q-062 — Parenthesized block constructs without a statement terminator
**Open; existing source-parser behavior, not a new rule.** Spec 15 §4 makes
+33 -1
View File
@@ -1242,6 +1242,38 @@ 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.
## Pruned-SSA liveness continuations
At HEAD `b2c5510`, 16/256/1,024 unary wrappers around a later read or a nested assignment join check successfully, but 16,384 wrappers abort without diagnostic JSON in `exprReads` or `After.expr`. Separate nested-block assignment/read probes also abort in `exprAssigns`/`blockAssigns` and `exprReads`/`blockReads`; some lower-depth probes already reach recursive control lowering. The new shared read/assign/After dispatcher removes that AST recursion. Root regions, loop steps, first-use kills and innermost-first rest frames retain their former rules.
The read and assignment child tables remain deliberately different. After captures sibling exclusion after if conditions, match scrutinees and select headers; endpoints retain their original per-arm ordering. A newly encountered loop construct resumes the former full-loop read scan in the same dispatcher, then restores the pending parent's mode. Position-only span comparison, including cross-file equal positions, is preserved. Metadata belongs to one caller allocator per reused Lowerer workspace. Queries clear pending entries on success and error; host OOM propagates and never manufactures a read/assignment fact, a source diagnostic or public partial AIR. The former implicit page-allocator/select-body flattening and its silent `true` on OOM are removed. Caller-arena buffers retain arena lifetime.
Invariant: pruned SSA carries only mutable SSA bindings that may be assigned inside a region and read later (or on a loop back edge); the existing source/verifier ownership and loan rules still validate the resulting AIR. No verifier/runtime rule, ownership/concurrency policy, syntax, AIR format/feature, code, bundle or acceptance limit changes. Valid branch joins and joins before a straight-line kill are exercised through complete source/AIR execution; existing lifetime/CFG rejection twins constrain borrow/cancellation/source-position behavior.
Independent tests copy the entire former family, including the outer rest-frame walk; AST parsing and span comparison helpers remain shared. Every shallow AST span, missing spans and equal positions with different provenance are queried with both seen states. Added root-region/step comparisons and 1,000 three-frame combinations cover shared current/current-expression seen, fresh state per frame, kills before backedges and innermost priority. Multi-statement/body/tail and loops inside match/select/if branches cover mode restoration. Additional 32,768-level groups put competing reads in later siblings and cancellation, with a false innermost loop rescan; exact false/seen and pre-seen true assertions distinguish exclusion from ordinary reads. Deep direct queries exercise 32,768 unary, binary-left/right, block, if/else-if, match, call, while, lock, select and mixed levels; a 65,536-element sequence uses one lazy cursor. Direct-heap and arena-backed per-call failure sweeps cover recovering/sticky failures, grown scratch, reuse after successful and recovering-OOM queries, and release; public lower sweeps cover both accepted and rejected modules.
Deep loop After queries can still perform repeated subtree scans (quadratic worst case), as in the old implementation. The full-depth missing-read loop fixtures deliberately use an absent construct, so they do not establish acceptable performance for that path. No arbitrary-depth control lowering or performance bound is claimed.
Build/format, all 1,793 ordinary conformance cases with exact unique current
coverage, frozen public check/lower byte parity (1,423/506), lifetime (188),
CFG provenance (146), independent-error (234) and repair-advice (299) checks
pass. The complete new `source_liveness_depth.py` suite passes 418 CLI calls:
read/After joins and later kills, both branch outcomes, check/AIR/formatter
fixed points through 65,536, exact unknown-name diagnostics across public
commands and formatted positions, and source/AIR/hosted runtime plus precise
fuel boundaries through 1,024. These do not establish arbitrary control
lowering depth. Final expanded units pass (332/332).
Claude's read-only core, expanded and final test reviews found no production divergence;
their frame/root/group/heap/retry coverage suggestions are addressed by the
added tests. They ran no builds or tests. Earlier failed fixture extraction
assumed every control root was a statement; the corrected test also handles a
tail expression. Earlier logs are historical checkpoints; the final expanded run records
11/11 successful build steps, 332/332 passed tests and terminal exit 0. The
Zig stderr-warning footer alone does not classify an execution outcome.
The repaired scalar probes reach later control callbacks on nested-block inputs: full checking still aborts in `blockBodyWant`/`expr`, independently of these now iterative queries. Shared block/statement/if/match lowering, other remaining callbacks, Q-060 full per-step GC validation and Phase 6 exit gates remain open.
## Remaining work
Follow-up checks accept 16 parenthesized/mixed-call levels but abort
@@ -1257,7 +1289,7 @@ includes confirmed block/if lowerer failures and inspection-only risks:
|---|---|
| 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. |
| Lowerer use-after-region/liveness and assignment scans (`After`, first-use/read scans, region/match/select helpers) | Shared iterative queries are repaired above; 32,768-level direct AST and 65,536-level scalar-wrapper CLI checks constrain them. Repeated nested-loop rescans retain quadratic worst-case work; that performance scope and arbitrary control lowering are not closed by this increment. |
The formatter's expression-marking traversal already uses a worklist, as
inspected and exercised by deep syntax-only probes. This inventory does not