Repository navigation
fix(session): 修复普通消息身份登记与 Codex App 启动回复 - #3241
Merged
deepcoldy merged 9 commits intoNov 9, 2026
Merged
Conversation
uestcwangci
requested review from
47seek,
LucasIcarus,
deepcoldy,
xiaoxueSunn and
xiongz-c
as code owners
November 9, 2026 06:54
空闲会话在同一 worker 内重连控制通道时,期间到达的消息被 flushPending 的签名就绪屏障暂存;新连接上报签名空闲后 markPromptReady() 因提示符早已就绪直接返回,消息会滞留到下一条输入才被带出。签名空闲且提示符已就绪时,若仍有待派发输入则补一次 flushPending。 同时补齐回归覆盖: - 重连期间暂存的输入在新连接签名空闲后被派发(去掉补派发即红); - 执行观察者授权不扩展到 final_output_offer、turn_interrupt_result、codex_app_dispatch_persisted、restart_result; - 重启控制进行中,历史最终回复投递失败后不重试、不结算;先推进假时钟再等待投递,使回归以断言而非用例超时判红; - worker-codex-session-upgrade 自带求值作用域补上 flushPending 新依赖的 isCodexAppCliId(vitest 2 例、bun 13 例 ReferenceError)。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Owner
|
已 squash 合入 master(落地提交 157be9c),感谢 @uestcwangci 的贡献。 这组改动把 Codex App 在 worker 重启、warm reattach 和连续消息合并时的 final 归属证明链路补完整了:execution observer 最小授权、FIFO 队首精确结算、进程/rollout 身份证明,以及控制连接重连后被签名屏障暂存输入的补派发,整体保持 fail-closed。相关测试与变异覆盖也比较扎实。 一个留待后续观察的点(PR 描述里也提到了):最初触发 final 被拒收的具体时序目前还没有独立复现,这次主要是恢复加固与诊断增强;建议后续线上再遇到 |
deepcoldy
pushed a commit
that referenced
this pull request
Nov 9, 2026
现象:#2854 上线后,长会话里普通 IM 追问轮 `lark-cli --as user` 报 "No current requesting user",`botmux actor current` 返回 current_actor_unverified;休眠时还误报"无法确认是否执行" (worker_retired_before_commit)。 根因:普通 IM 追踪投递(sendOrdinaryImDeliveryTracked)直接 worker.send, 绕过了 sendWorkerSessionInput 里唯一的 execution 登记。worker 手里没有登记过 的 execution,追问轮的 managed_turn_origin、收据和提交 ACK 都被契约层按 execution_scope_missing 丢掉(只打 debug),daemon 的当前轮身份拿不到这一轮 的发送者,投递追踪也一直结不清。#3241 已在 master 上给追踪投递补了登记; 但登记之后,worker 在提交 ACK 之前发出的 cli_input_backlog 也带上了这个尚未 绑定 runtime 的 execution,被事件网关拒掉,提交 ACK 又清空了投递追踪,队列里 还有输入的 worker 会在下一次 idle 时被延迟休眠收走,排队的消息丢失。 修法: - cli_input_backlog 不再携带 execution scope(队列观测横跨多轮), producer/runtime/binding 校验照留;参考 #3257。 - daemon 丢弃当前 worker 的 managed_turn_origin / managed_turn_origin_revoked 时打 WARN,带会话、turn 和原因;已被替换的 worker 仍是 debug。 - worker-managed-origin-contract 用例里对应断言从 debug 改为这条 WARN。 验证: - 新增 test/ordinary-im-follow-up-turn-origin.test.ts(真实 daemon handler、 SQLite 契约 store、worker 事件 scope 与 IPC send、actor current 与 lark-tool 身份路由,只桩飞书/网络与 tmux 拆除校验)。覆盖:relay 改绑 pid (runtime_identity_changed)后的普通追问轮,身份是该轮发送者;休眠不再误报 未确认;续聊时队列里有一条排队输入,不被提前休眠、伪造 producer 的 backlog 被拒、队列清空后照常休眠;丢弃身份时打 WARN。 #3241 之前的 a1f963f 上 5 条全红;当前 master 上排队输入和 WARN 2 条红 (其余 3 条已由 #3241 修好);加上本改动全绿。只撤回 backlog 那一行时排队 输入用例变红。 - #3257 的 test/lark-followup-authority.test.ts 拷到本地交叉验证:当前 master 上排队输入那条红,加上本改动后 2 条全绿(该文件未提交)。 - 相关 vitest 104 个文件 4420 条通过;bun 腿 5 个文件通过;bun run build(含 typecheck)通过。worker-codex-app-turn-routing.integration 的 12 条超时在 改动前的源码上同样失败,与本改动无关。 - 其它仍未登记 execution 的回合路径(排队激活提升、只读续跑、带 turnId 的 raw_input)另开 #3264;botmux list 的 (missing) 另见 #3261。 hotfix:线上 bug 快速通道 Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
pushed a commit
to superShen0916/botmux
that referenced
this pull request
Nov 9, 2026
deepcoldy
pushed a commit
to superShen0916/botmux
that referenced
this pull request
Nov 9, 2026
同步 master 后,deepcoldy#3241 引入的 current-actor-warm-engine-proof 在合并树上确定性失败 (vitest shard 与 bun-test 双腿同样两个用例)。它的 worker-pool 闭包 harness 在 hostEnv 里没提供 workerGeneration,而本 PR 的 attestation 代守卫把该自由变量与 ds.workerGeneration 比较:缺失时解析为 undefined,7 !== undefined 导致一条带 enginePid 的合法 attestation 被拦截,断言拿不到 engine 身份。 纯 master 单跑该文件 7/7 绿、合并树 2 红,属本 PR 守卫要求的 harness 补注入, 与上一轮 session-contract-gateway 同类。hostEnv 补 workerGeneration: 7,与 ds.workerGeneration 一致,仅改测试、src 零改动。 验证:current-actor vitest 7/7、bun 7/7;合并树相关 18 文件 469/469; find-launched bun 85/85;tsc、build 通过 Co-Authored-By: Claude Fable 5 <[email protected]>
|
@uestcwangci @deepcoldy 合入 master 后的 Midscene E2E 失败:Feishu live Midscene 失败。 这次运行覆盖 157be9c…7c0ad137d(4 个提交),同批合入的还有 #3250 #3251,失败不一定由本 PR 引起。
|
This was referenced Nov 9, 2026
deepcoldy
pushed a commit
that referenced
this pull request
Nov 9, 2026
现象:本机部署 7c0ad13(含 e95f067、#3251、#3241)后,机器人回复发不到 飞书,卡片一直停在「工作中」,冷启动第一轮和热会话追问轮都丢。worker 日志 "Dropped final output with unproven execution origin":origin 停在上一轮的旧 binding(runtime epoch 1),当前 binding 已换到 epoch 2;daemon 侧 managed_turn_origin 以 runtime_scope_missing / stale_runtime_scope 被丢, final_output 被拒只打 debug。 根因:#3241(157be9c88)让 worker 在同一个 CLI 的身份变化时(in-pane relay 解析到真实 CLI pid 替换 launcher pid、resume 后 native session id 变化)在进程 内发布新的 runtime binding,契约 runtime epoch 1→2。但 spawn 时注册的回调 (转写桥、pane 退出、hook)仍挂在旧 binding 上,在途轮次的 execution 也绑在 旧 runtime 上: - daemon 把旧 runtime 上的 final_output / managed_turn_origin 判为历史或 stale,currentAuthority 不成立,回复被静默丢弃; - worker 侧 ownsExecutionEvent 只认同一个 binding,转写桥对重绑后提交的轮次 判为来源不明,本地丢弃; - resume / restart 已确认后再重绑,新 binding 带着已结束的 operationId,被 记成 retiring,daemon 回 mayExecute=false,worker 杀掉 CLI; - launcher→真实 pid 重绑后 CLI 退出,退出事件挂在旧 runtime 上被当成历史 事件忽略,不会自动重启; - CLI 自己发起的轮次(定时任务、后台唤醒)重绑后同样被拒。 e95f067 和 #3251 不是根因。 修法: - worker 重绑时在 runtime_binding 上带 continuesBindingId;daemon 只在前驱 是同一 worker 的当前活跃 runtime 时记录进程内续接(runtime_continuation)。 - 事件网关和 currentAuthority 接受绑定在被续接 runtime 上的 execution 为当前; hook 的 nativeSignal 沿续接链指向当前 runtime。 - worker 事件 scope 把同一物理 CLI(physicalId 相同)的回调认作当前;重新 spawn 的 CLI 物理 id 不同,旧观察者仍然无权。 - 续接时会话没有进行中的控制操作,就丢掉 spawn 时留下的 operationId。 - claude_exit 结束的 runtime 包括它续接出去的 runtime。 - 没有 execution 的轮次上报若来自续接前驱,归到当前 runtime 再登记 execution。 - daemon 拒绝当前 worker 的 final_output 时打 WARN,并在群里发一次「回复没能 发出」提示;会话关闭、挂起、控制操作进行中或静默轮次不提示。 验证: - 新增 test/runtime-rebind-turn-delivery.test.ts(真实 daemon handler、SQLite 契约 store、worker 事件 scope、IPC send 与 runtime 发布,转写桥用 spawn 时 留下的回调):冷启动中途 relay 改绑 pid 后两轮送达、resume 后 native id 变化 两轮送达、热会话追问轮送达、追问轮 actor current verified、spawn 时 hook 指向 当前 runtime、restart 确认后再重绑不杀 CLI、重绑后 CLI 空闲退出按当前 runtime 处理、CLI 自发轮次送达,以及真拒绝时 WARN + 群提示、重启中不提示、重新 spawn 后旧观察者无权。9d202b2ca 上 12 条红 11 条(剩下 1 条是守卫用例),本改动全绿。 - 最终版本:相关 vitest 373 个文件 9264 条通过,仅 mojo-launcher-env-quarantine 2 条 失败(root 跑权限用例的环境问题,master 上同样失败);typecheck、bun run build 通过。 前一版的全量 vitest 18 条失败(9 个文件),维护者已对照 91743e6 确认:16 条在 master 上一样失败(root 跑沙箱/权限类用例),session-preview-proxy 单跑通过(高负载 超时抖动),turn-idle-version-skew 与 master 失败一致。 集成用例需 TMPDIR=/tmp:本会话继承的 TMPDIR 让 tmux socket 路径超长, master 上同样 16 条失败。 - G9(隔离环境,真 Claude Code 2.1.319 + in-pane relay + 私有 tmux + 本地假 Anthropic API,未碰线上 fleet)冷启动和 restart 确认后启动两种模式各跑一次: CLI 在 launcher 下启动,第一轮进行中 relay 解析到真实 pid,契约 runtime 升到 epoch 2;三轮回复都发到群里,第一轮、第二轮 Claude 自己跑的 botmux actor current --json 都是 verified,发送者和 turnId 与当轮一致;restart 操作为 confirmed,CLI 没被杀。 hotfix:线上 bug 快速通道 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🚀 Released in v3.59.0 |
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.
普通飞书消息在存活会话中走投递追踪时绕过执行登记:CLI 已收到输入,但 daemon 拒绝该轮的身份凭据发布和投递回执,随后
actor current/auth request返回current_actor_unverified。Codex App 另有启动重绑定、恢复期就绪与最终回复归属问题,会使话题停留在启动中或生成完成后没有正文回复。本 PR 修复执行登记、启动派发及完成结算链路,不放宽当前用户、进程或执行来源校验。
修改与影响面
普通消息登记属于共享 worker-pool 路径,影响启用 session contract 的各 CLI、话题/群会话及转移后追踪投递;行为回归覆盖 Codex App 与 Claude。Codex 的签名就绪和 observer 入口仅用于 Codex App。保留 PTY/tmux、adopt/remote 的现有边界;没有数据库 schema 或配置格式变更。现场为 Linux;macOS 未做现场验证,无法取得进程证明时仍拒绝。
实际验证
使用 Bun 1.4.4:
bun run build:完整编译、类型检查、资源与构建审计通过;保留既有浏览器补丁的单文件部署版本也完成构建。bun run test -- test/ipc-auth-request.test.ts test/current-actor-warm-engine-proof.test.ts test/worker-codex-app-input-proof.test.ts:3 文件、68 项通过。bun run test -- test/session-contract-gateway.test.ts test/session-contract-recovery.test.ts test/worker-input-delivery-redrive.test.ts test/worker-ipc-preload.test.ts test/worker-topic-output.test.ts test/worker-ordinary-im-receipt-wiring.test.ts:6 文件、174 项通过。bun run test -- test/worker-managed-origin-contract.test.ts:9 项通过。执行真实追踪 sender → command → worker scope/publisher → controller/gateway/SQLite → 绑定 HTTP 授权路由;追踪输入夹具不预先手工 admit。外部 OAuth/飞书传输受控。前期启动/最终回复/observer/身份回归:9 文件248项、4文件87项及10文件249项分别通过;恢复来源、observer、历史正文及签名就绪的守卫变异均被相关行为测试捕获。
合并最新主分支并解决输入循环及 IPC backlog 合并冲突后,
bun run build通过;bun run test -- test/worker-managed-origin-contract.test.ts test/current-actor-warm-engine-proof.test.ts test/worker-codex-app-input-proof.test.ts test/worker-codex-app-final-origin.test.ts test/worker-input-delivery-redrive.test.ts test/worker-topic-output.test.ts test/test-hygiene.test.ts:7 文件、146 项通过。重连补派发与回归补齐提交后:
bun run build通过;bun run test -- test/worker-codex-app-input-proof.test.ts test/codex-app-execution-observer.test.ts test/codex-app-historical-final-delivery.test.ts test/worker-codex-session-upgrade.test.ts test/test-hygiene.test.ts:5 文件、107 项通过;bun test --timeout=180000 ./test/worker-codex-session-upgrade.test.ts ./test/worker-codex-app-input-proof.test.ts:51 项通过。此前该升级测试自带的求值作用域缺少 flushPending 新依赖的isCodexAppCliId,vitest 2 例、bun 13 例报 ReferenceError,已一并补上。含 worker 求值夹具、Codex App 与 session contract 的 52 个测试文件:1128 项通过、4 项跳过。合入最新主分支后无冲突,构建与上述用例同样通过。异常场景与探针证据
execution_scope_missing拒绝,真实绑定授权路由返回403。修复后两种 CLI 的人类来源可发布,收据正确清账,授权接口返回200;准确 OAuth 收件人与原输入一致。现场状态与验证边界
已部署保留现有浏览器修复的单文件版本,仅重启目标机器人的 daemon;其它机器人 daemon PID 未改变,原话题和 native thread 保留。部署后原话题已认证并进入 prompt-ready;随后正常接收新的真人回合。
早先已从飞书读回成功恢复的正文回复。此次授权失败则进一步定位到普通消息缺少 execution,而不是仅凭启动就绪修复就认定授权已恢复。
经明确授权,向原运行时投递了一次只读诊断;该自动输入没有真人发送者,身份及授权仍按边界拒绝,没有伪造 actor 或回退 owner。
2026-11-09 17:56(北京时间),新的真实飞书用户回合已通过身份校验;17:57 修正原请求的表格权限名后,授权请求成功。daemon 于17:57:20记录私聊授权消息投递成功,17:57:33将“授权申请已私聊发送”的正文回复到原话题;通过会话绑定的
lark-cli im +threads-messages-list --no-reactions --as bot --format json独立读回确认。随后又正常接收用户“已授权”的下一条消息。此处确认身份恢复、授权签发及私聊/话题回复成功,不把用户文字当作后续表格写入成功的证明。