test(dispatcher): 引擎主链路集成测试(pool 抽接口 + 假替身端到端)

把 Orchestrator.pool 从 *llm.Pool 抽成 LLM 接口(Ready/ChatStream/StreamText/Chat),
*llm.Pool 天然满足、main 不变;从而可注入假模型做端到端测试,不依赖网络/Docker/LLM。

新增 integration_test.go(假 LLM/工具/sink/exec 替身):
- runGraph 分支路由:true/false 边标签精确选路(true 边故意列后)。
- runGraph 工具→agent:工具产出注入 agent 上下文。
- runGraph map fan-out:拆项 → 各章并行撰写 → 多章成稿。
- runGraph 输出护栏:流式 token 中疑似密钥被脱敏。
- handleReport:规划 → 分章撰写 → report_store 存源 → 流含标题/各章 + CompleteStream。

全部 go test -race 通过(修了测试替身 fakeExec 的并发追加竞态;生产 ExecSink 安全)。
至此引擎与报告主链路从"仅手动验证"升级为自动化端到端覆盖。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Blizzard
2026-06-19 10:51:39 +08:00
parent 9b33a62573
commit 8f619c2a62
3 changed files with 249 additions and 3 deletions
+1 -1
View File
@@ -84,7 +84,7 @@
- [x] 后端首批单测(19 纯逻辑用例:引擎/DSL/docx/报告)+ mcp-go 集成测试(Profile 迁移)
- [x] **真实鉴权(JWT)闭环**:后端注册/登录/校验 + RequireAuth 保护路由 + owner=已验证 uid(去掉 header 兜底);前端登录/注册门 + 存 token + Bearer + 401 自动登出 + 顶栏用户/登出。实跑验证(含 CORS Authorization 修复)
- [x] 生产安全硬化:JWT 默认密钥生产 fail-fast · /admin 加 RequireAdminADMIN_USER_IDS 白名单)· CORS 来源可配(CORS_ALLOW_ORIGIN
- [ ] 集成/前端测试(`runGraph` / `handleReport` 需 mock pool/tools/sink前端测试
- [x] 后端集成测试:pool 抽成 LLM 接口,runGraph(分支/工具/map/脱敏)+handleReport 端到端假替身测试(含 -race);🟡 前端测试仍无
---