cli: validate Copy content of source owning arrays

This commit is contained in:
dev committed 2026-10-08 09:01:58 +03:00
1 parent caf3b86e80
commit cfbe01a16f
42 files changed
+608 -3

No files matched your search

+2
View File
@@ -156,3 +156,5 @@ Q-041 source scope names (DD-020, cl100k): Quick Reference 8,859 → 8,889 (+30)
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.
Q-043 dynamic owning-array content (cl100k): Quick Reference stays 8,948; other source docs 66,761 → 66,827 (+66), full source 75,709 → 75,775 (+0.09%). o200k groups are 8,984 / 67,031 / 76,015; Qwen2.5 9,226 / 68,466 / 77,692. AIR remains 184,628 bytes / 47,445 cl100k tokens; library/std.md is unchanged. Existing Copy-content rules now reject annotations and repeated allocation values with structured E7005 before AIR, including known unused generic/static contracts and nominal contents. Unknown parameters defer to substitution; iref remains phantom. No new concept, syntax, code, feature or verifier/runtime state is added. Earlier invalid-source diagnostics and priority may change; graph-root properties retain verifier diagnostics. No empirical MCC benefit is claimed.
+13 -1
View File
@@ -319,4 +319,16 @@ Read-only P6-2 review reproduced `module nested fn f(p: ref<ref<u64>>) -> void e
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.
**Resolved (spec 15 §10):** annotation and repeated-allocation checks report E7005 at the non-Copy content/value, with `constraint: Copy` and `type_constructor: own_array`. The shared AST property query follows nominal fields and enum payloads in their declaring namespace, honors user types before built-in names, and keeps `iref` content phantom. Unused generic/static headers reject when linear content is already known; unknown parameter properties wait for substitution. Recursive generic paths are distinguished by the known-linear parameter vector, so parameter rotations cannot hide a known linear leaf. Pure by-value cycles retain E1003; a proven Copy-content violation may reject before a simultaneous layout error. Graph-root content checks retain E2111. AIR acceptance, codes, type identity, allocation/cleanup and interpreter behavior are unchanged; invalid source programs now stop earlier instead of producing invalid AIR. No new syntax, code, feature or verifier/runtime state is introduced.
## Q-044 — Nominal linearity query cost before layout rejection
Q-043 review identified a separate existing cost in `Lowerer.linearAt`: repeated fields and by-value cycles revisit nominal declarations until its depth bound, with no shared-result cache. `checkRequirements` asks this query before `checkFiniteLayouts` rejects E1003. The bound guarantees finite recursion but does not bound the number of branching revisits. Q-043's new annotation query has counted tests for shared acyclic/cyclic branches; the old classification query is unchanged. The precise cost and scope of other nominal property queries remain unverified.
Audit the existing classification/layout ordering and shared-query cost with counted tests, preserving structural ownership classes, graph/iref boundaries, source E1003 provenance, accepted-source canonical AIR and frozen AIR behavior. Avoid wall-clock timeout tests. This is an implementation audit, not a new recursion or memory rule.
## Q-045 — Source array literals with second-class elements
Q-043 review reproduced `fn unused(p: ref<u64>) -> void effects [] { let a = [p, p]; }`: the source array literal reaches AIR type checking with E1001 because borrows cannot be stored as array elements. Q-042 validates annotations; an inferred literal has none. Q-043 now rejects that array as a repeated `own.array` value, but constructing it without that operation remains a separate source validation gap.
Audit inferred list/repeat literals against existing member-position and Copy-duplication rules, including nested arrays and nominal values. Add source positives/rejections with E7005 at the offending source value while preserving explicit moves in fixed linear arrays, borrow provenance and frozen AIR semantics. Scope beyond this reproduced literal remains unverified.
+8
View File
@@ -245,3 +245,11 @@ Q-042/spec 15 §10 closes source annotation gaps using the verifier's existing p
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.
## P6-2 dynamic owning-array content (2026-10-08)
Q-043/spec 15 §10 enforces the existing Copy-content requirement for source `own_array<T>` annotations and `own.array` repeated values before AIR emission. One AST property query follows nominal fields/payloads and generic parameter states without calling lowering recursively. User type names precede built-ins; imported fields use their declaring namespace. Unused generic/static headers reject provable linear content; unknown parameters defer to substitution. A query-local cache shares completed branches, keeps positive witnesses final and rechecks negative results whenever a new positive proof is learned. Parameter-state queries repeat until that generation stabilizes; memo lookup is a linear scan, trading peak cost for implementation simplicity. Parameter rotations and deep nominal chains cannot hide a known linear leaf; iref content remains phantom and graph-root properties retain E2111.
The preserved invariant is that repeated dynamic heap arrays contain Copy values, so bulk release cannot destroy nested resources. AIR independently retains the same type/operation checks; allocation budgets, initialization, owner transfer, explicit release and deterministic interpreter behavior are unchanged. Valid Copy allocations run with explicit release; rejected annotations and repeated linear values report E7005 with `constraint` and `type_constructor`. Existing invalid-source codes/priority may change, including Copy violations preceding simultaneous layout errors. No syntax, code, feature, verifier/runtime state or evaluation input changes. Source bundle growth is recorded in docs/agent/README.md; P6-2 remains open.
Validation: full conformance 1,335/1,335; all 32 new fixtures also pass with per-instruction collection. Unit tests pass 128/128, including counted acyclic/cyclic diamond queries; the cyclic case failed before the cache correction. CLI integration passes 119 checks with exact annotations/value positions, nested package imports and source/AIR/hosted parity. Formatter passes 4,563 checks over 1,047 public files (1,039 parsed, eight existing syntax errors, 638 identical AIR outputs); source coverage remains 121/121. Comparison of all 1,017 preceding public sources preserves every check/lower result and all 631 successful canonical lowerings. No AIR verifier/runtime files change. Independent Claude review passes after checking shadowing, generic rotations, cache invalidation and the complete declaration snapshot used by the shared Copy predicate.
+1
View File
@@ -403,6 +403,7 @@ A byte string or array used where a `slice<u8>` is expected is materialized in f
- lossless widening by `as` (the verifier's own rule);
- slice element types of `slice.copy`;
- the element rules of channels and mutexes (no borrow, scope, task, shield or guard).
- Copy content of `own_array<T>` and the repeated value of `own.array`; an invalid content type is E7005 at that annotation/value, with `constraint: Copy` and `type_constructor: own_array`. Known linear content in unused generic signatures and static contracts MUST reject; unknown type parameters are checked after substitution.
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.