release: v0.20 Codex-ready skill-driven core
This commit is contained in:
@@ -62,6 +62,10 @@ def write_packet(path: Path, task_id: str, claim: str, source_id: str) -> None:
|
||||
"evidence_items": [{"source_id": source_id, "summary": f"{claim} 的证据"}],
|
||||
"counter_evidence": [{"claim": "仍需关注样本量和外推限制", "source_ids": ["src_counter"]}],
|
||||
"source_ids": [source_id, "src_counter"],
|
||||
"sources": [
|
||||
{"id": source_id, "title": "来源", "url": f"https://example.com/{source_id}"},
|
||||
{"id": "src_counter", "title": "反方来源", "url": "https://example.com/counter"},
|
||||
],
|
||||
"source_quality_notes": [f"{source_id} Tier 1"],
|
||||
"open_questions": ["还需要补充中国市场数据"],
|
||||
"raw_quotes_or_notes": ["English note can remain as source material."],
|
||||
@@ -76,6 +80,7 @@ def test_build_chapter_briefs_aggregates_packets_by_chapter(tmp_path: Path) -> N
|
||||
{
|
||||
"task_id": "ch01-clinical",
|
||||
"chapter_ids": ["ch01"],
|
||||
"chapter_title": "临床证据正在重塑需求判断",
|
||||
"topic_axis": "clinical",
|
||||
"questions": ["q"],
|
||||
"search_routes": ["scholar"],
|
||||
@@ -84,6 +89,7 @@ def test_build_chapter_briefs_aggregates_packets_by_chapter(tmp_path: Path) -> N
|
||||
{
|
||||
"task_id": "ch01-market",
|
||||
"chapter_ids": ["ch01"],
|
||||
"chapter_title": "临床证据正在重塑需求判断",
|
||||
"topic_axis": "market",
|
||||
"questions": ["q"],
|
||||
"search_routes": ["news"],
|
||||
@@ -101,6 +107,7 @@ def test_build_chapter_briefs_aggregates_packets_by_chapter(tmp_path: Path) -> N
|
||||
brief = briefs[0]
|
||||
validate_chapter_brief(brief)
|
||||
assert brief["chapter_id"] == "ch01"
|
||||
assert brief["chapter_title"] == "临床证据正在重塑需求判断"
|
||||
assert brief["packet_ids"] == ["ch01-clinical", "ch01-market"]
|
||||
assert "src_001" in brief["source_ids"]
|
||||
assert "src_002" in brief["source_ids"]
|
||||
@@ -118,6 +125,50 @@ def test_build_chapter_briefs_aggregates_packets_by_chapter(tmp_path: Path) -> N
|
||||
assert (project / "phase2/compressed_findings/ch01.json").exists()
|
||||
|
||||
|
||||
def test_build_chapter_briefs_skips_placeholder_packets(tmp_path: Path) -> None:
|
||||
project = tmp_path / "project"
|
||||
cards = [
|
||||
{
|
||||
"task_id": "ch01-good",
|
||||
"chapter_ids": ["ch01"],
|
||||
"chapter_title": "临床证据正在重塑需求判断",
|
||||
"topic_axis": "clinical",
|
||||
"questions": ["q"],
|
||||
"search_routes": ["scholar"],
|
||||
"output_packet": "phase2/packets/ch01-good.json",
|
||||
},
|
||||
{
|
||||
"task_id": "ch01-empty",
|
||||
"chapter_ids": ["ch01"],
|
||||
"chapter_title": "临床证据正在重塑需求判断",
|
||||
"topic_axis": "clinical",
|
||||
"questions": ["q"],
|
||||
"search_routes": ["scholar"],
|
||||
"output_packet": "phase2/packets/ch01-empty.json",
|
||||
},
|
||||
]
|
||||
(project / "phase2").mkdir(parents=True)
|
||||
(project / "phase2/task_cards.json").write_text(json.dumps(cards, ensure_ascii=False), encoding="utf-8")
|
||||
write_packet(project / "phase2/packets/ch01-good.json", "ch01-good", "临床证据支持核心判断", "src_001")
|
||||
empty = {
|
||||
"task_id": "ch01-empty",
|
||||
"claims": [],
|
||||
"evidence_items": [],
|
||||
"counter_evidence": [],
|
||||
"source_ids": [],
|
||||
"source_quality_notes": [],
|
||||
"open_questions": [],
|
||||
"raw_quotes_or_notes": [],
|
||||
}
|
||||
(project / "phase2/packets/ch01-empty.json").write_text(json.dumps(empty, ensure_ascii=False), encoding="utf-8")
|
||||
|
||||
briefs = build_chapter_briefs(project)
|
||||
|
||||
assert len(briefs) == 1
|
||||
warnings = json.loads((project / "phase2/brief_warnings.json").read_text(encoding="utf-8"))
|
||||
assert warnings[0]["task_id"] == "ch01-empty"
|
||||
|
||||
|
||||
def test_chapter_prompt_contains_brief_and_fragmentation_guard() -> None:
|
||||
brief = {
|
||||
"chapter_id": "ch01",
|
||||
@@ -161,6 +212,8 @@ def test_chapter_assembly_worker_writes_markdown(tmp_path: Path) -> None:
|
||||
assert output == tmp_path / "phase2/drafts/ch01.md"
|
||||
assert "结论先行" in output.read_text(encoding="utf-8")
|
||||
assert fake.calls[0]["model"] == role.model
|
||||
assert "章节证据分析师" in fake.calls[0]["system"]
|
||||
assert "中文章节组装 worker" in fake.calls[0]["system"]
|
||||
|
||||
|
||||
def test_validate_chapter_markdown_rejects_unknown_source_ids() -> None:
|
||||
|
||||
Reference in New Issue
Block a user