diff --git a/tests/test_rule_usage_wiring.py b/tests/test_rule_usage_wiring.py index 6b466ae..91dde55 100644 --- a/tests/test_rule_usage_wiring.py +++ b/tests/test_rule_usage_wiring.py @@ -908,9 +908,23 @@ def test_neither_rule_arm_logs_its_call_behind_a_results_guard(): # # The property is positional: between the search and the first guard that # can return early, the call row has already been written. + # The arm's BODY, which since #4633 lives in `_tool_rule_hint`; the public + # `build_tool_rule_hint` is a wrapper that adds the via-lesson step and + # searches nothing itself. Located by what it does — the function that + # calls the rule search under the pre_tool_rule source — so the next + # rename moves the guard with it instead of emptying it. fn = next( n for n in ast.walk(ast.parse(pc_src)) - if isinstance(n, ast.AsyncFunctionDef) and n.name == "build_tool_rule_hint" + if isinstance(n, ast.AsyncFunctionDef) + and any( + isinstance(c, ast.Call) and getattr(c.func, "id", None) == "semantic_search_rules" + for c in ast.walk(n) + ) + and any( + isinstance(k, ast.keyword) and k.arg == "source" + and isinstance(k.value, ast.Constant) and k.value.value == "pre_tool_rule" + for k in ast.walk(n) + ) ) search_at = min( n.lineno for n in ast.walk(fn) @@ -929,7 +943,7 @@ def test_neither_rule_arm_logs_its_call_behind_a_results_guard(): and any(isinstance(b, ast.Return) for b in n.body) ] assert bailouts, ( - "no early return found after the search in build_tool_rule_hint — the " + "no early return found after the search in the pre-tool arm — the " "guard has nothing left to protect, which means this test is now " "passing vacuously rather than the arm being correct" )