Repository navigation
/doctor 接入 MLX /v1/health 主动 OOM 检测 (P4.2 #4; fusion-mlx#564 下游) - #125
Merged
Merged
Conversation
…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
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
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-privategetMlxAuthHeaders/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 errorsbun test src/__tests__/— 396 pass, 0 failbun run build:dev— passbunx 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]