Skip to content

Commit 644ee24

Browse files
committed
docs: 沉淀 review_changes 评审排查经验笔记(pitfall×2,stable)
- 全轴 prepare 单次调用易挂起:串行 12 次 BM25 检索导致 MCP 通道卡住,应分步收集或并行化 - untracked 新文件不在分析图谱内导致 changed_sources 切片为空,需先 analyze_repo 增量
1 parent 51af4fe commit 644ee24

5 files changed

Lines changed: 100 additions & 3 deletions

‎repowiki/.meta/aggregate_state.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"notes_since_last_consolidation": 7,
3-
"notes_since_last_doctrine": 7,
2+
"notes_since_last_consolidation": 9,
3+
"notes_since_last_doctrine": 9,
44
"last_consolidation_at": "2026-08-24T15:40:33Z",
55
"last_doctrine_at": "2026-08-24T15:52:17Z",
66
"last_hinted_counter": {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
type: pitfall
3+
title: review_changes 全轴 prepare 单次调用易挂起(MCP 通道卡住)
4+
tags:
5+
- lastwritetime
6+
- pitfall
7+
aliases:
8+
- review_changes 卡住
9+
- 全轴 prepare 超时
10+
- MCP 长调用挂起
11+
- 四轴评审 prepare
12+
metadata:
13+
date: 2026-08-25
14+
related_modules:
15+
- mcp
16+
related_components:
17+
- codewiki/mcp/tools/review_changes.py
18+
severity: high
19+
root_cause: review_changes prepare 全轴模式内部串行执行约 12 次 BM25 全库检索,累计分钟级耗时,MCP 通道对长调用无进度反馈导致挂起
20+
status: stable
21+
generated:
22+
by: codewiki/5.4.3
23+
at: 2026-08-25 15:55:07+00:00
24+
stale_after: '2027-02-21'
25+
verified:
26+
- by: human:mambo-wang
27+
at: '2026-08-25T15:55:19Z'
28+
---
29+
30+
## 背景
31+
32+
调用 review_changes 做四轴评审(focus=all)时,MCP 调用界面表现为「卡住」,等待数十秒无返回。
33+
34+
## 现象与排查
35+
36+
- MCP 服务器并未死:后续轻量 query_wiki 调用秒回(宽泛词命中正常)。
37+
- 磁盘上 .codewiki/workspace/review_context.json 的 LastWriteTime 停留在调用前,说明该次全轴 prepare **从未成功写盘**——长调用在 MCP 通道上挂起,未等到返回。
38+
- 改用轻量、分步收集四轴证据后一切正常。
39+
40+
## 根因
41+
42+
prepare 的 focus=all 内部**串行**执行约 12 次 _query_wiki(convention 轴 6 次:5 查询 + overview;module_knowledge 轴最多 5 次),每次都是 BM25 全库检索,累计耗时达分钟级。MCP stdio 通道对长耗时、大返回的调用无进度反馈,容易挂起。
43+
44+
## 正确做法
45+
46+
1. 不依赖单次大调用:改用轻量分步收集证据(单次 query_wiki 秒回)。
47+
2. 诊断技巧:用文件 LastWriteTime 判断工具是否真的执行完成;用宽泛词 query_wiki 验证服务器存活。
48+
3. 工具侧改进方向:将多轴查询并行化(ThreadPoolExecutor)或拆分 focus 多次调用,降低单次调用时长。
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
type: pitfall
3+
title: untracked 新文件不在分析图谱内,review_changes changed_sources 切片为空
4+
tags:
5+
- pitfall
6+
aliases:
7+
- review_changes untracked
8+
- changed_sources 为空
9+
- 新文件不在分析图谱
10+
metadata:
11+
date: 2026-08-25
12+
related_modules:
13+
- mcp
14+
related_components:
15+
- codewiki/mcp/tools/review_changes.py
16+
- codewiki/mcp/tools/analysis.py
17+
severity: medium
18+
root_cause: 新文件未纳入分析图谱(analyze_repo 增量),prepare 无法对其做变更函数切片
19+
status: stable
20+
generated:
21+
by: codewiki/5.4.3
22+
at: 2026-08-25 15:55:10+00:00
23+
stale_after: '2027-02-21'
24+
verified:
25+
- by: human:mambo-wang
26+
at: '2026-08-25T15:55:20Z'
27+
---
28+
29+
## 背景
30+
31+
用 review_changes 评审包含新增文件(untracked)的变更时,上下文包的 file_level_changes 将新文件标注为 "untracked file not in analysis graph",对应 changed_sources annotated 为空,评审目标缺失。
32+
33+
## 现象
34+
35+
- 新增 review_changes.py / review_checklist.py / 测试文件时,prepare 产出的 changed_components 只有已跟踪组件,核心新文件不在评审目标内。
36+
- 曾导致测试失败(changed_sources annotated 为空),analyze_repo 增量更新图谱后恢复。
37+
38+
## 根因
39+
40+
新文件在 analyze_repo 之前未纳入分析图谱,prepare 无法对新文件做变更函数切片。
41+
42+
## 正确做法
43+
44+
1. 对 untracked 新文件,先运行 analyze_repo(incremental)把文件纳入图谱,再执行 review_changes prepare。
45+
2. 工具侧改进方向:prepare 对 untracked 新文件提示先增量分析,或将 untracked 文件全文纳入 changed_sources 而非仅行切片。

‎repowiki/wiki/index.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ aliases:
66
- 知识笔记索引
77
---
88

9-
<!-- 自动生成于 2026-08-25T23:27:05+08:00 | Health Score: 0/100 | 本文件由系统自动维护 -->
9+
<!-- 自动生成于 2026-08-25T23:55:12+08:00 | Health Score: 0/100 | 本文件由系统自动维护 -->
1010

1111
# 项目文档索引
1212

@@ -77,6 +77,8 @@ aliases:
7777

7878
* [doctrine 不会自动注入 Agent 上下文:唯一通道是 query_wiki(mode='overview')](../notes/2026-08-25-doctrine-不会自动注入-agent-上下文唯一通道是-query-wikimodeoverview.md) - architecture (architecture, 2026-08-25)
7979
* [MCP 参数长度受限时蒸馏 submit 应走 distilled_file 文件侧通道(勿内联大 JSON)](../notes/2026-08-25-mcp-参数长度受限时蒸馏-submit-走文件侧通道python-脚本直接调-handle-distill-conve.md) - pitfall (pitfall, 2026-08-25)
80+
* [review_changes 全轴 prepare 单次调用易挂起(MCP 通道卡住)](../notes/2026-08-25-review-changes-全轴-prepare-单次调用易挂起mcp-通道卡住.md) - pitfall (pitfall, 2026-08-25)
81+
* [untracked 新文件不在分析图谱内,review_changes changed_sources 切片为空](../notes/2026-08-25-untracked-新文件不在分析图谱内review-changes-changed-sources-切片为空.md) - pitfall (pitfall, 2026-08-25)
8082
* [知识摄入到自动检索链路:ingest_note 自动写索引、close_session 兜底终态](../notes/2026-08-25-知识摄入到自动检索链路ingest-note-自动写索引close-session-兜底终态.md) - general (general, 2026-08-25)
8183
* [移除 doctrine 备份机制:.backup 冗余且备份文件会污染检索索引](../notes/2026-08-25-移除-doctrine-备份机制backup-冗余且备份文件会污染检索索引.md) - decision (decision, 2026-08-25)
8284
* [聚合/doctrine 阈值等运行参数通过 repowiki/schema.yaml conventions.aggregation 覆盖,不改 py 源码默认值](../notes/2026-08-25-聚合doctrine-阈值等运行参数通过-repowikischemayaml-conventionsaggregati.md) - decision (decision, 2026-08-25)

‎repowiki/wiki/log.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* **ingest_note**: 添加笔记: 知识摄入到自动检索链路:ingest_note 自动写索引、close_session 兜底终态
1212
* **analyze_repo**: 分析仓库 CodeWiki-CN,1561 个组件
1313
* **analyze_repo**: 分析仓库 CodeWiki-CN,1561 个组件
14+
* **ingest_note**: 添加笔记: review_changes 全轴 prepare 单次调用易挂起(MCP 通道卡住)
15+
* **ingest_note**: 添加笔记: untracked 新文件不在分析图谱内,review_changes changed_sources 切片为空
1416

1517
## 2026-08-24
1618
* **lint_wiki**: 检查完成: 0 个问题

0 commit comments

Comments
 (0)