fix(tools): re-export dropped helpers through the split shim

Address review finding from #4423: the compatibility facade claimed to
preserve every original top-level symbol but omitted three helpers the
old src.tool_implementations exposed. Re-export them and pin them in
the shim protection test:

- _string_arg, _validate_cookbook_ssh_target <- src/tools/cookbook.py
- _mcp_allowed_commands <- src/agent_tools/admin_tools.py (lazily via
  __getattr__, to keep the agent_tools.__init__ <-> facade import acyclic
  after the #3629 admin-tools migration)

All three added to tests/test_tool_implementations_shim.py _EXPECTED so
the test contract now matches its "every original top-level function"
comment.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
yuandonghao
2026-06-24 18:17:20 +08:00
parent ea42e6a6c7
commit cf1f5e3ecf
2 changed files with 7 additions and 5 deletions
+2 -1
View File
@@ -27,7 +27,7 @@ from src.tools.system import ( # noqa: F401
_ADMIN_TOOL_SYMBOLS = ( _ADMIN_TOOL_SYMBOLS = (
"do_manage_endpoints", "do_manage_mcp", "do_manage_webhooks", "do_manage_endpoints", "do_manage_mcp", "do_manage_webhooks",
"do_manage_tokens", "do_manage_settings", "do_manage_tokens", "do_manage_settings",
"_MCP_DENIED_COMMANDS", "_validate_mcp_command", "_MCP_DENIED_COMMANDS", "_validate_mcp_command", "_mcp_allowed_commands",
) )
@@ -51,6 +51,7 @@ from src.tools.cookbook import ( # noqa: F401
_cookbook_register_task, _cookbook_apply_retry_suggestion, _cookbook_register_task, _cookbook_apply_retry_suggestion,
_scan_running_model_processes, _cookbook_kill_session, _scan_running_model_processes, _cookbook_kill_session,
_MODEL_PROCESS_PATTERNS, _MODEL_PROCESS_PATTERNS,
_string_arg, _validate_cookbook_ssh_target,
) )
# Search domain extracted to src/tools/search.py (slice 1, #4082/#4071). # Search domain extracted to src/tools/search.py (slice 1, #4082/#4071).
# Re-imported here so this module stays a working facade. # Re-imported here so this module stays a working facade.
+5 -4
View File
@@ -25,13 +25,14 @@ _EXPECTED = [
"do_serve_model", "do_serve_preset", "do_stop_served_model", "do_serve_model", "do_serve_preset", "do_stop_served_model",
"do_tail_serve_output", "do_trigger_research", "do_vault_get", "do_tail_serve_output", "do_trigger_research", "do_vault_get",
"do_vault_search", "do_vault_unlock", "do_vault_search", "do_vault_unlock",
# 15 module-private helpers (importable by name too) # module-private helpers (importable by name too)
"_cookbook_apply_retry_suggestion", "_cookbook_env_for_host", "_cookbook_apply_retry_suggestion", "_cookbook_env_for_host",
"_cookbook_kill_session", "_cookbook_register_task", "_cookbook_servers", "_cookbook_kill_session", "_cookbook_register_task", "_cookbook_servers",
"_ensure_served_endpoint", "_infer_serve_host", "_infer_serve_port", "_ensure_served_endpoint", "_infer_serve_host", "_infer_serve_port",
"_internal_headers", "_load_vault_config", "_parse_tool_args", "_internal_headers", "_load_vault_config", "_mcp_allowed_commands",
"_resolve_cookbook_host", "_run_bw", "_scan_running_model_processes", "_parse_tool_args", "_resolve_cookbook_host", "_run_bw",
"_skill_dump", "_scan_running_model_processes", "_skill_dump", "_string_arg",
"_validate_cookbook_ssh_target",
] ]