tests: audit feature-header context and rejection boundaries
This commit is contained in:
1 parent
fe63ae9586
commit
03305f0957
13 files changed
+326
-10
No files matched your search
@@ -50,6 +50,8 @@ The check compares code multisets, diagnostic kinds, offending AIR operations, i
|
||||
|
||||
Case-specific `required_ops` optionally checks minimum operation counts in the diagnostic's function in both original and generated AIR. Cancelled-join regressions require their cancellation operations, so a plain task-loan error cannot replace them. `exact_ops: true` instead requires the full opcode count table of that function to match `required_ops`. The shared-view push case uses it to reject ended decoy views and additional plain borrows; it preserves the reviewed straight-line shape without computing lifetimes. `required_identity_uses` additionally requires the reported SSA identity to occur as an operand of the named opcode. The shared-view case links `conflicts_with` to `buffer.view`, excluding a view of another buffer. These strict witnesses retain both trap continuations; otherwise valid twins may need a separate audit. `match_type_declarations: true` additionally compares the complete named type-declaration tables, ignoring only comments/whitespace. The nominal diamond regression uses it so flat arrays of the same byte size cannot replace its shared type graph. AIR witnesses require a lowered same-code pair. These witnesses and diagnostic facts supplement the manual rule audit; they do not prove full dataflow equivalence. An analogue without structured rule fields relies on the reviewed construct and exact code/position; the check does not infer facts from message prose.
|
||||
|
||||
For a single E0006 `feature_not_declared` pair, `feature_header_context: true` permits different unrelated declared features. Each diagnostic's `canonical_header` must first equal the sorted union of its module's unique feature header and the verifier-provided `closure`. The comparison then replaces only that repair header with the missing closure set; feature, reason, construct and all other facts remain exact. Invalid/missing closures, dependency errors and malformed repair headers fail closed. Source/raw payload mapping stays exact, including the repair header. This witness does not infer dependencies or support other E0006 reasons.
|
||||
|
||||
For lowered CFG cases whose diagnostic facts omit the handoff shape, `audited_context` pins three manually reviewed artifacts: the original AIR (`air`), each source file (`sources`) and its canonical UTF-8 lowering (`lowered`). Both maps must name exactly the declared twins; every value is a lowercase SHA-256 digest. Byte changes, including source comments/line endings and harmless lowering renames, require a fresh context review before updating the fingerprints. The regular compiled diagnostics, markers, raw mapping, related positions and lowering determinism remain checked. The five task-loan rows record their reviewed br/merge/back-edge/cancelled-handle contexts in `rule`; a straight-line error cannot replace them. These fingerprints attest unchanged artifacts, not the correctness of the manual audit, and add no provenance or lifetime analysis. Direct cbr/switch target-argument cases remain pending: source arm joins do not preserve those reviewed AIR shapes.
|
||||
|
||||
Early rejection produces no canonical AIR. Its mandatory `early_context` records SHA-256 fingerprints of both manually audited AIR/source files, alongside the rule audit; compiled code/kind/type and independent source positions still have to match. The fingerprints preserve the reviewed cycle shape, including long nominal chains and recursive arrays. They attest unchanged bytes, not the correctness of the audit. Any edit, including comments or line endings, requires a fresh context review before updating these fingerprints; do not regenerate them just to make a failed check pass.
|
||||
|
||||
@@ -1421,6 +1421,131 @@
|
||||
"kind": "air_only",
|
||||
"spec": "docs/spec/15-source-language.md \u00a77",
|
||||
"rule": "Every normal exit of a source lock block emits explicit borrow endings and mutex.unlock. The guard is never a source value, so leaving that guard live at ret cannot be authored; traps terminate without a normal-path leak."
|
||||
},
|
||||
"phase3/reject/tasks_handle_as_parameter.air": {
|
||||
"kind": "same_code",
|
||||
"site": "function",
|
||||
"spec": "docs/spec/04-concurrency-and-atomics.md \u00a733.1",
|
||||
"rule": "A task<u8> parameter requires reserved task_transfer. Each full canonical repair header is validated against that module's declared features and the supplied closure; the missing closure is task_transfer on both sides. Unused arrays and mandatory source effects are header context, not the forbidden parameter rule.",
|
||||
"feature_header_context": true
|
||||
},
|
||||
"phase2/reject/unknown_narrowing_form.air": {
|
||||
"kind": "same_code",
|
||||
"site": "instruction",
|
||||
"spec": "docs/spec/05-effects-and-capabilities.md \u00a710.4",
|
||||
"rule": "cap.narrow.budget is requested for cap<io.write>, which has no budget narrowing form; both diagnostics retain capability_kind io.write and form budget."
|
||||
},
|
||||
"phase2/reject/narrow_ok_arity.air": {
|
||||
"kind": "source_error",
|
||||
"spec": "docs/spec/15-source-language.md \u00a78",
|
||||
"rule": "The authored cap.narrow.budget success arm omits its required capability binding; source reports E7005 before emitting an outcome target. The source analogue uses mem.alloc to isolate arity; AIR also has an invalid io.write narrowing form masked by its earlier arity rejection.",
|
||||
"analogues": [
|
||||
{
|
||||
"source": "source/reject_twins/analogue_narrow_ok_arity.aji",
|
||||
"codes": [
|
||||
"E7005"
|
||||
],
|
||||
"fields": {
|
||||
"outcome": "ok",
|
||||
"expected": "1"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"phase2/reject/intrinsic_ok_arity.air": {
|
||||
"kind": "source_error",
|
||||
"spec": "docs/spec/15-source-language.md \u00a76",
|
||||
"rule": "fs.open_read success must bind one file; the authored source binding list is checked before emitting its continuation.",
|
||||
"analogues": [
|
||||
{
|
||||
"source": "source/reject_twins/analogue_intrinsic_ok_arity.aji",
|
||||
"codes": [
|
||||
"E7005"
|
||||
],
|
||||
"fields": {
|
||||
"outcome": "ok",
|
||||
"expected": "1"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"phase2/reject/fallible_without_targets.air": {
|
||||
"kind": "source_error",
|
||||
"spec": "docs/spec/15-source-language.md \u00a78",
|
||||
"rule": "A fallible fs.open_read is used as a plain statement instead of an outcome match or or trap; source prescribes E7006 invalid_operation.",
|
||||
"analogues": [
|
||||
{
|
||||
"source": "source/reject_twins/analogue_fallible_stmt.aji",
|
||||
"codes": [
|
||||
"E7006"
|
||||
],
|
||||
"fields": {
|
||||
"reason": "invalid_operation",
|
||||
"operation": "fs.open_read"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"std/endian_payload_type.air": {
|
||||
"kind": "source_error",
|
||||
"spec": "docs/spec/15-source-language.md \u00a713",
|
||||
"rule": "The registered std.bytes.ReadU16 ok variant receives u32 rather than u16; source rejects the same payload mismatch with E7005.",
|
||||
"analogues": [
|
||||
{
|
||||
"source": "source/reject_twins/analogue_endian_u32.aji",
|
||||
"codes": [
|
||||
"E7005"
|
||||
],
|
||||
"fields": {
|
||||
"expected": "u16",
|
||||
"found": "u32"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"std/bounded_arithmetic_payload.air": {
|
||||
"kind": "source_error",
|
||||
"spec": "docs/spec/15-source-language.md \u00a713",
|
||||
"rule": "A registered standard enum variant receives a bool payload instead of u64; source checks the payload before AIR.",
|
||||
"analogues": [
|
||||
{
|
||||
"source": "source/std/bounded_math_payload.aji",
|
||||
"codes": [
|
||||
"E7005"
|
||||
],
|
||||
"fields": {
|
||||
"expected": "u64",
|
||||
"found": "bool"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"std/text_utf8_payload.air": {
|
||||
"kind": "source_error",
|
||||
"spec": "docs/spec/15-source-language.md \u00a713",
|
||||
"rule": "A registered standard enum variant receives a bool payload instead of u32; source checks the payload before AIR.",
|
||||
"analogues": [
|
||||
{
|
||||
"source": "source/std/text_utf8_payload.aji",
|
||||
"codes": [
|
||||
"E7005"
|
||||
],
|
||||
"fields": {
|
||||
"expected": "u32",
|
||||
"found": "bool"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"phase2/reject/resource_copy.air": {
|
||||
"kind": "air_only",
|
||||
"spec": "docs/spec/15-source-language.md \u00a75",
|
||||
"rule": "Source only duplicates Copy values by plain use. A named linear file needs explicit move (E7003), which transfers rather than duplicates it; the frontend cannot emit AIR copy of a resource."
|
||||
},
|
||||
"phase2/reject/unknown_intrinsic.air": {
|
||||
"kind": "air_only",
|
||||
"spec": "docs/spec/15-source-language.md \u00a78",
|
||||
"rule": "Only registered intrinsic names emit AIR intrinsic calls. An undeclared io.teleport in source is ordinary E7002 name resolution, not an unknown AIR intrinsic; user functions are emitted as ordinary calls."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §13
|
||||
module test.endian
|
||||
import std.bytes;
|
||||
|
||||
fn main() -> u8 effects [] {
|
||||
let r = std.bytes.ReadU16::ok(1u32); // diagnostic here: 1u32)
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// expect: reject E7006
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §8
|
||||
module test.fallible_without_targets
|
||||
|
||||
fn f(c: cap<fs.read>) -> void effects [fs.read] {
|
||||
fs.open_read(c, b"/a"); // diagnostic here
|
||||
}
|
||||
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,13 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §6
|
||||
module test.intrinsic_ok_arity
|
||||
|
||||
fn f(c: cap<fs.read>) -> void effects [fs.read] {
|
||||
match fs.open_read(c, b"/a") {
|
||||
ok => {}, // diagnostic here: ok =>
|
||||
err(e) => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,13 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §8
|
||||
module test.narrow_ok_arity
|
||||
|
||||
fn f(c: cap<mem.alloc>, n: usize) -> void effects [] {
|
||||
match cap.narrow.budget(c, n) {
|
||||
ok => {}, // diagnostic here: ok =>
|
||||
err(e) => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E0006
|
||||
// phase: 6
|
||||
// spec: docs/spec/04-concurrency-and-atomics.md §33.1; docs/spec/15-source-language.md §10
|
||||
// AIR twin: phase3/reject/tasks_handle_as_parameter.air
|
||||
module test.p
|
||||
|
||||
fn f(t: task<u8>) -> void effects [] { // diagnostic here
|
||||
trap;
|
||||
}
|
||||
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,14 @@
|
||||
// expect: reject E3202
|
||||
// phase: 6
|
||||
// spec: docs/spec/05-effects-and-capabilities.md §10.4; docs/spec/15-source-language.md §8
|
||||
// AIR twin: phase2/reject/unknown_narrowing_form.air
|
||||
module test.unknown_narrowing_form
|
||||
|
||||
fn f(c: cap<io.write>, n: usize) -> void effects [] {
|
||||
match cap.narrow.budget(c, n) { // diagnostic here: cap.narrow.budget
|
||||
ok(d) => {},
|
||||
err(e) => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> void effects [] {}
|
||||
@@ -5,4 +5,4 @@ module test.bounded_math
|
||||
import std.math;
|
||||
fn main() -> std.math.U64Result
|
||||
effects []
|
||||
{ return std.math.U64Result::ok(true); }
|
||||
{ return std.math.U64Result::ok(true); } // diagnostic here: true)
|
||||
@@ -3,4 +3,4 @@
|
||||
// spec: docs/spec/16-standard-library.md §2.5–§2.7
|
||||
module test.text
|
||||
import std.utf8;
|
||||
fn main() -> std.utf8.NextResult effects [] { return std.utf8.NextResult::ok(true, 1); }
|
||||
fn main() -> std.utf8.NextResult effects [] { return std.utf8.NextResult::ok(true, 1); } // diagnostic here: true, 1
|
||||
Reference in new issue
Block a user