-
Notifications
You must be signed in to change notification settings - Fork 1
claude-code-chat-browser: Tool dispatch coordination - single authoritative KNOWN_TOOL_TYPES registry #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9104d31
refactor: single KNOWN_TOOL_TYPES registry with sync CI test
clean6378-max-it 44d7c6b
fix: address PR review feedback on tool dispatch sync
clean6378-max-it 69bdded
fix(md_exporter): distinguish known vs unknown tool fallback labels
clean6378-max-it d0e6f39
fix: tighten tool dispatch sync test per review feedback
clean6378-max-it File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| """Contract test: ``KNOWN_TOOL_TYPES`` must match all four dispatch sites. | ||
|
|
||
| Sites: | ||
| - ``utils/tool_dispatch.py`` — ``KNOWN_TOOL_TYPES`` / ``FILE_ACTIVITY_TOOL_TYPES`` | ||
| - ``utils/md_exporter.py`` — ``MD_EXPORTER_TOOL_TYPES`` | ||
| - ``static/js/render/registry.js`` — ``TOOL_USE_RENDERERS`` keys | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import re | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| from utils.md_exporter import MD_EXPORTER_TOOL_TYPES | ||
| from utils.tool_dispatch import FILE_ACTIVITY_TOOL_TYPES, KNOWN_TOOL_TYPES | ||
|
|
||
| _REPO_ROOT = Path(__file__).resolve().parents[1] | ||
| _FRONTEND_REGISTRY = _REPO_ROOT / "static" / "js" / "render" / "registry.js" | ||
|
|
||
|
|
||
| def _parse_frontend_tool_use_renderers(path: Path) -> frozenset[str]: | ||
| text = path.read_text(encoding="utf-8") | ||
| match = re.search( | ||
| r"export const TOOL_USE_RENDERERS = \{([^}]+)\}", | ||
|
clean6378-max-it marked this conversation as resolved.
Outdated
|
||
| text, | ||
| re.DOTALL, | ||
| ) | ||
| if not match: | ||
| msg = f"Could not find TOOL_USE_RENDERERS in {path}" | ||
| raise ValueError(msg) | ||
| body = match.group(1) | ||
| keys = re.findall(r"^\s*(\w+)\s*:", body, re.MULTILINE) | ||
| return frozenset(keys) | ||
|
|
||
|
|
||
| def _format_set_diff(expected: frozenset[str], actual: frozenset[str], site: str) -> str: | ||
| missing = sorted(expected - actual) | ||
| extra = sorted(actual - expected) | ||
| parts: list[str] = [] | ||
| if missing: | ||
| parts.append(f"missing tool type(s) {missing!r} in {site}") | ||
| if extra: | ||
| parts.append(f"unexpected tool type(s) {extra!r} in {site}") | ||
| return "; ".join(parts) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("site", "actual"), | ||
| [ | ||
| ("utils/tool_dispatch.py (FILE_ACTIVITY_TOOL_TYPES)", FILE_ACTIVITY_TOOL_TYPES), | ||
| ("utils/md_exporter.py (MD_EXPORTER_TOOL_TYPES)", MD_EXPORTER_TOOL_TYPES), | ||
| ], | ||
| ) | ||
| def test_tool_type_sets_match_known_registry(site: str, actual: frozenset[str]) -> None: | ||
| if actual != KNOWN_TOOL_TYPES: | ||
| pytest.fail(_format_set_diff(KNOWN_TOOL_TYPES, actual, site)) | ||
|
|
||
|
|
||
| def test_frontend_registry_matches_known_tool_types() -> None: | ||
| site = "static/js/render/registry.js (TOOL_USE_RENDERERS)" | ||
| try: | ||
| actual = _parse_frontend_tool_use_renderers(_FRONTEND_REGISTRY) | ||
| except ValueError as exc: | ||
| pytest.fail(f"{site}: {exc}") | ||
| if actual != KNOWN_TOOL_TYPES: | ||
| pytest.fail(_format_set_diff(KNOWN_TOOL_TYPES, actual, site)) | ||
|
|
||
|
|
||
| def test_known_tool_types_nonempty() -> None: | ||
| assert KNOWN_TOOL_TYPES | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.