cli: transform generic source ASTs iteratively

This commit is contained in:
dev committed 2026-10-10 19:07:06 +03:00
1 parent 50a7575efb
commit d39a422b2b
5 files changed
+978 -89

No files matched your search

+2
View File
@@ -535,4 +535,6 @@ The [binary operand increment](source-expression-depth-audit.md#binary-operand-l
The [external review and host-OOM follow-up](source-expression-depth-audit.md#external-review-and-host-oom-follow-up) supersede the initial query OOM-to-unknown policy. A one-shot allocation failure reproduces false E7007 before repair. Expression/expected-use queries and their annotation, field, signature and place callbacks now propagate host OOM separately from optional unknown answers. Worklist buffers retain caller-arena lifetime; list deinit is not immediate physical release. The audit explicitly inventories non-scalar parsing/lowering, generic cloning/path callbacks and liveness/read/assignment scans. Build/units/format checks, all 1,793 ordinary conformance cases, 360 expression-depth and 234 independent-error CLI checks pass; frozen old/new public checks/lowerings remain exact (1,423/506). Recovering caller/callback and public-lowering allocation tests reject false diagnostics and partial publication. Q-061 remains open; this follow-up has no external review yet.
The [generic transformation increment](source-expression-depth-audit.md#generic-ast-transformation-continuations) replaces expression/statement/block cloning and its qualified-path callback with typed work entries. AST/error/instance order, spans, Copy-transfer and static-worker policy are preserved; existing type/instance guards remain. A separate baseline confirms generics.path also aborted on a 16,384-field unknown callee. Full generic scalar checks/lowerings now accept through 65,536; deep unknown callees return exact E7002. Independent shallow/deep/OOM and 497/42/25 CLI checks pass; frozen old/new public checks/lowerings remain exact (1,423/506). All 1,793 ordinary conformance cases pass with exact coverage. Follow-up probes confirm remaining parser failures at 1,024 parenthesized/mixed-call levels and 16,384 qualified-variant fields. Q-061 remains open, without a new limit or external review of this increment.
Audit these paths separately with finite public/generated source inputs before claiming whole-frontend bounded native-stack processing. Prefer explicit continuations preserving existing syntax, evaluation/query order, diagnostics and OOM behavior. A new depth rejection requires a normative decision; Q-059's type-traversal resolution does not authorize one.
+73 -8
View File
@@ -320,20 +320,85 @@ lazy-query tests still avoid unnecessary right-side work. This establishes
compiler error policy, not a new model result or full GC pass. Q-061 is open;
this follow-up has not yet received external review.
## Generic AST transformation continuations
Baseline checks at 50a7575 accept a generic body's 16 negations but abort at
1,024 in `generics.expression`/reflective `walk`, with empty stdout. An unused
template also forces transformation of nongeneric bodies: a 16-component
unknown callee produces E7002, while 16,384 components abort in `generics.path`.
The latter is now an observed callback failure, not just an inspection risk.
Raw records are `generic-transform-before-probes.json` and
`generic-transform-before-*.stdout/.stderr` under the ignored evidence directory.
Typed work entries now clone structural AST children in the former field,
union, optional, pointer and slice order. Inputs borrow stable immutable AST
storage (including the root held throughout a walk); output targets live in
fresh caller-arena nodes. Entries never point into copied union payloads or
queue entries. Type/pattern/binding handling, source spans and generic Copy
transfer flags retain their original policy. Calls have explicit stages:
transform type_arg, resolve/check the callee, transform it, then process
arguments in order, with the existing static-worker exception for task.spawn's
second argument. Constructors resolve their named type before their fields.
Nested instantiation/type queries keep their unchanged depth-64 guards,
instance/key limits and public error policy; no expression-depth limit is added.
The qualified-path callback validates the immutable root first, then allocates
one complete string and fills components iteratively. Direct names and invalid
roots allocate nothing; path bytes and named/static-function decisions are
unchanged. Host allocation failure propagates without a source diagnostic or
public partial AST. List deinit is logical cleanup; work buffers, generated
AST/type nodes and partial internal instances keep caller-arena lifetime until
that arena is destroyed. Allocation requests and failure-index outcomes need
not match the recursive implementation.
An independent copy of the former clone/path descent compares 1,760 shallow
expression/environment combinations, plus function/statement/pattern/select/
lock binding-priority fixtures. It checks complete ASTs, problems, instance and
requirement order and guard counters. Binding/type/instantiation helpers are
shared; nested instance bodies use the production walker, outside this oracle's
independence. Separate helpers exercise 32,768 mixed expression levels, nested
callee targets, statement blocks, else-if unions and deepest static/binding
E7006 positions, plus 65,536 qualified fields. These synthetic helpers do not
claim arbitrary source acceptance. Persistent backing-allocation failures on
mixed/instance fixtures check host errors, guard restoration and physical arena
cleanup; every recovering direct-allocation failure in a public specialization
fixture rejects diagnostics, retries and partial publication.
Full source checks/lowerings now accept generic not/neg/cast/add bodies through
65,536 levels. Generic malformed dereferences retain their inner E7005 and
source position. Deep unknown callees return E7002 with the complete name and
exact location through 65,536 fields (`generic-transform-after-probes.json` and
`generic-transform-after-*.stdout/.stderr`). The permanent CLI suite independently
counts emitted instructions, fuel boundaries and values; it checks source/AIR
and deterministic/hosted parity for smaller accepted depths and exact rejection
records across check/lower/run/report/explore.
Build/unit/Zig format checks pass. The expression-depth suite passes 497 checks;
generic/static-function CLI suites pass 42/25 checks. Frozen old/new CLIs retain
exact exit/stdout/stderr on all 1,423 public source checks and 506 accepted
lowerings (`generic-transform-cli-compatibility.json`). All 1,793 ordinary
conformance cases pass with exact unique corpus coverage and terminal exit 0
(`generic-transform-conformance.jsonl` and its audit). These are compiler
regressions, not a full per-step GC pass or a model-capability measurement.
No normative, source/AIR format, feature, code, bundle, acceptance-limit,
ownership, runtime instruction or model result changes. Q-061 remains open;
this generic increment has no external review yet.
## Remaining work
Current follow-up checks still abort with empty stdout at 1,024 parenthesized
levels and 1,024 generic unary levels (`binary-followup-depth-probes.json` and
`binary-followup-*.stdout/.stderr`). The remaining inventory is broader than
these two observed failures:
Current follow-up checks accept 16 parenthesized/mixed-call levels but abort
with empty stdout at 1,024. A qualified enum variant returns E7002 at 16
components but aborts in Parser.exprPath at 16,384. Raw evidence is
`generic-followup-depth-probes.json` and `generic-followup-*.stdout/.stderr`.
Generic transformation and its path callback above are repaired; the remaining
inventory includes these observed parser failures and inspection-only risks:
| Production path | Evidence and next scope |
|---|---|
| Parser `postfix`/`primary` through parenthesized `expr` | Confirmed failure at 1,024 levels; preserve grouping, precedence and spans. |
| Parser `callArgs`, array/index/struct initializers, `ifExpr`, block/statement and match/arm expression entry | Recursive callbacks inspected; deep behavior unverified. Include mixed forms such as `n + f(n + f(...))`, not only homogeneous spines. |
| Parser `exprPath` | Recursive qualified-field callback inspected; deep source behavior unverified. |
| Generic `expression`/reflective `walk` | Confirmed generic unary failure at 1,024; include call/type/static-worker handling and nested statement/block cloning. |
| Generic `path` | Recursive qualified-field callback inspected; deep full-source behavior unverified. |
| Parser `callArgs`, array/index/struct initializers, `ifExpr`, block/statement and match/arm expression entry | Mixed `1i64 + id(...)` calls have a confirmed parser abort at 1,024. Other callback depth behavior is unverified; include alternating forms, not only homogeneous spines. |
| Parser `exprPath` | Confirmed qualified enum-variant abort at 16,384; preserve named-root classification, spelling, syntax/error priority and spans. |
| Lowerer non-scalar `expr` callbacks: calls, fields/indices/places, arrays/structs, if/match/arms and blocks/statements | Native re-entry remains outside the repaired scalar driver; deep behavior unverified, including 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. |