Repository navigation
Conversation
deepcoldy
left a comment
There was a problem hiding this comment.
审查结论(head d043041eb947a9942147d7f2d65e24b745a7cc0c):有 1 个 P1 阻断项,当前不建议合并。
P1:tokened raw 冷启动熔断后,普通新消息无法触发恢复,输入会持续积压在 activation tail
src/core/worker-pool.ts:23731-23755只在prompt_ready后下发 daemon 保存的pendingRawInput。因此 raw opening 在启动阶段连续退出时,queuedActivationPending/initialStartPending仍在等待queued_activation_submitted,raw activation 尚未提交。src/core/worker-pool.ts:25622熔断后保留同一个轻量 worker;但src/daemon.ts:31590-31675对 activation gate 仍存在的 live worker,会把下一条普通消息追加到 durable tail 后直接返回:既不向 worker 发消息,也不 refork。由于 CLI 已停、不会再产生prompt_ready/ activation ACK,卡片所称“发新消息可重新启动”在这条支持路径上不成立,后续普通消息会继续排队。- 若 tokened raw 已进入 worker 队列,
src/worker.ts:18184-18185又直接清空pendingRawInputs,没有发出queued_activation_submitted;修复时需要同时覆盖这个变体。
探针证据(最新 head 可复现):用真实 handleNewTopic 走现有 no-project raw fallback,创建 /goal OPENING_RAW_N,路由真实产生 tokened activation gate;叠加 parkCrashDiagnosticWorker(..., failPending=true) 的后置状态并保留同一 live worker,再用真实 handleThreadReply 发送恢复消息。结果为:
workerMessages=0, reforks=0,
initialStartPending=true, activationPending=true,
pendingRawInput="/goal OPENING_RAW_N",
tail=["om_startup_circuit_raw_recovery"]
期望下一条消息至少产生一次恢复 IPC 或 refork 的断言失败(实际为 0)。临时探针已撤销,工作树干净。
建议:熔断时若 pendingRawInput / activation gate 存在,不要保留一个永远无法取得 ACK 的路由所有权;可交给既有 worker-exit + exact activation refork 对账,或显式结算、重排队 activation 并保证下一条消息能够触发重启。请补充 raw cold-start + queued activation 的熔断回归;当前 argv opening 集成测试覆盖不到这条路径。
其余重点复核
网关豁免仍保留 runtime producer、worker channel、execution 引用以及历史 replacement 围栏;restart epoch 的 jitter、teardown、plugin/RPC、spawn、title 交叠和 ordinary 输入终态测试均通过,未另发现阻断项。
实际验证
- 最新 head
bun run build:通过。 - 网关 / epoch / 输入终态等 6 个测试文件:232 项通过。
- 最新新增生命周期与真实 worker + 私有 tmux + SQLite 集成等 3 个测试文件:32 项通过。
- 现有 no-project raw activation 路由基线:通过。
- 上述新增路由探针:按预期咬红,证明本发现;不是仓库既有测试失败。
- 截至本结论发布时,最新 head 的 CI 仍在运行,未将未完成项计为通过。
|
你好,感谢这个 MR!启动闪退的死锁定位得很准,网关准入、熔断预算、卡片安全文案三块的方向我认同。下面第 1 轮的结论里 1 条 P1 是 reviewer deepcoldy 的 review 正文意见,我们独立复核后确认成立并采纳。 第 1 轮评审 · 提交 初衷对齐:对齐
结论:2 条阻断 / 1 条不阻断(建议补),合前需要改。 合前需要改 / 建议补
可后续、不阻断
验证情况(评审侧)
合入门槛:未满足(作者处理)
基线:目标分支 更新记录
以上为自动评审的初步意见,最终以维护者审阅为准。 |
|
感谢指出 这条评审意见 中的 raw activation 恢复死锁,已补齐两处所有权边界:
另修正了「任务已交付、空闲后 CLI 非零退出」被误降级为需要你的问题,保留 attention 原优先级;跨 runtime claude_exit 仅增加边界回归,未改变准入条件。 修复提交: 实际验证:
完整命令与影响范围已补入 PR 描述,感谢对恢复所有权边界的提醒。 |
- 在 activation journal 中持久化 raw 文本与 turnId,restore/activate 精确恢复 immediate raw - parent-exit 在首个 RPC await 前取消旧 restart continuation,避免退休期间重新 spawn - 同步 pre-observer 安全 IPC 的旧测试断言,完整诊断仅保留在本机日志 Co-Authored-By: Claude Code <[email protected]>
|
P1 修复与追加边界已推送到作者分支,最新 head:
独立对抗复验:generic pre-ACK raw/turnId 均恢复且 eager fork 保持空 init;deferred title × RPC-stop 保持 实际验证:build 通过;activation adversarial 20 项、完整生产路由 220 项、circuit/gateway/hygiene 294 项、restore/activate/session-store 245 项、真实 worker 集成 2 项全部通过。Bun 下 circuit/shutdown 64 项、RPC + activation adversarial 23 项通过。旧 CI 失败的 sandbox 定向 4 用例通过;vitest 整文件 59 通过、2 跳过;Bun 整文件同为 59 通过、2 跳过、0 断言失败,但其 fenced 清理因两个私有测试 tmux 当时未退出而以 1 结束,随后已确认进程退出、socket 目录消失。 请在新 head 上复核。 |
retainQueuedActivationRawInput 原有测试只直接调 helper,删除 forkWorkerPrepared 里的生产调用点仍全绿,daemon 重启恢复 immediate raw 的守卫实际未被钉住。 新增用例驱动真实 forkWorker(仅 mock 子进程传输)并回读 SQLite 行, 配无 pendingRawInput 的负向对照;变异删除生产调用点时该用例咬红。 Co-Authored-By: Claude Fable 5 <[email protected]>
|
在最新 head(9ebb0982e5)上复核通过,无遗留阻断项。 此前阻断项核实:tokened raw 冷启动熔断后 activation gate 悬挂、恢复消息只进 tail 不触发重启的问题,已用真实路由探针独立复现(workerMessages=0、reforks=0、两个 gate 保持 true);当前 head 上同一探针转绿,恢复消息先持久进入 activation tail 再经 restart coordinator 唤醒 parked worker,ACK gate 不提前释放;in-flight 未 ACK 的 tokened 开场走 worker 退出 + exact activation journal 对账,不盲目重放。 本轮复核要点:
补充测试:发现 raw journal 的生产写入点(forkWorkerPrepared 内)缺少接线测试——已有用例直接调 helper,删除该生产调用点仍全绿。新增 test/queued-activation-raw-journal.test.ts 驱动真实 forkWorker 并回读 SQLite 行(含负向对照),变异删除生产调用点时该用例咬红。 本地验证:build 通过;vitest 定向 22 个文件 880+ 项全绿(含真实 worker + 私有 tmux + SQLite 集成 61 项);Bun 腿相关文件全绿;4 处修复守卫与 1 处新接线的变异复验均咬红后还原。CI 以当前 head 首跑结果为准。 这是自动评审的初步意见,最终以维护者审阅为准。 |
deepcoldy
left a comment
There was a problem hiding this comment.
复审结论(head 9ebb0982e52a451f230ff31dfb40686cb6a6bf1a):无阻断项,建议可合;G4 仍需等待 CI 全绿。
- 增量仅
test/queued-activation-raw-journal.test.ts,没有生产代码变化。 - 测试调用真实
forkWorker,只 mockspawnWorker子进程传输,确实经过forkWorkerPrepared的生产调用点,而不是直接调用retainQueuedActivationRawInputhelper。 - 正向用例回读 SQLite fresh row,精确断言
queuedActivationRawInput/queuedActivationRawTurnId落盘;无pendingRawInput的负向对照保持字段为空,且 activation 本身仍 pending,覆盖有效。
独立验证
bun run build:通过。- vitest:2/2 通过;Bun:2/2 通过;test-hygiene:28/28 通过。
- 独立删除
forkWorkerPrepared内实际 retain 调用:正向用例在test/queued-activation-raw-journal.test.ts:102因持久字段为undefined咬红,负向用例照常通过,复现为 1 红 1 绿。已还原并复跑 2/2 通过,工作树干净。 - 当前 CI 尚未全部完成,未将未完成项计为通过。
|
G7 合并树复核结论:认可按 #109 的非相邻豁免合入;G4 仍等待首跑 CI 全绿。 背书范围仅限当前输入:
如果合码瞬间 master tip 再前进,需要重新计算预测树并复测,不能沿用本次背书。此结论不代替 G4 的 CI 要求。 |
|
G7 重新背书:认可按 #109 的非相邻豁免合入;本次同时确认 G4 已满足(当前 PR head 首跑 15/15 全绿)。 范围:
若 master tip 再前进,仍需重新计算 tree 并复测;本背书只对上述 tip 生效。 |
|
@haozhenfei @deepcoldy 合入 master 后的 Midscene E2E 失败:Feishu live Midscene 失败。 这次运行覆盖 0d3e6e5…3d0de8711(7 个提交),同批合入的还有 #3764 #3762 #3758 #3778 #3765 #3763,失败不一定由本 PR 引起。
|
|
🚀 Released in v3.59.32 |
改了什么
托管命令行工具启动后立即异常退出时,会话不再永久卡在“启动中”或“工作中”。连续两次启动失败会停止自动重启、结束普通待处理输入,并在原卡片上显示安全的退出码说明;若进程在退出监听建立前就已死亡,则直接报告失败,修复安装或配置后在同一话题发新消息即可重新尝试;尚未确认提交的开场命令仍按原顺序恢复,不会被新消息越过。状态查询沿用现有版本字段,如实显示中断及原因;正常慢启动、已有重启恢复方式和卡片按钮语义保持不变。无需迁移配置或数据,无特殊合并要求。
为什么
首条任务直接放进启动参数时,进程可能在写出第一条执行记录前就退出。之前,事件网关错误地要求“任务已经绑定执行实例”才能接收物理退出;桥接进程已经失去底层程序,而管理端没有接到可执行的重启事件,后续消息只能不断排队。
影响范围是本地托管会话共用的退出、重启与状态展示路径。已有外部会话的接管、远端后端、共享终端服务故障恢复仍由原逻辑处理。熔断仅在实际非零退出后判定,不会因初始化耗时而杀死仍在运行的程序。
验证
以下为真实卡片数据的离线示意,非飞书客户端截图:
风险与回退
默认只给启动失败一次自动重试,修复前反复退出的任务会更快需要人工介入。未知副作用的持久投递继续由原有回执对账,不在桥接进程里偷偷重放;自动重试不会消耗用户下一次明确输入的尝试预算。回退本次提交可恢复原行为,没有新增数据库格式或破坏状态查询契约。
实现与追溯
docs/design/2026-11-24-cli-startup-failure.md。test/session-contract-gateway.test.ts中的 argv opening startup-exit 用例,修改前红、修改后绿。bun run test test/hc-worker-wiring.test.ts test/cli-startup-circuit.integration.test.ts,20 项通过;后续补充监听器安装前退出的覆盖,最终定向结果见下。bun run test test/restart-paths-worker-ready.test.ts test/post-terminal-status-settle.test.ts test/test-hygiene.test.ts,143 项通过。bun run build,使用本地隔离的 Bun 1.4.4,含类型检查和构建审计,通过;未改变机器上的默认运行时。bun run test test/cli-startup-circuit-policy.test.ts test/cli-startup-circuit-stop.test.ts test/cli-startup-failure.test.ts test/cli-startup-card.test.ts test/session-observe.test.ts,101 项通过;Bun 腿逐文件执行同一批测试,101 项通过。bun run test,60,274 项通过、13 项失败、243 项跳过(3,045 个文件通过、4 个失败、22 个跳过)。全量期间重建产物及修改源码造成的 whiteboard/Traex 失败与 tmux 计时失败,稳定源码和构建后分别复跑 12、2、1 项均通过。此历史全量结果不代表最后提交全套通过。test/hc-screen-mirror-tmux-parity.test.ts的 dim suggestion/inverse cursor 和行内带色擦除两项;当前改动与未修改基线4c32e2be5均是 13 项通过、同样两项失败,未扩大本次修复去修改无关渲染逻辑。bun run test test/cli-startup-circuit.integration.test.ts test/startup-failure-reason.test.ts test/tmux-legacy-pipe-guard.test.ts test/tmux-pipe-backend.test.ts test/crash-loop-diagnostic.test.ts test/worker-startup-suppress-recovery.test.ts test/worker-startup-retry-wiring.test.ts --maxWorkers=2,255 项通过、1 项跳过(要求真实 tmux 2.8)。bun run test test/cli-startup-circuit-policy.test.ts test/cli-startup-circuit-stop.test.ts test/cli-startup-failure.test.ts test/cli-startup-card.test.ts test/session-observe.test.ts test/session-contract-gateway.test.ts --maxWorkers=2,232 项通过。bun scripts/fenced-run.ts -- ...。未触碰在线会话或运行目录。补充验证(提交
e7d5b65b3、e315c539f):bun run build:通过,包含类型检查与构建审计。bun run test test/daemon-rename-route.test.ts test/session-contract-gateway.test.ts test/session-task-status.test.ts test/session-observe.test.ts test/cli-startup-circuit-stop.test.ts test/cli-startup-activation-adversarial.test.ts test/cli-startup-circuit-policy.test.ts test/cli-startup-failure.test.ts test/cli-startup-card.test.ts test/cli-startup-circuit.integration.test.ts test/crash-loop-diagnostic.test.ts test/startup-failure-reason.test.ts test/worker-startup-suppress-recovery.test.ts test/worker-startup-retry-wiring.test.ts test/restart-paths-worker-ready.test.ts test/queued-activation-receipts.test.ts test/raw-input-framed-lifecycle.test.ts test/post-terminal-status-settle.test.ts test/test-hygiene.test.ts --maxWorkers=2:19 个文件、716 项通过。bun test test/cli-startup-circuit-stop.test.ts、bun test test/cli-startup-activation-adversarial.test.ts、bun test test/session-task-status.test.ts、bun test test/session-observe.test.ts:逐文件分别 39、20、40、42 项通过,共 141 项。bun scripts/fenced-run.ts -- ...运行,固定 Bun 1.4.4,私有短临时目录。补充实现与回归:
admitQueuedActivationTail在后继落盘成功后唤醒熔断会话,沿用现有 restart coordinator;不清 activation gate、不伪造提交确认。stopStartupFailedInputs保留未写入的 tokened raw/开场输入。已经进入 carry-over 且提交结果尚未返回时,结束该 worker 交既有精确 journal 对账,不在原进程盲目重放。session-task-status只为无有效 delivered 结果的运行中断分支增加「需要你」,attention 优先级不变;observe v1 字段与卡片按钮语义不变。test/cli-startup-activation-adversarial.test.ts。异常场景与修法:
追加修复:raw activation 跨重启恢复与退出围栏
在
e315c539保留 tokened activation、后继先落 durable tail 再唤醒原 worker 的方案之上,补齐两个独立的持久状态边界,不改写该方案的路由语义:forkWorker创建 tokened raw activation 时,在同一持久化序列调用retainQueuedActivationRawInput保存 literal raw 与 turnId(optional 字段,ACK 时随 journal 清理)。snapshot/rollback/clear 同步覆盖;restoreActiveSessions和activateQueuedSession使用同一pending-repo-journal工具重建pendingRawInput,immediate raw 没有pendingRepoSetup也不会被空 opening 顶替。新增字段向后兼容,无需迁移。cliRestartEpoch、结算取消回调并清理 restart timer。deferred title 与 deferred RPC-stop 交叠时,旧 replacement continuation 不能在退休期间重新 spawn,避免形成第二个重放所有者。对抗复核发现与修法
pendingRepoSetup;restore 后pendingRawInput=undefined,activate 以{content:""}fork,原/goal被空 opening 取代。spawnCalls=2;普通 park/stop 能取消。另复核了 tokened raw 的 ordinary tail 持久化与唤醒、并发到达合并、写入已在飞/ACK 在途、普通非 raw 会话及关闭/暂停中的生命周期围栏。最终定点复核确认:
queued:false + pending:true + 无 pendingRepoSetup时 raw/turnId 均恢复且 eager recovery 保持空 init;deferred title × RPC-stop 保持spawnCalls=1;reactivateClosedSession等清理点同步覆盖新 raw 字段,未再发现新问题。本次追加验证
bun run build:通过。test/cli-startup-activation-adversarial.test.ts:20 项通过,覆盖 tail 先落盘再唤醒、持久化/IPC 失败、控制操作交叠与 worker raw ACK。test/daemon-rename-route.test.ts:220 项通过;包含 startup-circuited raw activation 在后续输入到达时重启,同时保持原 ACK gate。queued:true的 exact activate、queued:false + pending:true首次 pre-ACK eager restore,以及reactivateClosedSession清理。bun-test (3/4)暴露 3 条 pre-observer fatal IPC 旧断言仍要求终端原文;已改为“IPC 只有安全退出码、完整诊断只留本机日志”。原失败定向 4 用例通过;vitest 整文件 59 通过、2 跳过;Bun 整文件同为 59 通过、2 跳过、0 断言失败,但其 fenced 清理因两个私有测试 tmux 当时未退出而以 1 结束,随后已确认进程退出、socket 目录消失。🤖 Generated with Claude Code