Skip to content

/doctor 接入 MLX /v1/health 主动 OOM 检测 (P4.2 #4; fusion-mlx#564 下游) - #125

Merged
dahai80 merged 1 commit into
mainfrom
feat/doctor-mlx-oom-health-564
Aug 22, 2026
Merged

dahai80 merged 1 commit into
mainfrom
feat/doctor-mlx-oom-health-564

Conversation

@dahai80

@dahai80 dahai80 commented Aug 22, 2026

Copy link
Copy Markdown
Owner

背景

Closes #124. fusion-mlx#564 (PR #581 MERGED) 落地了 GET /v1/health 只读内存/OOM 端点 (management-gated, 返 memory + oom_risk 确定性双信号分类器)。#564 body 明示下游需 fusion-code 侧补 fetchMlxHealth() 接入 detectMlxHealth()。本 PR 完成该下游接入。

改动 (surgical, 4 文件)

  • fusion-mlx-types.ts — 扩 MLXHealthResponse: status 加 degraded/oom; 新增 memory (MLXHealthMemory: rss/used/free/total + nullable mlx_active/cache/peak + per_model) 和 oom_risk (none|low|high|imminent)。全 optional 兼容旧 MLX。
  • fusion-mlx-adapter.ts — 新 fetchMlxHealth(): GET /v1/health, 复用 module-private getMlxAuthHeaders/getMlxApiUrl/getOriginalFetch (Rule 7 auth 单源)。401/non-ok/timeout → null (fail-open: 单盒匿名 MLX 无 management 访问 → OOM 诊断静默跳过, 无误报)。
  • doctorDiagnostic.ts — detectMlxHealth 在有模型 loaded 后探 /v1/health (无模型不探 — 内存空无意义)。high/imminent oom_risk → warning 含内存统计 + 修复指引 (/mlx gc / unload); none/low → 静默。复活先前死类型 MLXHealthResponse。加 formatBytesLocal 助手。
  • doctorMlxHealth.test.ts — 7 新测: imminent/high/low/none, null fail-open, 401 fail-open, no-model-loaded 优先级。

scope

#4 /doctor 主动 OOM 检测 (surgical)。item 15 (OOM 自动恢复 / 网关重连续) = L-size follow-up, 另 issue/PR, 不在本 PR。

gate

  • bun run typecheck — 0 errors
  • bun test src/__tests__/ — 396 pass, 0 fail
  • bun run build:dev — pass
  • bunx biome check (改区) — 仅 pre-existing baseline 诊断, 改区零新诊断

风险

低。fail-open null 保证单盒匿名 MLX (无 management key, /v1/health 401 per fusion-mlx#350 loopback 不豁免) 不误报 OOM。oom_risk 由 fusion-mlx 确定性计算, fusion-code 仅 surface。有模型才探, 避免空内存噪音。

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

…lx#564)

fusion-mlx#564 (PR #581) landed upstream: GET /v1/health read-only
memory/OOM endpoint, management-gated (valid api_key, loopback not exempt
per fusion-mlx#350). Wire the fusion-code side.

- fusion-mlx-types.ts: extend MLXHealthResponse with memory (rss/used/free/
  total + nullable mlx_active/cache/peak + per_model) and oom_risk
  (none|low|high|imminent); widen status to ok|degraded|oom|error. All new
  fields optional — older MLX without the endpoint returns null (fail-open).
- fusion-mlx-adapter.ts: fetchMlxHealth() hits GET /v1/health reusing the
  module-private auth/url/fetch helpers (getMlxAuthHeaders single source of
  truth). 401/non-ok/timeout → null (fail-open: single-box anonymous MLX has
  no management access → OOM diagnostics silently skip, no false positive).
- doctorDiagnostic.ts: detectMlxHealth probes /v1/health only after a model
  is loaded (no point probing memory when nothing occupies it). high/imminent
  oom_risk → warning with memory stats + remediation (/mlx gc / unload);
  none/low → silent. Revives the previously-dead MLXHealthResponse type.
- doctorMlxHealth.test.ts: 7 new tests cover imminent/high/low/none, null
  fail-open, 401 fail-open, and no-model-loaded precedence.

Scope: #4 /doctor proactive OOM detection only (surgical). item 15 OOM
auto-recovery / gateway reconnect-resume = L-size follow-up (separate
issue/PR, not this one).

Co-Authored-By: Claude Fable 5 <[email protected]>
@dahai80
dahai80 merged commit 3cea944 into main Aug 22, 2026
1 check passed
@dahai80
dahai80 deleted the feat/doctor-mlx-oom-health-564 branch August 22, 2026 11:45
dahai80 added a commit that referenced this pull request Aug 22, 2026
Patch release bundling 17 commits since v0.4.23:
- item 15(a) MLX OOM auto-recovery gc+retry (#129)
- #7 one-click diagnostic fixAction framework (#131)
- 维度5 background-default spawn FUSION_SUBAGENT_DEFAULT_BACKGROUND (#127)
- #4 proactive MLX OOM detection via /v1/health (#125)
- item 17 fullscreen pre-compact history + :598 synthetic decouple (#123)
- item 25B workflow stagger fan-out (#122)
- item 21 auto-mode local rule classifier test coverage (#120)
- item 23 archive plugin source + SHA-256 lock (#118)
- item 24 marketplace command source (#116)
- item 6 transcript disk trimming + crash-safe checkpoint (#114)
- item 5 normalizeMessages secondary normalize cache (#112)
- item 19 screen-reader plaintext render (#110)
- item 16 compact retry countdown + stall hint (#108)
- item 25A workflow execution runtime docs (#106)
- item 25A minimal workflow execution runtime (#105)
- item 12 subagent auto-background threshold (#103)
- item 20 vimInsertModeRemaps dual-key INSERT sequence (#101)

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 /v1/health 内存/OOM 诊断 (P4.2 #4; fusion-mlx#564 落地下游)

1 participant