Commit Graph
128 Commits
Author SHA1 Message Date
lhl becd3e1f57 chore(assets): 参赛提交规范红线修复(ASCII 化 + 相对路径)
按《参赛成果物提交规范·赛道一》§6 红线:
- samples/ 目录改名 sample/(git mv,保留历史)
- 10 个中日文样本文件 + docs 参赛手册 PDF 重命名为 ASCII
  (requirements_*/template_*/rules_*/contestant-handbook.pdf)
- tests/test_zh_template.py 硬编码绝对路径 D:\00_project\Genesis 改为相对路径
- 全局更新 21 个活动文件引用;历史日志/审查文档不改(追加说明记录)
全量 pytest 431 passed / 99.15%
2026-08-26 14:15:52 +08:00
lhl 1925ef7239 feat(writer): 章级管道重试兜底 + 表格 caption 语言检查 + 文档收尾
#1/#2 真实 LLM 随机方差兜底:orchestrator.generate 新增 chapter_attempts(默认 3),
单章 WriterGenerationError 不连坐整次 run,重试耗尽才抛错(不吞错)。新增
tests/test_orchestrator_retry.py(前 N 次失败后恢复 / 耗尽仍抛错)。

#3 表格 caption 语言检查:find_language_violations 现检 table.caption(生成正文需跟随
输出语言),rows/headers 仍照抄源不检;QA 维度经 ChapterArtifact.blocks=(type,text,caption)
同步生效。修复真实 zh 输出中表格说明引用日文源表名绕过强制的问题。

文档收尾:README 新增 --output-language/中文模板用法;design.md §6.2.1 输出语言控制、
§7.2 校验清单 10→11 项;计划验收勾选;.gitignore 加 .opencode/。
全量 pytest 431 passed / 99.15%
2026-08-26 00:49:36 +08:00
lhl 84d3b87da3 docs: 输出语言功能文档收尾(README/design.md/计划/opencode忽略)
- README 新增 --output-language 参数表、中文模板用法、auto 推导规则与中文场景注意
- design.md §6.2.1 新增输出语言控制设计(贯通链路/auto推导/生成期强制/标签本地化);
  §7.2 十项校验清单 → 11 项(新增语言一致性维度)
- 计划文档验收复选框勾选
- .gitignore 加入 .opencode/(AI 工具本地配置不入库)
2026-08-26 00:45:09 +08:00
lhl 3f4d17cf69 fix(writer): auto 模式语言 fallback 改用规则文档,修复日文文档被误判期望 zh
真实 ja 试运行暴露:auto 模式 fallback 误用 impact/data 源数据(含中文元素名
止损风控等 + 汉字标签无假名)→ 把日文文档误判为期望 zh → LLM 正常日文输出被
判违规 → 硬失败。修复:fallback 改用 write_rules/design_rules(RAG 自日文作成
说明书/记入规则检索,含假名可靠判 ja);加回归测试
test_generate_chapter_auto_with_ja_rules_but_chinese_source_data_enforces_ja。
修复后 ja 真实试运行成功(7章);zh 真实试运行成功(7章);425 passed / 99.15%
2026-08-26 00:36:54 +08:00
lhl d01e1b720f feat(writer): 输出语言一致性保障 + 用户可选输出语言
- 步骤0: 新增中文镜像模板 scripts/make_zh_template.py 与 samples/概要设计书模板_中文.docx(7章锚点原样保留)
- 步骤1: config.WriterConfig.output_language→Settings.writer;GenerationContext.output_language + to_vars.language_instruction(zh/ja/auto);writer_agent【语言约束】改引变量;context_builder/orchestrator/run_trial 透传 --output-language
- 步骤A: 新建 src/genesis/writer/language.py(detect_script/resolve_expected_language/find_language_violations);WriterAgent.generate_chapter 按期望语言强制、违规重试、耗尽硬失败;max_retries 默认 1→2
- 步骤B: _format_impact 影响调查标签按 output_language 本地化(zh 新建/变更/删除/警告)
- 步骤C: eval scorer 第 11 维度 language_consistency(不可验证=满分,不拉低总分);ChapterArtifact.expected_language;QAValidator.validate_doc 透传;QALoop.run 透传 output_language
- 测试: test_zh_template/test_language_plumbing/test_writer_language/test_scorer_language/test_language_coverage,并更新 test_phase5_e2e
- 全量 pytest 424 passed / 99.15%(覆盖率门槛 99% 达标)
2026-08-25 23:30:24 +08:00
lhl 9d0d3409c2 docs(log): 修复 _AI_USAGE_LOG.md 表格渲染断裂
- 删除表内 4 处空行与 1 处误写入的工具输出残留行
- L55 摘要内嵌错误码表的管道符转义为 \\|(GFM 表格内反引号不保护 |)
- 拆分被 || 拼接的两条 2026-08-23 记录为独立两行
- 零日志行删除;修复后 116 行均为有效 5 列,单一表格完整渲染
2026-08-24 16:03:09 +08:00
lhl 5091125fbc fix(writer): 无子节章剔除 LLM 自造 heading 块
- writer_agent: prompt【小节约束】明确空结构时不得输出 heading 块
- writer_agent: generate_chapter 程序化强制——template_marker.sub_headings
  为空的章,剔除生成结果中全部 type=heading 的内容块(LLM 遵循度不完美,
  以模板结构为准做确定性兜底)
