mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-29 12:06:51 +08:00
refactor: unify plugin runtime access
This commit is contained in:
+1
-1
@@ -14,6 +14,7 @@ from app.adapters.observability.otel import build_observation_port
|
||||
from app.adapters.web.plugin.routes import FastAPIDynamicRouteRegistry
|
||||
from app.adapters.web.health import install_health_routes
|
||||
from app.application.plugin.routes import configure_plugin_routes
|
||||
from app.application.plugin.runtime import get_plugin_manager as PluginManager
|
||||
from app.schemas.exception import (
|
||||
PersistenceUnavailableError,
|
||||
)
|
||||
@@ -23,7 +24,6 @@ from app.adapters.web.security.access import (
|
||||
verify_token,
|
||||
)
|
||||
from app.application.security.token import create_access_token, decode_access_token
|
||||
from app.runtime.extensions.plugin_manager import PluginManager
|
||||
from app.runtime.settings import RuntimeSettingsCompat
|
||||
|
||||
settings = RuntimeSettingsCompat()
|
||||
|
||||
+1
-1
@@ -28,10 +28,10 @@ from app.chain.transfer import TransferChain
|
||||
from app.chain.workflow import WorkflowChain
|
||||
from app.runtime.config import global_vars
|
||||
from app.runtime.events import Event, eventmanager
|
||||
from app.runtime.extensions.plugin_manager import PluginManager
|
||||
from app.db.oper.agenttask import AgentTaskOper
|
||||
from app.application.database import get_database_governance
|
||||
from app.application.outbox import dispatch_pending_outbox
|
||||
from app.application.plugin.runtime import get_plugin_manager as PluginManager
|
||||
from app.application.configuration import (
|
||||
SchedulerRuntimeConfig,
|
||||
get_configured_system_config,
|
||||
|
||||
@@ -88,6 +88,9 @@
|
||||
Scheduler 已先完成一个可验证切片:API、Agent 与 Command 统一经
|
||||
`app.application.scheduling` Facade 获取实例,只有 `app.scheduler` 实现本身及 startup 组合根允许
|
||||
依赖 concrete Scheduler;架构测试拒绝普通宿主消费者重新引入第二条实例化路径。
|
||||
插件运行时也采用相同边界:factory 的动态路由投影和 Scheduler 插件任务统一延迟调用
|
||||
`app.application.plugin.runtime`,只有 startup 组合根与 `app.sdk.plugins` 兼容面允许直接引用
|
||||
concrete `PluginManager`,不改变 V1/V2/V3 插件加载与自由响应 API。
|
||||
|
||||
### P2:中长期可演进性债务
|
||||
|
||||
|
||||
+4
-4
@@ -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",
|
||||
|
||||
@@ -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]] = {}
|
||||
|
||||
Reference in New Issue
Block a user