rfc: define contract accounting and audit status candidate
This commit is contained in:
1 parent
9a3e135f43
commit
a4181f2d8d
4 files changed
+107
-3
No files matched your search
@@ -76,7 +76,7 @@ Each entry helper named by `contract.pre/old/post` must be in P and have no muta
|
||||
|
||||
Write freshness follows structurally. The entry helper receives no mutable root or owned linear value. Each permitted mutable view comes from a closure frame local, another mutable view, or a helper's declared `from` result. Shared views cannot become mutable; graph/buffer observations above create only shared children. By induction over dynamic calls, every mutable parameter in a helper originates in closure-frame scratch. Second-class borrows cannot escape through Data, and ordinary return/lifetime rules prohibit returning a view into dead frame storage. Helpers may therefore mutate their scratch through ordinary calls without an additional interprocedural write-summary system. Interior-mutability operations stay excluded by opcode, even when they accept a shared view.
|
||||
|
||||
Loops and recursion carry no totality claim: ordinary fuel and call-depth rules apply, and failure to finish a predicate produces no successful contracted return. P membership alone proves neither clause truth nor PROVEN_STATICALLY. Assertions inside predicates retain T0002; only returning false from a pre/post helper uses the new contract-false trap. Purity rejection needs stable function/type/operation facts and a deterministic witness from the clause; codes, diagnostic order and witness bounds remain integration work.
|
||||
Loops and recursion carry no totality claim: ordinary fuel and call-depth rules apply, and failure to finish a predicate produces no successful contracted return. P membership alone proves neither clause truth nor PROVEN_STATICALLY. Assertions inside predicates retain T0002; returning false from a runtime-mode pre/post helper uses the new contract-false trap. The assumed-mode candidate instead retains T0009; documented clauses invoke no helper. Purity rejection needs stable function/type/operation facts and a deterministic witness from the clause; codes, diagnostic order and witness bounds remain integration work.
|
||||
|
||||
An old iref snapshots identity, not graph contents; dereferencing it observes current content through a currently available root. It retains no owner and revives none. Old buffer length/capacity are scalar snapshots; copying a dynamic prefix requires an explicitly bounded Data representation rather than an implicit heap copy.
|
||||
|
||||
@@ -112,7 +112,7 @@ Post installation reads no resource and takes no loan. At each `ret`, the verifi
|
||||
|
||||
Explicit `ref` bindings of Copy SSA parameters/results need the instruction-internal temporary-place mechanism described in the [invariant research](../design/contract-invariant-boundaries.md): ordinary `borrow.ref` cannot address such a scalar or struct (both current probes reject E1001). Materialize a complete value only for the evaluation, end every observation view before resuming, and prohibit borrow escape through bool/Data results. Existing owner/borrow-root shapes and alias restrictions remain distinct; materializing a Copy observation cannot bypass them or make ordinary body/source SSA values addressable. Account these bounded activation slots with the snapshot/frame budget before implementation.
|
||||
|
||||
The snapshot cannot appear in body expressions, copies, branch arguments or a return; its only use is a post binding, and a snapshot used by no post is rejected. Multiple source `old` expressions lower to fields of one Data record. Its accounted size is bounded by `max_value_size`; the proposed combined snapshot plus `local.alloc` budget is `max_local_frame`, with checked arithmetic. These limits apply only to new contracted functions and need exact diagnostics. Prefix size and helper argument counts use existing instruction/call limits. Counted tests must cover member-edge visits, function removals/call-edge visits and the eventual diagnostic-witness length, including shared type diamonds and recursive helper components.
|
||||
The snapshot cannot appear in body expressions, copies, branch arguments or a return; its only use is a post binding, and a snapshot used by no executable post is rejected. Multiple source `old` expressions lower to fields of one Data record. Its accounted size is bounded by `max_value_size`. The [accounting candidate](../design/contract-accounting-and-status.md) bounds locals plus persistent snapshot plus the maximum simultaneous instruction-internal observation places by `max_local_frame`, with checked arithmetic and descriptors available before SSA inference. Pending callback/return SSA values retain their ordinary value bound rather than becoming frame storage. Documented-only snapshot use does not keep an otherwise unused snapshot. A separate syntactic virtual-binding limit bounds post/return expansion. These rules and diagnostics remain proposals. Prefix size and helper argument counts use existing instruction/call limits. Counted tests must cover member-edge visits, function removals/call-edge visits and the eventual diagnostic-witness length, including shared type diamonds and recursive helper components.
|
||||
|
||||
All three operations have empty declared effects, transfer no caller ownership, and perform no synchronization or capability use. `pre` and `old` read permitted observations; `old` additionally writes its bounded activation snapshot. `post` installation stores clause metadata, and its return-time evaluation reads only currently legal observations. Pure helper frame writes are local. No implicit heap allocation or opaque library hook is introduced. The prefix and implicit return obligations are semantic coverage constructs, not abbreviations for optional asserts. Source/package/generic lowering must supply the same verifiable operations; AIR verification cannot trust frontend coverage claims.
|
||||
|
||||
@@ -129,7 +129,7 @@ False pre/post conditions need distinct stable trap codes, not allocated here; a
|
||||
| ASSUMED_UNSAFE | an explicit unsafe assumption and its visible boundary; never inferred from an empty effect list |
|
||||
| UNPROVEN | no discharged obligation; no caller may rely on it as a fact |
|
||||
|
||||
The initial proof calculus and whether unproven/assumed clauses may be accepted remain undecided. The audit table must identify clause, boundary, status and source/AIR position; existing assertion counts remain counts. Proposed E7xxx reason fields and new AIR/contract trap codes are not allocated by this draft.
|
||||
The [status/accounting research](../design/contract-accounting-and-status.md) proposes a restricted automatic proof classifier, explicit assumed/documented clause modes and a staged diagnostic/report candidate. Proven runtime clauses still execute their predicates; assumption requires an unsafe boundary, documentation grants no truth guarantee, and checked value construction remains enforced. Exact proof-cost conventions, diagnostic collection, report schema and owner adoption remain gates. The audit table must identify clause, boundary, status and source/AIR position; existing assertion counts remain counts. Proposed E7xxx reason fields and new AIR/contract trap codes are not allocated by this draft.
|
||||
|
||||
Valid target example: a function with `requires { x > 0u64; }` and `ensures { result == old(x); }` returning x; a positive argument succeeds and zero traps at entry. Rejected target example: a postcondition dereferencing an owner consumed by the body; the existing availability rule must still reject it. These are design targets, not current conformance fixtures.
|
||||
|
||||
|
||||
Reference in new issue
Block a user