- 真实试运行验证:自造与章同名 H2 清零、H2 总数 14→6(仅模板定义子节)、
  内容引用不受影响
2026-08-24 13:19:11 +08:00
lhl 0a498e4f7a fix(writer): 无锚点子章归并父章生成 + 注入后裸重复子节去重
- template_mapper: 按 design §6.5 仅 Heading level<=1 起章,H2/H3 归入
  父章 sub_headings(此前每个 heading 独立成章,无 {{section:id}} 锚点的
  6 个子章生成后被静默丢弃)
- models: ChapterSpec.sub_headings 字段;to_vars 暴露 sub_headings 变量
- writer_agent: prompt 新增【小节约束】(有子节时按小节顺序以 level=2
  heading 组织,不得遗漏或新增)
- docx_injector: 注入后删除同章内与已生成标题同名且完全无内容的模板裸
  H2/H3(保守策略:带内容的模板子节保留)
- 真实试运行验证:7 章 / 无静默丢弃告警 / 14 个 H2 无重复
2026-08-24 12:23:35 +08:00
lhl 80ccc324fc fix(writer): 章节级数据注入 + 修复 prompt 从未渲染的关键缺陷
- models: CHAPTER_SHEET_TYPES/CHAPTER_IMPACT_ELEMENT 章节→数据映射(design §6.8 ①)
- models: _format_chapter_data 按章定向渲染 ExcelTable 为 Markdown;GENERIC 自由記述作通用背景
- models: _format_impact 支持按 ElementType 过滤(章节级影响上下文)
- writer_agent: {{source}}(全量repr) → {{data}}(章节数据);新增【主题约束】
- writer_agent: 关键修复——真实 PromptRegistry.get 返回模板字符串,
  引擎对 str 不做变量渲染,LLM 实际收到的是 {{占位符}} 原文;
  _resolve_prompt 统一包装为 Prompt 对象保证渲染
- 真实试运行验证:13 章主题全部正确、引用影响调查数据、语言漂移消除
2026-08-24 11:50:59 +08:00
lhl 6372bb17b9 feat(run): 试运行脚本 + 运行说明(真实 LLM 默认 / --fake 离线)
- scripts/run_trial.py:库级端到端驱动(argparse 默认指向 samples/ 股票追加改修+sunOnly+真实模板)
  - --fake 离线 FakeEngine(无 key)/ 默认 build_inference_engine 真实 LLM(读 .env)
  - SourceParser → WriteOrchestrator 门控自动影响调查 → output/output.docx + impact-report.json
  - 暴露 main(argv) 供测试
