Repository navigation
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 81050a475c
ℹ️ 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".
| session.cliSessionId = threadId; | ||
| session.existingAppServerEndpoint = opening.endpoint; |
There was a problem hiding this comment.
Reset inherited service tiers before launching the shared worker
For a valid bot configured with serviceTier: "priority", "default", or "ultrafast", buildNewSession() retains that tier, but this binding never resets it as the existing /adopt path does. sessionServiceTier() therefore includes it in the worker init, and src/worker.ts:31187-31188 explicitly rejects shared-server attachments with any defined service tier. Executing the production builder, binding, tier resolver, and worker guard confirmed that the remote thread is created but its first task cannot start. Reset the session preference to inherit when binding the externally managed thread.
AGENTS.md reference: AGENTS.md:L152-L152
Useful? React with 👍 / 👎.
| sessionStore.updateSession(ds.session); | ||
| } | ||
| reportAdmission('deferred'); | ||
| if (pendingSharedThreadOpenings.has(ds.session.sessionId)) return true; |
There was a problem hiding this comment.
Hand off pending openers across session reactivation
If a session is closed and reactivated while its original opener awaits thread/read, a new input's fork is absorbed by this session-ID-only set even though it belongs to a new runtime and activation token. When the original opener completes, the runtime-identity guard discards its continuation, and finally removes the set entry without waking the replacement. A SQLite/fake-clock probe using the production opener, fork function, and reactivation writer leaves the replacement with worker=null, initialStartPending=true, and its new input queued; subsequent messages only keep buffering. Coalesced replacement attempts need an explicit handoff after the stale opener finishes.
AGENTS.md reference: AGENTS.md:L171-L172
Useful? React with 👍 / 👎.
| forkWorker(ds, input, { resume: true, turnId: ds.session.queuedActivationTurnId, | ||
| dispatchAttempt: ds.session.queuedActivationDispatchAttempt, codexAppInputGateFrozen: true, | ||
| ...(initDurablePrimaryInbox ? { durablePrimaryInbox: true as const } : {}), | ||
| ...(initAtMostOnce ? { atMostOnce: true as const } : {}), | ||
| }, opts); |
There was a problem hiding this comment.
Release the opening gate when the deferred fork is rejected
If memory becomes hard-blocked while the bootstrap awaits the server, this second forkWorker() call reports rejected and returns true without spawning a worker. That nonthrowing rejection bypasses the cleanup in .catch(), so the pending-opener entry disappears while initialStartPending remains true. A SQLite/fake-clock probe of the production opener and fork function reproduces this workerless, gated state; even after memory recovers, later topic messages buffer behind an opening that nobody will retry. Handle the recursive fork's admission outcome and release the runtime claim on rejection while retaining the durable input journal.
AGENTS.md reference: AGENTS.md:L172-L172
Useful? React with 👍 / 👎.
newTopics:"create" 自动创建的会话在 buildNewSession 阶段保留 bot 配置的 显式 serviceTier,而远端 TUI worker 在挂载既有 App Server 时拒绝任何已定义 的 serviceTier(worker 附件守卫),导致 thread 已创建但首个任务无法启动。 /openSharedThread 的首个检查点事务内把 serviceTier 归一为 inherit,与 /adopt 绑定路径的既有处理一致,并覆盖所有重试与已绑定幂等再入路径。 Co-Authored-By: Claude Fable 5 <[email protected]>
自动评审初步意见(最终以维护者审阅为准)整体实现质量较好:创建三态检查点(unrequested / creating / received id)与绑定字段同事务落盘,回执丢失时 fail-closed 不重复创建,持久层对迟到元数据写入做了 opening/identity 防回退,测试覆盖了重启恢复、路由变更、关闭竞争等关键交叠,且真机 e2e 为显式 opt-in,不会进入默认 CI。 已代修(commit 9b4a866,追加在作者提交之后,未改写原提交)P1:显式
建议后续处理(未阻断,未在本提交修改)
本地验证
|
deepcoldy
left a comment
There was a problem hiding this comment.
复审结论(head 9b4a866)
P1 的 serviceTier 修复位置与持久化语义正确;但原 P3-1、P3-2 的“再发一条消息即可驱动”不成立。两条路径都会留下 initialStartPending=true,后续消息只追加 durable tail,不再 refork。建议升级为 P2 并在本 PR 内修复。原 P3-3 维持 P3,不单独阻断合并。
P2:绑定后的 admission 拒绝会持续保留 opening runtime gate,后续消息无法自恢复
位置:src/core/worker-pool.ts:20949-20957,后续入队分支见 src/daemon.ts:32227-32310。
绑定成功后递归调用的 forkWorker(...) 返回值/最终 admission 没有被检查。内存硬拒绝走 reportAdmission('rejected'); return true,不会抛错,因此外层 .catch 不会执行 initialStartPending=false / initialStartClaimToken=undefined 的清理。此时 durable head 仍在、worker=null,但 initialStartPending=true;下一条普通消息在 daemon.ts:32230 进入 follower 分支,追加 tail 后于 32310 返回,只有单独的 quarantine 标记才会触发 blank recovery fork,而本路径不会设置它。
真实 forkWorker 临时探针(使用 PR 现有测试组件,首次 admission 放行、绑定后的第二次拒绝)得到 deferred → rejected,并同时观察到 queuedActivationPending=true、worker=null、initialStartPending=true;期望可重试的 false 断言按预期咬红。现有路由用例 test/daemon-rename-route.test.ts:789 也证明该 gate 下后继消息不会 refork。
建议在递归 fork 的最终 rejected 分支按当前 session/generation/activation token 守护后释放 opening claim,保留 journal,并补一条“拒绝后下一条 IM 能重放旧 head”的路由级回归测试;不要把 deferred 误当作最终失败。
P2:close/reactivate 与旧 opener 交叠时,新 runtime 没有完成交接
位置:src/core/worker-pool.ts:20924-20925、20938-20941、20968。
创建途中 /close 后,同一 sessionId 可在尚未绑定 existingAppServerEndpoint 时恢复。reactivateClosedSession 会有意清除旧 FIFO(src/services/session-store.ts:2997-3009),新消息随后作为新 activation 入队;但 pendingSharedThreadOpenings 按 sessionId 命中后直接返回。旧 opener 随后因 active runtime 已替换而在代际守卫处退出,finally 仅删除 sessionId,没有唤醒或释放新 runtime 的 claim。新 runtime 同样留下 initialStartPending=true,所以“再发一条消息”仍只会追加 tail。
临时探针按上述语义驱动真实 forkWorker:旧 opener 被人为挂起;replacement runtime 的新输入 second 成功写入 journal,但没有第二次 open;旧 opener 完成后没有 child fork,replacement 的 initialStartPending 仍为 true,预期 false 的断言按预期咬红。
建议保留 sessionId 级远程创建去重(不能改成按 runtime 各自创建,否则会有重复 thread 风险),但为被去重的 replacement 注册完成后的交接/唤醒 continuation,并以当前 runtime、route、activation token 等代际条件守护。若最终状态是 creating 未知态,仍应保持 fail-closed,由 /adopt 对账。
P1 修复复核:通过
src/core/shared-thread-opening.ts:87 在首个 checkpoint 事务中写入显式 inherit,早于已绑定幂等再入的 early return,覆盖创建、重试与再入。这里不能用 undefined:src/services/session-store.ts:2222 会把旧 durable tier 回填。事务提交后 mutateOwnedSessionsAtomically 在原缓存对象上原地合并(session-store.ts:3156-3161),随后 sessionServiceTier 将 inherit 映射成 undefined(worker-pool.ts:4354-4357),因此递归启动不会再触发 worker.ts:31187 的附件守卫。新增测试同时覆盖真实 session store 和已绑定再入,位置恰当。
P3:JSON-RPC 字段仍建议补齐,但当前版本不阻断
src/core/shared-thread-opening.ts:14、:45、:56 的 error response、request、initialized notification 都缺少 jsonrpc:'2.0'。这与仓库既有 App Server 客户端不一致,也不符合 JSON-RPC 2.0 wire shape;建议随本轮修改顺手补齐并加 wire 断言,或单独后续处理。本机 Codex 0.167.0 的真实 App Server e2e 已通过,证明当前版本容忍该缺省,因此维持 P3。
实际验证
bun run build:通过(含 tsc/typecheck 与 dist audit)。bunx vitest run --project unit test/shared-thread-opening.test.ts test/session-store.test.ts test/session-lifecycle-start.test.ts test/existing-app-server.test.ts test/daemon-rename-route.test.ts test/worker-durable-expiry-order.test.ts:6 文件、1006 用例全绿。BOTMUX_TEST_REAL_CODEX_BIN=/root/.local/bin/codex bunx vitest run --project e2e test/shared-thread-real-server.e2e.ts:Codex 0.167.0,2/2 全绿,含真实远端 worker 首轮完成与另一客户端读取同一 thread。- 上述两个对抗探针均为临时测试、用于确认缺陷后已撤回;工作树恢复干净。
- 发布时 CI:
network-boundary已成功,其余 build/test/bun-test/binary 任务仍在排队,尚无完整 CI 结论。
绑定后的 admission 拒绝、同步启动失败与 tail-only false 均释放 runtime claim,保留 durable activation 供后续 IM 重放。 close/reactivate 复用 sessionId 时保留创建 single-flight,并以代际栅栏向 replacement runtime 交接旧 head;SharedThreadClient 补齐 JSON-RPC 2.0 字段。 Co-Authored-By: Claude Code <[email protected]>
|
已追加提交
验证: |
|
已合并,感谢贡献! 后续跟进项(不阻断本次合入):
评审中修复的共享话题开工门闩问题(显式 serviceTier 挂载失败、admission 拒绝与关闭恢复后的 gate 卡死)均已带回归测试和变异验证。 |
|
🚀 Released in v3.59.34 |
改动
目前,BotMux 接入共享 Codex App Server 后,新话题仍需手动
/adopt。本改动增加自动创建:开启existingAppServer.newTopics: "create"后,飞书新话题直接在指定的 App Server 上创建 thread,供 BotMux、Codex Desktop 和 CLI 共用同一会话。沿用 #974 的共享接入和现有消息处理链路,同时补齐创建失败和重启后的恢复,保留首条消息,避免重复创建和后续消息卡住。默认仍只接入已有 thread,其他入口保持原行为。
验证
完整构建通过;相关回归 2,633 个用例通过,2 个既有用例跳过;Bun 核心用例 27 个通过。真实 Codex App Server 和 worker 完成一轮模型测试服务推理,第二客户端读取同一 thread,2 个集成用例通过。移除回执防重、目录或关闭检查后,对应回归均失败。
飞书与 Desktop UI 的线上验收尚未执行。创建回执丢失时需核对实际 thread;初始化期间同时人工改名,初始名称可能覆盖人工名称。
复审修复与补充验证
serviceTier归一为inherit,避免 remote TUI worker 的附件守卫拒绝启动;覆盖真实 session store、重试和已绑定幂等再入。marginalReclaimScheduledout-flag 的调用方契约。同步false、同步拒绝、异步拒绝与启动异常分别覆盖;启动异常补偿按精确 claim token 对齐,不把正常的workerGeneration推进误判为 stale。/close后同 sessionId reactivate 与旧 opener 交叠时,继续保持 sessionId 级创建 single-flight;旧尝试结束后向 replacement runtime 交接 durable head。交接受 runtime、generation、route、activation token、background epoch 和 claim token 防护;creating未知态仍不发起第二次thread/start,保持/adopt对账路径。SharedThreadClient的请求、initialized通知和 bootstrap 错误响应补齐jsonrpc:"2.0"。实际执行:
bun run build:通过(含 tsc/typecheck、dashboard bundle 与 dist audit)。shared-thread-opening、session-store、session-lifecycle-start、existing-app-server、daemon-rename-route、worker-durable-expiry-order,6 文件、1016 用例全绿。其中包含路由级“gate 释放后下一条 IM 重放旧 head、 successor 留在 tail”的回归。BOTMUX_TEST_REAL_CODEX_BIN=/root/.local/bin/codex bunx vitest run --project e2e test/shared-thread-real-server.e2e.ts:Codex 0.167.0,2/2 全绿。shared-thread-opening与existing-app-server:29/29 全绿。false清理、同步/异步拒绝清理与 catch 清理,错误地要求 generation 不变、在 deferred 时释放 claim,或省略请求jsonrpc字段,对应测试均咬红;每次变异后均恢复实现并重新跑绿。对抗复核问题清单与探针证据
workerGeneration从undefined推进到1;初版补偿错误地要求 generation 不变,导致 catch 无法释放 claim,后续 IM 只入队不重试。真实forkWorker探针复现了worker=null、durable input/activation 保留、但initialStartPending=true的状态。修复改为按精确 claim token、activation token、route、background epoch 和 active owner fencing;原失败探针及正式 spawn-throw 回归均已通过。false与 catch 清理曾各自缺少能独立咬红的用例。现用真实 tail-only quarantine 覆盖同步false,用带 claim token 和 generation reservation 的 spawn-throw 覆盖 catch,并另测同步/异步拒绝;等待超时设为 5 秒以避免整机负载下的假失败。creating回执未知、deferred→accepted/rejected,以及 gate 释放后的真实后续 IM FIFO。🤖 Generated with Claude Code