cli: query field annotations iteratively and close type-depth audit
This commit is contained in:
1 parent
d98ddbc073
commit
46bd29953f
6 files changed
+291
-10
No files matched your search
@@ -1,6 +1,6 @@
|
||||
# AIR anonymous type-depth audit
|
||||
|
||||
Non-normative evidence for Q-059, initially at ba99ad6. This audit introduces no syntax-nesting limit, code, feature or acceptance rule. Parser repair preserves format-0 syntax and diagnostics; the verifier and other type traversals remain a separate open obligation.
|
||||
Non-normative evidence for Q-059, initially at ba99ad6. This audit introduces no syntax-nesting limit, code, feature or acceptance rule. The sections below record successive failures and repairs; their remaining-work statements are historical. The [closing inventory](type-traversal-inventory.md) gives the final compiler type-traversal scope and bounds. Runtime validation remains separately tracked by Q-060.
|
||||
|
||||
## Reproducer and observations
|
||||
|
||||
@@ -204,3 +204,38 @@ The identity writer now emits prefixes through a type cursor and stores suffix l
|
||||
Independent shallow comparisons cover scalar/nominal/generated names, capabilities, file modes, static functions, all wrappers, array lengths and prefixes around the exact byte boundary, including complete error objects and intermediate bytes. Writer-only deep fixtures produce an independently assembled 4,095-array key (16,382 bytes), reject the next array at its outer closing span (16,386 bytes), and reject a 32,768-array prefix at the original leaf checkpoint. These helper fixtures are not full source acceptance claims. Failed allocations check propagated OOM, prefix bytes and arena cleanup. Units/format checks and generic/static-function CLI integration (42/25 checks) pass; both new conformance regressions pin code E7006, and hosted checks pin implementation_limit/name/call-site provenance and identical check/lower/report/run/explore diagnostics.
|
||||
|
||||
Both previously failing growth sources now reach one E7006/implementation_limit at 2:35 without stderr; the one-array and single-64-array results retain their prior behavior. All 1,421 pre-existing public source checks and 506 accepted lowerings retain exact old/new exit/stdout/stderr. The full 1,791-case snapshot plus the two added focused regressions cover all 1,793 current conformance files exactly, with every case passing. Closing call-path inventory keeps Q-059 open; Q-056, Q-060 validation and Phase 6 gates remain separate. No normative/bundle/feature/code, runtime/effect/ownership or accepted-depth limit changes; no fresh Claude review is claimed.
|
||||
|
||||
## Best-effort field type lookup and closing inventory
|
||||
|
||||
The closing inspection finds native recursion in `typeOfNoFail`, called by
|
||||
`peekType`/use inference. At d98ddbc, a shallow `r.x.len` expression over a
|
||||
record's nested-array field accepts depth 4,096, but aborts at 16,384 and
|
||||
65,536 with 10,001 typeOfNoFail frames, exit -6 and no diagnostic JSON.
|
||||
Source arrays use `[T; N]`; the failing inputs are 65,662/262,270 bytes.
|
||||
Only child core capture is disabled; no timeout ends a probe.
|
||||
|
||||
The query now validates the chain and resolves its leaf before allocating,
|
||||
then constructs output with a fresh-node cursor. Its restricted name/array
|
||||
classification, length rules and best-effort OOM-to-null behavior are unchanged.
|
||||
Invalid/unknown leaves allocate nothing. Nodes are allocated outer-to-inner
|
||||
instead of inner-to-outer; request counts, sizes and alignments match the old
|
||||
query, and a partial private type is never returned. The caller arena owns
|
||||
partial storage on failure. No verifier, runtime, ownership or syntax rule changes.
|
||||
|
||||
Independent shallow comparisons cover all recognized leaves, unsupported
|
||||
constructors and valid/invalid nested lengths. A 65,536-node output is inspected
|
||||
and freed iteratively; invalid deep leaves/lengths allocate nothing. Every one
|
||||
of 64 node-allocation failures retains null, no diagnostic and complete cleanup.
|
||||
Units/format checks and all 1,793 conformance files pass with exact coverage;
|
||||
all 1,423 public source checks and 506 accepted lowerings retain byte-identical
|
||||
old/new exit/stdout/stderr. Nominal CLI integration passes 130 checks, including
|
||||
deep formatting/lowering, source/AIR checks, report parity and scalar execution.
|
||||
The complete formerly aborting checks now accept without output. These tests
|
||||
do not materialize a deeply nested runtime value.
|
||||
|
||||
The [production inventory](type-traversal-inventory.md) closes Q-059's compiler
|
||||
type-traversal scope: loops/continuations cover unbounded type descent, and
|
||||
remaining recursive type predicates retain their pre-existing fixed guards.
|
||||
Expression/statement depth is a separate scope. Q-056 policy, Q-060's unfinished
|
||||
full per-step GC validation and Phase 6 exit gates remain open. No accepted-depth
|
||||
limit, normative/bundle/feature/code growth or fresh Claude review is claimed.
|
||||
@@ -455,6 +455,8 @@ Compatibility impact is explicit: oversized values/frames formerly accepted now
|
||||
|
||||
## Q-059 — AIR type-syntax nesting and native recursion
|
||||
|
||||
**Resolved, 2026-10-10, for the compiler type-traversal scope in the [closing inventory](type-traversal-inventory.md).** The final inspection found another unguarded type walk: `typeOfNoFail`, reached by shallow `r.x.len` expressions with deep field annotations. At d98ddbc, 16,384/65,536 levels abort with 10,001 query frames and no diagnostic JSON; the iterative repair accepts both. All production paths in the inventory now use loops/continuations or their unchanged fixed-depth guards. Units, format checks, all 1,793 conformance files with exact coverage and deep source/AIR CLI integration pass. This adds no syntax-depth limit or semantic rule. Expression/statement recursion, fabricated cyclic host pointers and Q-060's runtime validation are outside this resolution. The following paragraphs retain the historical investigation states.
|
||||
|
||||
Source inspection during Q-058 finds recursive `parseType` in `src/air/parse.zig` without an explicit syntax-nesting bound. Size/property traversals also use native recursion over finite anonymous type syntax. **Unverified:** no parser stack-exhaustion reproducer has been run; syntactic finiteness alone does not establish a bound on native stack use.
|
||||
|
||||
2026-10-09 [executed audit](air-type-depth-audit.md): a 36,971-byte input with 4,096 length-one nested arrays aborts with a traceback containing thousands of parseType/parseCompoundType frames, rather than a diagnostic. The iterative parser repair accepts that input and unit-tests 32,768 levels, preserving old/new output on 364 public AIR files and constructor/error probes. A subsequent 16,384-depth check still aborts in verifier sizeQuery/sizeValue; that remaining failure is now verified. The original unverified note describes the state before these probes. No syntax-depth acceptance limit is introduced; Q-059 remains open for size, property, validity, equality and formatting traversal audits.
|
||||
@@ -512,3 +514,9 @@ The [runtime value-size increment](runtime-value-depth-audit.md#runtime-value-si
|
||||
The [runtime value JSON increment](runtime-value-depth-audit.md#runtime-value-json-repair) removes recursive value serialization and bypasses the outer stringify's fixed nesting table for internal payloads. Exact encoding/options, outer-container state, writer/allocation failure and deep returned-payload lifetimes are tested; the formerly failing CLI now emits a complete record in deterministic and hosted profiles. All five confirmed Q-060 failure paths have repairs, without a new limit or trap. Q-060 remains open for closing call-path checks, including the inspection-only cache-free public verification/runtime entry path and its connection to Q-059's uncached nominal queries; no verified failure on that path is claimed yet.
|
||||
|
||||
The [cache-free runtime increment](runtime-value-depth-audit.md#cache-free-runtime-size-query-path) removes the recursive accounted-size fallback available through public verification/runtime entry. All runtime size callers propagate temporary metadata OOM before authority charging, retaining quota, fuel and ownership behavior. The deep query-only failure is independently reproduced and repaired; verified library entry and cache equivalence are separately tested. Q-060 remains open for closing traversal checks and full per-step validation; no new normative limit, trap or diagnostic is introduced.
|
||||
|
||||
## Q-061 — Source expression/statement nesting and native recursion
|
||||
|
||||
Inspection during Q-059's closing inventory finds native recursion through source expression parsing (`binary`/`unary`), expression queries (`peekType`/`useIn`) and generic expression transformation (`expression`/`walk`). The fixed generic type/instantiation guards do not establish a bound on arbitrary expression or statement nesting. **Unverified:** no expression/statement stack-exhaustion probe has been run in this audit; this entry records inspection risk, not an observed failure or a new acceptance rule.
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,60 @@
|
||||
# Compiler type-traversal inventory
|
||||
|
||||
Non-normative closing inventory for Q-059, at d98ddbc plus the companion
|
||||
`typeOfNoFail` repair. The [executed audit](air-type-depth-audit.md) records
|
||||
individual failures, compatibility comparisons and allocation tests.
|
||||
|
||||
Scope: finite parsed AIR/source type syntax, resolved nominal declaration
|
||||
graphs, type diagnostics, canonical output and audit reports. Native stack
|
||||
depth must not grow with anonymous type nesting or nominal graph depth on
|
||||
these paths. This does not promise constant memory/time, bounded expression
|
||||
or statement nesting, or bounded processing of fabricated cyclic host pointers.
|
||||
|
||||
| Production path | Traversal / remaining bound |
|
||||
|---|---|
|
||||
| AIR `parseType`, compound construction (`src/air/parse.zig`) | Pending constructor frames; no recursive child parse. |
|
||||
| AIR `Type.eql`, `inner`, classification (`src/air/module.zig`) | Cursor comparison or one-node inspection; names stop at declaration identity. |
|
||||
| Verifier `accountedSize`, `SizeMemo.size`, `ValueSizes.visit` (`src/verifier/budget.zig`) | Affine anonymous fold, explicit nominal continuations and inner-node loop; nominal cycle depth changes exactly as before. |
|
||||
| `wellFormed`, `argumentLengths`, finite layouts (`src/verifier/types.zig`) | Anonymous cursors and nominal DFS frames; graph-owner stops and ordered diagnostics retained. |
|
||||
| Nine structural properties, dependencies, height/witness summaries (`src/air/properties.zig`) | Anonymous cursor/mode transitions plus monotone nominal worklist; summary saturation at 65/34 is unchanged. |
|
||||
| Public uncached property queries | Temporary prepared module, allocator/error API; no recursive raw fallback. Prepare once for repeated nominal queries to avoid repeated whole-module preparation. |
|
||||
| `bounded` (`src/air/properties.zig`) | Remaining production recursion checks `depth >= 64` before descent; cached nominal reads use height. |
|
||||
| AIR canonical/diagnostic type printer, report capability collector (`src/air/print.zig`, `src/report.zig`) | Explicit suffix stack or anonymous cursor; declaration roots enumerated separately. |
|
||||
| Source `typeExpr` (`src/frontend/parse.zig`) | Explicit constructors/argument continuations, including speculative advice parsing. |
|
||||
| Source formatter, generic-use detector (`src/frontend/format.zig`, `src/frontend/generics.zig`) | Token spans / AST work entries; reflective visitation queues children rather than recursively visiting type syntax. |
|
||||
| Source type-position and Copy-content scans (`src/frontend/type_positions.zig`, `src/frontend/type_properties.zig`) | Anonymous cursors, explicit nominal argument/member continuations and indexed cycle paths. |
|
||||
| Source resolution, text, AIR conversion, equality (`src/frontend/lower.zig`) | Pending constructors/suffixes, fresh output-target cursor or two comparison cursors. |
|
||||
| Source linearity, signature feature discovery, SSA zero | Iterative chains; the existing module-sized feature-discovery guard remains. Unsupported zero leaves reject before emission. |
|
||||
| Source best-effort `typeOfNoFail` | Validate chain/leaf before allocation, then build fresh output nodes iteratively. Only names/arrays are recognized; OOM remains `null`, without a diagnostic or published partial type. |
|
||||
| Source `forbiddenIn` | Remaining recursion checks `depth > 32` before descent; named cached distance prunes unreachable witnesses. Calls to annotation resolution use the iterative path above. |
|
||||
| Generic headers/substitution/static arguments | `headerType`/`headerArgument` and `ty`/`instantiate` retain their existing guards at 64. Static-function argument resolution re-enters guarded instantiation; reflective specialization intercepts `ast.Type` before visiting its representation. |
|
||||
| Composed specialization identities | Iterative prefix/leaf/suffix writer. Substitution can return an already composed type deeper than one guarded `ty` traversal, so identity emission must not rely on that guard. Existing key-size checks retain their postorder spans. |
|
||||
|
||||
Prepared reads have an explicit precondition. `verifyModule` discards caller
|
||||
caches; `types.check` prepares its module before type queries and subsequent
|
||||
borrow/init/bounds stages. Source lowering uses its separately prepared
|
||||
`property_module`. Raw public APIs prepare temporary facts rather than silently
|
||||
using the prepared-only API. Replacing declarations invalidates both caches.
|
||||
|
||||
The recursive `Reference*` derivations, `referenceSize`, `referenceTypeHint`
|
||||
and AIR-property `witness` are shallow test oracles, not production call paths.
|
||||
A textual self-call census was used as a search aid, followed by inspection of
|
||||
delegated and mutually recursive paths; it is not itself a proof. The module
|
||||
import graph has a separate existing depth-256 guard and does not traverse
|
||||
type syntax. Recursive expression parsing, expression queries and generic
|
||||
expression transformation remain outside this type-depth claim and are logged
|
||||
separately as inspection-only Q-061.
|
||||
|
||||
Validation combines the increment-specific independent shallow oracles,
|
||||
32,768/65,536-level helper and CLI probes, nominal cycles/shared graphs,
|
||||
allocation failures and exact diagnostic/canonical-output comparisons. The
|
||||
latest field-expression probe is deliberately shallow (`r.x.len`) with a deep
|
||||
annotation: it catches a type walk missed by plain parameter checks. Its CLI
|
||||
integration also checks formatting, source/AIR checking, lowering, report parity
|
||||
and scalar execution. It does not materialize a deep runtime value.
|
||||
|
||||
Q-060 separately tracks runtime value/copy/collector/JSON traversal and its
|
||||
unfinished full collection-before-each-instruction validation. Neither this
|
||||
inventory nor the compiler tests close that runtime gate or the Phase 6 exit
|
||||
review. Claude's earlier review covers uncached nominal properties only;
|
||||
subsequent frontend repairs have prepared review requests, not a received review.
|
||||
@@ -508,3 +508,9 @@ The [Q-059 zero increment](../design/air-type-depth-audit.md#source-ssa-zero-emi
|
||||
The [Q-059 identity increment](../design/air-type-depth-audit.md#composed-specialization-identity) repairs native failures on tiny expanding-substitution sources. Key emission is iterative; canonical bytes, postorder size/error-span checks, reuse/names and all existing specialization limits remain unchanged. Two permanent conformance cases and hosted CLI checks retain one E7006/implementation_limit at the call site across all rejection entry points.
|
||||
|
||||
Units/format checks, shallow/deep key-boundary and OOM tests, generic/static-function integration (42/25), and old/new checks/lowerings over the pre-existing source corpus (1,421/506) pass. The full 1,791-case snapshot plus the two focused additions cover all 1,793 current conformance files exactly. Closing call-path inventory, Q-056 policy, Q-060 validation and Phase 6 gates remain open. No normative/bundle/feature/code or accepted-depth limit changes; no fresh Claude review is claimed.
|
||||
|
||||
## Type-depth closing audit (2026-10-10)
|
||||
|
||||
Q-059 is resolved for the [compiler type-traversal inventory](../design/type-traversal-inventory.md). The final repair removes a confirmed `typeOfNoFail` failure reached through shallow field expressions; complete checks accept 16,384/65,536 nested field-array levels. The best-effort query retains its type classification and OOM-to-null contract without publishing partial output. Independent shallow/deep/allocation tests, units/format checks, all 1,793 conformance cases with exact coverage, nominal CLI integration (130 checks) and byte-identical old/new source checks/lowerings (1,423/506) pass.
|
||||
|
||||
This closes type descent, not arbitrary expression/statement recursion (inspection-only Q-061), Q-056 policy, Q-060's unfinished full per-step GC validation or Phase 6 exit review. No normative/bundle/feature/code or acceptance-limit changes; Claude's earlier nominal-property review does not cover these later frontend increments.
|
||||
Reference in new issue
Block a user