- tests/test_run_trial.py(fake 模式断言 13 章 + summary 16/5/8/3/50/0 + 文件产出 + docx 注入)
- .gitignore 新增 output/(试运行产物不入库)
- 新建 README.md(安装 / .env 配置 / 离线与真实试运行 / 输出 / 测试)
- 全量 364 passed / 99.28%;fake 试运行 PASS(13 章、summary 与 MVP 基线一致)
2026-08-24 11:05:45 +08:00
lhl 61ac47c7af refactor(impact): CodeParser 多语言就绪——语言适配器注册表(仅 Java,行为不变)
- BaseLanguageParser 抽象基类 + JavaLanguageParser(迁移全部 Java 正则,输出逐字节一致)
- LANGUAGE_PARSERS 注册表 + register_language_parser 扩展点(新增语言=加适配器类并注册,下游零改动)
- CodeParser 分发器:parse(root, language=None) 自动按扩展名探测 / 显式语言覆盖 / 多语言合并(language 逗号连接)/ 无源码或语言不支持抛 CodeParseError
- source_aggregator 新增 existing_system_language 透传;config.py 探测扩展名补 .py/.ts/.go/.cs
- 删除自动探测下不可达死分支;全量 362 passed / 99.28%(基线 351/99.27%)
- 门禁复跑 PASS:summary 与 MVP 基线一致(16/5/8/3/50/0),概要设计书 13 章
2026-08-23 18:49:34 +08:00
lhl 2e11720a2d feat(impact): Impact Agent MVP —— 变更点定位 + 影响调查书(追加改修场景)
- 门控:用户提供 existing_system 路径 → 进入影响调查;未提供 → 原流程不变
- CodeParser 解析 Java(@RestController/@Service/@Entity/@TableName)+ ExistingSystemExplorer 组装
- ImpactAgent 变更点定位(变更区分×既存対応 确定性比对,无 LLM)→ ImpactReport(JSON 可下载)
- 影响调查结果作为 Writer 生成概要设计书的主上下文({{impact}},无专用影响章)
- source_aggregator 解除 existing_system=None 硬编码
- 既有系统样本 sunOnly/stock-trade-system(无 LICENSE,仅测试输入,保留来源标注)
- 新造股票交易域追加改修样本 要件定義_追加改修_股票.xlsx(对齐 sunOnly 真实类名)
- 全量 351 passed / 99.27% 覆盖;门禁 PASS(16 要素:新规5/変更8/削除3/未受影响50)
2026-08-23 17:59:08 +08:00
lhl da33df92e1 fix(writer): 防静默丢章告警 + 占位符正则宽容化(大小写/全角冒号) 2026-08-23 14:47:14 +08:00
lhl 48a9624723 fix(writer): 正文语言须与章节标题一致(模板日文则输出日文) 2026-08-14 00:12:51 +08:00
lhl 4da5f7087d fix(inference): chat 每次调用新建 httpx client,修复同步门禁 Event loop is closed 2026-08-14 00:09:29 +08:00
lhl 752fd2df6d fix(writer): 透传底层 LLM 错误详情(401 等)便于门禁定位 2026-08-13 23:55:38 +08:00
lhl 24b9511d43 test(writer/qa): 覆盖 engine=None 委托工厂的真实门禁路径 2026-08-13 23:13:58 +08:00
lhl 2cd3ecd0f3 docs: 追加 P5-T10 引擎工厂接线 AI 使用日志 2026-08-13 23:12:28 +08:00
lhl 958e2602cc feat(inference): 接通真实 LLM 引擎工厂(P5-T10 门禁接线)
- 新增 inference/factory.build_inference_engine:读 GENESIS_INFERENCE__* / 裸
  DEEPSEEK_API_KEY·LLM_BASE_URL 环境变量与 .env,构造 HttpLLMClient + InferenceEngine
