diff --git a/TASKS.md b/TASKS.md index b35d593d905b..2550d9091077 100644 --- a/TASKS.md +++ b/TASKS.md @@ -153,8 +153,8 @@ Find Rust owners in the [compiler map](source-rust/README.md#where-code-belongs) - 43 samples: "dependency … exceeds its reach ceiling with service …". Families: `opaque_closed_carrier_exchange` 40, `principal_component_row` 1, `process_exit_binding` 1, `range_only_localization` 1. - 39 samples: "this call's declared result-domain set does not equal its expected result-domain set; without an expected result, a call selects the empty set: declar". Families: `foreign_retained_shared_borrow` 9, `foreign_nested_record_backing` 8, `foreign_retained_mutable_borrow` 8, `selected_provider_issuance` 8, `case_store_shapes` 1, `const_extent_node_ordinal` 1, and 4 more. -- **SAMPLE-SECTOR-REQUIRES-CONTRACT.** 40 failing samples. A session claimed this sector (requires-contract by family) on 2026-12-04. The families fail on different unproved facts, so work this one family at a time. - - 40 samples: "cannot prove requires contract for call ...". Families: `match_reference_referent` 13, `match_computed_root` 10, `nested_array_element_projection` 8, and 7 more. +- **SAMPLE-SECTOR-REQUIRES-CONTRACT.** 14 failing samples. A session claimed this sector (requires-contract by family) on 2026-12-04. The families fail on different unproved facts, so work this one family at a time. + - 14 samples: "cannot prove requires contract for call ...". Families: `nested_array_element_projection` 8, and 5 more. - **SAMPLE-SECTOR-BITWISE-DISPATCH-ENTRY.** 40 failing samples. A session claimed this sector (bitwise, dispatch and hosted entry) on 2026-12-04. - 10 samples: "not supported yet: cannot prove requires contract for call ...". Families: `signed_64bit_bitwise_and_mask_bound` 2, `unsigned_64bit_bitwise_or_bound` 2, `checked_asm_add_carry` 3, `checked_asm_flag_snapshot` 2, `runtime_count_index` 1. These are intended-invalid twins the checker refuses without a verdict. The bitwise four (`invalid_field`, `invalid_match_join`) read the operand through a record field or a join, where the input counterexample search does not reach, so it cannot show `masked` reaching a value below 40. The asm twins compare flag words (`snapshot ^ 1 & 2261 == 85`), which no rule decides. @@ -200,8 +200,8 @@ Find Rust owners in the [compiler map](source-rust/README.md#where-code-belongs) - 3 samples: "not supported yet: contract dynamic selection used as a static structural subject". Families: `partitioned_match_records` 1, `partitioned_scan_output` 1, `reborrowed_partition_output` 1. - 3 samples: "not supported yet: declaration proposition". Families: `named_proposition_roster` 1, `plural_named_witnesses` 1, `proposition_surface` 1. -- **SAMPLE-SECTOR-UNCLAIMED.** 731 failing samples that no session has claimed. When you take a bullet, move it into its own sector item. - - 22 samples: "storage is changed while a conflicting reference remains live (conflicting loans)". Families: `match_loan_last_use` 14, `match_computed_root` 4, `reference_arrival_handoff` 2, `case_match_payload_loan` 1, `stamped_message_dispatch` 1. +- **SAMPLE-SECTOR-UNCLAIMED.** 727 failing samples that no session has claimed. When you take a bullet, move it into its own sector item. + - 18 samples: "storage is changed while a conflicting reference remains live (conflicting loans)". Families: `match_loan_last_use` 14, `reference_arrival_handoff` 2, `case_match_payload_loan` 1, `stamped_message_dispatch` 1. - 21 samples: "machine … has an uncovered Trap crash; publish a same-cause … route whose guard covers this site". Families: `build_target_provider` 9, `disk_collision_lab` 5, `returned_write_destination` 4, `mold_front_vent_analysis` 2, `inferred_record_equation_call` 1. - 20 samples: "root grant subject … must name one visible provider or admitted machine declaration". Families: `progress_selector` 9, `selected_value_application` 8, `write_only_reference_store` 1, `sealed_requirement_member` 1, `selected_crash_formal` 1. - 19 samples: "cannot prove requires clause N of the called machine". Families: `ieee_guard_i32_from_f64` 11, `stored_exclusive_byte_view` 1, `stored_shared_byte_view_element_lend` 1, `signed_64bit_shift_right_arithmetic_bound` 1, `signed_64bit_wrapping_subtraction_bound` 1, `signed_8bit_exact_subtraction_bound` 1, and 3 more. diff --git a/samples/cli/facts/core/match_computed_root/README.md b/samples/cli/facts/core/match_computed_root/README.md index 8379929e5680..a4298d7033d6 100644 --- a/samples/cli/facts/core/match_computed_root/README.md +++ b/samples/cli/facts/core/match_computed_root/README.md @@ -7,7 +7,8 @@ The counter starts at 0. `compute` increments it and returns index 0; the match selects `@mutable chosen[0]` when that element is 17. The consumer writes 41 through the selected loan. The runtime oracle checks the written value, `chosen[1] == 5`, `other[0] == 0` and `visits == 1`. The reject twin overwrites `chosen` while -`selected` is live and must report ``while local borrow `selected` is still active``. +`selected` is live and must report +`storage is changed while a conflicting reference remains live (conflicting loans)`. The original programs assigned `counter = 1`, so running the computation twice could still leave the count at 1. Their passing runtime results do not prove single diff --git a/samples/cli/facts/core/match_join_place_read/README.md b/samples/cli/facts/core/match_join_place_read/README.md index 82ee9f12fa57..215062ca3033 100644 --- a/samples/cli/facts/core/match_join_place_read/README.md +++ b/samples/cli/facts/core/match_join_place_read/README.md @@ -177,8 +177,12 @@ obligation. The `target_body` place and its twin carry no source target prefix. Build-owned target selection replaces the prefixed family with ordinary named implementations (`X86...` and `Arm...`) of a boundary-trait requirement, selected -by explicit target-keyed Build rows. The operation, inputs, contracts and exit -oracle are unchanged. The entry wrapper and each implementation check a tag +by explicit target-keyed Build rows. The operation, inputs and exit oracle are +unchanged. The requirement and both implementations state +`requires chosen.kept == 17`: an implementation of a declared requirement must +accept every input its contract admits +([private entry inference](../../../../../wiki/spec/language/state_contracts.md#private-entry-inference)), +so it cannot rely on what one caller happens to pass. The entry wrapper and each implementation check a tag (17 for x86-64, 29 for AArch64), so a wrong Build row traps. Observed evidence is Linux x86-64 native and Terminal Psi agreement for the positive and source rejection for the twin; the other hosted targets keep their authored rows, diff --git a/samples/cli/facts/core/match_join_place_read/invalid_target_body/main.omg b/samples/cli/facts/core/match_join_place_read/invalid_target_body/main.omg index 0076a05d03d1..35dab9cd38a0 100644 --- a/samples/cli/facts/core/match_join_place_read/invalid_target_body/main.omg +++ b/samples/cli/facts/core/match_join_place_read/invalid_target_body/main.omg @@ -38,11 +38,13 @@ ArmBodyCheck satisfies SelectedBodyCheck { boundary trait SelectedApply { machine apply(chosen: @Pair, spare: @Pair) -> i64 + requires chosen.kept == 17 reaches SelectedBodyCheck invokes SelectedBodyCheck crashes? Trap; } X86Apply satisfies SelectedApply { machine apply(chosen: @Pair, spare: @Pair) -> i64 + requires chosen.kept == 17 reaches SelectedBodyCheck invokes SelectedBodyCheck crashes? Trap { SelectedBodyCheck::require_tag(17u64); @@ -56,6 +58,7 @@ X86Apply satisfies SelectedApply { ArmApply satisfies SelectedApply { machine apply(chosen: @Pair, spare: @Pair) -> i64 + requires chosen.kept == 17 reaches SelectedBodyCheck invokes SelectedBodyCheck crashes? Trap { SelectedBodyCheck::require_tag(29u64); diff --git a/samples/cli/facts/core/match_join_place_read/target_body/main.omg b/samples/cli/facts/core/match_join_place_read/target_body/main.omg index d206b8dd2cd1..7ac2fe08cbe3 100644 --- a/samples/cli/facts/core/match_join_place_read/target_body/main.omg +++ b/samples/cli/facts/core/match_join_place_read/target_body/main.omg @@ -38,11 +38,13 @@ ArmBodyCheck satisfies SelectedBodyCheck { boundary trait SelectedApply { machine apply(chosen: @Pair, spare: @Pair) -> i64 + requires chosen.kept == 17 reaches SelectedBodyCheck invokes SelectedBodyCheck crashes? Trap; } X86Apply satisfies SelectedApply { machine apply(chosen: @Pair, spare: @Pair) -> i64 + requires chosen.kept == 17 reaches SelectedBodyCheck invokes SelectedBodyCheck crashes? Trap { SelectedBodyCheck::require_tag(17u64); @@ -56,6 +58,7 @@ X86Apply satisfies SelectedApply { ArmApply satisfies SelectedApply { machine apply(chosen: @Pair, spare: @Pair) -> i64 + requires chosen.kept == 17 reaches SelectedBodyCheck invokes SelectedBodyCheck crashes? Trap { SelectedBodyCheck::require_tag(29u64); diff --git a/samples/cli/facts/core/match_primitive_local_origin/README.md b/samples/cli/facts/core/match_primitive_local_origin/README.md index cf2f66484fe5..4f0e37bb6588 100644 --- a/samples/cli/facts/core/match_primitive_local_origin/README.md +++ b/samples/cli/facts/core/match_primitive_local_origin/README.md @@ -140,8 +140,12 @@ primitive-local origin recorded on a match join and read by a consumer. The `target_body` place and its twin carry no source target prefix. Build-owned target selection replaces the prefixed family with ordinary named implementations (`X86...` and `Arm...`) of a boundary-trait requirement, selected -by explicit target-keyed Build rows. The operation, inputs, contracts and exit -oracle are unchanged. The entry wrapper and each implementation check a tag +by explicit target-keyed Build rows. The operation, inputs and exit oracle are +unchanged. The requirement and both implementations state +`requires chosen == 17`: an implementation of a declared requirement must +accept every input its contract admits +([private entry inference](../../../../../wiki/spec/language/state_contracts.md#private-entry-inference)), +so it cannot rely on what one caller happens to pass. The entry wrapper and each implementation check a tag (17 for x86-64, 29 for AArch64), so a wrong Build row traps. Observed evidence is Linux x86-64 native and Terminal Psi agreement for the positive and source rejection for the twin; the other hosted targets keep their authored rows, diff --git a/samples/cli/facts/core/match_primitive_local_origin/invalid_target_body/main.omg b/samples/cli/facts/core/match_primitive_local_origin/invalid_target_body/main.omg index 212a985227c9..0a20470ba939 100644 --- a/samples/cli/facts/core/match_primitive_local_origin/invalid_target_body/main.omg +++ b/samples/cli/facts/core/match_primitive_local_origin/invalid_target_body/main.omg @@ -36,11 +36,13 @@ ArmBodyCheck satisfies SelectedBodyCheck { boundary trait SelectedApply { machine apply(chosen: i64, spare: i64) -> i64 + requires chosen == 17 reaches SelectedBodyCheck invokes SelectedBodyCheck crashes? Trap; } X86Apply satisfies SelectedApply { machine apply(chosen: i64, spare: i64) -> i64 + requires chosen == 17 reaches SelectedBodyCheck invokes SelectedBodyCheck crashes? Trap { SelectedBodyCheck::require_tag(17u64); @@ -54,6 +56,7 @@ X86Apply satisfies SelectedApply { ArmApply satisfies SelectedApply { machine apply(chosen: i64, spare: i64) -> i64 + requires chosen == 17 reaches SelectedBodyCheck invokes SelectedBodyCheck crashes? Trap { SelectedBodyCheck::require_tag(29u64); diff --git a/samples/cli/facts/core/match_primitive_local_origin/target_body/main.omg b/samples/cli/facts/core/match_primitive_local_origin/target_body/main.omg index 246a639268fb..84b4d28fd437 100644 --- a/samples/cli/facts/core/match_primitive_local_origin/target_body/main.omg +++ b/samples/cli/facts/core/match_primitive_local_origin/target_body/main.omg @@ -36,11 +36,13 @@ ArmBodyCheck satisfies SelectedBodyCheck { boundary trait SelectedApply { machine apply(chosen: i64, spare: i64) -> i64 + requires chosen == 17 reaches SelectedBodyCheck invokes SelectedBodyCheck crashes? Trap; } X86Apply satisfies SelectedApply { machine apply(chosen: i64, spare: i64) -> i64 + requires chosen == 17 reaches SelectedBodyCheck invokes SelectedBodyCheck crashes? Trap { SelectedBodyCheck::require_tag(17u64); @@ -54,6 +56,7 @@ X86Apply satisfies SelectedApply { ArmApply satisfies SelectedApply { machine apply(chosen: i64, spare: i64) -> i64 + requires chosen == 17 reaches SelectedBodyCheck invokes SelectedBodyCheck crashes? Trap { SelectedBodyCheck::require_tag(29u64); diff --git a/samples/cli/facts/core/match_reference_referent/README.md b/samples/cli/facts/core/match_reference_referent/README.md index d0ab899889f4..062922e527ba 100644 --- a/samples/cli/facts/core/match_reference_referent/README.md +++ b/samples/cli/facts/core/match_reference_referent/README.md @@ -93,18 +93,14 @@ with that same compiler and run configuration `6ab3b2410ace`; the other hosts ru it in the matrix above. Each capture verifies all 180 copied inputs and nine product files, including `.omega-owner`. -## Unchanged failure in the broader row - -The nested twin expects caller/state names `main`/`pick`; the diagnostic reports -`pick`/`entry` for the same missing 17 requirement. Its source, Build file and expectations are unchanged from fixed main. -The compiler and library sources are also unchanged. -The changed provider and control packages do not enter that nested program. -The failure therefore predates this migration and is outside its changed scope, -as allowed by [validation scope](../../../../../wiki/development/testing.md#validation-scope). - -The expectation and strict validation rule are unchanged. Every failed report -remains failed. Correcting that expectation is separate work on the broader row; -this migration does not claim the row or either parent task complete. +## Reject twin expectations + +Each twin pins the diagnostic the compiler prints for the unproved read: +`cannot prove requires contract for call read_through from : $joined == 17`, +with the fact the call needs (`$place == 17`) and the state it is in. The +diagnostic names the joined reference by its binding rather than repeating the +match expression. The nested twin names `pick` as the caller and `entry` as +its state, because `pick` is the machine that makes the call. Earlier experiments and four-host observations retain their actual producer identities and failed conclusions in the diff --git a/samples/cli/facts/core/match_reference_referent/invalid_call_result/sample.json b/samples/cli/facts/core/match_reference_referent/invalid_call_result/sample.json index 1a24e1f69a05..61c545133596 100644 --- a/samples/cli/facts/core/match_reference_referent/invalid_call_result/sample.json +++ b/samples/cli/facts/core/match_reference_referent/invalid_call_result/sample.json @@ -2,6 +2,6 @@ "role": "intended-invalid", "entry": "main.omg", "rejection_contains": [ - "cannot prove requires contract for call read_through from main: match choose() { true => spare_ref, false => chosen_ref } == 17 (needs fact `place == 17` here; establish it before the call via a prior contract guarantee, domain membership, or guard) in state `entry`" + "cannot prove requires contract for call read_through from main: $joined == 17 (needs fact `$place == 17` here; establish it before the call via a prior contract guarantee, domain membership, or guard) in state `entry`" ] } diff --git a/samples/cli/facts/core/match_reference_referent/invalid_const_name/sample.json b/samples/cli/facts/core/match_reference_referent/invalid_const_name/sample.json index 1a24e1f69a05..61c545133596 100644 --- a/samples/cli/facts/core/match_reference_referent/invalid_const_name/sample.json +++ b/samples/cli/facts/core/match_reference_referent/invalid_const_name/sample.json @@ -2,6 +2,6 @@ "role": "intended-invalid", "entry": "main.omg", "rejection_contains": [ - "cannot prove requires contract for call read_through from main: match choose() { true => spare_ref, false => chosen_ref } == 17 (needs fact `place == 17` here; establish it before the call via a prior contract guarantee, domain membership, or guard) in state `entry`" + "cannot prove requires contract for call read_through from main: $joined == 17 (needs fact `$place == 17` here; establish it before the call via a prior contract guarantee, domain membership, or guard) in state `entry`" ] } diff --git a/samples/cli/facts/core/match_reference_referent/invalid_field/sample.json b/samples/cli/facts/core/match_reference_referent/invalid_field/sample.json index cd1d98d26115..61c545133596 100644 --- a/samples/cli/facts/core/match_reference_referent/invalid_field/sample.json +++ b/samples/cli/facts/core/match_reference_referent/invalid_field/sample.json @@ -2,6 +2,6 @@ "role": "intended-invalid", "entry": "main.omg", "rejection_contains": [ - "cannot prove requires contract for call read_through from main: match choose() { true => pair.spare, false => pair.chosen } == 17 (needs fact `place == 17` here; establish it before the call via a prior contract guarantee, domain membership, or guard) in state `entry`" + "cannot prove requires contract for call read_through from main: $joined == 17 (needs fact `$place == 17` here; establish it before the call via a prior contract guarantee, domain membership, or guard) in state `entry`" ] } diff --git a/samples/cli/facts/core/match_reference_referent/invalid_local/sample.json b/samples/cli/facts/core/match_reference_referent/invalid_local/sample.json index 1a24e1f69a05..61c545133596 100644 --- a/samples/cli/facts/core/match_reference_referent/invalid_local/sample.json +++ b/samples/cli/facts/core/match_reference_referent/invalid_local/sample.json @@ -2,6 +2,6 @@ "role": "intended-invalid", "entry": "main.omg", "rejection_contains": [ - "cannot prove requires contract for call read_through from main: match choose() { true => spare_ref, false => chosen_ref } == 17 (needs fact `place == 17` here; establish it before the call via a prior contract guarantee, domain membership, or guard) in state `entry`" + "cannot prove requires contract for call read_through from main: $joined == 17 (needs fact `$place == 17` here; establish it before the call via a prior contract guarantee, domain membership, or guard) in state `entry`" ] } diff --git a/samples/cli/facts/core/match_reference_referent/invalid_match_join/sample.json b/samples/cli/facts/core/match_reference_referent/invalid_match_join/sample.json index 1a24e1f69a05..61c545133596 100644 --- a/samples/cli/facts/core/match_reference_referent/invalid_match_join/sample.json +++ b/samples/cli/facts/core/match_reference_referent/invalid_match_join/sample.json @@ -2,6 +2,6 @@ "role": "intended-invalid", "entry": "main.omg", "rejection_contains": [ - "cannot prove requires contract for call read_through from main: match choose() { true => spare_ref, false => chosen_ref } == 17 (needs fact `place == 17` here; establish it before the call via a prior contract guarantee, domain membership, or guard) in state `entry`" + "cannot prove requires contract for call read_through from main: $joined == 17 (needs fact `$place == 17` here; establish it before the call via a prior contract guarantee, domain membership, or guard) in state `entry`" ] } diff --git a/samples/cli/facts/core/match_reference_referent/invalid_other_machine/sample.json b/samples/cli/facts/core/match_reference_referent/invalid_other_machine/sample.json index b4e0a9cf9081..71d8f2339562 100644 --- a/samples/cli/facts/core/match_reference_referent/invalid_other_machine/sample.json +++ b/samples/cli/facts/core/match_reference_referent/invalid_other_machine/sample.json @@ -2,6 +2,6 @@ "role": "intended-invalid", "entry": "main.omg", "rejection_contains": [ - "cannot prove requires contract for call read_through from apply: match choose() { true => spare, false => chosen } == 17 (needs fact `place == 17` here; establish it before the call via a prior contract guarantee, domain membership, or guard) in state `entry`" + "cannot prove requires contract for call read_through from apply: $joined == 17 (needs fact `$place == 17` here; establish it before the call via a prior contract guarantee, domain membership, or guard) in state `entry`" ] } diff --git a/samples/cli/facts/core/match_reference_referent/invalid_other_state/sample.json b/samples/cli/facts/core/match_reference_referent/invalid_other_state/sample.json index 2e9a231024c0..3443deaa2ee1 100644 --- a/samples/cli/facts/core/match_reference_referent/invalid_other_state/sample.json +++ b/samples/cli/facts/core/match_reference_referent/invalid_other_state/sample.json @@ -2,6 +2,6 @@ "role": "intended-invalid", "entry": "main.omg", "rejection_contains": [ - "cannot prove requires contract for call read_through from main: match choose() { true => spare, false => chosen } == 17 (needs fact `place == 17` here; establish it before the call via a prior contract guarantee, domain membership, or guard) in state `pick`" + "cannot prove requires contract for call read_through from pick: $joined == 17 (needs fact `$place == 17` here; establish it before the call via a prior contract guarantee, domain membership, or guard) in state `entry`" ] } diff --git a/samples/cli/facts/core/match_reference_referent/invalid_parameter/sample.json b/samples/cli/facts/core/match_reference_referent/invalid_parameter/sample.json index b4e0a9cf9081..71d8f2339562 100644 --- a/samples/cli/facts/core/match_reference_referent/invalid_parameter/sample.json +++ b/samples/cli/facts/core/match_reference_referent/invalid_parameter/sample.json @@ -2,6 +2,6 @@ "role": "intended-invalid", "entry": "main.omg", "rejection_contains": [ - "cannot prove requires contract for call read_through from apply: match choose() { true => spare, false => chosen } == 17 (needs fact `place == 17` here; establish it before the call via a prior contract guarantee, domain membership, or guard) in state `entry`" + "cannot prove requires contract for call read_through from apply: $joined == 17 (needs fact `$place == 17` here; establish it before the call via a prior contract guarantee, domain membership, or guard) in state `entry`" ] } diff --git a/samples/cli/facts/core/match_reference_referent/invalid_target_body/sample.json b/samples/cli/facts/core/match_reference_referent/invalid_target_body/sample.json index b4e0a9cf9081..71d8f2339562 100644 --- a/samples/cli/facts/core/match_reference_referent/invalid_target_body/sample.json +++ b/samples/cli/facts/core/match_reference_referent/invalid_target_body/sample.json @@ -2,6 +2,6 @@ "role": "intended-invalid", "entry": "main.omg", "rejection_contains": [ - "cannot prove requires contract for call read_through from apply: match choose() { true => spare, false => chosen } == 17 (needs fact `place == 17` here; establish it before the call via a prior contract guarantee, domain membership, or guard) in state `entry`" + "cannot prove requires contract for call read_through from apply: $joined == 17 (needs fact `$place == 17` here; establish it before the call via a prior contract guarantee, domain membership, or guard) in state `entry`" ] } diff --git a/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/calls/entry_inputs/entry_inputs.rs b/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/calls/entry_inputs/entry_inputs.rs index e69696d0cf58..a11cbb67f81f 100644 --- a/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/calls/entry_inputs/entry_inputs.rs +++ b/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/calls/entry_inputs/entry_inputs.rs @@ -10,9 +10,10 @@ it to the same prover and kernel as an authored requirement. Describing an arrival is inference, never evidence: the final discharge checks all calls, body operations and joins before anything can be accepted. -Only facts about exact actuals cross here. Scalar inputs and the current -values of fields under structural inputs have names in the callee, and so -does the case a sum input holds when the callee's entry names it. A written +Only facts about exact actuals cross here. Scalar inputs, the scalar a +reference such as `@i64` refers to, and the current values of fields under +structural inputs have names in the callee, and so does the case a sum input +holds when the callee's entry names it. A written boundary stops caller inference, while its own declared facts can justify calls within its body. */ diff --git a/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/tests/calls/boundaries/provider_supplies.rs b/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/tests/calls/boundaries/provider_supplies.rs index 8f6c63a4f648..21bb619e0ea0 100644 --- a/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/tests/calls/boundaries/provider_supplies.rs +++ b/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/tests/calls/boundaries/provider_supplies.rs @@ -738,6 +738,49 @@ machine entry() {{ ); } +/// A provider that states `requires $chosen == 17` forwards to a private +/// helper, and the helper's read needs that fact. The provider's refinement +/// witness reads the helper's body again, and must give it the caller's fact +/// as the whole-program check does. The twin's helper selects the other +/// reference, about which no caller says anything. +#[test] +fn a_provider_passes_its_requirement_to_a_private_helper() { + let text = r#" +boundary trait Service { + machine go(chosen: @i64, spare: @i64) -> i64 requires $chosen == 17 reaches none; +} +Native satisfies Service { + machine go(chosen: @i64, spare: @i64) -> i64 requires $chosen == 17 reaches none { + apply(chosen, spare) + } +} +machine choose() -> bool ensures result == true { true } +machine read_through(place: @i64) -> i64 requires $place == 17 { $place } +machine apply(chosen: @i64, spare: @i64) -> i64 { + let joined: @i64 = match choose() { + true -> chosen, + false -> spare + }; + read_through(joined) +} +machine entry() { + let chosen: i64 = 17; + let spare: i64 = 5; + let reply: i64 = Service::go(@chosen, @spare); +} +"#; + // The helper is private only in a package the compilation checks whole. + let subjects = [Some(crate::tests::build_purpose::package())]; + supplied_with_subjects(text, "Service", &subjects) + .expect("every call of the helper passes a reference to 17"); + let other = text + .replace("true -> chosen,", "true -> spare,") + .replace("false -> spare", "false -> chosen"); + let refused = supplied_with_subjects(&other, "Service", &subjects) + .expect_err("no caller establishes `$spare == 17`"); + assert!(refused.contains("rejected"), "{refused}"); +} + #[test] fn a_provider_conformance_witness_infers_private_helper_inputs() { let source = |native_body: &str, sibling_body: &str| { diff --git a/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/tests/calls/inputs/entry_inputs.rs b/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/tests/calls/inputs/entry_inputs.rs index 544e6548d6fe..b52528676466 100644 --- a/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/tests/calls/inputs/entry_inputs.rs +++ b/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/tests/calls/inputs/entry_inputs.rs @@ -1678,3 +1678,70 @@ machine entry() -> u32 { "{unproved:?}" ); } + +/// `forward` omits `requires` and receives a reference to a local that holds +/// 17. The scalar behind the reference crosses into the helper like a record +/// field behind one, so `read` gets the 17 it requires. The twin passes 5. +#[test] +fn a_private_helper_learns_the_scalar_behind_a_reference_argument() { + let program = r" +machine entry() -> i64 { + let chosen: i64 = 17; + forward(@chosen) +} +machine forward(place: @i64) -> i64 { read(place) } +machine read(place: @i64) -> i64 requires $place == 17 { $place } +"; + let result = judge_source_arrivals(program, &["forward"]); + let RouteVerdict::Accepted(accepted) = result else { + panic!("the caller's local holds 17: {result:?}"); + }; + accepted.publish_invocation().unwrap(); + let other = program.replace("let chosen: i64 = 17;", "let chosen: i64 = 5;"); + let result = judge_source_arrivals(&other, &["forward"]); + let RouteVerdict::Rejected { unproved, .. } = result else { + panic!("a local that holds 5 cannot satisfy the read: {result:?}"); + }; + assert!( + unproved + .iter() + .any(|row| matches!(row.kind, ObligationKind::CallRequirement { .. })), + "{unproved:?}" + ); +} + +/// The subject of the match is a local bound to `true`, so the `false` arm +/// never runs and the join holds 17 alone. The twin swaps the arms, and the +/// join then holds 5. +#[test] +fn a_join_ignores_the_arm_a_literal_subject_rules_out() { + let program = r" +machine entry() -> i64 { + let decide: bool = true; + let chosen: i64 = match decide { + true -> 17, + false -> 5 + }; + read(chosen) +} +machine read(value: i64) -> i64 requires value == 17 { value } +"; + let result = judge_source_arrivals(program, &[]); + let RouteVerdict::Accepted(accepted) = result else { + panic!("only the `true` arm reaches the join: {result:?}"); + }; + accepted.publish_invocation().unwrap(); + let swapped = program + .replace("true -> 17,", "true -> 5,") + .replace("false -> 5", "false -> 17"); + let result = judge_source_arrivals(&swapped, &[]); + let RouteVerdict::Rejected { unproved, .. } = result else { + panic!("the arm that runs yields 5: {result:?}"); + }; + assert!( + unproved + .iter() + .any(|row| matches!(row.kind, ObligationKind::CallRequirement { .. })), + "{unproved:?}" + ); +}