给 app-server 关闭原因加可观测日志并定位 DirectProject 收尾 Killer
Project CI / AI game creator shell Rust crates (push) Successful in 1m40s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m10s
Project CI / Backend tests (push) Successful in 4m34s
Project CI / Frontend tests (push) Successful in 2m16s
Project CI / Native shell tests (push) Successful in 6m50s
Project CI / AI game creator shell Rust lane 2/2 (push) Successful in 9m10s
Project CI / AI game creator shell Rust lane 1/2 (push) Successful in 9m31s
Project CI / Repository checks (push) Successful in 2m28s
Project CI / AI game creator shell web tests (push) Has been cancelled
Project CI / AI game creator shell Rust crates (push) Successful in 1m40s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m10s
Project CI / Backend tests (push) Successful in 4m34s
Project CI / Frontend tests (push) Successful in 2m16s
Project CI / Native shell tests (push) Successful in 6m50s
Project CI / AI game creator shell Rust lane 2/2 (push) Successful in 9m10s
Project CI / AI game creator shell Rust lane 1/2 (push) Successful in 9m31s
Project CI / Repository checks (push) Successful in 2m28s
Project CI / AI game creator shell web tests (push) Has been cancelled
- codex_app_server:shutdown_game_creator_codex_app_server_inner 在 GENARRATIVE_AGC_DIRECT_DEBUG=1 下打印关闭原因,避免以后再靠插桩区分「宿主收尾」与「通道自己断了」 - 用该日志定位到:夹具里是宿主自己的 shutdown_and_report(execution.rs:938,reason=宿主执行预算或交付收尾)先置 closed 再关 app-server,关进程给在途回合发 TransportClosed,于是 CLI 回合拿到「连接断开」、账本落 interrupted - 记录修复方向(宿主主动收尾时先交付结果、不向该回合发 TransportClosed)与影响面(CLI / 单回合宿主,GUI 常驻不走这条路) - DirectProject 里程碑与 pitfalls 同步:四层排除结论 + Killer 定位;两条运行时验收继续未勾选
This commit is contained in:
@@ -81,4 +81,4 @@ AGC 项目开发对话的显示与恢复只依赖两项输入:**项目对话
|
||||
- **缺陷**:全新项目的第一次对话直接失败。夹具 `--cases completed` 下 AGC 进程 4 秒退出、`requests=[]`,stderr 只有 `Codex app-server JSON-RPC 失败:items must not be empty`。根因是 `thread_created` 时无条件发 `thread/inject_items`,而空项目没有 `.agent/conversations/project.jsonl`,载荷成了 `items: []`;codex app-server 0.155.1 起把空数组当协议错误。GUI 路径没暴露是因为前端会先写用户消息,CLI / 无前端宿主是裸的。
|
||||
- **修复**:`build_direct_project_history_injection_params()` 在历史为空时返回 `Ok(None)`,调用方跳过注入;新增单测「空历史不得构造载荷」「有历史仍构造 1 条」。`cargo test … direct_project_history_wire`(3 passed)与 `cargo fmt --check` 通过。
|
||||
- **复验**:同一条命令下夹具从「4 秒失败」变成「走到 loopback Provider:`requests=3`、`markers.ready=true`、AGC exit=0」,说明第一层已经修通。
|
||||
- **仍未完成(第二层)**:修好第一层后,夹具的**全部 6 个用例**都走到 loopback Provider(`requests=3`、`markers.ready=true`、exit=0),但统一失败在账本阶段——`phase=interrupted`(期望 `completed`/`exhausted`),stderr 为 `agent.runner.failed: Codex app-server 连接终止 … stderrBytes=1242`,CLI 回执是「执行通道已断开,不能自动重放未确认操作」。本轮用插桩排除三层:① 不是 codex 版本漂移(换 0.147.0 结果相同);② 不是 stdin 被忽略(改 `pipe` 结果相同);③ 不是 `Drop for ExecutionBinding` 的补刀(插桩后一次都没打印);④ app-server 也不是崩溃(打印出来的 1242 字节全是 ProgramData/模型元数据/PowerShell shell snapshot 之类 WARN,没有 panic/error)。结论:现象是「app-server 被宿主优雅关掉,回合收尾却按连接断开处理」,下一步插桩点应在宿主侧关闭 stdin / kill 子进程的代码(`shutdown_game_creator_codex_app_servers`、prefetch 收尾、runner 生命周期)。**两条运行时验收本质上要真实客户端窗口**(夹具只能证历史持久化,证不了「界面不显示忙碌态」),因此继续未勾选;插桩代码已全部回滚。
|
||||
- **仍未完成(第二层)——已定位到 Killer**:修好第一层后夹具的**全部 6 个用例**都走到 loopback Provider(`requests=3`、`markers.ready=true`、exit=0),但统一失败在账本阶段(`phase=interrupted`,期望 `completed`/`exhausted`;CLI 回执是「执行通道已断开,不能自动重放未确认操作」)。排查结论:① 不是 codex 版本漂移(换 0.147.0 相同);② 不是 stdin 被忽略(改 `pipe` 相同);③ 不是 `Drop for ExecutionBinding`(插桩后一次没打印);④ app-server 不是崩溃(1242 字节 stderr 全是 ProgramData/模型元数据/PowerShell snapshot 之类 WARN);⑤ **是宿主自己关的**——关闭原因日志显示 `reason=宿主执行预算或交付收尾`,来自 `codex_app_server/execution.rs:938` 的 `shutdown_and_report()`:它先置 `closed` 再关 app-server,而关进程会给在途回合通道发 `TransportClosed`,于是等待中的 CLI 回合拿到"连接断开"、账本落 `interrupted`。修复方向:宿主主动收尾时先交付回合结果、不向该回合发 `TransportClosed`(GUI 常驻 app-server,不走这条路径,影响面是 CLI / 单回合宿主与依赖它的夹具)。**两条运行时验收本质上要真实客户端窗口**(夹具只能证历史持久化,证不了「界面不显示忙碌态」),因此继续未勾选;除关闭原因日志(留在 `GENARRATIVE_AGC_DIRECT_DEBUG=1` 下)外,临时插桩已全部回滚。
|
||||
|
||||
@@ -6113,5 +6113,8 @@ Cocos Creator 根目录由 `package.json.creator.version` 与普通 `assets/`
|
||||
- **根因**:`codex_app_server/mod.rs` 在 `thread_created` 时无条件调用 `thread/inject_items`,载荷由 `build_direct_project_history_injection_params()` 从 `.agent/conversations/project.jsonl` 构造;**全新项目该文件不存在 → `items: []`**,而 codex app-server 0.155.1 起把空数组当协议错误拒绝。GUI 路径之所以没暴露:前端会先调 `append_direct_project_conversation_message` 把用户消息写进历史,注入时至少有 1 条;`--direct-codex-chat` 这类无前端宿主(以及任何直接调用 `run_direct_game_creator_turn_at` 的夹具/CLI)没有这一步。
|
||||
- **处理(2026-09-28 已修)**:`build_direct_project_history_injection_params()` 在历史为空时返回 `Ok(None)`,调用方跳过 `thread/inject_items`;新增两条单测(空历史不得构造载荷、有历史仍构造 1 条)。
|
||||
- **复验**:同一条夹具命令下,AGC 进程从「4 秒失败、`requests=[]`」变成「走到 loopback Provider、`requests=3`、`markers.ready=true`、exit=0」——第一层缺陷确实修掉了。
|
||||
- **仍未解决(第二层,另一个问题)**:同一个夹具的全部 6 个用例(`completed/passes/mcp/mcp-write/native/deadline`)在修好第一层后都走到 loopback Provider,但**统一**失败在账本阶段:`phase=interrupted`(期望 `completed`/`exhausted`),stderr 为 `agent.runner.failed: Codex app-server 连接终止 … exitStatus=unknown;stderrBytes=1242`,CLI 回执文本为「执行通道已断开,不能自动重放未确认操作」。已排除:① 不是 codex 版本漂移(换成 0.147.0 结果相同);② 不是 stdin 被忽略(`stdio[0]` 改 `pipe` 结果相同);③ **不是 `Drop for ExecutionBinding`**——在该分支插桩(打印 phase/background_done/closed)后一次都没打印,说明账本 `interrupted` 不是它补的 `cancel_from_host()`;④ **app-server 也不是崩溃退出**——临时把 stderr 分段原文打印出来后,1242 字节全是良性告警:`Failed to resolve ProgramData known folder … HRESULT 0x80070003`、`Unknown model gpt-5.1-codex is used`、`Failed to create shell snapshot for powershell`,没有任何 panic 或 error。所以现象是「app-server 被宿主优雅关掉/主动退出,而回合收尾却按连接断开处理」。下一步的插桩点应该落在**宿主侧谁关掉子进程 stdin / 谁 kill 子进程**(`shutdown_game_creator_codex_app_servers`、prefetch「项目预取」收尾、runner 生命周期),不要在 Drop 或协议层继续猜。以上插桩都已回滚,工作树保持干净。
|
||||
- **仍未解决(第二层,另一个问题)**:同一个夹具的全部 6 个用例(`completed/passes/mcp/mcp-write/native/deadline`)在修好第一层后都走到 loopback Provider,但**统一**失败在账本阶段:`phase=interrupted`(期望 `completed`/`exhausted`),stderr 为 `agent.runner.failed: Codex app-server 连接终止 … exitStatus=unknown;stderrBytes=1242`,CLI 回执文本为「执行通道已断开,不能自动重放未确认操作」。
|
||||
- **已排除的四层**(都靠插桩,不是推测):① 不是 codex 版本漂移(换成 0.147.0 结果相同);② 不是 stdin 被忽略(`stdio[0]` 改 `pipe` 结果相同);③ **不是 `Drop for ExecutionBinding`**(在该分支插桩打印 phase/`background_done`/`closed`,一次都没打印);④ **app-server 也不是崩溃**(分段打印 stderr 原文,1242 字节全是 `ProgramData known folder 0x80070003`、`Unknown model gpt-5.1-codex`、`powershell shell snapshot` 之类 WARN,没有 panic/error)。
|
||||
- **定位到的真正 Killer**:给 `shutdown_game_creator_codex_app_server_inner` 加一行关闭原因日志后,夹具里依次出现 `agent.direct_codex.shutdown reason=宿主执行预算或交付收尾` → `agent.runner.failed: … 连接终止` → (CLI 自己的两次 `shutdown`)。也就是**宿主收尾主动关掉 app-server**:`codex_app_server/execution.rs:938` 的 `shutdown_and_report()` 先 `self.closed.store(true)`、再 `shutdown_game_creator_codex_app_server_inner(inner, "宿主执行预算或交付收尾")`,而后者会给所有在途回合通道发 `CodexTurnEvent::TransportClosed(reason)`(`mod.rs:5207`)。于是**等待中的那一轮**(CLI 单回合宿主就是 CLI 自己的 await)拿到的是「连接断开」,回执变成失败文案、账本落 `interrupted`,尽管这是宿主自己收的尾。修复方向:宿主主动收尾时**先交付回合结果、不要向它发 `TransportClosed`**(或让等待方把「宿主收尾」识别为终态而不是 transport 失败);注意 GUI 常驻 app-server,不会每轮走这条路径,所以影响面是 CLI / 单回合宿主(`--direct-codex-chat` 与依赖它的夹具),不是用户日常对话。
|
||||
- **保留的诊断开关**:关闭原因日志留在 `GENARRATIVE_AGC_DIRECT_DEBUG=1` 下(与既有的 `agent.direct_codex.stderr bytes=` 同一开关),以后排查这类「谁关掉的」问题不用再插桩;其余临时插桩都已回滚。
|
||||
- **顺带记一条环境陷阱(2026-09-28 已修)**:`apps/ai-game-creator-shell/src-tauri/resources/codex/win-x64/` 下曾有两个 codex 二进制——`bin/codex.exe` 是**真正被解析**的那份(0.155.1),而包根目录那份 `codex.exe` 是 0.147.0 的旧残留(tauri 的 Windows 资源映射只引用 `bin/` 等路径),检查都查不出来,却会让本地核对误判「应用跑的是 0.147.0」。根因是 `src-tauri/build.rs` 的 `stage_codex_target()` 只按布局拷贝、从不清理目录,旧布局的组件会永久留在随包资源目录里。现在加了 `prune_stale_codex_components()`:拷贝前删掉不在本轮布局、也不在 `manifest.json`/`NOTICE.md` 白名单里的文件并收掉空目录;实测重建后根目录 `codex.exe` 被清掉、六个声明组件与清单/声明保留。
|
||||
|
||||
Reference in New Issue
Block a user