Skip to content

feat(div-anthropic): /doctor MLX 网关连通 + 模型加载探测 (P4.2 #1+#3) - #92

Merged
dahai80 merged 1 commit into
mainfrom
feat/doctor-mlx-health-probe-p42
Aug 20, 2026
Merged

dahai80 merged 1 commit into
mainfrom
feat/doctor-mlx-health-probe-p42

Conversation

@dahai80

@dahai80 dahai80 commented Aug 20, 2026

Copy link
Copy Markdown
Owner

背景

Closes #91

enhance-0819.md §P4.2 定 7 项 /doctor 本地健康检查。审计 (iter #9/#10):

改动

src/utils/doctorDiagnostic.ts (+62/-0, 纯插入, 匹配原 2-space/single-quote/no-semi 风格):

  • detectMlxHealth() async fn — 复用 model-status.ts 的 fetchMlxStatus (/api/tags, 3s timeout) + fetchMlxPs (/api/ps)
  • Gating: 仅当 shouldAutoUseFusionMlx() (MLX 配置 provider) — cloud-active 跳过, 避免 3s 浪费 + 噪音
  • 两 warning: (1) 不可达 — 含 URL + fusion service start mlx 起服命令; (2) 已连通但无模型 loaded — 含可用模型名截断 (前 3 + …) + fusion model load 命令
  • 在 getDoctorDiagnostic() 内 detectLinuxGlobPatternWarnings 之后 push — runtime health 独立于 config correctness, dev 模式也运行
  • MLX_GATEWAY_URL 复算 model-status.ts:3 env 表达式 (error msg 需 URL, fetchMlxStatus 返回值不含) — 注释标 "keep in sync"

src/__tests__/utils/doctorMlxHealth.test.ts (新, 169 行, 6 单测):

  • cloud-active (FUSION_API_KEY) → [] 不探 (验证 fetch 未调)
  • MLX 不可达 (/api/tags throw) → 1 warning 含 URL + ECONNREFUSED + 起服命令
  • MLX 连通 + 有模型 + loaded=[] → 1 warning "no model loaded" + 可用名 + load 命令
  • MLX 连通 + 0 available + 0 loaded → 1 warning, fix 含 "Download one via the model hub"
  • MLX 连通 + 4 模型 + loaded=[] → available 名截断 3 + …
  • MLX 连通 + loaded=['qwen-coder'] → [] (健康)
  • mock: spyOn(globalThis, 'fetch') route by URL + env 快照/恢复 (shouldAutoUseFusionMlx env-gated)

不改

验证

  • bun run typecheck — 0 errors
  • bun test src/__tests__/utils/doctorMlxHealth.test.ts — 6 pass
  • bun test src/__tests__/ — 122 pass, 0 fail (无回归)
  • bun run build + bun run build:dev:full — pass
  • git diff -w — +62/-0 纯插入, 零 churn
  • biome: 新 test 文件 0 error; prod 文件 2 error 为 main 既有 (outlier 风格组, CI 不扫 src/utils/)

Co-Authored-By: Claude Fable 5 [email protected]

enhance-0819.md §P4.2 定 7 项 /doctor 本地健康检查。审计 (iter #9/#10):
- ✅ #5 CLAUDE.md 裁剪 (已覆盖)
- ✅ #6 配置冲突 (PR #90)
- ⏳ #4 OOM/内存 (跨仓: MLX 无 memory 端点, 仅 POST /api/v1/gc mutating)
- ⏳ #7 一键修复 (远期)
- **真 gap = #1 MLX 网关连通 + #3 模型加载状态** — /doctor 此前完全不探 MLX

落地 detectMlxHealth(): 复用 model-status.ts 的 fetchMlxStatus
(/api/tags) + fetchMlxPs (/api/ps), 3s timeout。Gating: 仅当
shouldAutoUseFusionMlx() (MLX 配置 provider) — cloud-active 时跳过
避免 3s 浪费 + 噪音。两 warning: 不可达 (含 URL + 起服命令) / 已连通
但无模型 loaded (含可用模型名截断 + load 命令)。

不改 Doctor.tsx — diagnostic.warnings 已数据驱动渲染。#4 OOM 跨仓
延后 (fusion-mlx 需加 status 端点, 遵循 "上游问题先提 issue")。

验证: typecheck 0, 6 单测 pass, 122 全测 pass 无回归, build +
build:dev:full pass, git diff -w +62/-0 纯插入零 churn。

Co-Authored-By: Claude Fable 5 <[email protected]>
@dahai80
dahai80 merged commit 285e9ea into main Aug 20, 2026
1 check passed
@dahai80
dahai80 deleted the feat/doctor-mlx-health-probe-p42 branch August 20, 2026 12:05
dahai80 added a commit that referenced this pull request Aug 20, 2026
追 CC 2.1.196→2.1.234 Tier-1 特性批量落地 (13 PR):

变更自 v0.4.22:
- WS1 DirectoryAdded hook + Notification agent_* 类型 (#73)
- WS2 堆叠 slash-skill 调用, 最多 5 前导 (#74)
- LSP+filecache 内存泄漏 cap, 对齐 CC 2.1.208 (#76)
- skill body-defer 懒加载, item 9 (#78)
- SessionStart source "fork" 区分 fork 与 resume (#80)
- P2.1 子代理护栏 — 并发/会话/深度三限 (#82)
- P1.1 大输出 tool_result tail 预览 (#84)
- P4.1 --ax-screen-reader 入口点对齐 — env 别名 + settings key (#86)
- item 13 WebSearch per-session 搜索次数上限 (#88)
- P4.2 §6 /doctor FUSION_* vs ANTHROPIC_* 环境变量冲突检测 (#90)
- P4.2 #1+#3 /doctor MLX 网关连通 + 模型加载探测 (#92)
- item 4 MCP 工具自动后台化 FUSION_MCP_AUTO_BACKGROUND_MS (#94)
- item 22 审计日志凭证脱敏 (#96)

- package.json: version 0.4.22 → 0.4.23

Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/doctor 增加 MLX 网关连通 + 模型加载状态探测 (P4.2 #1+#3; #4 OOM 跨仓延后)

1 participant