mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 23:17:20 +08:00
refactor: unify host agent runtime access
This commit is contained in:
@@ -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 端点、调度器与命令注册表内部实现。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user