Skip to content

fix(doctor): /doctor 检测 FUSION_* vs ANTHROPIC_* 环境变量冲突 (P4.2 §6) - #90

Merged
dahai80 merged 1 commit into
mainfrom
feat/doctor-config-conflict-p42
Aug 20, 2026
Merged

dahai80 merged 1 commit into
mainfrom
feat/doctor-config-conflict-p42

Conversation

@dahai80

@dahai80 dahai80 commented Aug 20, 2026

Copy link
Copy Markdown
Owner

背景

Closes #89. enhance-0819.md §P4.2 /doctor 本地健康体检 spec #6 要求 配置冲突检测 (FUSION_BASE_URL vs ANTHROPIC_BASE_URL 残留陷阱)。

审计结论

src/screens/Doctor.tsx 渲染 diagnostic.warnings,diagnostic 来自 getDoctorDiagnostic() (src/utils/doctorDiagnostic.ts)。detectConfigurationIssues() 现仅检查 install-method / PATH / npm-leftover,不检查 env 冲突。

src/entrypoints/cli.tsx:30-49 有 6 对 FUSION_* → ANTHROPIC_* 映射,每对模式 if (FUSION_X && !ANTHROPIC_X) ANTHROPIC_X = FUSION_X。两者都设置时 FUSION_ 被静默忽略* — 用户以为 FUSION_BASE_URL 生效实则用 ANTHROPIC_BASE_URL,无告警。spec 点名的 "残留陷阱"。

改动

新增纯同步 helper detectFusionEnvConflicts() (doctorDiagnostic.ts),挂入 detectConfigurationIssues warnings 数组,复用 Doctor.tsx:417 既有 render 路径 (不改 UI)。

覆盖 6 对 (与 cli.tsx:30-49 一致):API_KEY / BASE_URL / AUTH_TOKEN / BETAS / MODEL / LOG。warning {issue, fix} 文案明确指出 FUSION_* 被忽略 + unset 修复动作。

export function detectFusionEnvConflicts(): Array<{ issue: string; fix: string }> {
  const warnings: Array<{ issue: string; fix: string }> = []
  for (const { fusion, anthropic } of FUSION_ENV_CONFLICT_PAIRS) {
    if (process.env[fusion] && process.env[anthropic]) {
      warnings.push({
        issue: `Both ${fusion} and ${anthropic} are set; ${fusion} is silently ignored ...`,
        fix: `Unset the one you don't intend to use, e.g. \`unset ${anthropic}\` ...`,
      })
    }
  }
  return warnings
}

范围 (surgical)

  • src/utils/doctorDiagnostic.ts: +38/-0 (纯插入,零 churn,匹配原 2-space/single-quote/no-semi 风格)
  • src/__tests__/utils/doctorEnvConflicts.test.ts: 新文件,6 用例 (无 env / 仅 FUSION / 仅 ANTHROPIC / 单对冲突 / 全 6 对冲突 / 混合态),env snapshot+restore 隔离

不在本 PR (后续 iteration)

验证

  • bun run typecheck — 0 error
  • bun test src/__tests__/utils/doctorEnvConflicts.test.ts — 6 pass / 0 fail
  • bun test src/__tests__/ — 122 pass / 0 fail (无回归)
  • bun run build + bun run build:dev:full — pass
  • bunx biome check — 干净
  • git diff -w — +38/-0 prod, 零 churn

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

enhance-0819.md §P4.2 spec #6 要求配置冲突检测 (FUSION_BASE_URL vs
ANTHROPIC_BASE_URL 残留陷阱)。cli.tsx:30-49 有 6 对 FUSION_* -> ANTHROPIC_*
映射,模式 `if (FUSION_X && !ANTHROPIC_X)`,两者都设置时 FUSION_* 被静默忽略。
用户以为 FUSION_BASE_URL 生效实则用 ANTHROPIC_BASE_URL,无任何告警。

新增 detectFusionEnvConflicts() 纯同步 helper,挂入 detectConfigurationIssues
warnings 数组,复用 Doctor.tsx:417 既有 render 路径 (不改 UI)。覆盖 6 对:
API_KEY / BASE_URL / AUTH_TOKEN / BETAS / MODEL / LOG。warning {issue, fix}
文案明确指出 FUSION_* 被忽略 + unset 修复动作。

范围 surgical: +38/-0 prod (doctorDiagnostic.ts),1 新测试文件 6 用例。
MLX 端口/网关/模型加载/OOM (#1-4 async probe) 与一键修复 (#7) 延后单独 iteration。

验证: typecheck 0; 6 新测 pass; 122 单测无回归; build + build:dev:full pass;
biome check 干净。Closes #89

Co-Authored-By: Claude Fable 5 <[email protected]>
@dahai80
dahai80 merged commit 5935452 into main Aug 20, 2026
1 check passed
@dahai80
dahai80 deleted the feat/doctor-config-conflict-p42 branch August 20, 2026 12:04
dahai80 added a commit that referenced this pull request Aug 20, 2026
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 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.

fix(doctor): /doctor 应检测 FUSION_* vs ANTHROPIC_* 环境变量冲突 (P4.2 §6)

1 participant