docs: specify contract runtime continuations and failure context
This commit is contained in:
1 parent
2db752dba9
commit
c633f23952
6 files changed
+454
-1
No files matched your search
@@ -39,6 +39,8 @@ The callback can perform ordinary multi-field updates and use disjoint fields in
|
||||
|
||||
Successful callback completion is not yet successful update completion. Predicate false, callback/predicate traps or fuel exhaustion publish no checked result. Failure traps with no rollback of state or external effects. Pending borrow-free results, including linear ones, must be retained and traced until validation finishes. Candidate fuel accounting is one unit for the make/modify operation, then ordinary helper instructions, with no synthetic callback-to-predicate instruction. Callback and predicate use normal call frames, sequentially; the callback frame ends before the predicate starts. Exact dispatch, temporary-view and trap rules still require RFC integration and tests. Checking after a callback must use a legal shared view after its exclusive loan has ended, not privileged access through a frozen ancestor.
|
||||
|
||||
The [runtime/context candidate](contract-runtime-and-context.md) now supplies concrete continuation, last-fuel, publication, depth/quantum, GC-root and failure-location rules for this sequence. Its executed evidence is ordinary calls/returns/traps, not checked updates. New callback/predicate transitions, pending linear results and context mapping still require normative adoption and vertical implementation/tests.
|
||||
|
||||
Candidate source surface is an explicit API under type.checked: a shared `ref raw = type.checked.view(parent)` binding, `type.checked.make::<R, fn p>`/`type.checked.take`, and `type.checked.modify::<fn update>(parent, args...)` on a named exclusive binding. Callback specialization uses existing static function identity, not a runtime function value. The module/source refinement gives grammar and clause-root rules; diagnostics and any later scoped block form still need integration. A block form must specify captures and effects before adoption.
|
||||
|
||||
## Stability is stronger than purity
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
# Contract runtime dispatch and context candidate
|
||||
|
||||
Non-normative continuation of [RFC 0039](../rfcs/0039-verifier-visible-contracts.md), [AIR bindings](contract-air-bindings.md) and [invariant boundaries](contract-invariant-boundaries.md). This completes a candidate runtime rule, not an implementation or a feature/code allocation. Format-0 compatibility, source reasons, owner adoption and vertical delivery remain gates.
|
||||
|
||||
## Continuations and publication
|
||||
|
||||
A frame retains an explicit continuation describing the invocation it is awaiting: ordinary call, pre, old, post index with pending return, make validation, modify callback or modify validation. Record the installing instruction, evaluated boundary and helper identity as module indices; never infer this from its opcode after an ordinary result assignment. Parent frames remain active until their pending operation/return completes. Returning from a helper goes through the saved continuation rather than the current ordinary `caller result; inst += 1` path. Continuations are per task and frame, with at most one pending operation in each frame; nested callbacks/calls use the ordinary frame stack, not an unbounded side stack.
|
||||
|
||||
| Initiating instruction | State until helper completion | Successful completion |
|
||||
|---|---|---|
|
||||
| pre, runtime/assume | invocation views/places, bool helper | inspect bool, end temporary observations, advance prefix once |
|
||||
| old | invocation views/places, Data helper | end observations, save one snapshot, advance prefix once |
|
||||
| post, any mode | install ordered metadata, no evaluation | advance prefix once |
|
||||
| ret with executable posts | retain frame, exact ret and pending value; select first executable post | finish normal return only after every executable post succeeds |
|
||||
| checked.make | retain unexposed complete R and whole-R observation | end observation, form checked value and bind result once |
|
||||
| checked.modify | retain capsule root, suspend its access; invoke callback through temporary mut<R> | retain callback result, end mutation loan, invoke p through shared whole-R observation; bind callback result only after p succeeds |
|
||||
|
||||
Pre.document is a paid metadata operation with no helper. Post.document installs metadata but is skipped by return-time dispatch. Proven runtime clauses still execute. Old executes once after all pre groups; documented old notation only reuses the existing snapshot. A callback returning never never reaches validation/publication. Void callbacks carry a pending void value. Normal cleanup is the explicit AIR that preceded ret, not hidden work in these continuations.
|
||||
|
||||
A helper ret is charged as an ordinary instruction; the same step inspects its bool/Data result and performs its continuation. A false bool stops immediately, before scheduling or beginning another instruction. A true final post completes the original ret: end temporary observations, remove the contracted frame, transfer the pending value to the caller's saved continuation, or mark the task done and expose its result. Task.join cannot observe a pending value. Main completes only at this point. Cascaded completion uses an iterative dispatcher: every transition consumes a completed helper, advances a finite clause list or completes a frame; it cannot reexecute a paid ret or spin through a cyclic continuation.
|
||||
|
||||
A callback's successful return is not a successful modify. The callback frame ends before the validation frame is pushed, so they do not count simultaneously. Its borrow-free result, including a linear owner, is retained but unavailable to the caller until validation succeeds. No callback mutation or external effect is rolled back on failure. Trap, fuel/task limit and blocked outcomes grant no completed checked/postcondition claim. A failure ends the whole program under format-0 policy, including failure in a child task; no destructor, unwind, rollback, join or cleanup callback is invented.
|
||||
|
||||
## Fuel, depth and scheduling
|
||||
|
||||
Every textual instruction pays one fuel and quantum unit when it begins, including all document prefix operations, post installation, ret, make and modify. Helper/callback instructions pay separately. Pushing a helper, processing its returned value, advancing to the next predicate and completing a pending return add no synthetic instruction/unit. Before pushing any helper/callback apply the ordinary 1,024-active-frame bound; a contracted parent still counts. The dispatcher performs that check explicitly, not only through the ordinary call opcode path.
|
||||
|
||||
Normalize the completed instruction's continuation before the current loop's quantum check: inspect bool, retain/publish values, end temporary loans and push the next helper when required. There is no fuel check inside this normalization. False on the last fuel unit is a trap. If the original ret or callback ret spent the last unit, a needed next predicate frame is ready, but execution stops before its first instruction with limit_exceeded. If the final predicate ret spent the last unit and succeeds, return/update completion still happens; fuel is checked only when another instruction would begin. A depth violation discovered while pushing after a paid instruction is T0007 even when no fuel remains, as with ordinary call.
|
||||
|
||||
After normalization apply the usual quantum rule to the still-runnable task, except that completing a task/returning main follows today's scheduling/termination path. Switching may occur after the initial ret, between predicate instructions or between callback and validation. No validation region is an atomic section; all saved values/loans must survive switching. Contract execution can change interleavings and schedule.choices; equivalence with a contract-free instruction stream is not claimed. Modes also differ in their executed instructions.
|
||||
|
||||
P/S operations have no newly visible synchronization/atomic/ambient operation, so prefix/install/validation dispatch adds no exploration choice or scheduler draw of its own. The existing visible operations in an unrestricted callback keep their ordinary exploration, weak-memory and cancellation behavior. Callback waiting retains its continuation and existing fuel_paid handling; resume does not repay the waiting instruction or restart callback/validation. Cancellation of the current task does not skip a predicate/post: only existing explicit cancellation operations observe it. The pending claim is never published because a scheduler selected another task.
|
||||
|
||||
## Execution memory and observations
|
||||
|
||||
GC roots include all ordinary frame values plus each frame's pending return/candidate/callback value, persistent snapshot and active observation places. Copy them with the same Copier/memoization as ordinary cells, arrays, graphs and owners, preserving aliasing, backing-frame identity, paths and race shadows. Indices into immutable module data require no execution-heap tracing. Retained runtime context must remain valid after the execution heap is released. No Value/place pointer may live solely in a Zig local across a collection, scheduling point or hosted wait.
|
||||
|
||||
Linear make and whole linear checked observations use an SSA-backed cell rather than a copied local. Copy observations get distinct complete temporary cells, each covered by the activation formula L+S+max E; temporary helper descendant views cannot escape. Checked representation access needs an explicit runtime representation edge/accessor, not a fake user field 0. Ordinary owner-content adaptation and whole-R validation are distinct. Collection traverses checked representation values without invoking predicates or changing fuel, authority charges, task clocks, schedules or graph identities. An old iref copies only its opaque identity/slot and does not retain a destroyed graph.
|
||||
|
||||
After each successful helper end its evaluation views/places; after final success bind/transfer the value once. Scratch, snapshots and pending slots are unreachable after their activation completes, except ordinary escaping ancestor storage allowed by existing borrow-return rules. GC every step must produce byte-identical records, including all context positions, to ordinary collection. Retention is bounded by active frames/verified value and activation budgets, not the number of completed calls/updates. This is a requirement for new continuations, not evidence that today's GC already visits them.
|
||||
|
||||
## False conditions and additive context
|
||||
|
||||
Candidate false codes/kinds are T0011 trap.contract_precondition, T0012 trap.contract_postcondition and T0013 trap.type_invariant. A false assumed pre/post retains T0009 trap.unsafe_precondition. The primary function/block/inst for these dispatch-generated failures is the installing pre/post or make/modify instruction; existing source_location therefore maps to the clause/checked operation. The helper ret that yielded false is retained as the context's at position. Old returns Data and has no false code. A helper/callback's own trap retains its existing code and actual innermost instruction, including arithmetic/assert/unsafe/depth traps; do not relabel it as a false condition. An implicit frame-push depth failure has the evaluated boundary as its primary instruction and at null because no helper instruction began. No trap code is allocated here.
|
||||
|
||||
Propose one optional `contract` object on trapped, limit_exceeded, blocked and race_detected records when the failing/current execution unit is inside an active contract evaluation. Race context identifies the same actual detected access and does not turn a verifier defect into a contract-false trap. Omit it on successful return, not_instantiated and ordinary failures outside evaluation. Existing fields/values and the relative order of existing fields remain unchanged. Object field order is:
|
||||
|
||||
```text
|
||||
kind, mode, phase, helper, task, site, boundary, at
|
||||
```
|
||||
|
||||
Kind is pre/post/old/make/modify. Mode is runtime for old/make/modify and ordinary pre/post, assume for assumed pre/post; document starts no active evaluation. Phase is predicate, snapshot (old) or callback (modify). Helper is the directly selected phase function name without @, not an invented source variable. Task is the actual zero-based task identity. Site is the installing prefix/checked operation. Boundary is the evaluated ret for post, otherwise the initiating operation. At is the actual failing/completing instruction; for fuel it is the next instruction prevented from beginning; for task limits/blocked/races it is the actual spawn/wait/access instruction. An implicit push-depth failure has at null. This does not claim that a fuel-stopped instruction executed.
|
||||
|
||||
Each non-null position is `function,block,inst`, optional file/line/col when exactly source-mapped, then mandatory air_line/air_col. Function/block are AIR names without sigils; inst is zero-based. Map every position independently using its real lowering span, including imported/template/standard-library helpers. AIR-only positions omit source coordinates. No map is inferred from a helper name; missing exact context maps stay omitted. Primary source_location retains existing behavior. A failure inside a helper's ordinary descendant call retains the innermost trap as primary/at but still identifies the directly selected evaluation helper in contract.helper.
|
||||
|
||||
Use the nearest active evaluation continuation in the same task. Nested callback contracts replace the reported context with their own innermost boundary; there is no unbounded dumped stack or ambiguous outer-root selection. Child tasks do not inherit the creator's active evaluation: their own contracts identify their own boundaries; an ordinary child trap carries no fabricated parent context. For global fuel, use the task selected to begin the prevented instruction. For blocked, use the existing oldest-waiter selection, including that waiter's task and continuation; unrelated pending validations are not reported as its cause.
|
||||
|
||||
Build/enrich typed context before JSON serialization. writeOutcome emits contract after the base outcome fields and before captured stdout/stderr/files/schedule; the CLI appends primary source_location last as today. Lowered-source position mapping must enrich each context position before serialization, rather than append a second contract object or patch nested JSON text. Position/context values reference immutable module data or result-arena-owned storage, not released execution memory. Hosted result files use the same schema and enforcement; hosted program streams remain owned by the program.
|
||||
|
||||
Explore keeps today's identity rule: distinct outcomes are the exact bytes produced by writeOutcome, sorted by those bytes. Include the complete AIR-only contract object in that key, task included; do not strip/normalize metadata during deduplication. Schedule-dependent task IDs or different boundaries may therefore produce distinct records for the same trap code, even when the program-visible failure is similar. This is an explicit consequence of factual outcome identity. Explore does not enrich source positions or append primary source_location today; its new context also stays AIR-only for .aji input. Normal run/hosted result mapping remains as specified above. Required tests pin enumeration/dedup/order and bounded max-runs behavior without conflating metadata-distinct records with different returned program values.
|
||||
|
||||
## Evidence and delivery
|
||||
|
||||
The [runtime vectors](contract-runtime-vectors.json) record six current-language groups at `2db752d` (16 CLI runs, quantum 1): ordinary return/fuel cuts, assertion at the last unit, depth at 1023/1024 steps, a linear owner across a returned call, exact source mapping of a helper trap, and a child assertion under five schedule seeds. Nine ordinary fixture variants pass normal-versus-GC-every-step comparison (13 schedule cases, 26 interpreter runs, race detection enabled). These executed programs contain no contracts. Six separately marked hypothetical context components pin field/position order, false versus existing trap identity, a depth-null at, callback fuel and an assumed child post. The components are schema vectors, not executed new-contract output. These show constraints on the proposed dispatcher/serializer, not successful new-contract execution.
|
||||
|
||||
Required vertical coverage includes pre/old/post/install/document fuel, false at the final unit, cuts before/within/between helpers, helper-depth boundaries, several returns/posts, void/never callbacks, nested callback contracts, blocked/cancelled callbacks, unexposed linear callback results, distinct Copy places, graph/owner/checked pending roots under GC every step, joined workers and quantum/weak-memory exploration. Preserve contract-free bytes. New false codes, exact typed context and continuation state must land in spec/reference, verifier/interpreter, source/formatter/Quick Reference and AIR/source conformance together; these research rules alone do not complete P6-6.
|
||||
@@ -0,0 +1,379 @@
|
||||
{
|
||||
"purpose": "Non-normative runtime research: baseline groups are executed current-language programs; context components are unimplemented schema vectors, not compiler output.",
|
||||
"compiler": "2db752d",
|
||||
"cli_runs": 16,
|
||||
"baseline_groups": [
|
||||
{
|
||||
"case": "ordinary_call_return",
|
||||
"suffix": "air",
|
||||
"source": [
|
||||
"module contract.runtime",
|
||||
"air 0",
|
||||
"lang 0.1",
|
||||
"features [effects]",
|
||||
"fn @main() -> u64",
|
||||
"effects []",
|
||||
"entry:",
|
||||
" %v = call @leaf()",
|
||||
" ret %v",
|
||||
"fn @leaf() -> u64",
|
||||
"effects []",
|
||||
"entry:",
|
||||
" %v = const.u64 42",
|
||||
" ret %v"
|
||||
],
|
||||
"runs": [
|
||||
{
|
||||
"fuel": 0,
|
||||
"quantum": 1,
|
||||
"exit_code": 5,
|
||||
"record": {"status": "limit_exceeded", "kind": "fuel", "limit": 0, "steps": 0}
|
||||
},
|
||||
{
|
||||
"fuel": 1,
|
||||
"quantum": 1,
|
||||
"exit_code": 5,
|
||||
"record": {"status": "limit_exceeded", "kind": "fuel", "limit": 1, "steps": 1}
|
||||
},
|
||||
{
|
||||
"fuel": 2,
|
||||
"quantum": 1,
|
||||
"exit_code": 5,
|
||||
"record": {"status": "limit_exceeded", "kind": "fuel", "limit": 2, "steps": 2}
|
||||
},
|
||||
{
|
||||
"fuel": 3,
|
||||
"quantum": 1,
|
||||
"exit_code": 5,
|
||||
"record": {"status": "limit_exceeded", "kind": "fuel", "limit": 3, "steps": 3}
|
||||
},
|
||||
{
|
||||
"fuel": 4,
|
||||
"quantum": 1,
|
||||
"exit_code": 0,
|
||||
"record": {"status": "returned", "value": 42}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"case": "helper_trap_last_fuel",
|
||||
"suffix": "air",
|
||||
"source": [
|
||||
"module contract.runtime",
|
||||
"air 0",
|
||||
"lang 0.1",
|
||||
"features [effects]",
|
||||
"fn @main() -> void",
|
||||
"effects []",
|
||||
"entry:",
|
||||
" call @fail()",
|
||||
" ret",
|
||||
"fn @fail() -> void",
|
||||
"effects []",
|
||||
"entry:",
|
||||
" %v = const.bool false",
|
||||
" assert %v",
|
||||
" ret"
|
||||
],
|
||||
"runs": [
|
||||
{
|
||||
"fuel": 2,
|
||||
"quantum": 1,
|
||||
"exit_code": 5,
|
||||
"record": {"status": "limit_exceeded", "kind": "fuel", "limit": 2, "steps": 2}
|
||||
},
|
||||
{
|
||||
"fuel": 3,
|
||||
"quantum": 1,
|
||||
"exit_code": 4,
|
||||
"record": {"status": "trapped", "code": "T0002", "kind": "trap.assert", "function": "fail", "block": "entry", "inst": 1}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"case": "call_depth_before_next_fuel",
|
||||
"suffix": "air",
|
||||
"source": [
|
||||
"module contract.runtime",
|
||||
"air 0",
|
||||
"lang 0.1",
|
||||
"features [effects]",
|
||||
"fn @main() -> void",
|
||||
"effects []",
|
||||
"entry:",
|
||||
" call @rec()",
|
||||
" ret",
|
||||
"fn @rec() -> void",
|
||||
"effects []",
|
||||
"entry:",
|
||||
" call @rec()",
|
||||
" ret"
|
||||
],
|
||||
"runs": [
|
||||
{
|
||||
"fuel": 1023,
|
||||
"quantum": 1,
|
||||
"exit_code": 5,
|
||||
"record": {"status": "limit_exceeded", "kind": "fuel", "limit": 1023, "steps": 1023}
|
||||
},
|
||||
{
|
||||
"fuel": 1024,
|
||||
"quantum": 1,
|
||||
"exit_code": 4,
|
||||
"record": {"status": "trapped", "code": "T0007", "kind": "trap.call_depth", "function": "rec", "block": "entry", "inst": 0}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"case": "linear_owner_across_return",
|
||||
"suffix": "aji",
|
||||
"source": [
|
||||
"module contract.runtime",
|
||||
"fn pass(o: own<u64>) -> own<u64> effects [] { return move o; }",
|
||||
"fn main(heap: cap<mem.alloc>) -> u64 effects [mem.alloc] {",
|
||||
" let owner = own.new(42u64, heap) or trap;",
|
||||
" let after = pass(move owner);",
|
||||
" return own.take(move after);",
|
||||
"}"
|
||||
],
|
||||
"grants": ["heap=mem.alloc:4096"],
|
||||
"runs": [
|
||||
{
|
||||
"fuel": 10000,
|
||||
"quantum": 1,
|
||||
"exit_code": 0,
|
||||
"record": {
|
||||
"status": "returned",
|
||||
"value": 42,
|
||||
"stdout": "",
|
||||
"stderr": "",
|
||||
"files": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"case": "mapped_helper_trap",
|
||||
"suffix": "aji",
|
||||
"source": ["module contract.runtime", "fn fail() -> void effects [] {", " assert(false);", "}", "fn main() -> void effects [] { fail(); }"],
|
||||
"runs": [
|
||||
{
|
||||
"fuel": 10000,
|
||||
"quantum": 1,
|
||||
"exit_code": 4,
|
||||
"record": {
|
||||
"status": "trapped",
|
||||
"code": "T0002",
|
||||
"kind": "trap.assert",
|
||||
"function": "fail",
|
||||
"block": "entry",
|
||||
"inst": 1,
|
||||
"source_location": {"file": ".zig-cache/contract-gate/runtime/mapped_helper_trap.aji", "line": 3, "col": 5}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"case": "child_task_global_trap",
|
||||
"suffix": "air",
|
||||
"source": [
|
||||
"module contract.runtime",
|
||||
"air 0",
|
||||
"lang 0.1",
|
||||
"features [effects, ownership, tasks]",
|
||||
"fn @main() -> void",
|
||||
"effects [task.spawn, task.wait]",
|
||||
"entry:",
|
||||
" %s = task.scope.begin",
|
||||
" %t = task.spawn %s, @worker()",
|
||||
" task.join %t",
|
||||
" task.scope.end %s",
|
||||
" ret",
|
||||
"fn @worker() -> void",
|
||||
"effects []",
|
||||
"entry:",
|
||||
" %v = const.bool false",
|
||||
" assert %v",
|
||||
" ret"
|
||||
],
|
||||
"runs": [
|
||||
{
|
||||
"fuel": 10000,
|
||||
"quantum": 1,
|
||||
"schedule_seed": 0,
|
||||
"exit_code": 4,
|
||||
"record": {
|
||||
"status": "trapped",
|
||||
"code": "T0002",
|
||||
"kind": "trap.assert",
|
||||
"function": "worker",
|
||||
"block": "entry",
|
||||
"inst": 1,
|
||||
"schedule": {"seed": 0, "quantum": 1, "choices": 1}
|
||||
}
|
||||
},
|
||||
{
|
||||
"fuel": 10000,
|
||||
"quantum": 1,
|
||||
"schedule_seed": 1,
|
||||
"exit_code": 4,
|
||||
"record": {
|
||||
"status": "trapped",
|
||||
"code": "T0002",
|
||||
"kind": "trap.assert",
|
||||
"function": "worker",
|
||||
"block": "entry",
|
||||
"inst": 1,
|
||||
"schedule": {"seed": 1, "quantum": 1, "choices": 2}
|
||||
}
|
||||
},
|
||||
{
|
||||
"fuel": 10000,
|
||||
"quantum": 1,
|
||||
"schedule_seed": 2,
|
||||
"exit_code": 4,
|
||||
"record": {
|
||||
"status": "trapped",
|
||||
"code": "T0002",
|
||||
"kind": "trap.assert",
|
||||
"function": "worker",
|
||||
"block": "entry",
|
||||
"inst": 1,
|
||||
"schedule": {"seed": 2, "quantum": 1, "choices": 2}
|
||||
}
|
||||
},
|
||||
{
|
||||
"fuel": 10000,
|
||||
"quantum": 1,
|
||||
"schedule_seed": 3,
|
||||
"exit_code": 4,
|
||||
"record": {
|
||||
"status": "trapped",
|
||||
"code": "T0002",
|
||||
"kind": "trap.assert",
|
||||
"function": "worker",
|
||||
"block": "entry",
|
||||
"inst": 1,
|
||||
"schedule": {"seed": 3, "quantum": 1, "choices": 1}
|
||||
}
|
||||
},
|
||||
{
|
||||
"fuel": 10000,
|
||||
"quantum": 1,
|
||||
"schedule_seed": 4,
|
||||
"exit_code": 4,
|
||||
"record": {
|
||||
"status": "trapped",
|
||||
"code": "T0002",
|
||||
"kind": "trap.assert",
|
||||
"function": "worker",
|
||||
"block": "entry",
|
||||
"inst": 1,
|
||||
"schedule": {"seed": 4, "quantum": 1, "choices": 2}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"gc_baseline": {
|
||||
"fixtures": 9,
|
||||
"schedule_cases": 13,
|
||||
"interpreter_runs": 26,
|
||||
"quantum": 1,
|
||||
"child_schedule_seeds": 5,
|
||||
"normal_vs_collect_every_step": "byte_identical",
|
||||
"detect_races": true,
|
||||
"source_headers": "// metadata for .aji; ; metadata for AIR"
|
||||
},
|
||||
"context_components": [
|
||||
{
|
||||
"case": "false_pre",
|
||||
"expected_code": "T0011",
|
||||
"primary": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
|
||||
"contract": {
|
||||
"kind": "pre",
|
||||
"mode": "runtime",
|
||||
"phase": "predicate",
|
||||
"helper": "p",
|
||||
"task": 0,
|
||||
"site": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
|
||||
"boundary": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
|
||||
"at": {"function": "p", "block": "entry", "inst": 1, "air_line": 21, "air_col": 2}
|
||||
}
|
||||
},
|
||||
{
|
||||
"case": "false_post",
|
||||
"expected_code": "T0012",
|
||||
"primary": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
|
||||
"contract": {
|
||||
"kind": "post",
|
||||
"mode": "runtime",
|
||||
"phase": "predicate",
|
||||
"helper": "p",
|
||||
"task": 0,
|
||||
"site": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
|
||||
"boundary": {"function": "f", "block": "exit", "inst": 2, "air_line": 15, "air_col": 2},
|
||||
"at": {"function": "p", "block": "entry", "inst": 1, "air_line": 21, "air_col": 2}
|
||||
}
|
||||
},
|
||||
{
|
||||
"case": "implicit_post_depth",
|
||||
"expected_code": "T0007",
|
||||
"primary": {"function": "f", "block": "exit", "inst": 2, "air_line": 15, "air_col": 2},
|
||||
"contract": {
|
||||
"kind": "post",
|
||||
"mode": "runtime",
|
||||
"phase": "predicate",
|
||||
"helper": "p",
|
||||
"task": 0,
|
||||
"site": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
|
||||
"boundary": {"function": "f", "block": "exit", "inst": 2, "air_line": 15, "air_col": 2},
|
||||
"at": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"case": "predicate_arithmetic_trap",
|
||||
"expected_code": "T0003",
|
||||
"primary": {"function": "descendant", "block": "entry", "inst": 2, "air_line": 27, "air_col": 2},
|
||||
"contract": {
|
||||
"kind": "post",
|
||||
"mode": "runtime",
|
||||
"phase": "predicate",
|
||||
"helper": "p",
|
||||
"task": 0,
|
||||
"site": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
|
||||
"boundary": {"function": "f", "block": "exit", "inst": 2, "air_line": 15, "air_col": 2},
|
||||
"at": {"function": "descendant", "block": "entry", "inst": 2, "air_line": 27, "air_col": 2}
|
||||
}
|
||||
},
|
||||
{
|
||||
"case": "callback_fuel_cut",
|
||||
"expected_status": "limit_exceeded",
|
||||
"contract": {
|
||||
"kind": "modify",
|
||||
"mode": "runtime",
|
||||
"phase": "callback",
|
||||
"helper": "update",
|
||||
"task": 0,
|
||||
"site": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
|
||||
"boundary": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
|
||||
"at": {"function": "update", "block": "loop", "inst": 3, "air_line": 34, "air_col": 2}
|
||||
}
|
||||
},
|
||||
{
|
||||
"case": "assumed_post_false_in_child",
|
||||
"expected_code": "T0009",
|
||||
"primary": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
|
||||
"contract": {
|
||||
"kind": "post",
|
||||
"mode": "assume",
|
||||
"phase": "predicate",
|
||||
"helper": "p",
|
||||
"task": 3,
|
||||
"site": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
|
||||
"boundary": {"function": "f", "block": "exit", "inst": 2, "air_line": 15, "air_col": 2},
|
||||
"at": {"function": "p", "block": "entry", "inst": 1, "air_line": 21, "air_col": 2}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -415,6 +415,8 @@ The next candidate fixes contract artifact name encoding/order and typed declara
|
||||
|
||||
The [AIR binding grammar](contract-air-bindings.md) now proposes exact prefix/checked spellings, root descriptors, observation adaptation and E8001 reason/field shapes. Eighteen ordinary view/call/unknown-opcode probes confirm existing constraints, including optional never-call result bindings and the difference between an owner root and a complete Copy place. Candidate grammar is not adopted spec; source reasons, trap/dispatch schemas, compatibility, model adoption and vertical delivery remain gates.
|
||||
|
||||
The [runtime/context candidate](contract-runtime-and-context.md) gives concrete continuation/publication, fuel/depth/quantum, pending GC-root and additive trap/environment context rules, including AIR-only byte-identity exploration. Sixteen ordinary CLI runs and nine normal/GC-every-step fixture variants constrain current behavior; hypothetical context components are not new compiler output. Claude independently checked the mechanics, replayed the CLI records and reviewed the refined schema. Source reasons, compatibility/model adoption and full vertical runtime tests remain open; no implemented contract claim is made.
|
||||
|
||||
## Q-055 — Feature-gated AIR headers and frozen rejection codes
|
||||
|
||||
Spec 07 §8.7 permits changes to earlier E0004/E0006 rejections, not E0001. Source inspection of the parser before commit `0086549` shows that an unfeatured `trusted "..."` header was parsed as a block label and failed while expecting `:`; current spec 13 §6.3 and the parser require E0006 `feature_not_declared`. RFC 0009 calls the header additive, although this diagnostic transition is outside the literal exception. The historical parser has not been executed in this audit.
|
||||
|
||||
@@ -364,3 +364,5 @@ The [property/inventory refinement](../design/contract-source-and-module-state.m
|
||||
The [naming/provenance candidate](../design/contract-source-and-module-state.md#generated-names-and-source-provenance) fixes full descriptor bytes, ordinary-first collision allocation, emission categories and clause/witness maps. Three current-language naming groups pass ten CLI checks; seven proposed descriptors agree under two SHA-256 implementations. The [diagnostic refinement](../design/contract-accounting-and-status.md#collection-at-returns) preserves ordinary return/leak facts while isolating virtual post checks, orders required P/S subpasses, and bounds shortest real-call witnesses. Five executed return baselines and six graph vectors independently verify current constraints and proposed selection. No semantic/code/registry change is made; the vectors are not new-contract conformance. Binding/source-reason/trap schemas, Q-055 compatibility, owner adoption and full vertical implementation remain gates; RFC 0039 stays Draft and full P6-6 remains doing.
|
||||
|
||||
The [AIR binding candidate](../design/contract-air-bindings.md) supplies prefix/type/operation grammar, explicit root/form identity, exact shared adaptation, snapshot-use checks and proposed E8001 reasons/fields. Eighteen current-language probes verify view/alias/never-call constraints and isolated E0004 rejection of complete candidate prefixes. Claude independently reproduced all eighteen and the nine descriptor hashes/order cases; review clarified linear checked root access, repeated Copy-place budgets, SSA/root priority, source dedup positions and stable return-fact ordering. This is non-normative design evidence, with no implementation or registry change. Source reasons, trap/dispatch schema, compatibility, owner adoption and vertical tests remain gates; RFC 0039 stays Draft and P6-6 remains doing.
|
||||
|
||||
The [runtime/context candidate](../design/contract-runtime-and-context.md) specifies frame continuations, normal completion only after validation, free normalization before quantum checks, depth/fuel precedence, traced pending roots and exact additive failure context. Six ordinary groups pass 16 CLI runs at quantum 1; nine fixture variants pass GC-every-step record comparison (13 schedule cases, 26 interpreter runs). Six hypothetical schema components are explicitly unimplemented. Claude independently reproduced the CLI records and reviewed the rules; corrections fixed old/make/modify modes, race context and AIR-only byte-identity exploration. No normative/compiler/registry/bundle changes are made. Source reasons, compatibility/model adoption, RFC 0040 observations and full vertical runtime tests remain gates; RFC 0039 stays Draft and full P6-6 remains doing.
|
||||
@@ -120,6 +120,8 @@ Each prefix operation costs one fuel/quantum step; helper instructions use ordin
|
||||
|
||||
False pre/post conditions need distinct stable trap codes, not allocated here; a predicate's own arithmetic/bounds trap retains its code. Clause identity/location and invocation context need an exact additive run-record schema. Entry predicates run in the invoked task, including spawned workers. Capability exclusions still permit parameter-free conditions on `@main`, including a false condition. Both profiles enforce the same contracts. Predicate execution consumes fuel and can change schedule interleavings: contracts are not observationally free. Fuel exhaustion during a postcondition produces no successful return; cancellation checks and synchronization remain excluded from predicate code.
|
||||
|
||||
The [runtime/context refinement](../design/contract-runtime-and-context.md) specifies frame continuations, publication after validation, free normalization before quantum checks, explicit helper-depth checks and traced pending roots. It proposes exact false-code identities and additive same-task context, with source/run versus AIR-only explore mapping and byte-identity outcome enumeration. Sixteen current-language CLI runs constrain last-fuel, depth, returned ownership, source traps and child failure; nine ordinary fixture variants also pass GC-every-step comparison. Hypothetical context components pin the proposed schema, not implemented output. Neither runtime dispatch nor new traps/context are implemented.
|
||||
|
||||
## Status and diagnostics
|
||||
|
||||
| Status | Required evidence |
|
||||
@@ -159,7 +161,7 @@ The source refinement also fixes descriptor encodings, collision order, emission
|
||||
|
||||
The [AIR binding candidate](../design/contract-air-bindings.md) gives complete prefix/type/operation spellings, discriminated parameter/snapshot/result observations, exact adaptation and candidate E8001 reasons/fields. It preserves ordinary never-call binding forms and distinguishes whole checked observation from representation access. Eighteen current-language view/call/opcode probes constrain the proposal; they do not implement it or settle format-0 compatibility.
|
||||
|
||||
Remaining decisions: shared observation coverage (Q-057) and invariant-evaluation interactions; source diagnostic reason allocations; final purity/snapshot schema adoption and format-0 compatibility; final feature/status policy adoption; invariant/module model adoption; traps/run-record schema and tested pending-return dispatch. The RFC stays Draft until these have concrete rules and counterexamples, followed by full vertical delivery.
|
||||
Remaining decisions: shared observation coverage (Q-057) and invariant-evaluation interactions; source diagnostic reason allocations; final purity/snapshot/runtime schema adoption and format-0 compatibility; final feature/status policy adoption; invariant/module model adoption; full vertical implementation and pending-return/GC/scheduler tests. The RFC stays Draft until these have concrete rules and counterexamples, followed by full vertical delivery.
|
||||
|
||||
## Compatibility and integration
|
||||
|
||||
|
||||
Reference in new issue
Block a user