Repository navigation
fix: 稳定性专项——恢复广播抑制、loopback 放行扩展、ps maxBuffer 补点 - #1005
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 182414f482
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // (rememberLastCliInput) so later failures notify normally. Do NOT set | ||
| // failureNotified here: a later generation failing after the flag clears | ||
| // must still surface. | ||
| if (ds.suppressRecoveryCard) { |
There was a problem hiding this comment.
Suppress fork-level recovery failures as well
When restoration fails at the child-process fork boundary (for example, spawn EAGAIN before worker IPC is established), execution never reaches this guard: the separate normal and adopt worker.on('error') handlers still call sessionReply without checking suppressRecoveryCard. Under resource pressure during batch restore, this can therefore still post one startup-failure message per restored normal/adopt session—the broadcast storm this change is intended to prevent—so both fork-error paths need the same chat-notification suppression while retaining their logging and lifecycle handling.
AGENTS.md reference: AGENTS.md:L68-L68
Useful? React with 👍 / 👎.
|
感谢这个稳定性专项 PR,5 个修复都是近期用户真实反馈的痛点,方向很好 👍 我们做了一轮自动评审 + 交叉复核,绝大部分逻辑扎实(默认行为字节等价、fail-closed、向后兼容都做得很到位)。有一处建议在合入前修,其余是可选 nit,具体如下。 🟠 建议合前修:Fix3 恢复抑制——queued 两条 refork 路径的 flag 永不清除Fix3 的核心不变量( 但在两条 queued refork 路径上不成立:
这两条 失败链(复合条件,production 可达):
结果:用户零反馈,且后续每条消息重复静默吞掉——体验上比"报错卡片"更糟(用户以为消息发出去了)。 建议修法(很小):在这两条 queued 路径用户触发 refork 时清 🟡 可选 nit(不阻断)
✅ 其余确认无问题
以上为自动评审的初步意见,供参考,最终以维护者审阅为准。 🙏 |
|
补充一个 Fix3 修法的实现细节(供参考):清
核心 bug 场景(fork 被接受 + 异步失败)两种时序都能修好,放在 fork 后只是更干净、且和主路径保持一致。清 flag 后 streaming card 恢复是预期行为(用户已介入 = 恢复结束)。 |
|
感谢评审,🟠 合前修已处理并推送(commit af7c48c): Fix3:queued 两条 refork 路径清除 suppressRecoveryCard 认同失败链分析——这两条路径 修法按建议实现:
回归测试加在 daemon-ordinary-ingress-failure-notice(复用真实 inbound 路由 + forkWorker mock):
两个 🟡 nit:均为已知/可选,本 PR 不展开(migrate-to-chat 的 endsWith 放宽不可利用已确认;preflight clamp 上界后续可补独立测试)。 验证: |
listPm2GodDaemonPids 的 ps/powershell 扫描及各适配器(reasonix、 zellij、adopt-route、session-discovery、codex-rpc-engine)的 ps 回退 路径均未设 maxBuffer,Node 默认 1MiB,macOS 进程表超 1MiB 时抛 ENOBUFS,导致 start/stop/restart 的 God 查重 fail-closed。统一显式 传 32MiB(与 browser-restart 一致),真 ENOBUFS 仍 fail-closed 抛出。 Co-Authored-By: Claude <[email protected]>
notifyStartupFailure 只检查 failureNotified 和 managedAuxUiSuppressed, 不检查 suppressRecoveryCard。daemon 重启批量恢复会话时每个失败 worker 都往自己会话发「会话启动失败」卡片,形成广播风暴。现在在 failureNotified 检查之后短路:恢复模式下只写 daemon 日志、不发卡片; 故意不置 failureNotified,待抑制解除后新一代失败仍可正常通知。 Co-Authored-By: Claude <[email protected]>
三处内部 HMAC 端点(dashboard verifyHmac、daemon-internal-auth、 v3 daemon-ipc-auth)写死 127.0.0.1/::1/::ffff:127.0.0.1 字面量检查, 定制内核把 loopback peer 上报成 LAN IP 时内部请求全 401。抽出 utils/loopback-peers.ts:默认语义逐字节保留,BOTMUX_LOOPBACK_PEERS (逗号分隔 IP/CIDR,IPv4/IPv6 双栈)额外放行,非法项 fail-closed 忽略并告警。 Co-Authored-By: Claude <[email protected]>
DaemonDescriptor 增加 version 字段(daemon 启动时从 package.json 写入),botmux status 读取在线 daemon 描述符并与 CLI 版本比较, 不一致时打印醒目警告提示 restart。旧 daemon 无 version 字段自动 跳过(向后兼容),源码 checkout(0.0.0)跳过避免噪音。 Co-Authored-By: Claude <[email protected]>
- browser-restart 的 ps 进程表扫描补 maxBuffer 32MiB(统一 ENOBUFS 清扫) - dashboard-ipc-server /api/sessions/migrate-to-chat 迁移到 isLoopbackPeer, BOTMUX_LOOPBACK_PEERS 放行地址对该端点同样生效 - worker-pool suppressRecoveryCard 注释修正:owner 并非总能收到恢复 DM (崩溃/pm2 自动重启无 breadcrumb),失败写 daemon 日志、下一轮用户消息兜底 Co-Authored-By: Claude <[email protected]>
重启恢复的 ordinary 会话带 suppressRecoveryCard=true 且有 queued activation 时,queuedActivationPending / retainedQueuedActivation 两条 refork 路径 forkWorker 后直接 return,从不经过 rememberLastCliInput (全仓唯一常规清 flag 点),flag 永不清除。复合失败链:worker 死后用户 发消息触发 queued refork → fork 同步被接受、随后异步 'error' 携带 queuedActivationTurnId → scheduleTransientStartupRetry 因 turnId 非空 不自治重试 → notifyStartupFailure 被静默 flag 吞掉、fork 未同步抛错 也没有 ingress notice——用户零反馈,且后续每条消息都被静默吞掉。 两条路径在 forkWorker 同步返回后(未 throw)显式 ds.suppressRecoveryCard = undefined:用户已介入即恢复静默结束;只清 恢复标志、不补 rememberLastCliInput(避免 lastCliInput 毒记录破坏空 启动 --resume 契约)。时序对齐主 refork 路径——fork 同步 throw 时 flag 保留,走 ingress notice 通道。 回归测试 3 条:两条 queued 路径 refork 后 flag 清除;fork 同步 throw 时 flag 保留(钉住清 flag 必须在接受之后的时序约定)。 Co-Authored-By: Claude <[email protected]>
af7c48c to
df77de8
Compare
|
感谢这个稳定性专项里的细致排查 🙏 其中 maxBuffer / ENOBUFS 部分已基于最新 master 单独拆成 #1888(保留了你的署名),并按 master 现状补齐了几处新发现的全表 ps 扫描。其余几项(恢复期广播抑制、loopback 放宽、版本错配告警)我们会分别评估:版本告警部分 master 已有 botmuxVersion 可复用,loopback 涉及安全面需要单独讨论。这个 PR 先保持打开,有新进展会在这里同步。 |
合并 master 到稳定性专项分支,冲突以 master 为准: - 进程表 ps maxBuffer 复用 master 的 PROCESS_TABLE_MAX_BUFFER 常量(deepcoldy#1888) - CLI/daemon 版本错配检测复用 master 已落地的 botmuxVersion 描述符与 daemon-version-display,删除本分支的重复实现 - loopback 放行(BOTMUX_LOOPBACK_PEERS)增加 /0~/7 过宽网段拒绝 - 文档补充环境变量说明:仅放宽本机来源层,HMAC 校验不变
独立 dashboard 进程只按白名单加载 ~/.botmux/.env,而 CLI→dashboard 轮换鉴权(verifyHmac)也消费 loopback 判定;不进 DAEMON_ENV_KEYS 时 文档指引的 .env 配置对该进程不生效,且从会话内发起的重启会丢值。 该变量非密、daemon 与 dashboard 共同消费,按 BOTMUX_PUBLIC_URL 同例处理。
双栈 Node 把 IPv4 对端上报为 ::ffff:a.b.c.d,此前 /0~/7 宽度下限只 按位宽判断,::/80 或 ::ffff:0:0/96 这类条目等价于放开整个 IPv4 互联网却能通过。覆盖映射块 ::ffff:0:0/96 的 IPv6 条目改按等效 v4 前缀(prefix-96)执行同一 /8 下限。 dispatch-launch IPC、native-subagent 运行时 IPC、current-actor 归属解析三处仍是字面量 loopback 判断,在定制内核机器上同样 401, 统一委托 isLoopbackPeer;最后一道保留本机 socket inode 进程归属链, 放宽的仅为地址层。各补 env 放行集成断言与 mapped 宽度用例。
两条 queued refork 路径此前不看 forkWorker 返回值就清 suppressRecoveryCard,与主路径 reforkAccepted 判据不一致:fork 返回 false(quarantine / 会话已非 active 的不抛错拒绝腿)时清早了。改为 仅在返回 true 时清标志,同步抛错与 false 都保留静默并回落 ingress notice,补 false 保留路径用例。
过宽告警此前只提“wider than /8”,对 ::/80 等位宽不小却等价 v4 /0 的 IPv6 条目有误导,文案补出两类拒绝原因;环境变量文档补跨族匹配 规则:IPv4 对端应配 IPv4 条目(同时覆盖原生与 mapped 上报形式)。
|
感谢 @ITcathyh 这个稳定性专项 🙏 已合并。 你原始 PR 的三件核心工作在最终落地中完整保留:
合并过程中维护者侧追加的部分(供你了解最终形态):原 pm2 项随仓库 pm2→supervisor 迁移作废;CLI/daemon 版本错配告警主干已有更完整的实现( 无遗留 follow-up。欢迎继续贡献。 |
Bring the branch to current master (e9d0f8b, deepcoldy#1758/deepcoldy#2074/deepcoldy#1005/deepcoldy#2016); content is the clean merge with the reviewed LinkRef tree: link-ref register+resolve in the narrow aperture, zero deepcoldy#2057/deepcoldy#2058 resurrections.
|
🚀 Released in v3.49.0 |
稳定性专项:恢复广播抑制、loopback 放行扩展、ps maxBuffer 补点
来自用户反馈的稳定性专项,整体合入。原 5 项中 pm2 jlist 超时项随 master 完成 pm2→supervisor 迁移作废;ps maxBuffer 主体已由 #1888 合入,本 PR 补齐其未覆盖的扫描点;CLI/daemon 版本错配告警 master 已落地更完整的实现(
botmux status版本列 + restart 提示),本 PR 不再重复带入。改了什么
1.
fix(worker-pool):恢复模式下抑制启动失败卡片广播daemon 重启批量恢复会话时,每个起不来的 worker 都往自己会话发「会话启动失败」卡片,形成广播风暴。
notifyStartupFailure在suppressRecoveryCard期间只写 daemon 日志、不发卡片。关键不变量:不置
failureNotified—— 抑制解除后同代 worker 再失败仍会正常通知,失败不会被永久吞掉。配套修复两条 queued refork 路径(
queuedActivationPending/retainedQueuedActivation):两条路径 fork 后直接 return、不走rememberLastCliInput(全仓唯一清除suppressRecoveryCard的地方),标志会永久残留。改为在 forkWorker 被接受(返回 true,与主 refork 路径同一判据)之后清除该标志;fork 同步抛错或返回 false(quarantine/会话已非 active 的不抛错拒绝腿)时保留标志,回落到 ingress notice 通道。2.
fix(dashboard):loopback 判定支持自定义放行地址定制内核会把 loopback peer 上报成 LAN IP,导致内部认证点的严格
127.0.0.1/::1判定全部 401。新建src/utils/loopback-peers.ts,支持环境变量BOTMUX_LOOPBACK_PEERS(IP/CIDR 列表)额外放行。127.0.0.1/::1/::ffff:127.0.0.1)。/0~/7(含0.0.0.0/0、::/0,等于放开整个互联网)按非法条目忽略;下限/8,10.0.0.0/8、fd00::/8可用。双栈主机的 IPv4 对端以::ffff:a.b.c.d上报,覆盖映射块::ffff:0:0/96的 IPv6 条目按等效 IPv4 前缀判定:::/80、::ffff:0:0/96(等价 v4/0)同样拒绝,::ffff:10.0.0.0/104(等价10.0.0.0/8)可用。dashboard/auth、daemon-internal-auth、workflows/v3/daemon-ipc-auth、dashboard-ipc-server(migrate-to-chat)、dispatch-launch-ipc-auth、native-subagent-runtime-ipc-auth、current-actor-attestation(最后一道另含 /proc socket inode 本机进程归属校验)。~/.botmux/.env对 daemon 与独立 dashboard 进程均生效(已纳入 fleet 生命周期环境变量快照,会话内发起的 restart 不丢值)。3.
fix(cli):补齐 #1888 未覆盖的 ps 扫描 maxBuffer统一用 #1888 引入的
PROCESS_TABLE_MAX_BUFFER(32MiB),补 4 处仍用 Node 默认 1MiB 的 ps 调用:session-discovery(×2)、adopt-route、codex-rpc-engine。只影响输出超限的失败路径,成功路径输出字节等价。影响面
测试验证
bun run build通过/0~/7原生与 mapped 形式拒绝、/8(::ffff:10.0.0.0/104)边界