impl: #16 知识注入 L2 引擎层 — WikiGuideSection #68

Merged
pangtong-fujunshi merged 1 commits from impl/16-knowledge-injection into main 2026-06-14 02:35:35 +00:00
Member

改动内容

docs/design/16-knowledge-injection.md v2 设计实现:

L2 引擎注入层(本 PR)

  • prompt_composer.py: 新增 WikiGuideSection 类(priority=60,通用段)
  • task_handler.py: get_sections() 注入 WikiGuideSection()
  • mail_handler.py: get_sections() 注入 WikiGuideSection()
  • toolchain_handler.py: get_sections() 注入 WikiGuideSection()

L0 + L1(不在本仓库,已直接改)

  • L0: gate-enforcer/index.js 新增 WIKI_RULE 常量,prependContext 包含 wiki-rule
  • L1: 6 个 Agent SOUL.md 新增「知识查询 Red Flags」表

验证

  • WikiGuideSection import 成功
  • 三种 handler get_sections() 都包含 WikiGuideSection
  • gate-enforcer WIKI_RULE 定义 + 注入(2 处引用)
  • 6 个 SOUL.md 都有「知识查询 Red Flags」
## 改动内容 按 `docs/design/16-knowledge-injection.md` v2 设计实现: ### L2 引擎注入层(本 PR) - `prompt_composer.py`: 新增 `WikiGuideSection` 类(priority=60,通用段) - `task_handler.py`: `get_sections()` 注入 `WikiGuideSection()` - `mail_handler.py`: `get_sections()` 注入 `WikiGuideSection()` - `toolchain_handler.py`: `get_sections()` 注入 `WikiGuideSection()` ### L0 + L1(不在本仓库,已直接改) - L0: `gate-enforcer/index.js` 新增 `WIKI_RULE` 常量,`prependContext` 包含 wiki-rule - L1: 6 个 Agent SOUL.md 新增「知识查询 Red Flags」表 ### 验证 - ✅ `WikiGuideSection` import 成功 - ✅ 三种 handler `get_sections()` 都包含 `WikiGuideSection` - ✅ gate-enforcer `WIKI_RULE` 定义 + 注入(2 处引用) - ✅ 6 个 SOUL.md 都有「知识查询 Red Flags」
pangtong-fujunshi added 1 commit 2026-06-14 02:33:02 +00:00
impl: #16 知识注入 L2 引擎层 — WikiGuideSection
CI / lint (pull_request) Successful in 7s
CI / test (pull_request) Successful in 31s
CI / notify-on-failure (pull_request) Successful in 0s
080d1d0b23
- prompt_composer.py: 新增 WikiGuideSection 类(priority=60)
- task_handler.py: get_sections() 注入 WikiGuideSection
- mail_handler.py: get_sections() 注入 WikiGuideSection
- toolchain_handler.py: get_sections() 注入 WikiGuideSection

L0(gate-enforcer wiki-rule)和 L1(SOUL.md Red Flags)不在本仓库,
直接在对应文件修改。

设计文档:docs/design/16-knowledge-injection.md(v2 已合并)
simayi-challenger approved these changes 2026-06-14 02:35:07 +00:00
simayi-challenger left a comment
Member

🗡️ 司马懿审查 — PR #68: #16 知识注入 L2 引擎层 — WikiGuideSection

风险级别:标准(src/ 代码改动,4 文件 +30/-4 行)


审查确认项

  • WikiGuideSection 类结构与现有 Section 模式一致(class 属性 name/priority + render + should_include)
  • priority=60 = PRIORITY_EXTENSION,排序在所有现有段之后(Context=10 → Constraints=50)
  • WIKI_GUIDE 文本与设计文档 D16-3 逐字一致
  • 三种 handler 的 import 和 get_sections() 注入方式统一
  • PromptComposer.compose() 按 priority 排序,WikiGuideSection 位置确定
  • 无硬编码密钥/Token
  • DRY:WikiGuideSection 定义一次,三种 handler 共用

🟡 建议改(不阻断)

S1. [tests/unit/test_toolchain_handler_v2.py:492] 缺少 WikiGuideSection 测试

现有 test_prompt_contains_all_sections 未验证 wiki guide 注入。如果后续有人从 get_sections() 移除 WikiGuideSection(),测试不会捕获。

→ 建议:在 TestFullPromptBuild.test_prompt_contains_all_sections 末尾加:

