Repository navigation
fix(worker): 剥启动层时不计僵尸子进程,修复 tmux + Claude Code 会话 current_execution_unverified - #2380
Merged
Merged
Conversation
…unverified tmux 后端的 Claude Code 会话,CLI 跑在 pane 内的 OSC 7501 relay 和会话 scope 外壳后面, worker 要从 pane 进程往下剥这两层,把进程校验的受信根改成 CLI 本身。pane 的登录 shell 若在后台跑了 rc 钩子(如 autojump)再 exec 成 relay,relay 会多一个永不回收的僵尸子进程; 剥层要求「恰好一个子进程」,于是一直停在 relay,受信根停在 relay。v3.51.0 起 bytedcli 与 lark-cli --as user 都要过进程校验,校验从工具进程往上走先撞到本轮开始前就存在的 CLI 进程, 每一轮都判 current_execution_unverified。 剥层时不再把已退出、未回收的僵尸子进程算作载荷(relay 层与 scope 外壳层同一口径)。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 26, 2026 11:42
find-launched-cli-pid 的合成探针表只注入了 readCmdline/childrenOf/commOf/ scopePayloadOf,isZombie 落到 DEFAULT_PROBES 读真实 /proc:合成用的低 pid (150 等)在本机恰好存在且为存活态所以不红,换宿主/容器若该 pid 为僵尸会 假红。补一行 () => false(合成表不建模僵尸),恒真变异下 14 个 relay 用例双引擎变红,证明接线在真实 walk 路径上。 Co-Authored-By: Claude Code <[email protected]>
Owner
Author
|
🚀 Released in v3.53.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.
背景
有用户反馈:tmux 后端的 Claude Code 会话里,
bytedcli和lark-cli --as user每一轮都报botmux: current_execution_unverified(exit 77)。重新授权、重新 @ 都不管用。中心化平台显示凭据已发放成功,问题出在凭据发放之前的进程校验。根因(现场与代码一致)
program-status relay → 会话 scope 外壳(sh)→ claude。worker 起来后要把这两层剥掉,把进程校验的受信根从 relay 改成 claude 本身。剥成时日志会有一行「program-status-relay → session-scope: resolved real CLI pid …」。stty不算)。现场 relay 下挂着两个子进程:autojump:pane 的登录 shell 在后台跑了 rc 钩子,随后 exec 成了 relay;relay 不认识这个子进程、永远不回收,它就一直是僵尸。bytedcli走按轮次的执行身份路由,lark-cli --as user也要先过进程校验。校验从工具进程往上找受信根,到达 relay 之前先经过 claude 进程。claude 在本轮开始前就已存在,且不是 Codex 原生工具宿主,按规则拒绝。所以这类会话每一轮都是current_execution_unverified。本机同形态的会话(relay → scope sh → claude,relay 下没有僵尸进程)0.7 秒内就剥成,校验正常,这也解释了为什么只有部分机器、部分用户遇到。
改了什么
src/core/session-scope.ts:新增isZombieProcess(pid),读/proc/<pid>/stat的状态字段。Z或X视为已退出;非 Linux 或读不到时视为「不是」,行为与改前一致。sessionScopePayloadPid数 scope 外壳的子进程时不计僵尸。src/core/launch-layers.ts:relay 层数子进程时同样不计僵尸(与stty并列排除),并把它做成可注入的isZombie探针。僵尸进程已经退出,不可能是 CLI,不计它不会把别的进程错认成载荷。「两个都活着的子进程」仍然停下,有用例钉住。
影响面
bytedcli/lark-cli --as user/botmux的当前执行证明恢复正常;验证
新增用例:
test/launch-layers.test.ts(合成 /proc):test/launch-layers-real-proc.test.ts(真实 Linux 进程树,复现现场形状):sh -c 'true & exec <relay 形状的进程>',relay 继承了一个未回收的子进程,剥层得到['program-status-relay'],载荷是 relay 真正的子进程。只杀测试自己的进程组。变异:3/3 变红。
第二轮
c88680bef:find-launched-cli-pid的合成进程表补齐isZombie探针,避免默认探针读宿主真实 /proc。2d183b6e1:真实进程树用例改为用脚本文件起 pane shell,不再sh -c带路径参数(CodeQL 对此报了一条测试里的误报,检查本身是 pass)。用例仍在修复下通过、去掉修复时变红。Follow-up(不在本 PR)
🤖 Generated with Claude Code