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 @@
|
||||
"""Profile:一次 Run 的插件装配清单与参数包。
|
||||
|
||||
层叠顺序(产品 PRD §9.2 / lingtai-runtime.md §4.2):
|
||||
平台硬边界 → 平台目录 → 用户偏好/BYOK → 人物覆写 → 镜树临时选择。
|
||||
M0 只有平台目录层;后续里程碑逐层接入。Profile 快照写入事件日志,保证可回放。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ProfileLayer:
|
||||
"""层叠中的一层:来源标识 + 参数(后者覆盖前者同键)。"""
|
||||
|
||||
source: str
|
||||
params: dict[str, Any] = field(default_factory=dict)
|
||||
|
||||
|
||||
_PLATFORM_LAYER = ProfileLayer(source="platform", params={"slot": "chat"})
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Profile:
|
||||
"""解析后的最终装配:插件名列表 + 合并参数。"""
|
||||
|
||||
plugins: tuple[str, ...] = ()
|
||||
params: dict[str, Any] = field(default_factory=dict)
|
||||
|
||||
def snapshot(self) -> dict[str, Any]:
|
||||
"""写入 context.projected 事件的快照视图。"""
|
||||
return {"plugins": list(self.plugins), "params": dict(self.params)}
|
||||
|
||||
|
||||
def resolve_profile(layers: list[ProfileLayer] | None = None) -> Profile:
|
||||
"""层叠解析:平台层恒在最底,逐层覆盖参数;M0 无插件装配。"""
|
||||
merged: dict[str, Any] = {}
|
||||
for layer in [_PLATFORM_LAYER, *(layers or [])]:
|
||||
merged.update(layer.params)
|
||||
return Profile(plugins=(), params=merged)
|
||||
Reference in new issue
Block a user