Repository navigation
fix(host-runtime): keep non-Desktop callers off the local Host Runtime - #899
BytePioneer-AI merged 12 commits into
Conversation
A remote app-server listener started with a leaked local Launcher session could lock the local Mapping Store. Codex Desktop then failed to start its Host Runtime with "Another codexhost process owns Mapping Store", but showed only the Shim's cleanup note "terminated official CLI descendants after root exit". On macOS, Computer Use helpers kept starting full Host Runtimes after the Launcher exited, failing on the same lock about every ten minutes. - Shim: classify macOS Desktop helpers by validated Desktop ancestry when Launcher metadata is stale (Launcher exited or its PID reused). - Shim: a caller positively not started by Codex Desktop runs on the official CLI when a live Host Runtime owns the Mapping Store or another live Desktop owns the local Host Runtime lease. Desktop's main app-server keeps the explicit failure. - Shim: refuse to start a managed remote listener inside a local Launcher session or without CODEXHOST_DATA_DIR, so it cannot take the local Mapping Store. - Shim: label Host Runtime children as Host Runtime, and end a failed Host Runtime's stderr with its last diagnostic so Desktop shows the cause. - Mapping Store: record the owner role in store.lock and name the owner's directory, PID, role and start time in STORE_LOCKED. - Host Runtime: restate a Host initialization failure as the final diagnostic before exiting. Signed-off-by: Vincent <[email protected]>
The summary unit test was gated to macOS and Linux, which left its import unused on Windows and failed clippy with -D warnings. Build the failed exit status per platform instead. Signed-off-by: Vincent <[email protected]>
…ration The fixture exited immediately, so under parallel load the Shim could fail to inspect the already-exited child while publishing the lease and report "cannot inspect PID" instead of the startup failure under test. Give it a short startup time, as a real Host Runtime has. Signed-off-by: Vincent <[email protected]>
…corded When the child exits before the Shim records it in the local runtime lease, the process snapshot fails and the proxy returned that error without copying the child's stderr. Wait briefly for the exit and fall through to the normal exit report instead, and drop the fixture delay that hid this path. Signed-off-by: Vincent <[email protected]>
Signed-off-by: Vincent <[email protected]>
Signed-off-by: Vincent <[email protected]>
Resolve proxy test conflicts by keeping this branch's CODEXHOST_DATA_DIR fixtures together with main's CODEXHOST_REMOTE_EXECUTION_SESSION and concurrent reconnect coverage.
Rebase the lock-coordination work onto current main and drop what main now already covers (BytePioneer-AI#828 store ownership diagnostics, BytePioneer-AI#859 stale-lock takeover, the managed listener's stale socket replacement and the Host Runtime failure summary). What stays is the part that decides who may own the local Host Runtime at all: - classify a Shim caller by the validated Desktop ancestry of its official CLI instead of the Launcher executable snapshot, so Computer Use helpers keep working after the Launcher exits or its PID is reused; - a caller positively known not to be Desktop falls back to the official CLI when another live process owns the Host Runtime or the Mapping Store, instead of failing Desktop startup; - a managed remote listener refuses a leaked local Launcher session or a missing CODEXHOST_DATA_DIR, so it cannot lock the local Mapping Store; - report the child's exit instead of a registration error when the Host Runtime exits before its identity is recorded.
|
Caution Review failedThe pull request is closed. No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Summary
按 #766 的最后一条 review 意见,基于当前
main(4112ad65)重新收敛成独立的一支,只保留"谁能拥有本地 Host Runtime"这一部分,主干已经覆盖的内容全部剔除。已删除(主干已覆盖)
packages/mapping-store/**:STORE_LOCKED的目录 / PID / 启动时间诊断(fix: expose Mapping Store ownership and preserve child failure diagnostics #828)与失效锁接管(fix(mapping-store): take over stale locks without replacing a live owner #859)由主干实现。crates/shim/src/lib.rs里"非零退出时不被清理提示覆盖 stderr 末行",改用主干的preserve_child_error;删掉本分支自带的child_diagnostics模块与重复的失败摘要测试。app-server-host.startup-failure.test.ts、run-host-runtime.ts、external-thread-repository.ts里的角色标签等辅助改动。保留(6 个文件,+472/−46)
crates/shim/src/desktop_invocation.rs:用官方 CLI 所在的、经过校验的 Desktop bundle 祖先判定 Shim 调用方,不再依赖 Launcher 可执行文件快照;Launcher 退出或 PID 被复用后,Computer Use 等 native helper 仍走官方 CLI。crates/shim/src/local_runtime_lease.rs+lib.rs:admit_local_runtime对"确认不是 Desktop"的调用方,在本地 Host Runtime 或 Mapping Store 已被其它存活进程持有时回退到官方 CLI,而不是让 Desktop 启动失败;Host Runtime 在身份登记前退出时报告子进程退出状态。CODEXHOST_DATA_DIR,避免它锁住本地 Mapping Store。docs/platforms/macos/macos-native-tools.md:说明新的调用方分类。Related issues
Test plan
cargo fmt -p codexhost-shim --check:通过。cargo clippy -p codexhost-shim --features test-utils --all-targets:无 warning / error。cargo test -p codexhost-shim --features test-utils(macOS 15 arm64,rustc 1.97.1):host_runtime_selection5 passed;proxy48 passed / 1 ignored / 3 failed。失败的三个是managed_remote_listener_detaches_and_reuses_a_matching_socket_owner、remote_lifecycle_refuses_a_mismatched_installed_command、remote_lifecycle_terminates_only_the_matching_socket_listener。同一份环境里在未修改的main(4112ad65)上单独跑--test proxy也以同样的报错失败(remote Host socket owner does not match the requested installed listener,以及等待<tmp>/ready超时),因此判定为本机环境失败,与本分支无关;本分支新增的managed_remote_listener_refuses_a_local_launcher_session_or_missing_data_directory通过。crates/shim与文档,未改 TypeScript / Renderer 代码。(AI 辅助完成;以上命令在作者机器上实际执行。)