fix(desktop): stop stale ephemeral Host at startup - #4781
Merged
Conversation
jackwener
approved these changes
Sep 4, 2026
jackwener
left a comment
Member
There was a problem hiding this comment.
Approved at exact head 162b5096cd07a8c690ca633d10e94007de673fa7 at the explicit direction of M4n5ter. No technical review was performed as part of this action; M4n5ter requested the approval and accepts responsibility for subsequent handling.
Review notice: This approval was submitted by an automated review agent operated by jackwener and is published at the direction of M4n5ter, who requested this action and is the human accountable for it.
M4n5ter
force-pushed
the
fix/stale-ephemeral-host-recovery
branch
from
September 4, 2026 14:12
162b509 to
2529dec
Compare
Offer an explicit recovery action when an incompatible local ephemeral Runtime Host still owns the State Root. Bind the action to a validated Host handshake and an OS process-lifetime identity, then revalidate the registration and live Desktop intent immediately before signaling; managed, remote, and unverifiable Hosts fail closed. Generated-by: OpenAI Codex
M4n5ter
force-pushed
the
fix/stale-ephemeral-host-recovery
branch
from
September 4, 2026 14:44
2529dec to
4c55017
Compare
20 tasks
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.
Summary
English
When an incompatible local ephemeral Runtime Host still owns the State Root, startup only offered Wait, Copy Diagnostics, or Cancel. Users were told to find and terminate a PID outside Maka even though Desktop can safely recover this case itself.
This change adds an explicit Stop Host and Continue choice while retaining Wait and Cancel Startup. It never silently terminates an unknown process. Desktop first records an OS-owned identity for the exact process lifetime, then connects to the registered endpoint and validates the Host/root/epoch handshake. After the user confirms, it rereads the complete registration, current Desktop authority, and process-lifetime identity immediately before signaling the exact root PID. Any changed or unavailable evidence fails closed.
The process identity comes from the operating system rather than a flattened command line: macOS uses
proc_pidinfostart time, Windows usesGetProcessTimes, and Linux uses boot ID plus/proc/<pid>/statstart ticks. Arguments and workspace paths therefore cannot impersonate the identity. This support lives in the already-shipped Runtime Host native addon; Linux retains a procfs fallback when the addon is unavailable.Owned Host shutdown remains on the existing process-tree path. Managed services, remote Hosts, unknown lifecycle registrations, older native addons without the identity API, and failed identity queries keep the existing non-destructive Wait/Cancel behavior.
中文
本地旧版临时 Runtime Host 仍占用工作区时,启动窗口以前只有“等待”“复制诊断信息”和“取消启动”。问题发生在 Maka 里,用户却只能自己去系统进程管理器查 PID、结束进程。
本次增加了明确的 “停止 Host 并继续”,同时保留 “等待” 和 “取消启动”。Maka 不会只凭一个 PID 就结束进程:它会先记录该 PID 对应的操作系统进程实例,再连接注册端点并完成 Host、State Root 和 epoch 校验。用户确认后,真正发信号前还会重新核对完整注册信息、当前 Desktop 是否仍拥有这次操作的授权,以及 PID 是否仍是刚才那个进程实例。任何证据缺失或发生变化,操作都会安全停止。
进程身份直接来自操作系统,不再解析容易歧义的命令行文本:macOS 使用
proc_pidinfo的启动时刻,Windows 使用GetProcessTimes,Linux 使用 boot ID 与/proc/<pid>/stat的启动 tick。即使工作区路径里恰好包含类似命令行参数的文字,也不可能被误认成身份。实现复用了产品已经随包发布的 Runtime Host 原生模块;Linux 在原生模块不可用时仍可直接读取 procfs。Desktop 自己启动的 Host 仍走原有的进程树退出路径。托管服务、远程 Host、无法确认生命周期的注册、缺少新身份能力的旧原生模块,以及身份查询失败的情况,都继续只提供非破坏性的等待或取消,不会冒险结束进程。
Verification
npm run lintnpm run format:checknpm run buildnpm run typechecknpx knip --workspace apps/desktopnpx knip --workspace packages/uicargo fmt --all --manifest-path native/runtime-host-peer/Cargo.toml -- --checkcargo clippy --locked --all-targets --manifest-path native/runtime-host-peer/Cargo.toml -- -D warningscargo test --locked --manifest-path native/runtime-host-peer/Cargo.toml— 31 passedAI use
Select exactly one:
Tool(s) and scope: OpenAI Codex diagnosed the unsafe stale-process recovery boundary, implemented the OS process-lifetime fence and Desktop recovery action, added regression coverage, and performed parallel correctness and simplification audits.
Checklist
Does this PR entail a change in behavior?