Skip to content

Commit fdd20d2

Browse files
Trecekclaude
andcommitted
fix(review): scope dispatch_feasible checks to function-level AST
File-level substring checks would pass even if the target function lacked the gate. Use AST walking scoped to get_recipe and load_recipe. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f23cdc7 commit fdd20d2

1 file changed

Lines changed: 28 additions & 8 deletions

File tree

tests/arch/test_capability_admission_control.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,40 @@ def test_get_recipe_gates_on_dispatch_feasible() -> None:
6868
"""get_recipe resource must check dispatch_feasible."""
6969
kitchen_path = SRC_ROOT / "server" / "tools" / "tools_kitchen.py"
7070
src = kitchen_path.read_text(encoding="utf-8")
71-
assert "dispatch_feasible" in src, (
72-
"get_recipe resource must reference 'dispatch_feasible' to gate "
73-
"capability-DOA recipe serving."
74-
)
71+
tree = ast.parse(src)
72+
for node in ast.walk(tree):
73+
if isinstance(node, ast.FunctionDef) and node.name == "get_recipe":
74+
found = False
75+
for child in ast.walk(node):
76+
if isinstance(child, ast.Constant) and child.value == "dispatch_feasible":
77+
found = True
78+
break
79+
assert found, (
80+
"get_recipe resource must reference 'dispatch_feasible' to gate "
81+
"capability-DOA recipe serving."
82+
)
83+
return
84+
pytest.fail("get_recipe function not found in tools_kitchen.py")
7585

7686

7787
def test_load_recipe_gates_on_dispatch_feasible() -> None:
7888
"""load_recipe tool must check dispatch_feasible."""
7989
recipe_path = SRC_ROOT / "server" / "tools" / "tools_recipe.py"
8090
src = recipe_path.read_text(encoding="utf-8")
81-
assert "dispatch_feasible" in src, (
82-
"load_recipe tool must reference 'dispatch_feasible' to surface "
83-
"capability-DOA signal to calling orchestrators."
84-
)
91+
tree = ast.parse(src)
92+
for node in ast.walk(tree):
93+
if isinstance(node, ast.AsyncFunctionDef) and node.name == "load_recipe":
94+
found = False
95+
for child in ast.walk(node):
96+
if isinstance(child, ast.Constant) and child.value == "dispatch_feasible":
97+
found = True
98+
break
99+
assert found, (
100+
"load_recipe tool must reference 'dispatch_feasible' to surface "
101+
"capability-DOA signal to calling orchestrators."
102+
)
103+
return
104+
pytest.fail("load_recipe function not found in tools_recipe.py")
85105

86106

87107
def test_capability_gate_callables_have_matching_ingredient() -> None:

0 commit comments

Comments
 (0)