Files
DevFlow/docs/walkthrough-2026-08/04-df-ideas-execute-mcp-walkthrough.md
T
lxy ef77120912 文档: 全库走查报告(walkthrough-2026-08,summary + 4 分方向)
4 workflow/35 维度走查产出:P0(2 已修)+ P1(4 修 + 2 专项登记)+ P2/P3 清单 +
推翻假设(AiChat 798 非 God / human_node 测试 76% 无债)。每发现 file:line 源码佐证。
2026-08-02 03:19:25 +08:00

62 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# df-ideas + df-execute + df-mcp 代码走查报告
> 走查日期: 2026-08-02
> 范围: df-ideas(7 文件, 63KB) + df-execute(2 文件, 34KB) + df-mcp(3 文件, 52KB)
---
## 问题汇总
| # | 等级 | 文件 | 类型 | 简述 |
|---|---|---|---|---|
| 1 | 🟡 P1 | adversarial.rs(29KB) | smell | 正反方论点模板化,evidence/reasoning 启发式拼接痕迹重,LLM 路径未充分验证 |
| 2 | 🟡 P1 | adversarial.rs | risk | LLM 评估 evaluate_with_llm 的 final_score 与 analyst.final_assessment 自洽性未校验 |
| 3 | 🟡 P1 | env_snapshot.rs | risk | `probe_version``std::process::Command::output()` 无 timeoutWindows Store alias 卡死 |
| 4 | 🟡 P1 | shell.rs | bug | `build_command``ShellType::default()` 时依赖 `PWSH_CACHE`,但 `probe_pwsh()` 异步填充,首次 `execute()` 时可能读到未初始化值 |
| 5 | 🟡 P1 | df-mcp/tools.rs | risk | `update_project`/`update_task` 未校验实体类型(同 B-260801-01 缺陷),跨实体误操作 |
| 6 | 🟡 P1 | df-mcp/server.rs | risk | dispatch 阶段 High 风险工具先拒绝,但 handler 内二次防御是纯文本返回,不保证线程安全 |
| 7 | 🟢 P2 | adversarial_helpers.rs | smell | 366 行纯函数文件,可进一步拆注重录/解析/枚举映射 |
| 8 | 🟢 P2 | scoring.rs | smell | 关键词正向/负向信号权重硬编码(+0.5/-0.6),不接 LLM 前无法调整 |
| 9 | 🟢 P2 | scoring_keywords.rs | smell | 24 行关键词硬编码,维护成本高 |
| 10 | 🟢 P2 | shell.rs | smell | `execute_streaming``on_output` 回调在 `select!` 中调用,`FnMut` 不可重入 |
| 11 | 🟢 P2 | env_snapshot.rs | smell | OS 版本探测依赖 `reg.exe`,无 `winreg` crate 跨平台路径 |
| 12 | 🟢 P2 | df-mcp/server.rs | smell | `Box::leak` 静态化 ToolSpec 可接受但违背进程生命周期假设 |
---
## 🟡 P1 问题详述
### #1 adversarial.rs 启发式论点模板化
**文件**: `adversarial.rs:180-280`
**影响**: 启发式评估的正反方论点高度模板化,evidence 和 reasoning 拼接痕迹重,区分度有限。
### #3 env_snapshot.rs Windows Store alias 卡死
**文件**: `env_snapshot.rs:95-100`
**根因**: 已修复(5s timeout + spawn_blocking),但修复本身复杂(超时后线程仍在跑)。
### #4 shell.rs pwsh 首次探测时序
**文件**: `shell.rs:75-80`
**风险**: `execute()` 中先 `probe_pwsh().await``build_command``ShellType::default()` 读缓存,但两行之间若 probe 未完成,default 读到错误值。
**现状**: 已修复(单源 PWSH_CACHE),但代码注释说明此依赖关系,初次阅读易漏。
### #5 df-mcp 未校验实体类型
**文件**: `df-mcp/tools.rs:240-280`
**风险**: MCP server 的 `update_task`/`update_project` 复用 df-storage 的 `update_full`,不校验 ID 对应的实体类型,与 B-260801-01 同根因。
---
## 正面评价
1. **对抗评估三路径**: LLM → HeuristicFallback → Heuristic,降级链路完整
2. **parse_llm_eval 容错**: 剥离 ```json 围栏 + 正则兜底 + 枚举校验 + 数值 clamp
3. **否定前缀处理**: `不复用` 不计入正向命中,设计精巧
4. **shell 执行器**: `execute_streaming` 流式输出 + mpsc 解耦 + kill_on_drop + CREATE_NO_WINDOW
5. **MCP 安全降级**: High 风险默认拒绝 + read-only 模式 + dispatch 层二次防御
6. **MCP 协议纯手写**: 不引入 serde_json 之外的依赖,零 JSON-RPC 库依赖
7. **env_snapshot 超时兜底**: 已修复 Windows Store alias 卡死问题
8. **测试覆盖**: adversarial.rs 有 8+ 测试,scoring.rs 有 10+ 测试,shell.rs 有探测缓存测试