From 880019aa41f4d267b38ab507aedbf2f8f3921ed3 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Dec 2026 02:19:53 +0000 Subject: [PATCH 1/2] psi: carry caller facts into helpers that read a match-selected value A helper that reads the value a match selected was refused with "cannot prove requires contract for call" in three situations where the fact it needs is established. The checker now carries that fact in each of them, and the twin programs that select the other value are still refused. A private helper that omits `requires` may rely on what every caller proves. The checker already told such a helper what a record field behind a reference holds. It now also tells it what a reference to one scalar holds, so `apply(chosen: @i64, ...)` called with a reference to 17 can pass that reference to a reader that requires `$place == 17`. A provider's conformance witness reads the bodies of the helpers the provider calls. It checked them for every possible input, while the root checked them under the conditions their callers establish, so a helper the root accepted was refused in the witness. The witness now treats a helper as private when the root did, and stage 06 infers its inputs from the calls the witness contains. A join's predicate lists what each arriving edge knows. An edge whose own facts contradict each other, such as the `false` arm of a match on a local bound to `true`, used to stay in that list without its contradiction, so the join could not rule the arm's value out. Such an edge now adds no alternative. Its arrival must still prove the predicate from the same contradiction. Samples: the `target_body` programs of match_primitive_local_origin and match_join_place_read now state the requirement on the provider trait and its implementations, as the spec requires of an implementation and as match_reference_referent already does. Eighteen reject twins pin the wording the compiler prints today. Agent: Claude Code | Model: claude-fable-5-2 | Effort: low | Tokens: unavailable in (unavailable cached), unavailable out | Steps: unavailable | Time: unavailable | Steers: 0 --- TASKS.md | 8 +-- .../facts/core/match_computed_root/README.md | 3 +- .../invalid_call_result/sample.json | 2 +- .../invalid_const_name/sample.json | 2 +- .../invalid_field/sample.json | 2 +- .../invalid_local/sample.json | 2 +- .../invalid_match_join/sample.json | 2 +- .../invalid_other_machine/sample.json | 2 +- .../invalid_other_state/sample.json | 2 +- .../invalid_parameter/sample.json | 2 +- .../invalid_target_body/sample.json | 2 +- .../core/match_join_place_read/README.md | 8 ++- .../invalid_target_body/main.omg | 3 + .../target_body/main.omg | 3 + .../match_primitive_local_origin/README.md | 8 ++- .../invalid_target_body/main.omg | 3 + .../target_body/main.omg | 3 + .../core/match_reference_referent/README.md | 20 +++--- .../invalid_call_result/sample.json | 2 +- .../invalid_const_name/sample.json | 2 +- .../invalid_field/sample.json | 2 +- .../invalid_local/sample.json | 2 +- .../invalid_match_join/sample.json | 2 +- .../invalid_other_machine/sample.json | 2 +- .../invalid_other_state/sample.json | 2 +- .../invalid_parameter/sample.json | 2 +- .../invalid_target_body/sample.json | 2 +- .../README.md | 7 ++ .../src/compilation/compilation.rs | 7 ++ .../src/elaboration/finish.rs | 7 +- .../src/elaboration/forms.rs | 6 ++ .../src/read/bodies/machine/components.rs | 21 ++++-- .../README.md | 7 +- .../src/calls/entry_inputs/entry_inputs.rs | 5 +- .../src/control_flow/joins/description.rs | 12 ++-- .../places/bindings/call_observations.rs | 9 ++- .../calls/boundaries/provider_supplies.rs | 43 ++++++++++++ .../src/tests/calls/inputs/entry_inputs.rs | 67 +++++++++++++++++++ 38 files changed, 234 insertions(+), 52 deletions(-) diff --git a/TASKS.md b/TASKS.md index 497da96cea48..c2568667a2ed 100644 --- a/TASKS.md +++ b/TASKS.md @@ -110,8 +110,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.** 81 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. - - 81 samples: "cannot prove requires contract for call ...". Families: `match_reference_referent` 13, `match_computed_root` 10, `machine_tuple_dispatch` 9, `nominal_loan_backing_cleanup` 9, `skipped_short_circuit_call` 9, `nested_array_element_projection` 8, and 13 more. +- **SAMPLE-SECTOR-REQUIRES-CONTRACT.** 55 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. + - 55 samples: "cannot prove requires contract for call ...". Families: `machine_tuple_dispatch` 9, `nominal_loan_backing_cleanup` 9, `skipped_short_circuit_call` 9, `nested_array_element_projection` 8, and 11 more. - **SAMPLE-SECTOR-BITWISE-DISPATCH-ENTRY.** 78 failing samples. A session claimed this sector (bitwise, dispatch and hosted entry) on 2026-12-04. - 29 samples: "not supported yet: cannot prove requires contract for call ...". Families: `signed_64bit_bitwise_and_mask_bound` 10, `unsigned_64bit_bitwise_or_bound` 10, `checked_asm_add_carry` 3, `signed_8bit_division_remainder_bound` 3, `checked_asm_flag_snapshot` 2, `runtime_count_index` 1. @@ -162,8 +162,8 @@ Find Rust owners in the [compiler map](source-rust/README.md#where-code-belongs) - **SAMPLE-SECTOR-ADDRESS-CASTS.** 2 failing samples. A session claimed this sector (address casts) on 2026-12-04. - 2 samples: "not supported yet: expression cast to or from an address". Families: `address_model_package` 1, `exact_address_conversion` 1. -- **SAMPLE-SECTOR-UNCLAIMED.** 729 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.** 725 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_computed_root/invalid_call_result/sample.json b/samples/cli/facts/core/match_computed_root/invalid_call_result/sample.json index 62c7d71279c1..eae6d10a0a46 100644 --- a/samples/cli/facts/core/match_computed_root/invalid_call_result/sample.json +++ b/samples/cli/facts/core/match_computed_root/invalid_call_result/sample.json @@ -2,6 +2,6 @@ "role": "intended-invalid", "entry": "main.omg", "rejection_contains": [ - "while local borrow `selected` is still active" + "storage is changed while a conflicting reference remains live (conflicting loans)" ] } diff --git a/samples/cli/facts/core/match_computed_root/invalid_const_name/sample.json b/samples/cli/facts/core/match_computed_root/invalid_const_name/sample.json index 62c7d71279c1..eae6d10a0a46 100644 --- a/samples/cli/facts/core/match_computed_root/invalid_const_name/sample.json +++ b/samples/cli/facts/core/match_computed_root/invalid_const_name/sample.json @@ -2,6 +2,6 @@ "role": "intended-invalid", "entry": "main.omg", "rejection_contains": [ - "while local borrow `selected` is still active" + "storage is changed while a conflicting reference remains live (conflicting loans)" ] } diff --git a/samples/cli/facts/core/match_computed_root/invalid_field/sample.json b/samples/cli/facts/core/match_computed_root/invalid_field/sample.json index 62c7d71279c1..eae6d10a0a46 100644 --- a/samples/cli/facts/core/match_computed_root/invalid_field/sample.json +++ b/samples/cli/facts/core/match_computed_root/invalid_field/sample.json @@ -2,6 +2,6 @@ "role": "intended-invalid", "entry": "main.omg", "rejection_contains": [ - "while local borrow `selected` is still active" + "storage is changed while a conflicting reference remains live (conflicting loans)" ] } diff --git a/samples/cli/facts/core/match_computed_root/invalid_local/sample.json b/samples/cli/facts/core/match_computed_root/invalid_local/sample.json index 62c7d71279c1..eae6d10a0a46 100644 --- a/samples/cli/facts/core/match_computed_root/invalid_local/sample.json +++ b/samples/cli/facts/core/match_computed_root/invalid_local/sample.json @@ -2,6 +2,6 @@ "role": "intended-invalid", "entry": "main.omg", "rejection_contains": [ - "while local borrow `selected` is still active" + "storage is changed while a conflicting reference remains live (conflicting loans)" ] } diff --git a/samples/cli/facts/core/match_computed_root/invalid_match_join/sample.json b/samples/cli/facts/core/match_computed_root/invalid_match_join/sample.json index 62c7d71279c1..eae6d10a0a46 100644 --- a/samples/cli/facts/core/match_computed_root/invalid_match_join/sample.json +++ b/samples/cli/facts/core/match_computed_root/invalid_match_join/sample.json @@ -2,6 +2,6 @@ "role": "intended-invalid", "entry": "main.omg", "rejection_contains": [ - "while local borrow `selected` is still active" + "storage is changed while a conflicting reference remains live (conflicting loans)" ] } diff --git a/samples/cli/facts/core/match_computed_root/invalid_other_machine/sample.json b/samples/cli/facts/core/match_computed_root/invalid_other_machine/sample.json index 62c7d71279c1..eae6d10a0a46 100644 --- a/samples/cli/facts/core/match_computed_root/invalid_other_machine/sample.json +++ b/samples/cli/facts/core/match_computed_root/invalid_other_machine/sample.json @@ -2,6 +2,6 @@ "role": "intended-invalid", "entry": "main.omg", "rejection_contains": [ - "while local borrow `selected` is still active" + "storage is changed while a conflicting reference remains live (conflicting loans)" ] } diff --git a/samples/cli/facts/core/match_computed_root/invalid_other_state/sample.json b/samples/cli/facts/core/match_computed_root/invalid_other_state/sample.json index 62c7d71279c1..eae6d10a0a46 100644 --- a/samples/cli/facts/core/match_computed_root/invalid_other_state/sample.json +++ b/samples/cli/facts/core/match_computed_root/invalid_other_state/sample.json @@ -2,6 +2,6 @@ "role": "intended-invalid", "entry": "main.omg", "rejection_contains": [ - "while local borrow `selected` is still active" + "storage is changed while a conflicting reference remains live (conflicting loans)" ] } diff --git a/samples/cli/facts/core/match_computed_root/invalid_parameter/sample.json b/samples/cli/facts/core/match_computed_root/invalid_parameter/sample.json index 62c7d71279c1..eae6d10a0a46 100644 --- a/samples/cli/facts/core/match_computed_root/invalid_parameter/sample.json +++ b/samples/cli/facts/core/match_computed_root/invalid_parameter/sample.json @@ -2,6 +2,6 @@ "role": "intended-invalid", "entry": "main.omg", "rejection_contains": [ - "while local borrow `selected` is still active" + "storage is changed while a conflicting reference remains live (conflicting loans)" ] } diff --git a/samples/cli/facts/core/match_computed_root/invalid_target_body/sample.json b/samples/cli/facts/core/match_computed_root/invalid_target_body/sample.json index 62c7d71279c1..eae6d10a0a46 100644 --- a/samples/cli/facts/core/match_computed_root/invalid_target_body/sample.json +++ b/samples/cli/facts/core/match_computed_root/invalid_target_body/sample.json @@ -2,6 +2,6 @@ "role": "intended-invalid", "entry": "main.omg", "rejection_contains": [ - "while local borrow `selected` is still active" + "storage is changed while a conflicting reference remains live (conflicting loans)" ] } 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/05_prepared-typed-trees-to-lowered-program/README.md b/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/README.md index 09201dfa0718..4f3d17296366 100644 --- a/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/README.md +++ b/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/README.md @@ -20,6 +20,13 @@ The witness receives a bodyless requirement that permits writes to the entire mutable argument. If the root body has a narrower write frame, lowering records the original declaration and root machine for stage 06 to check. +A witness also reads the body of a helper whose inferred result its +implementation uses. When the root checks that helper under the conditions +its callers establish (`private_inputs`), the witness lists it the same way, +so stage 06 infers the helper's inputs from the calls the witness contains. +Without that, the witness would check the helper for every input and refuse +a body the root accepts. The root alone decides which helpers qualify. + An integer `Identity(x, y)` in a contract retains its declared type and both operands in Psi. Naming that proposition with a `let` produces the same clause as writing it directly. The checker can then verify where a proof moves between typed identity and integer comparison. For a fixed array, lowering names the literal element paths that the machine or its contracts use. Dynamic indices retain the identity of their selector. Zero initialization and restoration still owe the requirements of the element type and any separately qualified index. diff --git a/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/compilation/compilation.rs b/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/compilation/compilation.rs index c58afef1fbbd..1f81649315cd 100644 --- a/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/compilation/compilation.rs +++ b/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/compilation/compilation.rs @@ -162,6 +162,13 @@ fn collect_callee_summaries( // destructor and its callees to establish that automatic cleanup returns. // An ordinary call summary carries no such evidence. let module = &prepared.program.module; + if root { + for id in &prepared.program.private_inputs { + if let Some(&symbol) = prepared.program.machines.get(*id) { + summaries.root_private_inputs.insert(symbol, ()); + } + } + } let mut pending: Vec<_> = module .types .structural_types diff --git a/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/elaboration/finish.rs b/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/elaboration/finish.rs index 3710d0cde83e..a3c43612bb4c 100644 --- a/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/elaboration/finish.rs +++ b/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/elaboration/finish.rs @@ -166,7 +166,12 @@ pub(super) fn finish_reading_into<'source>( break components; } }; - let private_inputs = program.private_input_contracts(entry, diagnostic)?; + let root_private_inputs = match body_scope { + BodyScope::All => None, + BodyScope::UpTo { summaries, .. } => Some(&summaries.root_private_inputs), + }; + let private_inputs = + program.private_input_contracts(entry, diagnostic, root_private_inputs)?; program.finish_operational_envelopes(&bodies, &components)?; program.finish_declarations(diagnostic)?; program.prepare_external_providers(diagnostic)?; diff --git a/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/elaboration/forms.rs b/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/elaboration/forms.rs index b334ff5664c6..ba5973a939a0 100644 --- a/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/elaboration/forms.rs +++ b/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/elaboration/forms.rs @@ -451,6 +451,9 @@ pub(crate) struct CalleeSummary { pub(crate) struct CalleeSummaries { pub(crate) rows: arena::HandleKeyMap>, pub(crate) mutable_stubs: Option, + /// Helpers the root checks under the conditions its callers establish. + /// A witness that reads such a body infers its inputs the same way. + pub(crate) root_private_inputs: arena::HandleKeyMap, } impl CalleeSummaries { @@ -487,6 +490,9 @@ impl CalleeSummaries { } pub(crate) fn merge(&mut self, other: Self) { + for (symbol, ()) in other.root_private_inputs { + self.root_private_inputs.insert(symbol, ()); + } for (symbol, entry) in other.rows { match entry { Some(summary) => self.insert(symbol, summary), diff --git a/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/read/bodies/machine/components.rs b/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/read/bodies/machine/components.rs index a847bca1682f..a9e55b81b31f 100644 --- a/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/read/bodies/machine/components.rs +++ b/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/read/bodies/machine/components.rs @@ -188,11 +188,21 @@ impl<'t> Program<'t> { /// unserved selection refuses the whole route. Only direct calls remain /// for those helpers. A reached dependency need not include every caller, /// so its helpers and static requirement implementations keep their envelope. + /// + /// A conformance witness reads only the implementation and the helpers it + /// reaches, so none of them is its subject. `root_private` names the + /// helpers the root already found private over the whole program. The + /// witness infers their inputs from its own calls, as the root does from + /// all of them, and every call the witness contains still proves the + /// inferred condition. pub(crate) fn private_input_contracts( &self, entry: Option, diagnostic: MachineId, + root_private: Option<&arena::HandleKeyMap>, ) -> Checked> { + let inherited = + |symbol: &SymbolHandle| root_private.is_some_and(|set| set.contains_key(symbol)); let mut private = Vec::new(); let mut fixed = self.symbols.map(|_, _| false); for id in entry @@ -233,7 +243,7 @@ impl<'t> Program<'t> { let Some(machine) = self.typed.machine_by_symbol(*symbol) else { continue; }; - if subjects.get(id) != Some(&true) { + if subjects.get(id) != Some(&true) && !inherited(symbol) { let scope = self.typed.symbols.get(*symbol).parent; if incomplete_scopes.contains_key(&scope) || self @@ -298,9 +308,12 @@ impl<'t> Program<'t> { .declaration(*id, symbol) .expect("candidate declaration was checked") .1; - [symbol, state.symbol] - .iter() - .all(|symbol| !references.referenced_outside(*symbol, &lowered)) + // The root decided an inherited helper against every use in the + // program; the callers this witness leaves out are among them. + inherited(&symbol) + || [symbol, state.symbol] + .iter() + .all(|symbol| !references.referenced_outside(*symbol, &lowered)) }); Ok(private) } diff --git a/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/README.md b/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/README.md index a3833f3645f5..dfd28dc48786 100644 --- a/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/README.md +++ b/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/README.md @@ -2225,7 +2225,12 @@ builds one per join, so no shape of join is special: the join's parameters): `p == a` with the argument `a` unfolded through the Boolean and literal definitions on that edge, and each path fact transported into its denotation. For the example: `(p == (9000 < total) - and 9000 < total) or (p == (total < 3) and total <= 9000)`. + and 9000 < total) or (p == (total < 3) and total <= 9000)`. An arrival + whose own facts denote a contradiction adds no alternative: after + `match true { true -> 17, false -> 5 }` the `false` edge knows + `(true == true) == false`, so the join's predicate is `p == 17` alone. + That edge's arrival obligation still has to prove the predicate, from the + same contradiction. - Each arrival obligation is that predicate with `p` replaced by the edge's argument, proved by the same prover and decided by the kernel. Only then is the predicate a `BlockInvariant` knowledge row at the join's entry. If any 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 5a25278bc96c..e661f0fd2dc2 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,8 +10,9 @@ 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. 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. 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/control_flow/joins/description.rs b/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/control_flow/joins/description.rs index f8c581464c8e..794c1314f72e 100644 --- a/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/control_flow/joins/description.rs +++ b/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/control_flow/joins/description.rs @@ -448,10 +448,14 @@ pub(super) fn describe( in_scope(atom).then(|| atom.clone()) })); } - // A part outside the scope, or one this route does not state (a - // contradiction, which would make the disjunct unprovable here), is left - // out: that weakens the disjunct, never strengthens it. - parts.retain(|part| *part != Proposition::Falsehood); + // Every fact above holds on this edge, and projecting one only weakens + // it. One that still denotes a contradiction, such as the `false` arm of + // `match true`, shows that control never takes the edge, so the edge adds + // no alternative to the join. Its arrival obligation must still prove the + // joined predicate, which it can do only from that same contradiction. + if parts.contains(&Proposition::Falsehood) { + return Ok(Proposition::Falsehood); + } Ok(super::inference::fit_inferred_predicate( None, connective(parts, true), diff --git a/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/storage/places/bindings/call_observations.rs b/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/storage/places/bindings/call_observations.rs index b886b3e8948f..b7bcebff37e9 100644 --- a/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/storage/places/bindings/call_observations.rs +++ b/source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/storage/places/bindings/call_observations.rs @@ -260,7 +260,8 @@ impl<'a> CallObservations<'_, 'a> { /// Callee names of the scalar fields, descriptor lengths and fixed array elements of each /// readable structural input, with the caller value each holds at this - /// arrival. + /// arrival. An input that refers to one scalar, such as `@i64`, crosses + /// as that single leaf. /// /// A value is named in the callee by the field it was read from. After /// `main.sp = main.k`, the value of `main.k` is also what `main.sp` holds, @@ -473,6 +474,12 @@ impl<'a> CallObservations<'_, 'a> { { leaves.push((path, Read::Extent)) } + // A reference to one scalar, such as `@i64`, holds a + // single leaf at the storage itself. It crosses under the + // name a clause `$place == 17` states for it. + Some(StructuralTypeShape::PrimitiveScalar( + scalar_type @ (ScalarType::Integer(_) | ScalarType::Boolean), + )) => leaves.push((path, Read::Scalar(*scalar_type))), _ => continue, } for (leaf_path, read) in leaves { 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 590a045134dd..3c39cb881768 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,3 +738,46 @@ machine entry() {{ "a provider callback tying its result to an outer method lifetime instead of its invocation lifetime must be refused: {refused}" ); } + +/// 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}"); +} 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 118ddd000aca..be48308fb771 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 @@ -1598,3 +1598,70 @@ machine consume(p: @Plan, x: @[u8]) {} .any(|row| row.statement.contains("index is within length")) ); } + +/// `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:?}" + ); +} From 5d1e3aef0a13962a4113b7b924de83522d458c48 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Dec 2026 02:49:45 +0000 Subject: [PATCH 2/2] psi: format the witness private-input call Agent: Claude Code | Model: claude-fable-5-2 | Effort: low | Tokens: unavailable in (unavailable cached), unavailable out | Steps: unavailable | Time: unavailable | Steers: 0 --- .../src/elaboration/finish.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/elaboration/finish.rs b/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/elaboration/finish.rs index a3c43612bb4c..4646c67e9333 100644 --- a/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/elaboration/finish.rs +++ b/source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/elaboration/finish.rs @@ -170,8 +170,7 @@ pub(super) fn finish_reading_into<'source>( BodyScope::All => None, BodyScope::UpTo { summaries, .. } => Some(&summaries.root_private_inputs), }; - let private_inputs = - program.private_input_contracts(entry, diagnostic, root_private_inputs)?; + let private_inputs = program.private_input_contracts(entry, diagnostic, root_private_inputs)?; program.finish_operational_envelopes(&bodies, &components)?; program.finish_declarations(diagnostic)?; program.prepare_external_providers(diagnostic)?;