Files
aji/docs/design/contract-source-and-module-state.md
T

189 lines
34 KiB
Markdown

# Contract source elaboration and rooted module-state candidate
Non-normative continuation of [RFC 0039](../rfcs/0039-verifier-visible-contracts.md), [checked representations](contract-invariant-boundaries.md) and [proof/report rules](contract-proof-and-report.md), initially at `8260d35`, with the property/inventory refinement verified against `4cda448`. This proposal adds no implemented syntax, feature or normative rule. It preserves full P6-6, including type/module claims and all four statuses. Hidden globals, visibility, diagnostics/dispatch integration, adoption and vertical delivery are not established here.
## Module invariant and identity
Propose that a module may name its explicitly rooted persistent state with a narrow declaration:
```aji
module account
struct Rep { balance: u64, limit: u64 }
fn within(r: ref<Rep>) -> bool effects [] { return r.balance <= r.limit; }
invariant State = type.checked<Rep, fn within>;
```
`invariant` is contextual only at item start. State is a type binding for exactly the structural checked<R,p> identity; it is not an ordinary struct with a public rep field. Its defining module owns the declaration, while callers own each value. All exposed State values/shared content views satisfy p, even in unlisted functions/importers, because creation and updates use checked.make/modify and ordinary operations cannot manufacture it or mutate representation observations admitted by p. Interior-mutable interfaces may still change ignored members, as required by S. Extraction returns ordinary R with no claim. Neither a singleton nor an invocation of a module constructor is implied.
Correlated owners belong in one representation State: its borrow ancestry protects the joint relation while views are shared. A relation over independently owned roots instead remains a pre/post boundary claim; it can fail between calls. This is not a module-wide persistent guarantee. No new named boundary-group metadata is proposed: listing functions cannot establish that all mutators are listed when fields are public. Ordinary prefix coverage is still checked independently by the AIR verifier.
Choosing rooted state as spec 13's module-invariant model is an owner decision. If hidden module-global state is required, this candidate does not provide it and a separate state/encapsulation abstraction is needed. The module requirement is not silently replaced with function contracts.
Two invariant names with the same resolved R and p denote the same type. Distinct nominal representations remain distinct. This is a narrow checked-type binding, not a general alias facility. Direct type.checked<Rep, fn within> type expressions remain available. A generic declaration uses existing type/static-function parameters, for example `invariant State<T: Copy> = type.checked<Rep<T>, fn within::<T>>;`. Predicates specialize explicitly and must have exactly ref<R> -> bool, no captures, and S membership after substitution. A binding's constraints restrict its use; direct checked types still follow their own R/p validity rules, not an unrelated alias's constraints.
Resolve these bindings before equality, property tests and specialization-key construction. The canonical type key spells `checked<canonical-R,fn canonical-function-identity>`; an alias spelling does not create a different container specialization. Existing type/function keys are unchanged. Imports retain direct-import lookup; no module name is inferred from AIR mangling. Alias-resolution cycles fail with a stable E7006 reason; expansion depth, specialization count and key bytes use the existing 64/4096/16384 compiler bounds. Nominal representation references stop alias expansion; ordinary recursive-layout validation remains independent.
Every concrete declaration must reach AIR type verification even when no value is constructed. Candidate lowering emits a generated identity witness `fn @w(%value: checked<R,@p>) -> checked<R,@p> effects [] { ret %value }`. It is never implicitly invoked, holds no global state and validates the type/predicate through its signature. Linear values transfer on its ordinary ret. Its declaration appears in canonical AIR and the report's ordinary functions list, with no calls or check rows. Generic witnesses are emitted for concrete specializations; known template restrictions still check before substitution. The representation/type-position rules below require parameter/return admissibility, so this witness does not impose an additional position restriction on an otherwise valid checked type.
## Source grammar and explicit operations
Proposed additions to the existing grammar: new clause/declaration introducers are contextual; type/fn reuse existing reserved keywords.
```ebnf
checked_type = "type" "." "checked" "<" type "," "fn" name_path [ application ] ">" ;
invariant_decl = "invariant" ident [ type_params ] "=" checked_type ";" ;
checked_op = "type" "." "checked" "." ( "make" | "view" | "take" | "modify" )
[ application ] call_args ;
contract_mode = "assume" | "document" ;
contract_block = "{" expr ";" { expr ";" } "}" ;
requires_group = "requires" [ contract_mode ] contract_block ;
ensures_group = "ensures" [ contract_mode ] contract_block ;
fn_tail = "effects" "[" [ path { "," path } [ "," ] ] "]"
{ requires_group } { ensures_group } block ;
```
Groups are nonempty, use bool expressions with terminators, and appear after effects. Requires groups precede all ensures groups; relative source order within each class is preserved. No trailing expression substitutes for the semicolon and no clause occurs in the body. Requires/ensures/assume/document remain identifiers outside this header position; old/result remain ordinary names outside ensures. This deliberately replaces spec 13's illustrative clause placement, not today's implemented grammar.
Use existing explicit static-function argument syntax for checked operations:
```aji
let s: State = type.checked.make::<Rep, fn within>(Rep { balance: 0u64, limit: 10u64 });
ref whole = s;
ref raw = type.checked.view(whole);
// A later exclusive scope, after both shared views end:
type.checked.modify::<fn update>(state_borrow, amount);
let plain = type.checked.take(value); // use move value when it is linear
```
Make has two static arguments, representation and predicate. Modify has one explicit static function selection; its first runtime operand is a named exclusive checked borrow, followed by callback extras. View uses a named shared/exclusive checked borrow and returns a shared child; take uses an ordinary whole checked value with the existing move discipline. View/take have no static arguments. The `::` application form is chosen because selecting a static function uses the existing generic-argument syntax; channel.make/buffer.new's type-only dot-step syntax is unchanged. Built-in operations are not selectable function arguments. No runtime function value or special `fn` expression argument is introduced. Whole-value literals initialize R, not State: `State { ... }`, zero State and direct mutable content projections reject. Construction validation is visible in type.checked.make rather than hidden in a struct literal.
The reserved type keyword anchors these new forms. Ordinary modules/functions/types named checked, including user generic `checked<R, fn f>` and self-qualified `checked.make`, retain ordinary lookup. Using checked.* as the built-in namespace would hijack accepted programs; no such reservation or context-sensitive fallback is proposed. Exact source spelling uses type.checked, while AIR operations/type constructors retain checked.* / checked<...>. Grammar integration adds checked_type to types, checked_op to expression primaries, and the view form to borrow-binding calls; it does not admit type names or other checked operations as borrow results.
## Clause roots, result and snapshots
A clause is checked in a separate lexical environment containing original header parameters and directly accessible functions/types; it cannot capture a body local or a reassigned/shadowing body binding. Data parameters may be read by value. Borrow parameters expose a temporary read-only view (mut becomes ref; slice_mut becomes slice), not their writable mode. Owned/authority-containing non-Data values require an explicit shared root observation, such as `valid(ref owner)` or a nested expression block with `ref r = owner;`; they cannot be passed/loaded by value. Ordinary owner unwrap and whole-array/slice argument rules remain explicit. There is no new implicit owner dereference.
Expression blocks may use fresh Data scratch and ordinary P helper calls, including loops. Inline clause/old expressions cannot return from the surrounding function or the generated collector: reject return statements with a stable contract-context reason; break/continue target only loops inside the expression. Named predicate/Data helpers retain ordinary returns. Writing through a header root, synchronization, authority, ambient observations or ownership transfer remains forbidden. The helper is independently checked by AIR P membership; a source purity annotation is not evidence. Capture keys are (original parameter ordinal, value/shared-root form), with projections/adapters inside the helper. Repeated equal keys share an argument; value precedes shared-root form for each ordinal. Old's helper uses the same deduplicated union of captures across all executable old expressions. Post appends its one snapshot-record argument when used, then result observations (value before ref) when used. More than 64 helper arguments, including these, reports the mapped E5101 parameter/argument bounds; do not split a clause silently. This fixes AIR n/E/W independently of syntax repetition. Complete materialization and helper-frame budgets still apply; new observational root shapes require a separate addressability/loan audit rather than assuming that ordinary body SSA becomes addressable.
Inside ensures, unqualified result is the actual return observation, not a body variable or an entry capture. A header parameter or clause-local binder named result conflicts when ensures is present; reject with a stable source reason at the conflicting binder. Ordinary body bindings named result and functions without ensures keep their existing meaning. Void has no result; never has no postcondition. `old(expr)` is recognized as snapshot notation only as the unqualified one-argument call in ensures. If old is also visible there as a local function, parameter or clause binder, the unqualified call rejects with a source name-conflict reason; self-qualified/import-qualified old functions remain ordinary calls. Outside ensures, old calls use ordinary name resolution, not snapshot semantics. Result inside old, nested old and non-Data old results reject. Old's free value roots must be original header parameters; clause locals declared outside expr are unavailable at entry and reject. Local scratch binders declared inside expr remain allowed.
Every runtime/assumed old occurrence is evaluated once, in lexical clause/expression order, after all preconditions and before the body. Even an occurrence in a short-circuited post branch is captured eagerly. It may trap or exhaust fuel before the body; old is not observationally free. Distinct executable occurrences remain distinct slots, even with identical text; no optimizer deduplication changes fuel. All slots lower to one bounded Data record and one contract.old helper. Since ordinary struct.make has a 64-operand bound as well as the 256-member bound, package slots by greedy left-full chunking: zero-based group i holds slots 64*i through min(64*i+63, last). Only the final group may be short; always wrap it in a record, even when it has one slot. Recursively apply this same rule to child records until one root remains. Evaluate all expressions first, then construct each record level left to right, bottom up. A count at most 64 uses one direct record. Fields use their zero-based positions within each record; projection paths follow this fixed tree. Snapshot-record name keys extend the function/specialization key with zero-based level (leaves are 0) and group index. No padding, partial initialization or program heap allocation is introduced; existing type/value/frame/function/instruction bounds still apply.
A documented old(expr) must refer to an equal executable capture already present in this function; choose the first matching executable occurrence. Equality is structural over the typed expression tree, ignoring spans/comments/parentheses, retaining internal local binder spellings and resolved parameter/function/type identities. It is alpha-sensitive: changing an internal scratch binder's name does not match. It is not algebraic equivalence or hash equality. A document cannot add snapshot work of its own. No matching executable capture rejects with a stable source reason; deleting the last executable use must not silently retain a snapshot for documentation alone. This refines the AIR rule allowing documented binding of an existing executable snapshot.
Post helpers receive the snapshot record and result only when needed, alongside original roots. Snapshot field projection happens inside the helper. Original body SSA never enters the prefix binding list. Parameter-free predicates remain possible on main. Generic/static/package calls, recursive calls and spawned workers use the callee's same prefix; returns, implicit tails and ordinary cleanup lead to the same enforced post boundary. Source loan/cleanup machinery must retain required original roots without extending loans past ret or resurrecting consumed values; exact integration tests remain mandatory.
## Generated names and source provenance
First discover all ordinary declarations/specializations needed by bodies and clauses, resolving alias arguments before their existing specialization keys. Allocate their AIR names by today's linking/monomorphization rules, then reserve those names in both declaration categories. Contract artifacts cannot change an ordinary symbol's collision suffix. They are a separate final generation pass; visiting a clause before another body cannot allocate its public/helper names early.
An artifact has the full tuple `(kind,owner,ordinal,level,group)`. Kind is pre, post, old, witness or snapshot. Owner is the existing canonical `fn:` specialization key, or `fn:` plus the full defining-module/function path for a monomorphic function. A witness uses `invariant:` plus the defining-module/declaration path and its ordered canonical arguments when specialized. Its owner retains the declaration identity even if another alias denotes the same checked type. Physical source paths, file labels, spans, diagnostic order and predicate results contribute no key bytes. Owner keys have the existing 16,384-byte compiler-input bound, including these new monomorphic descriptors. The ordinal/level/group are unsigned u32 values in canonical decimal.
Pre/post ordinal counts every clause expression in its class in lexical order across groups, including assume/document. Mode is metadata, not a helper-name component. There is one old collector per function; old and witness use zero ordinal/level/group. Snapshot uses ordinal 0 and the packing algorithm's zero-based level/group. Pre/post use level/group 0. Distinct executable old occurrences retain their separate slots inside the one collector; documents do not add slots. Helpers for documented clauses are still emitted for independent typing/P validation, though they have no executable call edge.
Encode a tuple as these UTF-8 bytes, with LF at every indicated line end:
```text
aji.contract/1\n
KIND\n
OWNER_BYTE_LENGTH:OWNER\n
ORDINAL\n
LEVEL\n
GROUP\n
```
The owner length is canonical decimal and counts bytes. The length prefix makes components unambiguous; full tuples/bytes, not digests, determine identity and reuse. The descriptor adds bounded fixed overhead to its bounded owner; it does not tighten the existing ordinary specialization-key limit. The AIR base is `__aji_contract_` plus lowercase SHA-256 of these bytes. Sort artifacts lexicographically by complete encoding bytes, then allocate the smallest unused positive `_1`, `_2`, ... suffix when the base is occupied. Decimal fields compare as text: ordinal 10 sorts before 2, and owner length 100: before 16:. This is artifact emission order, not clause evaluation order, which remains lexical. Reserve each allocation immediately; handle a digest collision identically to an original-name collision. No user identifier prefix is reserved.
Emit ordinary types followed by snapshot types in artifact order, then ordinary functions followed by helper/witness functions in artifact order; each category retains today's original/generic ordering. Ordinary specialization counters retain their meaning, including specialized invariant declarations; helpers/snapshot records are not additional generic instantiations. All emitted types/functions/instructions/arguments count toward the ordinary AIR limits, including documented helpers and unused witnesses. No new unbounded generation exemption or private runtime storage is introduced. A contract-free input creates no descriptors and keeps today's canonical bytes.
Use the defining declaration/clause map rather than reversing a mangled name. The witness header/ret map to its invariant declaration. A pre/post prefix site maps to its bool expression; the old prefix/collector header map to the first executable old occurrence. Predicate/collector instructions preserve each original expression/subexpression span. Snapshot struct declarations and packing/projection operations map to the first old slot they represent. Explicit checked operations map to the source operation; implicit/tail returns retain today's return/tail span. Helper call/parameter adaptation maps to the source argument/root that caused it, not the surrounding generated name. A deduplicated capture binding maps to the first lexical occurrence of that root/form in its clause; old's capture union uses the first such occurrence across its executable old expressions. A post's snapshot argument maps to its first old occurrence, including a documented reuse; result forms map to their first corresponding result occurrence. Repeated generic specializations retain template spans; supplied static/type argument errors retain application spans. In a clause helper, its header/parameter facts map to that clause expression; a named external helper retains its own header and body spans.
The lowering output carries a separate typed declaration map `(canonical source declaration name, witness function identity, declaration span)` for inventory provenance. It is not parsed from comments or consumed as semantic evidence; verified signature/body/type identity still controls the inventory record. Runtime dispatch retains both the installing site and evaluated boundary, so a post failure reports its clause plus the actual ret separately. Missing exact mappings use the existing primary fallback; related positions omit source coordinates instead of borrowing another mapping. Complete dispatch/trap schema and AIR0 compatibility remain separate gates.
[Naming vectors](contract-naming-vectors.json) retain three current-language source groups at `8df6cac` (ten CLI checks): a generic base plus _1 collision allocates _2, two calls with the same static-function key reuse one specialization, and flattened module-name collisions allocate _2/_3 in canonical module order. Runs return 42 with fuel 10,000. Tested comment/position changes, path changes and import/mapping permutations preserve AIR bytes. Nine proposed artifact descriptors separately pin encoding, digest and collision allocation; hashlib and sha256sum agree. The follow-up ordinal 2/10 pair pins text-byte ordering. They are design vectors, not implemented contract-helper output.
## Representation, properties and positions
Candidate R validity requires ordinary well-formedness, a complete value, and admissibility as a function parameter and return. Borrow/storage/function-bound content is forbidden along the same content edges as aggregate-member checking, including inside owners, buffers and nested checked types. This combines the shallow `types.complete` test with recursive member validity; `complete` alone is insufficient. Void/never, local, ref/mut/slices, task/scope/shield and guard cannot be wrapped to bypass their ordinary position or transfer rules. An iref is an opaque content leaf; its referent still needs ordinary type validity. Ownership cycles through R retain E1003 and existing stage order. R is not restricted to Copy or Data: borrowed linear-state updates are a required use case.
The checked feature itself need not depend on linear_aggregates solely because R is a linear complete value. R's own features remain required, and placing a linear checked value in a field/payload/array or individual own content retains the ordinary linear_aggregates gate. This is a proposed dependency choice, not an allocated feature. All checks repeat after generic substitution; a template is rejected early only for a restriction invalid under every substitution.
| Property/query on checked<R,p> | Candidate rule |
|---|---|
| Copy / linear | exactly R's Copy / linear classification |
| Send / Share / Local | exactly R's corresponding structural property |
| IslandSafe / ArcSafe / Freeze | exactly R's corresponding property; the latter two still equal IslandSafe in format 0 |
| Data | exactly when R is Data; predicate identity is not a value/member |
| Zeroable | false, including constant-true predicates and zeroable R |
| Accounted size | size(R), with no predicate-handle charge |
| Forbidden content / endpoints / capability kinds | traverse R using each existing query's own edge rules |
| Type height / bounded syntax | one checked constructor edge followed by R; predicate identity contributes no edge |
| Ownership/layout cycle traversal | enter R; an iref edge remains non-owning |
Zeroability cannot depend on evaluating p at compile time: zero/local.zero/region zero-fill cannot manufacture a checked claim. Accounted size is not ABI layout. Anonymous checked edges preserve Q-058's nominal-edge size depth, while the separate type-height query counts the constructor. Size/property scans must stay total before type validation, including invalid cycles; use the accounting candidate's fixed-point linearity rather than module-free `Type.isLinear` for representation-dependent answers.
Keep `Type.inner()`'s storage/borrow/element meaning unchanged. Introduce a dedicated representation accessor and explicit checked cases in equality, canonical type keys, property caches/dependency edges, feature/position checks, finite-layout validation, size, source forbidden witnesses, capability inventory and runtime value traversal. A query that currently has an `else` default needs the same audit as an exhaustive switch. Do not make an ordinary borrow or integer operation accept checked content through a generic inner accessor.
| Position/operation | Candidate restriction |
|---|---|
| SSA, parameter, return, block parameter | complete checked value; ordinary linear consumption/edge rules |
| Struct/enum/fixed array, individual own | existing linear-member/content feature gate; no new partial moves |
| Frame local, region content, repeated own_array content | Copy checked values only; zero initialization remains forbidden |
| Buffer | existing complete-member rules and explicit drain obligations |
| Channel element / mutex content | Send and existing recursive endpoint/forbidden-content checks through R; channel_transfer is not bypassed |
| Island/frozen/arc content | existing graph-content property, inherited from R |
| Borrow/slice of checked | ordinary ancestry/alias/loan rules; shared representation access only through checked.view |
| Task argument/result | existing Send/Share and transfer rules |
| Main parameter | checked is not a capability and cannot receive a grant |
| AtomicScalar, arithmetic/casts, field/tag projection | checked remains a distinct type; extract/view R explicitly, then apply ordinary rules |
A whole checked Copy value may be loaded/stored; a linear one uses complete exchange/transfer. Ordinary struct literals, struct.get/unpack, enum.take and borrow.field cannot expose the capsule's R directly. `checked.take` relinquishes only this outer claim, preserving nested checked claims. These restrictions apply in AIR as well as source. Pure/stable closures may view checked roots and take Copy Data content; make/modify remain excluded, and the initial proof normal form still excludes checked extraction.
No ABI layout or foreign transparency is granted by size(R). Current FFI declarations are illustrative/unsupported; this refinement claims no FFI implementation. A future FFI feature must prevent foreign construction/writes from publishing checked values without validation. An ordinary foreign adapter should transport R and validate through make on re-entry; any unsafe promise needs its own explicit obligation and compatibility rules. Casts or serialization cannot confer checked identity.
Propose that canonical run-result rendering recursively renders R, without a checked tag, predicate identity or re-evaluation. Nested struct fields, enum payloads and arrays follow their existing order; opaque values retain their existing rendering. This is output serialization, not an Aji value conversion or validation bypass. Copies/transfers/GC visit the representation exactly as needed for its ordinary values and resource identities; predicate identity remains compile-time metadata with no allocation, refcount or destructor.
## Declared claims in the report
Make/modify rows alone omit a library invariant whose type has no construction site. Append `types` after `rows,totals` in the proposed contracts object; emit an empty array when no checked identity occurs. Contract-free report bytes remain unchanged. Enumerate distinct checked identities in first structural occurrence order: type declarations and members/payloads, then functions in textual order (parameters, return, each block's parameters and instruction type operands). Each walk is preorder, visiting checked identity before R, and follows ordinary type-parameter edges even for phantom iref targets. Visit each nominal declaration once globally and each checked identity once for inventory output; predicate identity is not a traversal edge. Ordinary resolved graph references are required, not string parsing or expansion of shared paths. This is an inventory walk, not the ownership-cycle query. The identity witness ensures concrete unused source declarations are represented. Its ordinary return is not an extra invariant-check row.
Type-record field order is `type,predicate,status,proof,enforcement,declarations`. Type spells `checked<R, @p>` with one space after the comma and ordinary recursive AIR spelling for R; predicate is the resolved function name without @. Proof uses the existing `result,reason,cost,limit` object. Enforcement is always `construction_update`: ordinary copies/transfers do not rerun p. Type invariants have no assume/document mode. Records contribute neither rows nor row totals, and have no separate totals.
Classify p over one universally unconstrained shared R observation (B=1, n=1, D=O=0). The universal root term is keyed by resolved checked identity and root parameter ordinal 0; ordinary field paths append resolved nominal declaration/field ordinals. It represents all raw R values, not only those already satisfying p or seen at make sites. Scalar/Data loads retain the existing eligibility rules, including alongside linear fields. A literal-true ref<R> predicate has H=3,N=1,C=5 and is proven. The Range predicate in the baseline vectors has H=17,N=5,C=23; distinct lo/hi terms leave it not_established. A constant {0,5} make can independently be proven at C=28. Unsupported helpers/bindings and budgets use the same closed fallback order. Proof never eliminates runtime evaluation or promises termination.
Declarations contain supplied source provenance only: ordered objects `name,witness,source`, where name is the canonical source declaration/specialization name, witness is the AIR function name without @, and source is the existing `{file,line,col}` or null. A frontend may supply these records only for its concrete identity witnesses. Before attaching one, require a verified witness with exactly one parameter of this checked type, the same return type, effects [], no trusted/prefix metadata, and one block containing only ret of that parameter. Omit mismatched records; never infer names/modules from mangled symbols. Order by witness function order, then supplied declaration order, deduplicating identical records. AIR-only input has declarations []; missing maps do not suppress a checked identity or alter proof/status. These names/positions make no independent semantic claim. Clearing declarations and other source fields must recover identical semantic reports for identical verified AIR.
The [report vector](contract-report-vector.json) now includes a constant Range make and three inventory identities, one with no construction site. The unused identity still has its universal proof; the modify identity uses an unsupported predicate and remains runtime. This component is proposed research data, not today's CLI output.
Valid target: a module exports State holding two correlated counters; unrelated imported code can share it, exchange it, or update it through a callback, and the persistent relation survives every successful update. An in-place update of a borrowed linear buffer representation needs no replacement allocation. Rejected targets: public field writes into State; callback returning a borrow from R; overlapping update arguments; predicate with mutable atomic observations; zero construction; an invariant declaration with wrong predicate signature even when unused. A boundary relation over separate mutable roots remains valid only at its explicit pre/post boundaries.
## Compatibility and delivery
No new AIR header/type-declaration kind is used. Identity witnesses use ordinary function declarations; checked type operands and operations retain the unknown-constructor/opcode E0004 path, subject to Q-055's dependent-error audit. The evidence below pins complete current spellings without claiming full format-0 compatibility. Source item/header, reserved expression and reserved type positions have the separately recorded E7001/E7002 transitions; existing ordinary identifiers/namespaces are preserved. Wrong static selections/argument types and invalid type positions follow existing E7002/E7005 rules; new source-context conflicts need stable E7006 reasons, not message parsing.
Costs: one narrow named declaration, clause groups, contextual result/old, four explicit checked operations, capture/snapshot elaboration, identity witnesses and type-level audit records. No module-global instance, hidden checking constructor, general alias system, new runtime function values or boundary-group verifier state is introduced. Compare this against inline checked types and nominal checked-struct syntax before adoption. Measure final Quick Reference/source/AIR growth; this research is outside the bundles. Remaining gates include exact mangling/source-map integration, source/semantic diagnostic order, traps and pending dispatch, RFC 0040, Q-055 compatibility, owner model selection and full source/AIR/package/generic/GC/schedule validation. Property/position/rendering and inventory rules above are candidate resolutions, not an accepted feature or completed implementation.
## Verified source compatibility constraints
Nineteen current-language probes at `8260d35` contain no implemented contracts. All source fixtures include main, so unknown-name cases do not accidentally measure a missing entry point. Executions use fuel 10,000.
| Cases | Current result |
|---|---|
| Ordinary functions/parameters named old, result, requires, ensures, invariant, assume, document and checked | accepts; returns 6 |
| Existing explicit static-function application | accepts; returns 6 |
| Invariant declaration / clause header | E7001 |
| Unresolved unprefixed checked type / make / modify | E7002, naming checked / checked.make / checked.modify |
| User module checked calling make/view/take/modify by self-qualified name | accepts; returns 10 |
| User generic struct checked<R, fn p> | accepts |
| Reserved type.checked type position | E7002, naming type.checked |
| Reserved type.checked.make / modify expressions | E7001 |
| A module or type binding named type | E7001 |
| Ordinary Copy / linear AIR identity witnesses | accepts |
| Complete checked AIR identity witness | E0004 alone |
| Flat AIR struct.make with 65 fields/operands | E5101: arguments per call, found 65, max 64 |
| Same 65 values packed into 64/1 leaf records and a two-field root | accepts; returns last value 64 |
The reserved-prefix choice is justified by inability to bind its first component, not by assuming every type position is a syntax rejection. The proposed type form changes an E7002 rejection to acceptance; the expression/item/header forms change E7001 rejections. Existing module checked and generic checked types must keep their meaning. Witness acceptance on ordinary R does not prove all checked type/property positions valid. Claude independently read the recorded results and reviewed name/capture/snapshot rules; no language feature or owner policy is adopted.
At `4cda448`, all twelve previously recorded property probes retain their exit status/code lists: scalar, linear-record, capability, atomic, mutex and buffer identity accept; guard/task/shield transfers reject E0006, borrowed member and linear own_array content reject E1001, and graph resource content rejects E2111. Eight additional [reproducible property vectors](contract-property-vectors.json) verify region/endpoint identity, recursive endpoint gates in channel/mutex, nonzeroable Copy capability, rejected nominal AtomicScalar, E0004 for a complete checked witness, and the ordinary Range predicate returning true with fuel 10,000. Concatenate header/body lines, then run the listed command (run uses the listed fuel). They validate current-language constraints, not the proposed checked feature, universal proofs or inventory output. The property rules incorporate Claude's earlier read-only audit; this refinement has not received a fresh Claude review because the live Herdr channel is unavailable.