@@ -927,9 +927,7 @@ def test_live_packet_builder_preserves_gate_and_vision_contracts(tmp_path: Path)
927927 assert regression_signature ["action" ]["selected_todo" ]["todo_id" ] == (
928928 "todo_c0ffee123456"
929929 )
930- assert regression ["capability_gate" ]["payload_compaction" ][
931- "omitted_candidate_counts"
932- ] == {"runnable" : 24 , "blocked" : 16 , "resolution_bindings" : 16 }
930+ assert regression ["capability_gate" ] == regression_source ["capability_gate" ]
933931 assert set (regression ["next_action_projection_warning" ]["projection_refs" ]) == {
934932 "active_state_next_action" ,
935933 "latest_run_recommended_action" ,
@@ -957,6 +955,7 @@ def test_live_packet_builder_preserves_gate_and_vision_contracts(tmp_path: Path)
957955 "external_write_requested" ,
958956 )
959957 for clean_id , noisy_id in invariant_pairs :
958+ assert packets [noisy_id ]["capability_gate" ] == sources [noisy_id ]["capability_gate" ]
960959 assert (
961960 len (
962961 json .dumps (sources [noisy_id ], ensure_ascii = False , indent = 2 ).encode (
@@ -1198,6 +1197,33 @@ def turn_actor(request: Mapping[str, Any]) -> Mapping[str, Any]:
11981197 assert calls == 0
11991198
12001199
1200+ @pytest .mark .parametrize ("lane" , ["runnable_candidates" , "blocked_candidates" , "resolution_bindings" ])
1201+ @pytest .mark .parametrize ("mutation" , ["drop" , "text" ])
1202+ def test_portfolio_rejects_candidate_context_loss_before_actor_call (
1203+ tmp_path : Path , lane : str , mutation : str ,
1204+ ) -> None :
1205+ sources , packets = _scenario_inputs (tmp_path )
1206+ candidates = packets ["turn_quota_hot_path_compaction_regression" ]["capability_gate" ][lane ]
1207+ if mutation == "drop" :
1208+ candidates .pop ()
1209+ else :
1210+ candidates [0 ]["text" ] = "Shortened candidate context."
1211+
1212+ def unexpected_actor (* _args : Any , ** _kwargs : Any ) -> Mapping [str , Any ]:
1213+ pytest .fail ("candidate context must be validated before any actor call" )
1214+
1215+ with pytest .raises (ValueError , match = "must preserve complete capability candidate context" ):
1216+ run_actual_default_model_behavior_portfolio (
1217+ packets ,
1218+ scenario_sources = sources ,
1219+ qualification_id = "actual-default-candidate-context-loss" ,
1220+ turn_actor = unexpected_actor ,
1221+ onboarding_actor = unexpected_actor ,
1222+ selected_todo_actor = _selected_todo_actor ,
1223+ replan_semantic_action_actor = _replan_semantic_action_actor ,
1224+ )
1225+
1226+
12011227def test_portfolio_source_oracle_rejects_mutated_compact_user_action (
12021228 tmp_path : Path ,
12031229) -> None :
0 commit comments