From 891f375715c0f794706826afe3d119812fa8e529 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Fri, 2 Oct 2026 23:12:40 -0400 Subject: [PATCH] test(rulings): the hook/route parity guards pin the rulings params (#4757) CI 7939 went red on test_the_hook_and_the_route_agree_on_every_parameter_name: the Bash hook now sends root and cwd, and the guard pins the exact set. Both guards (tool-rules and prior-art) now also pin seen_ruling_systems, spelled once in scribe_rulings_query, and check the routes read all three. Co-Authored-By: Claude Opus 5.5 --- tests/test_rule_usage_wiring.py | 12 ++++++++++-- tests/test_write_path_trigger.py | 5 ++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/test_rule_usage_wiring.py b/tests/test_rule_usage_wiring.py index 91dde55..a397abe 100644 --- a/tests/test_rule_usage_wiring.py +++ b/tests/test_rule_usage_wiring.py @@ -744,7 +744,9 @@ def test_the_hook_and_the_route_agree_on_every_parameter_name(): handler = route.split("async def pre_tool_rules")[1].split("\n@plugin_bp")[0] sent = set(re.findall(r"[?&]([a-z_]+)=", hook)) - assert sent == {"tool", "command", "exclude_rule_ids"}, sent + # `root` and `cwd` (milestone 444): where the command runs, so the paths it + # names can be made repo-relative for the rulings arm. + assert sent == {"tool", "command", "exclude_rule_ids", "root", "cwd"}, sent # The project-scope key is the shared helper's to choose (#4085): the hook # splices in `scribe_scope_query`'s output, which is `repo=` inside a git @@ -763,6 +765,12 @@ def test_the_hook_and_the_route_agree_on_every_parameter_name(): assert "printf '&held_rule_ids=" in defs, ( "the opened ledger's query key is no longer spelled in the helper" ) + # The rulings ledger, shared with the write-path hook (milestone 444) — + # spelled once in its helper for the same reason. + assert "scribe_rulings_query" in hook, "hook no longer sends the rulings ledger" + assert "printf '&seen_ruling_systems=" in defs, ( + "the rulings ledger's query key is no longer spelled in the helper" + ) # Both scope keys are read by the shared _project_scope() helper, not inline. assert "_project_scope()" in handler @@ -776,7 +784,7 @@ def test_the_hook_and_the_route_agree_on_every_parameter_name(): assert 'request.args.get("held_rule_ids")' in handler, ( "the hook sends held_rule_ids and the route never reads it" ) - for arg in ("tool", "command", "exclude_rule_ids"): + for arg in ("tool", "command", "exclude_rule_ids", "root", "cwd", "seen_ruling_systems"): assert f'request.args.get("{arg}")' in handler, ( f"the hook sends {arg!r} and the route never reads it" ) diff --git a/tests/test_write_path_trigger.py b/tests/test_write_path_trigger.py index 8800f5f..14ce8ab 100644 --- a/tests/test_write_path_trigger.py +++ b/tests/test_write_path_trigger.py @@ -970,7 +970,7 @@ def test_route_reads_every_arg_the_hook_sends(): routes._project_scope ) for arg in ("path", "code", "repo", "project_id", "exclude_ids", - "exclude_sync_ids", "shapes"): + "exclude_sync_ids", "shapes", "seen_ruling_systems"): assert f'request.args.get("{arg}"' in src, f"route ignores {arg}" hook = HOOK.read_text() @@ -991,6 +991,9 @@ def test_route_reads_every_arg_the_hook_sends(): assert "printf '&held_rule_ids=" in defs, ( "the opened ledger's query key is no longer spelled in the helper" ) + # The rulings ledger (milestone 444), shared with the tool-rules hook. + assert "scribe_rulings_query" in hook, "hook no longer sends the rulings ledger" + assert "printf '&seen_ruling_systems=" in defs def test_route_resolves_repo_to_a_project_not_to_a_location_filter():