@@ -1712,12 +1712,50 @@ def test_thin_json_budget_retains_full_supported_scope(tmp_path: Path) -> None:
17121712 )
17131713 payload = measurement ["payload" ]
17141714 assert scope in payload ["task_body" ]
1715- assert payload ["interface_budget" ]["max_chars" ] == 4500
1715+ assert payload ["interface_budget" ]["max_chars" ] == 4900
17161716 assert payload ["interface_budget" ]["within_budget" ] is True
17171717 assert "refresh-state --goal-outcome-update-json" in payload ["task_body" ]
17181718 assert "Local outcomes never replace root continuation, budget or stop criteria." in payload ["task_body" ]
17191719
17201720
1721+ @pytest .mark .parametrize ("route_padding, within_budget" , [("" , True ), ("x" * 48 , False )])
1722+ def test_thin_budget_covers_complete_capability_and_cli_routes (
1723+ tmp_path : Path , route_padding : str , within_budget : bool ,
1724+ ) -> None :
1725+ # Exercise the actual CLI composition, not a shortened instruction or an
1726+ # estimated sum. An oversized route must still report a budget failure.
1727+ with _stable_budget_fixture_root (tmp_path ) as root :
1728+ project , runtime , registry_path , state_file = _write_fixture (root , SCENARIOS [0 ])
1729+ import_fixture_authority (registry_path , GOAL_ID )
1730+ command = _surface_commands (
1731+ project = project , runtime = runtime , registry_path = registry_path ,
1732+ state_file = state_file , output_format = "json" ,
1733+ )["heartbeat_prompt_thin" ]
1734+ scope = "x" * 320
1735+ command [command .index ("--agent-scope" ) + 1 ] = scope
1736+ cli_route = f"/opt/loopx/{ route_padding } qualified-tools/bin/loopx"
1737+ command .extend (["--codex-app" , "--cli-bin" , cli_route ])
1738+ capabilities = ("shell" , "filesystem" , "network" , "external_evidence_poll" , "browser" )
1739+ for capability in capabilities :
1740+ command .extend (["--available-capability" , capability ])
1741+ exit_code , text = _invoke_cli (command )
1742+ assert exit_code == 0 , text
1743+ payload = json .loads (text )
1744+ body , budget = payload ["task_body" ], payload ["interface_budget" ]
1745+ assert scope in body and body .count (cli_route ) >= 2
1746+ assert all (f"--available-capability { capability } " in body for capability in capabilities )
1747+ assert "--codex-app" in body and "--runtime-root" in body and "--registry" in body
1748+ assert "--todo-id <id>" in body and "settlement_plan.ordered_steps" in body
1749+ assert "ambiguous effects need readback/recovery, not blind retry" in body
1750+ assert "refresh-state --goal-outcome-update-json" in body
1751+ assert "Local outcomes never replace root continuation, budget or stop criteria." in body
1752+ # Preserve the historical 4,500-character failure as a characterized
1753+ # input; the allowance changes, not the complete emitted instructions.
1754+ assert budget ["budget_char_count" ] > 4500
1755+ assert budget ["max_chars" ] == 4900
1756+ assert budget ["within_budget" ] is within_budget
1757+
1758+
17211759def test_brief_budget_retains_full_commands_on_real_long_paths () -> None :
17221760 # A reproducible 128-character absolute root; directory depth can still
17231761 # change JSON escaping cost. Keep full routes and this workload;
0 commit comments