feat(review): 审查结论改为结构化 JSON,移除二次 LLM 抽取

- checklist.py:系统提示加入结构化输出契约(只输出 {summary, issues[]},
  引用 handle 必须真实存在、不得编造)
- review.py:review_frame 返回 {summary, issues, raw};仅在「不再请求工具」的回合
  解析结论,中间工具回合的 content 永不解析;强制收口那次 chat 不传 tools
- report.py:删除 extract_issues 与 _EXTRACT_SYSTEM(不再需要第二次 LLM 调用);
  新增 format_finding(用 .get,顺带修复缺 frame 键 KeyError);save_report 的
  issues 省略时从 findings 拍平
- __main__.py:主流程改为 确定性检查 → review_frame → build_finding(合并+校验),
  issues 由 flatten_issues 派生

顺带修复既有 gap:summarize 硬下标 KeyError、extract_issues 单行围栏解析失败。
This commit is contained in:
gjm committed 2026-10-14 19:53:41 +08:00
1 parent f6d61f8d07
commit f7fa8f14d9
8 files changed
+224 -140

No files matched your search

+16
View File
@@ -65,6 +65,22 @@ def test_build_system_prompt_tool_hint_toggle():
assert "只读" not in without
def test_build_system_prompt_requires_structured_json_output():
# allow_tools=False 以隔离「工具提示块」里的「只读」字样
prompt = build_system_prompt(DEFAULT_CHECKLIST, allow_tools=False)
assert "JSON" in prompt
assert '"summary"' in prompt
assert '"issues"' in prompt
assert '"severity"' in prompt and '"category"' in prompt and '"handle"' in prompt
# 结构化契约本身不得含「只读」,否则会破坏 allow_tools 开关的判别
assert "只读" not in prompt
def test_build_system_prompt_forbids_fabricated_handle():
prompt = build_system_prompt(DEFAULT_CHECKLIST)
assert "不要编造" in prompt
def test_checklist_summary_mentions_name_and_count():
summary = checklist_summary(DEFAULT_CHECKLIST)
assert DEFAULT_CHECKLIST["name"] in summary