- src/muse 新版全模块(装配/共享/上下文/任务运行/作品规划/故事世界/正文写作/审校修订/知识方法/作者经验/效果评测/交付连载/资料研究/正式变更/元数据/接入/基础设施/编排)+ 测试树(单元/契约/集成/架构/迁移/端到端/夹具) - 129 项功能全部实现与自动验证(功能覆盖.json/矩阵),含 W31 补齐的规则与代价/节奏安排/伏笔与承诺 - 旧实现按处置清单退出(702 条中 324 删,保护合同与未迁移条目留存有据);web/app.py 旧工作台退役,新工作台为唯一写入口 - 数据库/旧库迁移:真实旧库内容批次迁移链(端点守卫/PG作品正文映射/质量资产缺省投影) - 运行手册 docs/运行手册.md;W30 本机服务阶段一已运行(infra PG 为正式内容权威) - R2 执行证据与私有运行材料在 .agents.local/改造/R2-20260909/(不入库)
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
"""执行底座纯度门:runtime 不得反向依赖 Muse 业务实现。"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import pathlib
|
||
import re
|
||
import unittest
|
||
|
||
ROOT = next(
|
||
parent
|
||
for parent in (pathlib.Path(__file__).resolve().parent, *pathlib.Path(__file__).resolve().parents)
|
||
if (parent / "AGENTS.md").is_file() and (parent / ".git").exists()
|
||
)
|
||
FORBIDDEN_IMPORTS = (
|
||
"agent_trace",
|
||
"muse_role",
|
||
"muse_role_contract",
|
||
"muse_db",
|
||
"psycopg",
|
||
"fixed-opus",
|
||
"role_task",
|
||
"role_policy",
|
||
"run_registry",
|
||
"persist_raw",
|
||
"read_tools",
|
||
)
|
||
|
||
|
||
class RuntimePurityTest(unittest.TestCase):
|
||
def test_runtime_does_not_import_muse_business(self) -> None:
|
||
offenders: list[str] = []
|
||
import_pattern = re.compile(
|
||
r"(?:from|import)\s+(?:" + "|".join(map(re.escape, FORBIDDEN_IMPORTS)) + r")\b"
|
||
)
|
||
muse_pattern = re.compile(r"(?:from|import)\s+muse(?:\.|\s)")
|
||
runtime_root = ROOT / "runtime"
|
||
self.assertTrue(runtime_root.is_dir(), "runtime/ 必须存在")
|
||
for path in runtime_root.rglob("*"):
|
||
if not path.is_file() or "__pycache__" in path.parts:
|
||
continue
|
||
if path.suffix not in {".py", ".ts", ".md"}:
|
||
continue
|
||
text = path.read_text(encoding="utf-8")
|
||
if import_pattern.search(text) or muse_pattern.search(text):
|
||
offenders.append(path.relative_to(ROOT).as_posix())
|
||
self.assertEqual(offenders, [], "runtime 反向依赖 Muse 业务:\n" + "\n".join(offenders))
|
||
|
||
|
||
|
||
if __name__ == "__main__":
|
||
unittest.main()
|