Compare commits

...

5 Commits

6 changed files with 157 additions and 5 deletions

View File

@@ -13,9 +13,9 @@ Focus: Stop `mma_exec.py` from injecting massive full-text dependencies and remo
## Phase 2: Complete MCP Tool Integration & Seal HITL Bypass (Application Core)
Focus: Expose all native MCP tools in the config and GUI, and ensure mutating tools trigger user approval.
- [ ] Task 2.1: Update `manual_slop.toml` and `project_manager.py`'s `default_project()` to include all new tools (e.g., `set_file_slice`, `py_update_definition`, `py_set_signature`) under `[agent.tools]`.
- [ ] Task 2.2: Update `gui_2.py`'s settings/config panels to expose toggles for these new tools.
- [ ] Task 2.3: In `mcp_client.py`, define a `MUTATING_TOOLS` constant set.
- [x] Task 2.1: Update `manual_slop.toml` and `project_manager.py`'s `default_project()` to include all new tools (e.g., `set_file_slice`, `py_update_definition`, `py_set_signature`) under `[agent.tools]`. e4ccb06
- [x] Task 2.2: Update `gui_2.py`'s settings/config panels to expose toggles for these new tools. 4b7338a
- [~] Task 2.3: In `mcp_client.py`, define a `MUTATING_TOOLS` constant set.
- [ ] Task 2.4: In `ai_client.py`'s provider loops (`_send_gemini`, `_send_gemini_cli`, `_send_anthropic`, `_send_deepseek`), update the tool execution logic: if `name in mcp_client.MUTATING_TOOLS`, it MUST trigger a GUI approval mechanism (like `pre_tool_callback`) before dispatching the tool.
## Phase 3: DAG Engine Cascading Blocks (Application Core)

View File

