一、技能重组(动作-对象命名) - 旧目录 clean/confirm/continuation/db/detect/embed/… 重组为 clean-book-text/decide-candidate/write-next-chapter/access-database/ check-content-consistency/embed-knowledge/…(git 识别为 rename,内容保持) - agents/*.md、AGENTS.md/CLAUDE.md 收编、example_skill 登记表同步新名 二、先审后入创作闭环(本次核心) 正文接受从"机械门一过就写正典"改为"机械门+语义审查双通过+用户批准+单事务原子提交", DB 级兜底,编排层跳步即被硬拒。 - candidate_cas.py + example_candidate_cas(109):持久化 CAS 状态链 - fact_delta.py + example_fact_delta/example_fact_ledger(106):结构化事实增量, 模型只提六型闭集增量+正文证据引文,仅用户批准的增量随正文同事务入账本 - projection_registry.py + example_projection_run(107):投影登记与恢复 - acceptance_state.py:接受前置实时状态重读 - lesson_registry.py + example_lesson(108):经验升格链,禁止自动升格 - DDL 105:example_candidate 增 semantic_status/semantic_report_sha256 - write_canonical.accept:语义兜底+同事务合并增量+登记投影; run_writer_pipeline/persist_writer_run/run_writer_semantic_detector/step2 接入全链 - claude_runtime:兼容新 CLI modelUsage 信息字段 三、审查修复(独立子代理四维审查后) - 事实增量 propose→approve 翻态正道,不撞唯一键 - 冻结配置探针重刷(CLI 2.1.211→2.1.231 漂移),profileSha256/adapterVersion 再登记 - 可视化合同悬空路径/五六空间矛盾、 SoT 旧技能名漂移、行尾空白清理 测试:离线 65 套 + 真实库集成 5 套(CAS/接受故障注入/事实增量/投影/经验升格)+ 回放 79 项全绿。 创作内容(docs/design、生成正文 artifacts)按"框架与创作分开"未入本提交。
113 lines
3.5 KiB
Python
113 lines
3.5 KiB
Python
#!/usr/bin/env python3
|
|
"""前期设计候选校验器的离线测试。"""
|
|
|
|
from pathlib import Path
|
|
import tempfile
|
|
import unittest
|
|
|
|
from validate_candidates import ValidationConfig, validate_candidates, validate_root
|
|
|
|
|
|
def make_candidate(second_heading: str = "二、资源规则", out_of_range: bool = False) -> str:
|
|
first_ids = range(1, 3)
|
|
second_ids = (101, 52) if out_of_range else range(51, 53)
|
|
first = "\n".join(f"- **S{value:03d}|规则:** 这一条有明确条件、代价和剧情用途。" for value in first_ids)
|
|
second = "\n".join(f"- **S{value:03d}|规则:** 这一条有明确条件、代价和剧情用途。" for value in second_ids)
|
|
return f"""# 候选
|
|
|
|
## 目录
|
|
|
|
- 第一章
|
|
- 第二章
|
|
|
|
## 一、故事发动机
|
|
|
|
<!-- S001-S050 -->
|
|
|
|
{first}
|
|
|
|
## {second_heading}
|
|
|
|
<!-- S051-S100 -->
|
|
|
|
{second}
|
|
"""
|
|
|
|
|
|
class CandidateValidatorTest(unittest.TestCase):
|
|
def setUp(self) -> None:
|
|
self.temp_dir = tempfile.TemporaryDirectory()
|
|
self.root = Path(self.temp_dir.name)
|
|
self.config = ValidationConfig(
|
|
min_candidates=2,
|
|
min_settings=4,
|
|
min_section_settings=2,
|
|
max_section_settings=3,
|
|
min_chars=0,
|
|
min_item_chars=10,
|
|
)
|
|
|
|
def tearDown(self) -> None:
|
|
self.temp_dir.cleanup()
|
|
|
|
def write(self, name: str, content: str) -> Path:
|
|
path = self.root / name
|
|
path.write_text(content, encoding="utf-8")
|
|
return path
|
|
|
|
def test_two_same_shape_candidates_pass(self) -> None:
|
|
paths = [self.write("a.md", make_candidate()), self.write("b.md", make_candidate())]
|
|
reports, problems = validate_candidates(paths, self.config)
|
|
self.assertEqual(2, len(reports))
|
|
self.assertEqual([], problems)
|
|
|
|
def test_heading_drift_fails_group(self) -> None:
|
|
paths = [
|
|
self.write("a.md", make_candidate()),
|
|
self.write("b.md", make_candidate(second_heading="二、人物关系")),
|
|
]
|
|
_, problems = validate_candidates(paths, self.config)
|
|
self.assertIn("CANDIDATE_STRUCTURE_MISMATCH", {problem.code for problem in problems})
|
|
|
|
def test_out_of_range_and_order_are_rejected(self) -> None:
|
|
paths = [self.write("a.md", make_candidate()), self.write("b.md", make_candidate(out_of_range=True))]
|
|
_, problems = validate_candidates(paths, self.config)
|
|
codes = {problem.code for problem in problems}
|
|
self.assertIn("SETTING_ID_OUT_OF_RANGE", codes)
|
|
self.assertIn("SETTING_ORDER", codes)
|
|
|
|
def test_root_contract_accepts_clean_items(self) -> None:
|
|
root_doc = self.write(
|
|
"root.md",
|
|
"""# 前期设计
|
|
|
|
## 一、根设定
|
|
|
|
- **作品前提:**主角刚结束高考,随后进入拥有星际机甲的陌生时代并寻找立足之地。
|
|
- **披露要求:**前三章只呈现当前危机和能力征兆,终局答案留到后续阶段逐步揭开。
|
|
|
|
## 二、定盘
|
|
""",
|
|
)
|
|
problems = validate_root(root_doc, self.config)
|
|
self.assertEqual([], problems)
|
|
|
|
def test_root_rejects_process_language(self) -> None:
|
|
root_doc = self.write(
|
|
"root.md",
|
|
"""# 前期设计
|
|
|
|
## 一、根设定
|
|
|
|
- **代理要求:**Claude 子代理分别生成候选文档,再由主会话比较和选择最终方向。
|
|
|
|
## 二、定盘
|
|
""",
|
|
)
|
|
problems = validate_root(root_doc, self.config)
|
|
self.assertIn("ROOT_PROCESS_LEAK", {problem.code for problem in problems})
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|