cli: validate structural source type positions before AIR

This commit is contained in:
dev committed 2026-10-07 23:54:55 +03:00
1 parent 5f76e92ff3
commit caf3b86e80
48 files changed
+423 -33

No files matched your search

+2
View File
@@ -154,3 +154,5 @@ DD-019 unique diagnostic fields (cl100k): Quick Reference stays 8,859; other sou
Q-041 source scope names (DD-020, cl100k): Quick Reference 8,859 → 8,889 (+30), other source docs 66,312 → 66,484 (+172), full source 75,171 → 75,373 (+0.27%). o200k groups are 8,925 / 66,690 / 75,615; Qwen2.5 9,167 / 68,115 / 77,282. AIR remains 184,628 bytes / 47,445 cl100k tokens; library/std.md is unchanged. One existing lexical block identifier is explicitly excluded from ordinary value expressions, removing ineffective transfers and misleading repair hints. There is no new syntax, diagnostic code/reason, verifier/runtime state or feature. Former source aliases now reject; ordinary shadowing and AIR scope flow remain available. No empirical MCC benefit is claimed.
Q-023 whole-array arguments (DD-021, cl100k): Quick Reference 8,889 → 8,948 (+59), other source docs 66,484 → 66,669 (+185), full source 75,373 → 75,617 (+0.32%). o200k groups are 8,984 / 66,873 / 75,857; Qwen2.5 9,226 / 68,303 / 77,529. AIR stays 184,628 bytes / 47,445 cl100k tokens; library/std.md is unchanged. One rule follows an explicit ordinary-call signature so existing array-borrow parameters are callable; exact modes, lengths, lexical cleanup, named retained origins and task loans remain checked. No new syntax, diagnostic, feature or verifier/runtime state. Existing primitives suffice; no empirical MCC benefit is claimed.
Q-042 structural type positions (cl100k): Quick Reference stays 8,948; other source docs 66,669 → 66,761 (+92), full source 75,617 → 75,709 (+0.12%). o200k groups are 8,984 / 66,965 / 75,949; Qwen2.5 9,226 / 68,398 / 77,624. AIR remains 184,628 bytes / 47,445 cl100k tokens; library/std.md is unchanged. Existing type-position predicates now reject invalid source annotations before AIR, including known unused generic headers, with structured E7005 fields at the constructor. No new concept, syntax, code, feature or verifier/runtime state is added. Earlier source diagnostic codes/fields may change; graph properties retain verifier diagnostics. No empirical MCC benefit is claimed.
+7 -1
View File
@@ -313,4 +313,10 @@ Clarify whether `let`/`move` aliases and rebinding of a scope name are permitted
Read-only P6-2 review reproduced `module nested fn f(p: ref<ref<u64>>) -> void effects [] {} fn main() -> void effects [] {}` on the preceding compiler. It reaches the verifier and reports E1001 (`position: borrowed`, `found: ref<u64>`) at the source function. Spec 15 §10 requires errors fully decided by source types to be reported as E7xxx, and the AIR type-position rule already rejects this referent. This is an existing frontend validation gap, independent of dereferenced argument parsing; no new borrow semantics is proposed.
Audit source type-position checks against the existing verifier rules, including unused generic signatures where a restriction is already known. Add valid/rejected source fixtures and report E7005 at the offending type annotation before generating invalid AIR; preserve the AIR rules and determine compatibility for existing source diagnostic consumers. The extent beyond this reproduced nested-borrow case is unverified.
**Resolved for structural positions (spec 15 §10):** frontend annotation checks use the verifier's pure type-position predicates. Parameters, returns, fields, payloads, nested constructors, local annotations and known unused generic/static-contract headers reject E7005 at the invalid constructor with `position` and `type_constructor`; unknown parameter restrictions are checked after substitution. Graph-content properties retain E2111. Existing AIR acceptance, diagnostics and runtime rules are unchanged. Invalid source types formerly rejected by E1001 or a feature diagnostic now reject earlier; known invalid unused generic headers and annotations previously skipped by lowering also reject. Generic argument diagnostics may have more precise coordinates and different fields. Property checks beyond structural positions are separate (Q-043); this does not establish complete source type-check coverage.
## Q-043 — Copy content validation for source dynamic owning arrays
Read-only review after Q-042 reproduced `module nested fn unused(p: own_array<own<u64>>) -> void effects [] { trap; } fn main() -> void effects [] {}`. It reaches the AIR verifier with E1001, `dynamic heap arrays require Copy content`. Spec 03 §25 requires Copy content for `own_array<T>`, and spec 15 §10 requires fully source-type-decided errors to be E7xxx. This is a content-property check, not a structural type position. Graph-content properties and Send/Share checks retain their separately specified verifier diagnostics.
Audit this source check, including nominal and substituted generic content, then add positive/rejected source tests and report E7005 before emitting invalid AIR. Preserve AIR's Copy predicate, type identity, allocation/cleanup rules and deterministic behavior. The extent beyond the reproduced signature is unverified.
+8
View File
@@ -237,3 +237,11 @@ The invariant is unchanged borrow mode, aliasing, provenance and child-first tem
Read-only review also found a missing formatter space in grouped `ref (*p)` / `mut (*p)` arguments. The grouped-form regression failed before correcting the keyword spacing; both spellings now preserve tokens and canonical AIR. The separate existing source type-position gap is recorded as Q-042 without changing its semantics here.
Validation: 12 new conformance tests pass with per-instruction collection; full conformance is 1,269/1,269 and unit tests 126/126. Formatter passes 4,357 checks over 983 public files (975 parsed, eight existing syntax errors, 631 identical AIR outputs); source coverage stays 121/121. Old/new CLI comparison over the 971 preceding public sources preserves all diagnostics and 624 successful canonical lowerings. Final independent Claude review passes.
## P6-2 structural type positions (2026-10-07)
Q-042/spec 15 §10 closes source annotation gaps using the verifier's existing pure position predicates. Nested borrows, non-value content, fields/payloads, local annotations and known unused generic/static-contract constructors reject E7005 at their own annotation; restrictions involving unknown parameters wait for substitution. Graph-content properties retain E2111. The invariant remains that second-class borrows cannot be stored or nested in forbidden positions. AIR independently enforces the same rule; no ownership transfer, runtime allocation/cleanup or deterministic interpreter behavior changes.
Thirty-four conformance fixtures cover valid runs/unused headers, forbidden positions, specialization and graph-diagnostic preservation. CLI checks exercise exact fields/positions, all diagnostic commands, package reachability and source/AIR/hosted parity. Existing invalid-source fixtures now expect the earlier E7005. No syntax, code, feature, verifier/runtime state or evaluation input changes; source bundle growth is recorded in docs/agent/README.md. Q-043 records the separately reproduced Copy-content validation gap. P6-2 remains open; the historical P6A-12 checkpoint does not establish completeness for the current language.
Validation: full conformance 1,303/1,303; all 34 new fixtures also pass with per-instruction collection. Unit tests and formatting checks pass. CLI integration passes 74 checks, existing generics/buffers/linear suites pass, and formatter passes 4,453 checks over 1,015 public files (1,007 parsed, eight existing syntax errors, 631 identical AIR outputs). Source coverage remains 121/121. Comparison of 983 preceding public sources finds only five expected invalid-type diagnostic changes, with no check acceptance changes and all other canonical lowerings identical. All 333 public AIR files preserve check diagnostics and acceptance. Independent Claude review passes after clarifying feature-gate precedence.
+2
View File
@@ -404,6 +404,8 @@ A byte string or array used where a `slice<u8>` is expected is materialized in f
- slice element types of `slice.copy`;
- the element rules of channels and mutexes (no borrow, scope, task, shield or guard).
Source type annotations MUST satisfy the existing AIR type-position rules (spec 07 §8.3/§8.8), including nested constructors. An invalid constructor is E7005 at its annotation, with `position` and `type_constructor` fields. Known constructors in unused generic signatures and static function contracts MUST be checked; restrictions depending on a type parameter are checked after substitution. Graph-content properties and feature gates for otherwise correctly positioned types retain their verifier diagnostics.
The verifier remains the authority for:
- ownership state, linearity and moves;