- orchestrator/qa_loop 的 engine=None 分支改用工厂,真正接通真实 LLM 路径
- 脚本注入校验改为通用(非空段落数 + 残留占位符),适配真实模式
- 补工厂测试(缺密钥/前缀变量/裸变量/默认值/.env 解析),覆盖率 99.04%
2026-08-13 23:11:31 +08:00
lhl e4f533799d chore: cleanup unused imports + design.md Phase5 notes 2026-08-13 11:49:58 +08:00
lhl 2770c76ba0 test(writer): cover async engine path in WriterAgent/orchestrator 2026-08-13 11:49:44 +08:00
lhl e2b4faedbe fix(writer): await async InferenceEngine.chat_structured in WriterAgent 2026-08-13 11:49:34 +08:00
lhl 545b9f4723 docs: backfill Phase 5 AI usage log entries 2026-08-13 11:36:11 +08:00
lhl dd86801dcc chore: remove unused imports in orchestrator/qa_loop 2026-08-13 11:36:09 +08:00
lhl 7368626de6 docs(design): add Phase 5 Writer/QA subsystem section 2026-08-13 11:36:08 +08:00
lhl 64c271a22c test(qa): add headless Phase5 e2e (FakeLLM pipeline) 2026-08-13 11:23:00 +08:00
lhl 86c3abb5fa fix(writer): 注入表格时渲染 caption 段落
表格 Block 的 caption 此前被 DocxInjector 丢弃,导致生成文档缺失表题。
_block_element 现按 [caption, table] 顺序返回元素,并在模板缺少 Caption
样式时回退为普通段落。该修复使 Phase5 headless e2e 的全管线验证得以成立。
2026-08-13 11:22:48 +08:00
lhl 24d3aa3b85 feat(qa): add QALoop (closed loop, regenerate only failed chapters) 2026-08-13 11:12:22 +08:00
lhl b318c9fd41 feat(qa): add QAReport + QAValidator.validate_doc 2026-08-13 11:05:01 +08:00
lhl 48024a40db feat(qa): add QAValidator (validate_chapter + validate_document) 2026-08-13 10:56:33 +08:00
lhl d29cb78167 feat(eval): populate EvalReport.per_chapter + failed_chapters in score() 2026-08-13 10:44:35 +08:00
lhl 08e311b0a1 feat(writer): add WriteOrchestrator.generate (vertical slice, real DocxInjector.inject) 2026-08-13 10:32:35 +08:00
lhl f175203a23 feat(writer): add build_contexts (template+rules -> GenerationContext list) 2026-08-13 10:14:03 +08:00
lhl 1c40262401 feat(writer): add renderer (ChapterContent -> DocxInjector.Block) 2026-08-13 10:08:41 +08:00
lhl 9f53d928ab feat(writer): add WriterAgent with real InferenceEngine API + retries 2026-08-13 09:58:40 +08:00
lhl 6994f234cb feat(writer): add GenerationContext.to_vars + ChapterContent.from_llm (T6 deps) 2026-08-13 09:55:01 +08:00
lhl 0a2dd17b0b feat(writer): add WriterState (cross-chapter regeneration tracking) 2026-08-13 09:46:38 +08:00
lhl d237201407 fix(writer): map_template consumes real ParsedTemplate sections (positional section ids) 2026-08-13 09:38:14 +08:00
lhl c1fbcff088 feat(writer): add template_mapper (ParsedTemplate -> ChapterSpec) 2026-08-13 09:31:28 +08:00
lhl 8db9cbfdf7 fix(services): make RagService protocol sync + fix no-op isinstance assertion 2026-08-13 09:27:16 +08:00
lhl ce64f2536f feat(services): add RagService protocol + CannedRagService stub 2026-08-13 09:20:43 +08:00
lhl 22ba32c34f feat(writer): add WriterGenerationError 2026-08-13 09:11:58 +08:00
lhl 6540698bf6 feat(writer): add Phase5 data models (ContentBlock/ChapterContent/GenerationContext/ChapterSpec) 2026-08-13 09:08:08 +08:00
lhl c7e7c95a19 plan(phase5): 锁定 Writer/QA 设计评审修正与实施计划基线
- spec 据 4 项评审决策落地 14 处修正 + GSTACK REVIEW REPORT
- 实施计划 16 任务 / 3 里程碑(M1 基础件 / M2 垂直切片 / M3 闭环硬化)
- _AI_USAGE_LOG.md 登记评审与计划
2026-08-13 09:06:11 +08:00
lhl dbf8c12881 docs: Phase5 spec 自审固化两处歧义(循环耗尽标记 / note 渲染降级) 2026-08-12 23:32:52 +08:00
lhl 0b16aeab49 docs: Phase 5 Writer/QA 完整实现设计规格(方案A,离线条到端) 2026-08-12 23:32:26 +08:00
lhl 0b704fb07e feat: QA 护栏 + fallback 路由(T15 架构审查整改收官,OV6)
- src/genesis/qa/guardrails.py: resolve_qa_model() 强制 QA 走 fallback 模型(防
  DeepSeek 校验 DeepSeek 自校验盲区);QALoopController(max_rounds=3) 约束
  「QA→Writer修正→重校验」循环边界防无限
