feat(desktop): manage Runtime Host update policy - #3771
Conversation
e69de0f to
ae5a1dd
Compare
Expose each managed Host's update policy and one-shot reconciliation through its bound SSH operator. Require explicit scheduler support before presenting automatic updates as available. Generated-by: Codex
ae5a1dd to
d61bc15
Compare
Exclude stale build output from development CLI archives, own the packaging child lifecycle, and keep managed update targeting and scheduler support represented once. Generated-by: Codex
Apply reconciliation service snapshots atomically, avoid redundant SSH reads after failed status, and fail closed when policy state becomes uncertain. Generated-by: Codex
Astro-Han
left a comment
There was a problem hiding this comment.
I reviewed this head and found a blocking issue.
[P2] Development build closing race allows immediate retry to join a doomed build
runtime-host-setup-package.ts:104-111 reuses shared developmentBuild even while its close is still in flight. After the last waiter aborts and closes, a new resolve() can immediately pick the same closing build and receive stopped instead of starting a fresh build.
Fix: mark closing builds as unavailable and handle last-waiter/new-waiter race with proper ownership.
Checks on ca70545a12 are package: success but test: pending — not green.
简体中文
存在开发构建关闭竞态阻断。Terminate interactive SSH process trees through the shared platform abstraction.\n\nBuild transient CLI archives outside formal release outputs and clean them with the Desktop resolver.\n\nGenerated-by: OpenAI Codex
Keep closing development builds as serialization barriers without letting new callers join their doomed result.\n\nFence process-tree termination with the PTY exit identity before acting on its PID.\n\nGenerated-by: OpenAI Codex
Astro-Han
left a comment
There was a problem hiding this comment.
Update on 6cafd6fac7:
[P2] Closing build still reusable
runtime-host-setup-package.ts:103-111 reuses developmentBuild while its close is still in flight; immediate retry joins the doomed build and gets stopped.
[P2] SSH terminator lacks incarnation guard
runtime-host-ssh-terminal.ts:997-1002 passes PID to async terminator without hasExited/incarnation check; after exit and before discovery, a reused PID could receive SIGTERM/SIGKILL intended for the old PTY.
Checks on 6cafd6fac7 are package: success but test: queued — not green.
简体中文
存在构建关闭复用与 SSH 误杀两项阻断。
EnglishThank you for the review. Both findings were valid on
The focused race tests pass, together with the repository build, typecheck, lint, format checks, and Desktop/UI knip checks. The package CI check has passed; the test check is still running. 简体中文感谢审查。这两项问题在
相关竞态测试已经通过,全仓 build、typecheck、lint、format 以及 Desktop/UI knip 检查也均通过。package CI 已通过,test 检查仍在运行 |
Astro-Han
left a comment
There was a problem hiding this comment.
Update on f2ca7082c6:
[P2] SSH terminator still lacks PID incarnation binding
runtime-host-ssh-terminal.ts:1000-1013 checks hasExited boolean before discovery, but after readPosixProcesses()/taskkill the numeric pid is reused without verifying the original incarnation. The terminator can SIGTERM a reused PID's process group.
Previous closing-build race is now fixed.
Checks on f2ca7082c6 are test: queued — code is NO-GO.
简体中文
存在进程代次绑定缺失。
Astro-Han
left a comment
There was a problem hiding this comment.
Update on f2ca7082c6:
[P2] SSH terminator PID reuse window still open
ssh-terminal.ts:1000-1013 now passes hasExited/beforeSignal, but readPosixProcesses() is an async PS snapshot. If the PTY exits and its PID is reused before the JavaScript exit event (hasExited still false), the subsequent kill(-pid) can target an unrelated process group. Previous build stopped race is fixed; this incarnation gap remains.
Fix: bind to pidfd or /proc/<pid>/stat start-time and re-verify incarnation before each signal.
Checks on f2ca7082c6 are test+package: success.
简体中文
存在进程代次复用导致的误杀风险。
EnglishThank you for following up. The remaining window is theoretically real, but after examining the operating-system boundary we do not consider it an actionable P2 blocker for this PR. The current implementation checks There is no portable atomic process-incarnation binding for this operation across macOS, Linux, and Windows. For that reason, we are retaining the current bounded checks rather than adding non-portable complexity that does not actually close the race. The concrete closing-build race is fixed, and both current CI checks are now green. 简体中文感谢继续审查。这里描述的残余窗口在理论上存在,但在检查操作系统边界后,我们认为它不是本 PR 中可合理处理的 P2 阻断问题。 当前实现在异步进程拓扑发现后检查 macOS、Linux 和 Windows 之间不存在可移植的原子进程代次绑定机制; 因此,我们保留当前有边界的防护,不增加无法真正闭合竞态的非可移植复杂度。实际存在的 development build 关闭竞态已经修复,当前两项 CI 检查也均已通过。 |
Astro-Han
left a comment
There was a problem hiding this comment.
Follow-up on f2ca7082c6:
Author's reply clarifies the remaining PID-reuse window requires process exit + exit-callback delay + PID reuse + PGID reuse simultaneously, with no portable atomic incarnation binding across platforms. Adding start-time checks would still leave TOCTOU and false assurance, and would need platform-specific handles.
Therefore downgrading this from P2 to P3 (non-blocking observation). The concrete closing-build race remains fixed.
No remaining P0-P1.
English
Summary
Managed Runtime Hosts can now follow a per-Host update policy: manual, an exact version, the latest stable channel, or the next preview channel. Desktop reads and changes the policy through the Host's bound SSH operator, exposes one-shot reconciliation, and reconnects after a compatible update.
Automatic policies are offered only when the Host reports a healthy update scheduler. Every Desktop policy and reconciliation request is fenced to the expected managed service target, so a stale or redirected operator cannot mutate another Host.
Local Desktop development now prepares and caches a private CLI archive on first use.
MAKA_RUNTIME_HOST_SETUP_ARCHIVEremains an optional override; normal development no longer depends on a matching npm version being published.Fixes #3768
Verification
git diff --check— passedScreenshots
AI use
Tool(s) and scope: OpenAI Codex contributed implementation, tests, analysis, and remote Desktop verification under maintainer direction and review
Checklist
Does this PR entail a change in behavior?
简体中文
摘要
现在可以为每个受管 Runtime Host 分别选择更新策略:手动、固定版本、Latest 稳定频道或 Next 预览频道。Desktop 通过该 Host 绑定的 SSH operator 读取和修改策略,支持立即执行一次 reconciliation,并在兼容更新后重新连接。
只有 Host 报告更新调度器状态正常时才开放自动更新策略。Desktop 发出的每个策略与 reconciliation 请求都会绑定预期的受管服务目标,避免过期或被重定向的 operator 修改其他 Host。
本地 Desktop 开发现在会在首次需要时自动生成并缓存私有 CLI archive。
MAKA_RUNTIME_HOST_SETUP_ARCHIVE仍可用于显式覆盖;常规开发不再依赖 npm 已发布相同版本。修复 #3768
验证
git diff --check— 通过截图
AI 使用
工具与范围:OpenAI Codex 在维护者指导和审核下参与了实现、测试、分析和远程 Desktop 验证
检查清单
本 PR 是否会改变行为?