From 734ea4b43c5115d5f9c88485937361a312c61895 Mon Sep 17 00:00:00 2001 From: xiaoan17 Date: Thu, 29 Oct 2026 12:50:19 +0800 Subject: [PATCH] test(turn): keep the missing-Todo Turn a hold under the scoped binding The Turn driver now resolves the settlement identity by scope, so an ordinary request no longer needs a pre-selected Todo: a missing Todo with a valid signature resolves no scoped binding and the plan reports 'blocked' instead of a contract error. That change came with the native Turn settlement binding, and this test still encoded the previous contract, so it failed on main. The test now states the current contract on both sides of the signature: a broken signature stays a contract error, a missing Todo holds the Turn, and neither reaches the Host, writes state or spends quota. The invariants the test was written to protect are asserted in full. No production code, schema, wire or default change. Validation: tests/test_loopx_turn_driver.py 148 passed; loopx canary premerge --from-git-diff green. Signed-off-by: xiaoan17 --- tests/test_loopx_turn_driver.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/test_loopx_turn_driver.py b/tests/test_loopx_turn_driver.py index 21716da259..93cd52b365 100644 --- a/tests/test_loopx_turn_driver.py +++ b/tests/test_loopx_turn_driver.py @@ -1327,9 +1327,17 @@ def test_signed_governance_can_run_while_normal_delivery_remains_withheld(hold): @pytest.mark.parametrize("invalid_signature", [False, True]) -def test_turn_plan_missing_todo_does_not_bypass_contract_errors( +def test_turn_plan_missing_todo_never_becomes_a_host_invocation( invalid_signature: bool, ) -> None: + """A missing Todo holds the Turn; it never spends, writes or invokes a Host. + + The route owner resolves the settlement identity by scope, so an ordinary + request no longer needs a pre-selected Todo. A missing Todo with a valid + signature is therefore a hold: the driver resolves no scoped binding and + reports `blocked`. A broken signature stays a contract error. Neither may + reach the Host, write state or spend quota. + """ envelope = _envelope( effective_action="autonomous_replan_required" if invalid_signature else "normal_run", ) @@ -1340,9 +1348,14 @@ def test_turn_plan_missing_todo_does_not_bypass_contract_errors( envelope, host="generic-cli", execution_mode="isolated-headless", ) - assert payload["ok"] is False - assert payload["route"]["kind"] == "contract_error" + if invalid_signature: + assert payload["ok"] is False + assert payload["route"]["kind"] == "contract_error" + else: + assert payload["ok"] is True + assert payload["route"]["kind"] == "blocked" assert payload["route"]["would_invoke_host"] is False + assert not any(payload["effects"].values()) def test_turn_plan_preserves_safe_bypass_when_user_action_is_visible() -> None: