Skip to content

fix(mcp): 保留网关标记间的 Codex 信任配置 - #1376

Open
Ginufet wants to merge 1 commit into
deepcoldy:masterfrom
Ginufet:fix/codex-hook-trust-preservation
Open

fix(mcp): 保留网关标记间的 Codex 信任配置#1376
Ginufet wants to merge 1 commit into
deepcoldy:masterfrom
Ginufet:fix/codex-hook-trust-preservation

Conversation

@Ginufet

@Ginufet Ginufet commented Sep 12, 2026

Copy link
Copy Markdown

背景

Codex CLI 审批 Hook 后,会将 hooks.state 写入用户级 TOML。实测新表可能插入 BotMux MCP Gateway 结束注释之前。旧逻辑更新 Gateway 时按注释起止位置删除整个块,误删信任记录,导致 botmux start 后原生 Codex 和 Bot 会话再次要求审批。

Closes #1375

改动

  • 将 Gateway 标记清理改为仅过滤起止标记行,不删除标记之间的全部文本。
  • 继续使用现有 stripCodexBotmuxSections 删除 BotMux 自己的 MCP 表和子表。
  • 安装与移除路径共用这一修复。
  • 新增 LF/CRLF 回归用例,覆盖两条 Hook 信任记录、用户 MCP、项目配置、旧 Gateway 子表清理,以及重复安装/移除的幂等性。

影响范围

  • 仅改变 Codex TOML Gateway 标记处理;Claude JSON 路径不变,现有 Claude 回归用例通过。
  • 不修改沙箱策略、Hook 审批机制、CLI 启动目录或用户凭据。
  • PTY/Tmux、不同会话类型使用这条共享配置更新路径时均受益;没有修改后端特有逻辑。
  • LF/CRLF 已覆盖;实际构建和部署平台为 Linux x64,未执行 macOS 运行验证。
  • 本次不改写 legacy plugin block 清理器,也不宣称实现了完整 TOML 解析器。

实际验证

构建工具 Bun 1.4.2,依赖通过 bun install --frozen-lockfile 安装。

bun run test -- test/plugin-mcp-gateway-installer.test.ts test/plugin-manifest-store.test.ts test/plugin-mcp-sandbox.test.ts test/bypass-codex-hook-trust-config.test.ts
bun run build
BOTMUX_VERIFY_BAKED_VERSION=3.21.0-hooktrust.89eb378c bun run build:bun --target bun-linux-x64
node scripts/smoke-bun-binary.mjs dist-bin/botmux-linux-x64
git diff --check
  • 相关测试:37 passed、3 skipped;3 项真实沙箱集成测试因宿主条件不满足而跳过。未执行全量测试。
  • 完整构建、类型检查、构建资产审计通过。
  • 二进制隔离 smoke 全部通过,包括 CLI 图加载、版本、配置资源、插件服务、supervisor、Dashboard HTTP/前端和二进制完整性。
  • 实机部署:用构建产物替换本地单文件安装,并以安装路径执行 botmux restart;确认新安装的 SHA-256 与构建产物一致,daemon 和 Dashboard 均 online。
  • 重启后 hooks.state 的原有信任哈希保留,且位于 Gateway 标记块外。此检查没有关闭 Hook 审批,也没有重新授予信任。
  • 尚未声称验证了重启后所有飞书业务流程,或用户再次新开 Codex 的最终 UI 结果。

效果

当 Codex 在 Gateway 注释块中插入其他表时,下一次 Gateway 更新或移除不再把这些表一并删除。已丢失的信任记录不会凭空恢复,需要用户正常审批;仍存在的记录会被保留。

@Ginufet
Ginufet requested a review from deepcoldy as a code owner September 12, 2026 13:24
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(mcp): Gateway 配置更新误删 Codex Hook 信任记录,导致重复审批

1 participant