M0:灵台 Kernel 骨架(事件溯源/命台席位/瀑布总线/插件注册)与神识客户端边界,新增 POST /runs 占位闭环与测试,Alembic 基线合并为单一起点
This commit is contained in:
1 parent
99e55fa0a8
commit
7ef3a15061
23 files changed
+2014
-1399
No files matched your search
@@ -0,0 +1,42 @@
|
||||
"""插件契约与注册表。
|
||||
|
||||
一切能力插件化(docs/architecture/lingtai-runtime.md §4):插件只通过订阅瀑布节点
|
||||
与提供能力参与运行,彼此不直接调用。M0 只需注册表与装配骨架,首个真实插件(司命
|
||||
占位裁决器)随 M5 落地;禁域挂载点在 Kernel,不在插件。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Protocol, runtime_checkable
|
||||
|
||||
from app.runtime.bus import WaterfallBus
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class Plugin(Protocol):
|
||||
"""插件契约:稳定标识 + 版本 + 注册入口。"""
|
||||
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
@property
|
||||
def version(self) -> str: ...
|
||||
|
||||
def register(self, bus: WaterfallBus) -> None: ...
|
||||
|
||||
|
||||
class PluginRegistry:
|
||||
"""按注册序持有插件;同名插件后注册覆盖前注册(Profile 层叠语义)。"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self._plugins: dict[str, Plugin] = {}
|
||||
|
||||
def register(self, plugin: Plugin) -> None:
|
||||
self._plugins[plugin.name] = plugin
|
||||
|
||||
def bootstrap(self, bus: WaterfallBus) -> None:
|
||||
for plugin in list(self._plugins.values()):
|
||||
plugin.register(bus)
|
||||
|
||||
def names(self) -> list[str]:
|
||||
return list(self._plugins)
|
||||
Reference in new issue
Block a user