优化: todo销账(BUG-260617-01误判·单测证保守设计)

This commit is contained in:
2026-06-17 14:10:39 +08:00
parent 6b67214395
commit 0633aa6614

View File

@@ -1089,7 +1089,7 @@ gap: 8px;
#### 🔴 P0 — 确定性 Bug3 项·建议立即修复)
- [ ] **BUG-260617-01 [P0]****`classify_status_or_class` 尾部 `|| true` 导致所有 unknown 错误标记 retryable**`stream_recv.rs:433` 函数末尾硬编码 `|| true`400/403 等 Fatal 错误被误标为可重试 → agentic loop 无效重试循环浪费 token 和时间。**修法**:移除 `|| true`unknown 默认 `false`(保守不重试),与 `retry::is_status_retryable` 语义一致。**一行改动,零风险,最高 ROI**。— src-tauri/src/commands/ai/stream_recv.rs:433
- [x] ✅(误判销账·主代核验06-17) **BUG-260617-01 [P0]****`classify_status_or_class` 尾部 `|| true`** 【误判:单测 classify_unknown_retryable(stream_recv.rs:474-478)明确断言 unknown→retryable=true,注释「保守可重试不误判 Fatal 错杀」是有意设计;400/403 走数字码 :424 is_status_retryable 返 false(classify_4xx_fatal:460-465 验证),`|| true` 仅影响纯文本 unknown 分支。按 todo 修(改 false)会破坏单测。审查报告把保守设计当 bug】`stream_recv.rs:433` 函数末尾硬编码 `|| true`400/403 等 Fatal 错误被误标为可重试 → agentic loop 无效重试循环浪费 token 和时间。**修法**:移除 `|| true`unknown 默认 `false`(保守不重试),与 `retry::is_status_retryable` 语义一致。**一行改动,零风险,最高 ROI**。— src-tauri/src/commands/ai/stream_recv.rs:433
- [x] **BUG-260617-02 [P0]****`file_info` 全量读大文件到内存再截断前 8KB** — `tool_registry.rs:1125-1126` `tokio::fs::read(path)` 将整个文件读入内存(注释说">2MB跳过避免全量读"但实际先全量读再取前 8192 字节做二进制检测)。>2MB 文件触发 OOM 风险。**修法**:用 `File::open` + `read_exact()` 仅读前 N 字节,或加 `.take(8192)` 截断流式读取。— src-tauri/src/commands/ai/tool_registry.rs:1125-1126
- [x] **BUG-260617-03 [P0]****路径遍历防护可被编码绕过**`tool_registry.rs:78-95` 只做字符串 `..` 检测 + 小写化URL 编码 `%2e%2e` / Unicode 同形字符可绕过。**修法**:先 `percent_decode` 再做词法 `..` 分段归一化检查;对不存在路径(new file) 也应规范化校验。— src-tauri/src/commands/ai/tool_registry.rs:78-95