Skip to content

Commit 86a965e

Browse files
committed
fix(review): add test for fix-required hook with empty scripts list
The `not h.scripts` guard added in _get_fix_required_hook_matchers treats a fix-required HookDef with scripts=[] as always-unenforced (dispatch blocked). No test covered this guard branch. Add test to verify the behavior explicitly.
1 parent e58f628 commit 86a965e

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

tests/server/test_run_skill_backend_compat.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,49 @@ def test_allows_claude_code_dispatch_even_with_fix_required_hook(
276276
)
277277
assert result is None
278278

279+
def test_refuses_codex_dispatch_when_fix_required_hook_has_empty_scripts(
280+
self, monkeypatch: pytest.MonkeyPatch
281+
) -> None:
282+
import json
283+
from unittest.mock import MagicMock
284+
285+
from autoskillit.core import AGENT_BACKEND_CODEX, CodingAgentBackend
286+
from autoskillit.hook_registry import HookDef
287+
from autoskillit.server.tools import tools_execution
288+
from autoskillit.server.tools.tools_execution import _check_backend_compat
289+
290+
# scripts=[] means the hook has no guard scripts to check coverage against;
291+
# the `not h.scripts` guard treats it as always-unenforced and blocks dispatch.
292+
registry = [
293+
HookDef(
294+
matcher=r"Read|Write",
295+
scripts=[],
296+
codex_status="fix-required",
297+
),
298+
]
299+
monkeypatch.setattr(tools_execution, "HOOK_REGISTRY", registry)
300+
301+
backend = MagicMock(spec=CodingAgentBackend)
302+
backend.name = AGENT_BACKEND_CODEX
303+
backend.capabilities.applicable_guards = frozenset({"any_guard"})
304+
305+
skill_info = MagicMock()
306+
skill_info.backend_requirements = frozenset({AGENT_BACKEND_CODEX})
307+
308+
result = _check_backend_compat(
309+
skill_command="/autoskillit:test",
310+
resolved_command="/autoskillit:test",
311+
effective_order_id="ord-empty",
312+
target_name="test",
313+
skill_info=skill_info,
314+
effective_backend_obj=backend,
315+
skill_resolver=MagicMock(),
316+
)
317+
assert result is not None
318+
parsed = json.loads(result)
319+
assert parsed["subtype"] == "crashed"
320+
assert "Read|Write" in parsed["result"]
321+
279322
def test_allows_codex_dispatch_when_no_fix_required_hooks(
280323
self, monkeypatch: pytest.MonkeyPatch
281324
) -> None:

0 commit comments

Comments
 (0)