Skip to content

fix(runtime-host): recover approved Guest regeneration - #4636

Merged
M4n5ter merged 1 commit into
apache:mainfrom
M4n5ter:fix/guest-regenerate-managed-host-crash
Sep 3, 2026
Merged

fix(runtime-host): recover approved Guest regeneration#4636
M4n5ter merged 1 commit into
apache:mainfrom
M4n5ter:fix/guest-regenerate-managed-host-crash

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Sep 3, 2026

Copy link
Copy Markdown
Member
English

Summary

Fix approved Session Guest regeneration from crashing the managed Runtime Host and replaying the same pending request on every restart.

The Guest approval is durable authorization for the regenerated root, so the storage contract now accepts that proof for both external messages and regenerations. The coordinator test exercises the real store boundary and verifies that a retry without the same proof conflicts.

This also makes Desktop repair usable after that crash:

  • an interrupted host.upgrade.prepare is treated as an unknown retirement outcome;
  • without explicit interruption authority, repair reports possible active work instead of guessing;
  • after the user explicitly authorizes interruption, the exact supervised deployment is retired and the State Root fence is acquired before replacement;
  • development archives no longer receive the published-version-only --allow-manual-update flag.

No workspace or Session data is migrated or deleted.

Root cause

PR #4608 began carrying session_turn_access_request authorization into turn.regenerate, but the durable admission store still rejected authorization on every execution kind except external_message. The approval coordinator consequently requested Host drain while leaving the request pending. Startup replay hit the same invariant again, producing the apparent MANAGED_ROOT_REQUIRES_OPERATOR loop.

The existing Repair action then had two independent failure paths: it aborted on an interrupted retirement mutation, and a subsequent development-archive repair passed an invalid CLI flag combination.

Verification

  • npm run lint
  • npm run format:check
  • npm run typecheck
  • npm --workspace @maka/storage run build and the regenerate admission test
  • npm --workspace @maka/runtime-host run build and the approved-regenerate coordinator test
  • npm --workspace @maka/cli run build
  • npm --workspace @maka/desktop run build:main and the local-operator test
  • npm --workspace @maka/runtime-host run test:dist: 1,607 passed, 12 skipped, 0 failed
  • npm run build:test, then node scripts/run-workspace-tests-parallel.mjs --concurrency=1: all workspace tests passed
  • Recovered the original damaged macOS development workspace through the real Electron Repair flow: the managed deployment was replaced, the pending approval advanced to started, and the Session loaded with its regenerated answer without deleting state

The default concurrent local runner exceeded existing fixed Runtime Host startup deadlines under process contention; the same compiled Runtime Host suite passed in isolation and every workspace passed serially.

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: OpenAI Codex diagnosed the persisted crash loop, implemented the contract and recovery fixes, added focused tests, and exercised the real Electron repair path.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No
中文

概要

修复 Session Guest 的“重新生成”请求在批准后导致 managed Runtime Host 崩溃,并在每次启动时反复重放同一条待处理请求的问题。

Guest 审批记录是重新生成这条 root Turn 的持久授权凭据,因此存储契约现在同时允许外部消息和重新生成携带这份凭据。协调器测试会穿过真实存储边界,并确认缺少同一份授权的重试会发生冲突。

同时补齐崩溃后的 Desktop 修复路径:

  • host.upgrade.prepare 中断时,不猜测这次修改是否已经生效;
  • 未经用户明确允许中断时,先提示 Host 可能仍有工作;
  • 用户明确确认后,只停止身份匹配的受管部署,并在替换前取得 State Root 所有权;
  • 开发归档不再携带只适用于已发布版本选择器的 --allow-manual-update 参数。

不会迁移或删除工作区、Session 数据。

根因

#4608 开始把 session_turn_access_request 授权传给 turn.regenerate,但持久化 admission 仍只允许 external_message 携带授权。审批协调器因此要求 Host 退出,却把请求留在 pending 状态;下次启动重放后再次撞上同一条不变量,最终表现为 MANAGED_ROOT_REQUIRES_OPERATOR 循环。

原来的“修复”操作还有两个独立问题:退休请求在连接中断后直接失败;再次修复开发归档时,又传入了 CLI 不接受的参数组合。

验证

  • lint、format、typecheck 均通过
  • storage、Runtime Host、CLI 与 Desktop 的针对性构建和测试通过
  • Runtime Host 全套:1,607 通过,12 跳过,0 失败
  • 完整测试构建后串行运行所有 workspace:全部通过
  • 直接使用原来已经损坏的 macOS 开发工作区走了一遍真实 Electron 修复流程:managed Host 成功替换,pending 审批进入 started,原 Session 和重新生成的回答均可正常加载,未清理任何用户状态

本机并发执行时,已有的 Runtime Host 固定启动时限在进程竞争下被超过;同一份产物隔离运行 Runtime Host 全套和串行运行全部 workspace 均通过。

@github-actions github-actions Bot added the effort/M Under 500 readable lines label Sep 3, 2026

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at exact head f0dc0f4cdf55b280859673b5e07037bbc38393be 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.

Admit durable Guest authorization on regenerate roots, and let explicit managed-Host repair safely replace a Host that dies while preparing retirement.

Generated-by: OpenAI Codex
@M4n5ter
M4n5ter force-pushed the fix/guest-regenerate-managed-host-crash branch from f0dc0f4 to bbd769c Compare September 3, 2026 08:32
@M4n5ter
M4n5ter merged commit afe06f2 into apache:main Sep 3, 2026
1 check passed
@M4n5ter
M4n5ter deleted the fix/guest-regenerate-managed-host-crash branch September 3, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/M Under 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants