Repository navigation
Conversation
xushulong-solo
requested review from
47seek,
LucasIcarus,
deepcoldy,
xiaoxueSunn and
xiongz-c
as code owners
November 12, 2026 13:41
- 新一代 worker 先绑定外层启动器过渡 epoch、随后解包出与重启前存活 CLI 拥有相同 physicalId(pid:procStart) 和 nativeSessionId 的叶子进程时,精确恢复仍在运行的历史 RuntimeRef 并衔接 reconciling 执行记录 - 新增 readCodexLiveSessionId 校验首行 session_meta 头并剔除子代理 rollout,在多 rollout 句柄并存时唯一识别顶层用户会话,启动器延迟解包后补调 refreshActiveRuntimeContract - WorkerSessionEventScope 记录同进程物理延续组,并在本地回合权威与 relay capability 仍活跃时于 runtime_contract_assigned 后安全重发带执行契约的 managed_turn_origin - 补充单元、对抗交叠(本地释放后延迟 IPC 闭合)与真实 tmux 重接集成回归测试
xushulong-solo
force-pushed
the
fix/restart-reattach-report-continuity
branch
from
November 12, 2026 13:56
99bf155 to
4ee056b
Compare
Contributor
Author
|
已追加提交(
本地相关 |
- runtime_contract_assigned 重签:逐项钉住回合已退休、能力属于别的回合或派发、 本地回合权威已换、宿主判 runtime 退役、分配的是同进程旧绑定、执行已结算时都不重签 - 真实 worker 发布链路 + 真实 daemon 处理:执行挂在旧启动器 runtime、重启后恢复叶子 runtime 时,managed_turn_origin 以恢复后的叶子 runtime 重签并被宿主接受,重复分配不再轮换能力 - refreshActiveRuntimeContract:首次身份前、身份不变、不透明观测、别的进程的回调都不重报, 启动器解包到叶子时重报 - 启动器链恢复:外层启动器上有新开回合时不抛错也不恢复旧叶子;同 worker 中间绑定过 链外的其它进程时拒绝恢复 - Codex 头校验识别:子代理 rollout 同开时取唯一顶层会话,进程不持有的 id 不采纳; codex-app 恢复路径同理 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Owner
|
感谢贡献,已 squash 合入 master。 这个修复补齐了 worker 重启重接与同进程多跳身份延续下的回合归属链路:按内核进程身份(pid + 启动时间)与原生会话 ID 精确恢复仍在运行的历史 runtime,并在重接后安全重签 managed_turn_origin,使 合入前评审中记录的几个非阻断 follow-up(不影响本次合入,供后续迭代参考):
以上为自动评审的初步意见,最终以维护者审阅为准。 |
This was referenced Nov 12, 2026
|
@xushulong-solo @deepcoldy 合入 master 后的 Midscene E2E 失败:Feishu live Midscene 失败。 这次运行覆盖 c69af10…d3ef976c0(2 个提交)。
|
|
🚀 Released in v3.59.8 |
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+session-scope包装器下的 CLI 子进程)正在执行长回合时,若守护进程重启并换上新一代 worker 重接同一存活 CLI 进程,或同一 worker 在启动解包/原生会话延迟发现期间经历多跳运行时绑定延续(epoch 1 -> 2 -> 3),当前运行回合会出现归属断裂,表现为:turn_provenance_stale):重接后新 worker 虽然从存活 CLI 的 PID marker 恢复了currentBotmuxTurnId,但首次重接先绑定了外层session-scope启动器(无nativeSessionId)分配了过渡runtimeepoch;随后解包出真实子进程并识别nativeSessionId时,SessionContractStore.bindRuntime()只比对当前state.runtime(即刚生成的过渡启动器 epoch),未能识别它与重启前已持久化且仍在协调同一running执行记录的原存活运行时拥有相同的physicalId(pid:procStart)与nativeSessionId,因而分配了全新 epoch 而未恢复原运行时,也未在runtime_contract_assigned下发observedExecutions后重新签发带有效sessionContract的managed_turn_origin,导致session.liveOrigin缺失,botmux report --status completed被turn_provenance_stale拒绝。findCodexRolloutSetByPid因size > 1直接放弃识别,导致重接时nativeSessionId为空,无法完成运行时身份对齐。execution_scope_unproven):重接或同进程多跳延续(epoch 1 -> 2 -> 3)后,WorkerSessionEventScope与SessionEventGateway在校验managed_turn_origin、final_output、turn_terminal时未能沿已证明同进程延续链或受授权的reconciling观察者承认该运行中回合,导致零注入(promptInjection: 'none')自动回传也被丢弃。修复方案与安全边界
src/services/session-contract-store.ts、src/core/session-controller.ts)continuesBindingId指向该过渡绑定)时,若会话中存在处于活跃阶段(admitted/dispatched/running)的历史运行时满足:backend相同;proof === 'process_start'且physicalId(含内核启动时间戳pid:procStart)完全一致;nativeSessionId非空且完全一致;则直接恢复原存活
RuntimeRef并将该执行记录从reconciling恢复为当前可继续完成状态。epoch 1 -> 2 -> 3)下活跃执行记录的runtime推进与authorizeExecutionObserver对原地补齐nativeSessionId后观察者的授权判定。session_meta头校验识别唯一顶层 Codex 会话(src/services/codex-transcript.ts、src/worker.ts)readCodexLiveSessionId(pid)/selectCodexLiveSessionIdFromPaths(paths):只读取已完整刷盘(以\n结尾)的首行session_meta,校验payload.id与文件名 UUID 一致,剔除明确带子代理溯源(thread_source: 'subagent'、parent_thread_id、source.subagent)的 rollout;仅当剩余顶层用户 rollout 唯一时返回该会话 ID,存在多个顶层用户 rollout(如/new切换瞬间)或首行未刷盘完时严格返回undefined。spawnCliBody各条启动器延迟解包出真实子进程 PID 的路径补调refreshActiveRuntimeContract(),确保解包后立即上报叶子进程合约。managed_turn_origin(src/services/session-event-scope.ts、src/core/session-event-gateway.ts、src/worker.ts)WorkerSessionEventScope记录同进程physicalId延续组,并在收到runtime_contract_assigned的executions/observedExecutions后,仅当本地回合权威与sandboxRelayCapability均仍处于未撤销活跃态时,按匹配的(originBinding, resumedExecution)重新发布一次managed_turn_origin,恢复重接后的botmux report/botmux send能力。physicalId包含内核进程启动标识procStart;同 PID 但procStart变化的进程被拒绝恢复(返回execution_scope_unproven)。/new新会话串入旧回合:nativeSessionId不一致或多顶层 rollout 并存时拒绝恢复原运行时。runtime_producer_unproven拒绝。/stop/ 回合结束后延迟 IPC 复活僵尸凭证:一旦本地调用releaseActiveTurnAuthority、revokeManagedTurnOriginForRestart或backend.onExit清空sandboxRelayCapability,后续延迟到达的runtime_contract_assigned绝不再重发managed_turn_origin。影响面评估
readCodexLiveSessionId依赖/proc/<pid>/fd时在无/proc环境(如 macOS 或受限容器)捕获异常安全返回undefined,回退至既有单文件 / 桥队列证明路径,不引入跨平台回归。session-scope/wrapperCli两层启动器托管的tmux、pty、zellij、zmx后端。promptInjection: 'none'、显式botmux report与零注入final_output自动回报)及普通群聊/话题会话。测试与验证
src/改动后在基线运行新增单元与真实tmux重接集成测试,确认在未修复代码上稳定复现失败(退出码1),恢复改动后全部通过。ActiveTurnAuthority释放或sandboxRelayCapability撤销后收到滞后的runtime_contract_assigned(快照仍为running),验证不会复活managed_turn_origin。session_meta.id不符:全部闭合返回拒绝或undefined。tmux持久面板下父 rollout 与 2 个子代理 rollout 同时打开、回合中途杀掉旧 worker 启动新 worker 重接:端到端验证复用原RuntimeRef、恢复managedTurnOrigin并投递零注入最终输出。bun run test -- test/restart-reattach-report-continuity.test.ts test/restart-reattach-report-continuity.integration.test.ts test/session-contract-recovery.test.ts test/restored-observer-grant-release.test.ts test/session-contract-gateway.test.ts test/test-hygiene.test.ts:6 个文件 191 项测试全部通过bun run typecheck:通过bun run build:通过(含audit:domains、audit-dist、audit-embedded-assets)