- 集成测试验证 QA 调用实际落到 fallback 而非 primary(FakeLLMClient 记录 model)
- design.md §7.4 补 QA 护栏说明(循环边界 + 独立校验模型)
- TDD:257 passed / 100.00% 覆盖,17 项架构审查整改全部完成
2026-08-12 23:24:15 +08:00
lhl a1336f6dd3 docs: Writer 串行约束写回(T10 架构审查整改,I14)
- design.md §6.8.1 新增串行生成约束:理由(章间引用依赖前章 WriterState /
  并行收益低复杂度高 / Token 友好)+ 落地点(编排层严格顺序串行、UI 预估
  总时长与逐章进度、禁止并发多章)
- api-design §4.3 补串行消费说明(对应 §6.8.1)
- web-ui-design 进度 UI 补串行语义(预计=章数×单章 3-5 分)
- 纯文档,无代码变更;全量 248 passed / 100.00% 不回归
2026-08-12 23:11:14 +08:00
lhl 3ae1f5f38f refactor(parsers): 提取 _validate_path helper(T7 架构审查整改,I8 DRY)
- source_aggregator.py 三处重复校验(扩展名白名单 + 存在性)提取为
  _validate_path(path, allowed_exts) -> Path,保留 ValueError/FileNotFoundError
  语义与错误信息,parse 三分支改用 helper
- 外部契约不变:未知扩展名→ValueError、不存在→FileNotFoundError
- 新增 3 用例直接测 helper
- TDD: RED(helper 不存在)→ GREEN(聚焦 13 passed)→ 全量 248 passed / 100.00%(1356 stmts/332 br)
2026-08-12 23:01:58 +08:00
lhl e3c714d5d9 feat(writer): docx 注入原型提前(T17 架构审查整改,OV8)
- T17 (OV8, P1): 新建 src/genesis/writer/ 包
  - docx_injector.py: DocxInjector 用原生 python-docx 实现 §6.6 占位符注入
    - 章节级 {{section:id}} → 内容块 docx 元素序列(heading/paragraph/table)
    - 行内 {{meta}} → 元信息填充
    - 残留检查: 未替换 {{...}} 抛 DocxInjectError
    - 格式精度: 注入 heading 继承模板 Heading 样式,原内容不被破坏
  - 新增 test_docx_injector.py(5 用例)
  - 同步 design.md §6.7 渲染链路 T17 原型说明
- TDD: RED(模块缺失)→ GREEN(聚焦 5 passed)→ 全量 245 passed / 100.00%(1361 stmts/340 br)
2026-08-12 22:47:43 +08:00