@@ -478,13 +478,11 @@ def test_real_guard_saved_before_envelope_and_read_without_reexecution(tmp_path,
478478
479479
480480def test_full_display_is_unchanged_by_capture_location ():
481- from loopx .cli_commands .quota import _project_quota_cli_payload
481+ from loopx .cli_commands .quota_presentation import project_saved_quota_initial_view
482482 from tests .test_turn_envelope import _full_decision
483- args = argparse .Namespace (turn_envelope = False , quota_command = 'should-run' )
484483 source = _full_decision ()
485- baseline = _project_quota_cli_payload (source , args , frozenset (), None )
486- captured = _project_quota_cli_payload (source , args , frozenset (), None ,
487- captured_decision_path = '/tmp/observation/decision.json' )
484+ baseline = project_saved_quota_initial_view (source , frozenset (), captured_decision_path = '/first/decision.json' )
485+ captured = project_saved_quota_initial_view (source , frozenset (), captured_decision_path = '/other/decision.json' )
488486 assert captured == baseline
489487
490488
@@ -891,11 +889,15 @@ def test_composed_guard_refusal_keeps_turn_envelope_markdown():
891889
892890
893891@pytest .mark .parametrize ('provider' , ['file' , 'sqlite' ])
894- @pytest .mark .parametrize (('delivery' , 'output_format' ), [('off' , 'json' ), ('off' , 'markdown' ), ('on' , 'json' )])
892+ @pytest .mark .parametrize (('delivery' , 'output_format' , 'fault_kind' ), [
893+ ('off' , 'json' , 'unavailable' ), ('off' , 'markdown' , 'unavailable' ), ('on' , 'json' , 'unavailable' ),
894+ ('off' , 'json' , 'missing_contract' ),
895+ ])
895896def test_failed_complete_composition_captures_only_recovery_evidence (
896- tmp_path , monkeypatch , capsys , provider , delivery , output_format ,
897+ tmp_path , monkeypatch , capsys , provider , delivery , output_format , fault_kind ,
897898):
898899 from loopx .cli import main
900+ from loopx .cli_commands import quota_result_delivery
899901 from loopx .control_plane .effect_runtime import EffectRuntimeStartupError
900902 from loopx .control_plane .quota import turn_envelope
901903 from loopx .control_plane .turn_driver import codex_context
@@ -922,14 +924,23 @@ def test_failed_complete_composition_captures_only_recovery_evidence(
922924 binding = ['--goal-id' , GOAL_ID , '--agent-id' , AGENT_ID , '--turn-instance-id' , TURN_ID ]
923925 captured = []
924926 run_typed = turn_envelope ._turn_envelope_result
927+ compose = quota_result_delivery .compose_quota_work_contract
928+
929+ def compose_without_contract (payload , * args , ** kwargs ):
930+ unsigned = {** payload }
931+ del unsigned ['interaction_contract' ]
932+ return compose (unsigned , * args , ** kwargs )
925933
926934 def interrupt_compose (action , ** kwargs ):
927935 if action == 'compose_complete' :
928936 captured .append (kwargs ['payload' ])
929- raise EffectRuntimeStartupError ('fixture composition unavailable' , diagnostic_code = 'fixture_unavailable' )
937+ if fault_kind == 'unavailable' :
938+ raise EffectRuntimeStartupError ('fixture composition unavailable' , diagnostic_code = 'fixture_unavailable' )
930939 return run_typed (action , ** kwargs )
931940
932941 with monkeypatch .context () as fault :
942+ if fault_kind == 'missing_contract' :
943+ fault .setattr (quota_result_delivery , 'compose_quota_work_contract' , compose_without_contract )
933944 fault .setattr (turn_envelope , '_turn_envelope_result' , interrupt_compose )
934945 code = main (['--registry' , str (registry ), '--runtime-root' , str (runtime ), '--format' , output_format ,
935946 'quota' , 'should-run' , * binding , '--todo-id' , TODO_ID , * delivery_args , '--decision-output-dir' , str (capture )])
0 commit comments