refactor: unify user chain data port access

This commit is contained in:
jxxghp
2026-08-24 04:16:09 +08:00
parent 48e796cab7
commit a13c96d30b
6 changed files with 54 additions and 15 deletions
+24
View File
@@ -428,6 +428,30 @@ def test_workflow_domain_uses_explicit_chain_data_port_getters():
assert violations == []
def test_user_and_messaging_chains_use_explicit_data_port_getters():
"""用户、交互和消息链不得把迁移期 UserPortProxy 伪装成 UserOper。"""
paths = [
APP_ROOT / "chain" / "user.py",
APP_ROOT / "chain" / "interaction.py",
APP_ROOT / "chain" / "_messaging.py",
]
violations: list[str] = []
for path in paths:
tree = ast.parse(path.read_text(encoding="utf-8-sig"), filename=str(path))
for node in ast.walk(tree):
if not isinstance(node, ast.ImportFrom):
continue
if node.module != "app.application.chain.data":
continue
for alias in node.names:
if alias.name == "UserPortProxy":
violations.append(
f"{path.relative_to(PROJECT_ROOT).as_posix()}:{node.lineno}"
)
assert violations == []
def test_plugin_components_do_not_reexport_legacy_abi_names():
"""新插件组件只提供 canonical 能力,不得复制旧 Helper、Manager 或 Oper 导出。"""
violations: list[str] = []