范围(不含 design-story-foundation、docs/、humanization/README.md 等进行中改动):
1. 新增 harness/ 控制平面
- skill_harness.py 静态审计:32 个运行时 Skill 的 frontmatter/manifest/文档污染,当前 0 问题
- run_selected.py 选择性执行器:manifest 与磁盘一一对账、依赖阻断、
空跑与 skip-only 失败关闭、AST 测试形状门
- manifests/skills.json:32 个 Skill 的合同责任方与协作领域登记
- manifests/test-inventory.json:81 个测试资产登记
- specs/skill-testing.md 与 README.md:测试分层、证据边界与 harness 职责
2. 实现测试从 .claude/skills/*/scripts/ 迁至 tests/skills/<skill>/
- 71 个测试文件迁移并修复项目根与临时目录运行导入
- 数据库触发器测试宽泛异常收窄为 psycopg.errors.RaiseException
- 抽取离线大测试拆出真实 PG smoke(默认阻断,不计入离线通过)
- 抽取 presence 去重边界拆出独立测试:493 + 78 = 571 项检查不变
3. 运行时文档清理
- 13 个 SKILL.md 移除自测/离线验证段落、测试命令与测试文件事实源表述,
只保留运行时合同;业务运行合同、额度、授权与离线模式均保留
4. SoT 同步
- AGENTS.md:新增 Skill 领域索引(7 个合同责任方分组,覆盖 32 个运行时 Skill)
- 领域 07:测试入口改由 harness/manifests/ 登记,SKILL.md 不承载测试命令
- humanization 覆盖矩阵:活动测试路径同步迁移
验证证据: harness 自测 15 项 + runner 自测 13 项通过;静态审计 32 Skill / 0 问题;
73 个非数据库测试通过;8 个集成条目中 6 个 PostgreSQL 项被依赖门明确阻断;
py_compile 与 git diff --check 通过。未连接 PostgreSQL、网络、真实模型或额度。
已知边界: 真正 skill_behavior_eval 仍为 0,尚未验证任何 Skill 自然语言行为;
evaluate-frozen-replay 的 raw 存储边界冲突留待单独治理。
62 lines
2.6 KiB
Python
62 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
|
"""知识确认合同的离线测试,不连接 PostgreSQL。"""
|
|
import pathlib
|
|
import sys
|
|
import unittest
|
|
|
|
|
|
PROJECT_ROOT = pathlib.Path(__file__).resolve().parents[3]
|
|
SCRIPT_DIR = PROJECT_ROOT / ".claude" / "skills" / "decide-candidate" / "scripts"
|
|
sys.path.insert(0, str(SCRIPT_DIR))
|
|
|
|
import confirm_knowledge as confirm # noqa: E402
|
|
|
|
|
|
class ConfirmKnowledgeContractTest(unittest.TestCase):
|
|
def test英文实体卡投影到正式实体字段(self):
|
|
card = confirm.normalize_entity_payload({
|
|
"type": "character", "name": "林深", "brief": "机师",
|
|
"fields": {"身份": "驾驶员"},
|
|
"source": {"workId": 12, "chapter": 1, "chapterId": 17473},
|
|
"evidence": "林深坐在二号观测位。",
|
|
})
|
|
self.assertEqual(card["entity_type"], "character")
|
|
self.assertEqual(card["normalized_name"], "林深")
|
|
self.assertEqual(card["attributes"], {"身份": "驾驶员"})
|
|
self.assertEqual(card["source_ref"]["chapterId"], 17473)
|
|
|
|
def test关系端点从对象名称解析(self):
|
|
relation = confirm.normalize_relation_payload({
|
|
"type": "驾驶", "source": {"name": "林深"},
|
|
"target": {"name": "茧"}, "description": "首次实战驾驶",
|
|
})
|
|
self.assertEqual(relation["source_name"], "林深")
|
|
self.assertEqual(relation["target_name"], "茧")
|
|
self.assertEqual(relation["relation_type"], "驾驶")
|
|
|
|
def test缺失关系端点失败关闭(self):
|
|
with self.assertRaisesRegex(confirm.KnowledgeConfirmationError, "relation.target"):
|
|
confirm.normalize_relation_payload({
|
|
"type": "驾驶", "source": "林深", "description": "x",
|
|
})
|
|
|
|
def test来源回放链只追加去重结构化引用(self):
|
|
old = {"sourceRefs": [{"chapter": 1}], "lastDraftId": 10}
|
|
same = confirm._lineage(old, {"chapter": 1}, 11, "chapter_extract")
|
|
self.assertEqual(same["sourceRefs"], [{"chapter": 1}])
|
|
newer = confirm._lineage(same, {"chapter": 2}, 12, "chapter_extract")
|
|
self.assertEqual(newer["sourceRefs"], [{"chapter": 1}, {"chapter": 2}])
|
|
self.assertEqual(newer["lastDraftId"], 12)
|
|
|
|
def test已确认关系点名重试返回幂等结果(self):
|
|
row = (7, 12, "relation", {}, "confirmed", "chapter_extract", 17473, 0.9,
|
|
"active", "allowed", 2, None, 91)
|
|
result = confirm._confirm_relation_locked(None, row, kb_id=3, decided_by="1")
|
|
self.assertEqual(result, {
|
|
"draft_id": 7, "status": "already_confirmed", "relation_id": 91,
|
|
})
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|