refactor: unify plugin runtime access

This commit is contained in:
jxxghp
2026-08-23 23:56:31 +08:00
parent 066757888c
commit 9b0a96083f
5 changed files with 26 additions and 6 deletions
+4 -4
View File
@@ -14,7 +14,7 @@
"workflow_to_db": []
},
"edge_count": 6500,
"edge_sha256": "7afa6e61ca564c1ec0c5981304cdb219afa99eb3318bb1703e8acf363cab9aae",
"edge_sha256": "d143f65c278b6eb1887240583c9ecce7b17a8cf7931a22b4f4cd39f269ac676c",
"edges": [
"app -> app.runtime",
"app -> app.runtime.compat",
@@ -3880,12 +3880,11 @@
"app.factory -> app.application",
"app.factory -> app.application.plugin",
"app.factory -> app.application.plugin.routes",
"app.factory -> app.application.plugin.runtime",
"app.factory -> app.application.security",
"app.factory -> app.application.security.token",
"app.factory -> app.runtime",
"app.factory -> app.runtime.correlation",
"app.factory -> app.runtime.extensions",
"app.factory -> app.runtime.extensions.plugin_manager",
"app.factory -> app.runtime.localization",
"app.factory -> app.runtime.log",
"app.factory -> app.runtime.observability",
@@ -5764,6 +5763,8 @@
"app.scheduler -> app.application.messaging",
"app.scheduler -> app.application.messaging.message",
"app.scheduler -> app.application.outbox",
"app.scheduler -> app.application.plugin",
"app.scheduler -> app.application.plugin.runtime",
"app.scheduler -> app.application.scheduling",
"app.scheduler -> app.application.site",
"app.scheduler -> app.chain",
@@ -5783,7 +5784,6 @@
"app.scheduler -> app.runtime.correlation",
"app.scheduler -> app.runtime.events",
"app.scheduler -> app.runtime.extensions",
"app.scheduler -> app.runtime.extensions.plugin_manager",
"app.scheduler -> app.runtime.extensions.service_config",
"app.scheduler -> app.runtime.gc",
"app.scheduler -> app.runtime.log",
+17
View File
@@ -877,6 +877,23 @@ def test_runtime_consumers_use_scheduler_application_facade():
assert violations == {}
def test_runtime_consumers_use_plugin_application_facade():
"""插件 concrete 管理器只允许组合根和兼容 SDK 直接依赖。"""
allowed = {
"app.sdk.plugins",
"app.startup.initializers.modules",
"app.startup.initializers.plugins",
}
violations = {
module_name: dependencies & {"app.runtime.extensions.plugin_manager"}
for module_name, dependencies in _build_module_graph().items()
if module_name not in allowed
and "app.runtime.extensions.plugin_manager" in dependencies
}
assert violations == {}
def test_api_does_not_import_factory():
"""装配器(factory)只允许 app.main 使用,HTTP 端点不得回引。"""
violations: dict[str, set[str]] = {}