Answer stability round 1: 0 🔴, 1 🟡 (0 misread); count each --tools against a --strict-mcp-config
This commit is contained in:
@@ -10,14 +10,14 @@ from repo_checks import ROOT
|
||||
|
||||
|
||||
def denies_tools_without_strict_mcp(source: str) -> bool:
|
||||
"""Whether the source passes "--tools" but never "--strict-mcp-config", so the MCP servers of the user's config would load beside the denied tools."""
|
||||
strings = {node.value for node in ast.walk(ast.parse(source)) if isinstance(node, ast.Constant) and isinstance(node.value, str)}
|
||||
return "--tools" in strings and "--strict-mcp-config" not in strings
|
||||
"""Whether the source passes "--tools" more often than "--strict-mcp-config", so a call that denies tools would load the MCP servers of the user's or the project's config."""
|
||||
strings = [node.value for node in ast.walk(ast.parse(source)) if isinstance(node, ast.Constant) and isinstance(node.value, str)]
|
||||
return strings.count("--tools") > strings.count("--strict-mcp-config")
|
||||
|
||||
|
||||
class HeadlessMcp(unittest.TestCase):
|
||||
def test_each_file_that_passes_tools_passes_strict_mcp_config_too(self):
|
||||
# A file not yet staged counts too, so a new call is checked before its first commit.
|
||||
# Untracked files count too, so a new call is checked before its first commit.
|
||||
listed = subprocess.run(["git", "ls-files", "--cached", "--others", "--exclude-standard", "*.py"], capture_output=True, check=True, cwd=ROOT, text=True).stdout.split()
|
||||
self.assertIn("reviewer-merge-trials/analyze.py", listed)
|
||||
self.assertIn("bin/agent_cycle/judge.py", listed)
|
||||
@@ -30,6 +30,10 @@ class HeadlessMcp(unittest.TestCase):
|
||||
self.assertFalse(denies_tools_without_strict_mcp('args = ["--tools", "", "--strict-mcp-config"]'))
|
||||
self.assertFalse(denies_tools_without_strict_mcp('args = ["-p"]'))
|
||||
|
||||
def test_a_second_call_without_the_flag_is_found_in_a_file_where_another_call_has_it(self):
|
||||
self.assertTrue(denies_tools_without_strict_mcp('a = ["--tools", "", "--strict-mcp-config"]\nb = ["--tools", ""]'))
|
||||
self.assertFalse(denies_tools_without_strict_mcp('a = ["--tools", "", "--strict-mcp-config"]\nb = ["--tools", "", "--strict-mcp-config"]'))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user