refactor: unify host agent runtime access

This commit is contained in:
jxxghp
2026-08-24 06:42:07 +08:00
parent 46c5eec54e
commit 8e669d415e
11 changed files with 55 additions and 23 deletions
+21
View File
@@ -1156,6 +1156,27 @@ def test_agent_application_facade_does_not_import_agent_implementation():
} == set()
def test_host_consumers_get_agent_manager_through_application_facade():
"""宿主消费者不得绕过 Application 门面直接定位 Agent manager。"""
forbidden = {"get_agent_manager", "get_running_agent_manager"}
violations: dict[str, set[str]] = {}
for module_name, path in _discover_modules().items():
if module_name.startswith(("app.agent", "app.startup")):
continue
tree = ast.parse(path.read_text(encoding="utf-8"), filename=str(path))
imported = {
alias.name
for node in ast.walk(tree)
if isinstance(node, ast.ImportFrom)
and node.module == "app.agent.runtime_loader"
for alias in node.names
if alias.name in forbidden
}
if imported:
violations[module_name] = imported
assert violations == {}
def test_agent_tools_do_not_import_entrypoint_internals():
"""Agent 工具不得穿透导入 HTTP 端点、调度器与命令注册表内部实现。