Repository navigation
fix(session): 修复普通续聊身份登记并保留排队输入保护 - #3257
Closed
lijason1121 wants to merge 2 commits into
Closed
lijason1121 wants to merge 2 commits into
lijason1121 wants to merge 2 commits into
Conversation
added 2 commits
November 9, 2026 16:44
在投递追踪冻结重试消息前登记 execution,使复用 CLI 的后续回合可以发布当前用户身份。保留首轮初始化路径,并用真实会话账本覆盖首轮、续聊、重复投递和终态撤销。 Co-authored-by: codex
将整个 worker 队列的 backlog 观察与尚未绑定运行时的 execution 解耦,仍保留 producer 和 runtime 校验。覆盖 ACK 清空投递追踪后的延迟暂停、队列清空及旧 worker 迟到事件。 Co-authored-by: codex
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]>
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.
问题与修复
普通 IM 会话在首轮完成后复用同一个 CLI 处理后续消息时,投递追踪直接向 worker 发送消息,绕过了
sendWorkerSessionInput中的 execution 登记。worker 发布本轮用户身份时还没有对应的 execution,导致依赖当前用户身份的受管工具请求被拒绝。sendOrdinaryImDeliveryTracked冻结消息供重试前登记 execution,并放入sessionCommand。重复投递复用同一份消息与 execution,首轮 init 路径保持不变。cli_input_backlog保持为 runtime 观察,去掉无关的 execution scope,仍保留 producer/runtime/binding 校验。否则 queued execution 会让 backlog 被网关拒绝,而随后的 commit ACK 清空投递追踪,导致仍有排队输入的 worker 被回收。影响面
修改 worker-pool 的普通消息投递路径、worker 队列观察事件的元数据,并增加行为回归测试。这些路径由多种 CLI/后端共用;测试执行真实投递函数、worker 身份发布/ACK、事件网关和 SQLite 会话账本,覆盖首轮、复用运行时的续聊、重复投递、接收及终态撤销。身份校验和用户授权要求保持不变,workflow dispatch 等独立投递路径未修改。
验证基线为
a5de3150a,修复提交为74489d6fc。验证
bun run test test/lark-followup-authority.test.ts test/session-contract-gateway.test.ts test/worker-cli-input-backlog.test.ts test/worker-pool-unaccepted-cli-input.test.ts test/worker-ordinary-im-receipt-wiring.test.ts test/worker-ordinary-im-init-concurrency.integration.test.ts:6 个文件、108 项测试通过。bun scripts/fenced-run.ts -- bun test test/lark-followup-authority.test.ts:Bun 下 2/2 通过。git diff --check origin/master...HEAD、bun run build、bun run workflow-core:test、bun run test -- --maxWorkers=8、bun run test:bun;全部通过后才推送并创建本 PR。异常场景与变异验证