@@ -79,7 +79,15 @@ KIND_COLORS: dict[str, tuple[float, ...]] = {"request": C_REQ, "response": C_RES
HEAVY_KEYS: set[str] = {"message", "text", "script", "output", "content"}
DISC_ROLES: list[str] = ["User", "AI", "Vendor API", "System"]
AGENT_TOOL_NAMES: list[str] = ["run_powershell", "read_file", "list_directory", "search_files", "get_file_summary", "web_search", "fetch_url"]
AGENT_TOOL_NAMES: list[str] = [
"run_powershell", "read_file", "list_directory", "search_files", "get_file_summary",
"web_search", "fetch_url", "py_get_skeleton", "py_get_code_outline", "get_file_slice",
"py_get_definition", "py_get_signature", "py_get_class_summary", "py_get_var_declaration",
"get_git_diff", "py_find_usages", "py_get_imports", "py_check_syntax", "py_get_hierarchy",
"py_get_docstring", "get_tree", "get_ui_performance",
# Mutating tools — disabled by default
"set_file_slice", "py_update_definition", "py_set_signature", "py_set_var_declaration",
]
def truncate_entries(entries: list[dict[str, Any]], max_pairs: int) -> list[dict[str, Any]]:
if max_pairs <= 0:

View File

@@ -43,6 +43,25 @@ search_files = true
get_file_summary = true
web_search = true
fetch_url = true
py_get_skeleton = true
py_get_code_outline = true
get_file_slice = true
py_get_definition = true
py_get_signature = true
py_get_class_summary = true
py_get_var_declaration = true
get_git_diff = true
py_find_usages = true
py_get_imports = true
py_check_syntax = true
py_get_hierarchy = true
py_get_docstring = true
get_tree = true
get_ui_performance = true
set_file_slice = false
py_update_definition = false
py_set_signature = false
py_set_var_declaration = false
[gemini_cli]
binary_path = "C:\\projects\\manual_slop\\.venv\\Scripts\\python.exe C:\\projects\\manual_slop\\tests\\mock_gemini_cli.py"

View File

@@ -40,6 +40,17 @@ import urllib.parse
from html.parser import HTMLParser
import re as _re
# ------------------------------------------------------------------ mutating tools sentinel
# Tools that write or modify files. ai_client checks this set before dispatch
# and routes to pre_tool_callback (GUI approval) if the tool name is present.
MUTATING_TOOLS: frozenset[str] = frozenset({
"set_file_slice",
"py_update_definition",
"py_set_signature",
"py_set_var_declaration",
})
# ------------------------------------------------------------------ state
# Set by configure() before the AI send loop starts.

View File

@@ -102,7 +102,26 @@ def default_project(name: str = "unnamed") -> dict[str, Any]:
"search_files": True,
"get_file_summary": True,
"web_search": True,
"fetch_url": True
"fetch_url": True,
"py_get_skeleton": True,
"py_get_code_outline": True,
"get_file_slice": True,
"py_get_definition": True,
"py_get_signature": True,
"py_get_class_summary": True,
"py_get_var_declaration": True,
"get_git_diff": True,
"py_find_usages": True,
"py_get_imports": True,
"py_check_syntax": True,
"py_get_hierarchy": True,
"py_get_docstring": True,
"get_tree": True,
"get_ui_performance": True,
"set_file_slice": False,
"py_update_definition": False,
"py_set_signature": False,
"py_set_var_declaration": False,
}
},
"discussion": {

View File

@@ -0,0 +1,95 @@
"""
Tests for architecture_boundary_hardening_20260302 — Phase 2.
Tasks 2.1-2.4: MCP tool config exposure + MUTATING_TOOLS + HITL enforcement.
"""
import tomllib
import pytest
from project_manager import default_project
MUTATING_TOOLS = {"set_file_slice", "py_update_definition", "py_set_signature", "py_set_var_declaration"}
ALL_DISPATCH_TOOLS = {
"run_powershell", "read_file", "list_directory", "search_files", "get_file_summary",
"web_search", "fetch_url", "py_get_skeleton", "py_get_code_outline", "get_file_slice",
"py_get_definition", "py_update_definition", "py_get_signature", "py_set_signature",
"py_get_class_summary", "py_get_var_declaration", "py_set_var_declaration", "get_git_diff",
"py_find_usages", "py_get_imports", "py_check_syntax", "py_get_hierarchy",
"py_get_docstring", "get_tree", "get_ui_performance", "set_file_slice",
}
# ---------------------------------------------------------------------------
# Task 2.1: manual_slop.toml and default_project() expose all tools
# ---------------------------------------------------------------------------
def test_toml_exposes_all_dispatch_tools():
"""manual_slop.toml [agent.tools] must list every tool in mcp_client.dispatch()."""
with open("manual_slop.toml", "rb") as f:
config = tomllib.load(f)
toml_tools = set(config["agent"]["tools"].keys())
missing = ALL_DISPATCH_TOOLS - toml_tools
assert not missing, f"Tools missing from manual_slop.toml: {missing}"
def test_toml_mutating_tools_disabled_by_default():
"""Mutating tools must default to false in manual_slop.toml."""
with open("manual_slop.toml", "rb") as f:
config = tomllib.load(f)
tools = config["agent"]["tools"]
for tool in MUTATING_TOOLS:
assert tool in tools, f"{tool} missing from toml"
assert tools[tool] is False, f"Mutating tool '{tool}' should default to false"
def test_default_project_exposes_all_dispatch_tools():
"""default_project() agent.tools must list every tool in mcp_client.dispatch()."""
proj = default_project()
project_tools = set(proj["agent"]["tools"].keys())
missing = ALL_DISPATCH_TOOLS - project_tools
assert not missing, f"Tools missing from default_project(): {missing}"
def test_default_project_mutating_tools_disabled():
"""Mutating tools must default to False in default_project()."""
proj = default_project()
tools = proj["agent"]["tools"]
for tool in MUTATING_TOOLS:
assert tool in tools, f"{tool} missing from default_project"
assert tools[tool] is False, f"Mutating tool '{tool}' should default to False"
# ---------------------------------------------------------------------------
# Task 2.2: AGENT_TOOL_NAMES in gui_2.py exposes all dispatch tools
# ---------------------------------------------------------------------------
def test_gui_agent_tool_names_exposes_all_dispatch_tools():
"""AGENT_TOOL_NAMES in gui_2.py must include every tool in mcp_client.dispatch()."""
from gui_2 import AGENT_TOOL_NAMES
gui_tools = set(AGENT_TOOL_NAMES)
missing = ALL_DISPATCH_TOOLS - gui_tools
assert not missing, f"Tools missing from gui_2.AGENT_TOOL_NAMES: {missing}"
# ---------------------------------------------------------------------------
# Task 2.3: MUTATING_TOOLS constant in mcp_client.py
# ---------------------------------------------------------------------------
def test_mcp_client_has_mutating_tools_constant():
"""mcp_client must expose a MUTATING_TOOLS frozenset."""
import mcp_client
assert hasattr(mcp_client, "MUTATING_TOOLS"), "MUTATING_TOOLS missing from mcp_client"
assert isinstance(mcp_client.MUTATING_TOOLS, frozenset)
def test_mutating_tools_contains_write_tools():
"""MUTATING_TOOLS must include all four write tools."""
import mcp_client
for tool in MUTATING_TOOLS:
assert tool in mcp_client.MUTATING_TOOLS, f"{tool} missing from mcp_client.MUTATING_TOOLS"
def test_mutating_tools_excludes_read_tools():
"""MUTATING_TOOLS must not include read-only tools."""
import mcp_client
read_only = {"read_file", "get_file_slice", "py_get_definition", "py_get_skeleton"}
for tool in read_only:
assert tool not in mcp_client.MUTATING_TOOLS, f"Read-only tool '{tool}' must not be in MUTATING_TOOLS"