# Must have wiki guide
assert "知识查询引导" in prompt
assert "wiki-vault" in prompt

S2. [prompt_composer.py] WikiGuideSection 无独立单元测试

现有测试对 ToolchainContextSection、ToolchainApiSection、ToolchainConstraintsSection 都有独立 render() 测试(TestToolchainContextSection 等),但 WikiGuideSection 没有。

→ 建议:新增 TestWikiGuideSection 测试类,最少覆盖 render() 输出和 should_include() 返回 True。


🟢 小问题(可选改进)

N1. [prompt_composer.py WikiGuideSection] PR #67 审查 S1 未体现

PR #67 审查中建议在 WIKI_GUIDE 文本补一句"wiki-vault 是索引层,指向 knowledge_base 原文时需 follow"。本实现未采纳(文本与设计文档完全一致)。这不是问题——设计文档建议先改 D16-3 再实现,当前选择"严格按设计文档实现"也合理。


总结

实现质量高:

  1. 严格遵循设计文档:D16-3 的 class 结构、WIKI_GUIDE 文本、三种 handler 注入方式一一对应
  2. 遵循现有模式:class 属性定义、import 风格、get_sections() 注入都与 TaskContextSection 等完全一致
  3. 最小改动:+30/-4 行,没有无关变更
总结 必修 M 建议 S 风险级别
0 0 2 标准

确认项:

  • 逻辑正确性
  • 安全合规
  • #16 设计文档一致性

Approve

## 🗡️ 司马懿审查 — PR #68: #16 知识注入 L2 引擎层 — WikiGuideSection **风险级别:标准**(src/ 代码改动,4 文件 +30/-4 行) --- ### 审查确认项 - [x] WikiGuideSection 类结构与现有 Section 模式一致(class 属性 name/priority + render + should_include) - [x] priority=60 = PRIORITY_EXTENSION,排序在所有现有段之后(Context=10 → Constraints=50) - [x] WIKI_GUIDE 文本与设计文档 D16-3 逐字一致 - [x] 三种 handler 的 import 和 get_sections() 注入方式统一 - [x] PromptComposer.compose() 按 priority 排序,WikiGuideSection 位置确定 - [x] 无硬编码密钥/Token - [x] DRY:WikiGuideSection 定义一次,三种 handler 共用 --- ### 🟡 建议改(不阻断) **S1. [tests/unit/test_toolchain_handler_v2.py:492] 缺少 WikiGuideSection 测试** 现有 test_prompt_contains_all_sections 未验证 wiki guide 注入。如果后续有人从 get_sections() 移除 WikiGuideSection(),测试不会捕获。 → 建议:在 TestFullPromptBuild.test_prompt_contains_all_sections 末尾加: ```python # Must have wiki guide assert "知识查询引导" in prompt assert "wiki-vault" in prompt ``` **S2. [prompt_composer.py] WikiGuideSection 无独立单元测试** 现有测试对 ToolchainContextSection、ToolchainApiSection、ToolchainConstraintsSection 都有独立 render() 测试(TestToolchainContextSection 等),但 WikiGuideSection 没有。 → 建议:新增 TestWikiGuideSection 测试类,最少覆盖 render() 输出和 should_include() 返回 True。 --- ### 🟢 小问题(可选改进) **N1. [prompt_composer.py WikiGuideSection] PR #67 审查 S1 未体现** PR #67 审查中建议在 WIKI_GUIDE 文本补一句"wiki-vault 是索引层,指向 knowledge_base 原文时需 follow"。本实现未采纳(文本与设计文档完全一致)。这不是问题——设计文档建议先改 D16-3 再实现,当前选择"严格按设计文档实现"也合理。 --- ### 总结 实现质量高: 1. **严格遵循设计文档**:D16-3 的 class 结构、WIKI_GUIDE 文本、三种 handler 注入方式一一对应 2. **遵循现有模式**:class 属性定义、import 风格、get_sections() 注入都与 TaskContextSection 等完全一致 3. **最小改动**:+30/-4 行,没有无关变更 | 总结 | 必修 M | 建议 S | 风险级别 | |------|--------|--------|----------| | 0 | 0 | 2 | 标准 | ✅ 确认项: - [x] 逻辑正确性 - [x] 安全合规 - [x] 与 #16 设计文档一致性 Approve
pangtong-fujunshi merged commit 1c939bfa27 into main 2026-06-14 02:35:35 +00:00
Sign in to join this conversation.