verifier: preserve resource obligations across CFG handoff
This commit is contained in:
1 parent
0e98638bc6
commit
09fbf8a5bc
34 files changed
+1267
-67
No files matched your search
@@ -143,3 +143,15 @@ Q-050 corrects empty parentheses on qualified enum variants, contrary to spec 15
|
||||
Q-051 validates ordinary effect names before body lowering using the existing closed registry. Templates/static contracts use the same E7002 with `name` and `effect`; legacy E0006 without a feature reason was incorrect. Function/template positions remain declaration starts, static contracts use their parameter start. Ordinary parameter/return/from checks retain priority; existing template/header ordering remains. Unknown effects cannot generate malformed AIR or E7900. AIR E0004 and its registry contract are unchanged.
|
||||
|
||||
Only invalid-source codes/priority/fields change. Registered effects, explicit authority, effect coverage, duplicate-list set semantics and static-contract uniqueness remain unchanged; no code, reason, syntax, AIR feature, verifier/runtime or ownership/concurrency state is added. Positive/rejected source tests and CLI/package tests cover headers, unused declarations, priority, missing-effect/capability diagnostics, formatting and source/AIR execution. Budget growth is measured in docs/agent/README.md. This completes this diagnostic correction, not P6-2 or an empirical MCC claim.
|
||||
|
||||
## DD-024 — Resource obligations survive SSA handoff
|
||||
|
||||
Q-052 corrects the verifier's loss of task loans/scopes, guard parents and shield order at block parameters. The preserved invariants are no ending or conflicting access to a loan before its task is joined, no live child at scope completion, no ending a mutex borrow while its guard lives, and properly nested shields. Spec 04 clarifies the already permitted function-local transfer; no AIR feature or new semantic restriction is introduced.
|
||||
|
||||
The verifier records static definition/consumption events, solves sparse relations over the CFG to a fixed point, then checks instructions in the existing diagnostic order. Edge transfer renames both positions simultaneously: a scope association follows the scope even if its task is not passed. This preserves correlated permutations of scopes and tasks; independent origin sets would reject valid code. Task/loan/guard alternatives join by union, while the existing shield-stack equality rule is checked separately. Definition sites retain diagnostic spawn positions. The collecting walk excludes relational error recovery; extra facts about subsequently rejected/dead resources are filtered by final liveness. Functions without these resource types retain one walk.
|
||||
|
||||
Valid: forward a task and its scope, join the renamed task, then end the renamed scope; end renamed shields inner first; unlock a renamed guard before ending its mutex borrow. Rejected: end the lent borrow or store through its exclusive loan before joining the forwarded task; end a forwarded scope with a live child; end the guard's parent borrow; end the outer forwarded shield first. Source/AIR conformance fixtures cover these cases, cancelled joins, joins with different loan origins, loops and correlated scope/task permutations.
|
||||
|
||||
Diagnostic impact: the existing E4302/E4101/E4301/E2102/E4305/E3002 rules now apply after handoff. A transferred live child reports E4301 in preference to E3002. E4302 identifies the current handle and the original spawn. Incompatible shield stacks report E3002 with a shield identity; a subsequent wrong end can also report E4305. New codes, reasons and repairs are unnecessary.
|
||||
|
||||
Runtime and deterministic interpreter behavior are unchanged: transfer already moves the same resource, and a cancelled join already returns the same task. Compatibility changes only for violations formerly accepted, or reported with a generic leak after provenance was lost; valid lowering remains unchanged. Counted rotation tests bound fixed-point visits, scheduler/collection tests cover execution, and CLI tests cover exact source/package/generic positions and canonical AIR. Bundle growth is recorded in docs/agent/README.md. This strengthens verification without claiming an empirical MCC improvement or completing P6-7.
|
||||
@@ -374,3 +374,9 @@ The parser accepted `E::Empty()` and the corresponding match pattern, although s
|
||||
An ordinary function declaring `effects [bogus.effect]` reaches AIR and reports E7900 with `air_code: E0004`; templates/static contracts reject the same known-invalid effect directly with E0006. Effect membership is determined entirely from source and the registry. A P6-2 task should align ordinary signature validation with the existing template contract, preserving effect/capability semantics and checking diagnostic priority/positions. No implementation is included in DD-022.
|
||||
|
||||
**Resolved (DD-023, spec 15 §9):** ordinary signatures validate the existing effect registry before body lowering; templates/static contracts replace the incorrect E0006 with E7002. Fields `name` and `effect` identify the atom without prose; locations retain declaration/parameter starts. Signature/type/from and template/header priority, accepted AIR, effect/capability semantics and AIR E0004 are preserved. Invalid-source diagnostics can change; no new code or reason.
|
||||
|
||||
## Q-052 — Resource provenance through CFG parameters
|
||||
|
||||
P6-7 rejection-twin work reproduced accepted source that returns the cancelled handle from an inner block, ends its lent borrow at that block's exit, then joins the renamed handle. Ordinary AIR `br` has the same defect: loans and creating scopes remain attached to the moved SSA value. Review also reproduced lost guard parents and shield order. These violate existing spec 04 §33–§34, §37.3 and §40; they are verifier bugs, not missing transfer semantics.
|
||||
|
||||
**Resolved (DD-024):** resource relations follow simultaneous edge renaming, with a finite worklist covering later predecessors and backedges. Loans retain the creating spawn; tasks retain scope associations even when only the scope is passed. Guard parents and ordered shield relations survive handoff. Task/guard facts merge by union; shield stacks retain their existing exact join requirement. Existing codes E4302/E4101/E4301/E2102/E4305/E3002 apply. Valid correlated scope/task permutations and joins remain accepted. Runtime, source lowering and AIR format-0 meanings are unchanged; previously accepted violations now reject.
|
||||
Reference in new issue
Block a user