"""core/evolution/ 子包的只读 Protocol 定义。 三个 Protocol 均为只读——core/ 返回结果 dataclass,写入由 app/ 持久化。 SkillStore / PromptStore 为同步(文件读取量小且快),RunLog 为异步 (隔离 SQLite 查询,core/ 不写 SQL)。 """ from __future__ import annotations from typing import Any, Protocol, runtime_checkable @runtime_checkable class SkillStore(Protocol): """版本化技能读取端口。 实现方解析 manifest 指针,core/ 不感知版本号。 """ def read_skill(self, filename: str) -> str: """读取指定 skill 文件的全文内容。 参数: filename: skill 文件名,如 'temporal-reasoning.md'。 返回: 文件全文内容。 """ ... def list_skill_files(self) -> list[str]: """列出当前版本所有 skill 文件名。 返回: 文件名列表。 """ ... @runtime_checkable class PromptStore(Protocol): """版本化提示词读取端口。 覆盖 system.md 和 tool extract/verify 文件。 """ def read_prompt(self, filename: str) -> str: """读取指定 prompt 文件的全文内容。 参数: filename: prompt 文件名,如 'system.md'。 返回: 文件全文内容。 """ ... def list_prompt_files(self) -> list[str]: """列出当前版本所有 prompt 文件名。 返回: 文件名列表。 """ ... @runtime_checkable class RunLog(Protocol): """实验日志查询端口。 隔离 SQLite 实现细节,core/ 不写 SQL。 """ async def get_predictions( self, run_id: str, *, question_ids: list[str] | None = None, ) -> list[dict[str, Any]]: """查询指定 run 的预测记录。 参数: run_id: 运行标识。 question_ids: 可选的题目 ID 过滤列表。 返回: 预测记录字典列表。 """ ... async def get_traces( self, run_id: str, *, question_ids: list[str] | None = None, ) -> list[dict[str, Any]]: """查询指定 run 的推理轨迹。 参数: run_id: 运行标识。 question_ids: 可选的题目 ID 过滤列表。 返回: 轨迹记录字典列表。 """ ...