Skip to content

fix(runtime): reserve State Root migrations for Host - #4770

Merged
M4n5ter merged 1 commit into
mainfrom
fix/runtime-host-schema-migration-authority
Sep 4, 2026
Merged

fix(runtime): reserve State Root migrations for Host#4770
M4n5ter merged 1 commit into
mainfrom
fix/runtime-host-schema-migration-authority

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Sep 4, 2026

Copy link
Copy Markdown
Member

Summary

English

A newer Desktop process could open the shared runtime.sqlite before a resident managed Runtime Host and implicitly migrate its schema. When the migration removed core_agent_runs.record_json, the older Host kept running against the changed database and all subsequent Session reads failed.

This change makes the Runtime Host the sole schema-migration authority for its State Root:

  • Desktop starts the Host before opening its Work Board table.
  • Desktop-owned Work Board and Session-copy cleanup stores require an already-current schema and fail closed without changing it.
  • Compatibility epoch 110 rejects the unsafe epoch-109 mixed generation before either side admits domain work, allowing the existing managed-Host replacement flow to install the matching Host.

No database deletion or data repair is involved. Once a matching Host owns the root, it performs the normal schema migration and Desktop opens its shared tables afterward.

中文

问题的根源不是会话数据损坏,而是两个不同版本的进程同时使用同一个 runtime.sqlite:新版 Desktop 会在旧版托管 Runtime Host 仍然运行时抢先迁移数据库。迁移删掉 core_agent_runs.record_json 后,旧 Host 仍按旧结构查询,于是所有会话加载都开始失败。

本次修复把 State Root 的数据库迁移权收回到 Runtime Host:

  • Desktop 先启动并确认 Host 就绪,再打开 Work Board 表。
  • Desktop 自己使用的 Work Board 和会话副本清理逻辑只接受已经完成迁移的 schema;发现版本不对时直接停止,不会背着 Host 改库。
  • 兼容 epoch 提升到 110。109 代的 Desktop 和 Host 不能再混跑,现有托管 Host 更新流程会负责换成配套版本。

这里不会删除数据库,也不需要靠清理用户数据恢复。配套 Host 接管 State Root 后会按正常流程完成迁移,随后 Desktop 再打开自己的共享表。

Verification

  • npm exec -- biome check on all changed TypeScript files
  • npm --workspace @maka/storage run build
  • Storage regression suites: 74 passed
  • npm --workspace @maka/runtime-host run build
  • npm --workspace @maka/desktop run typecheck
  • npm --workspace @maka/desktop run build:main
  • Runtime Host protocol and handshake suites: 81 passed
  • Desktop startup-lifetime and Runtime Host manager suites: 58 passed
  • Protocol epoch guard: 13 passed

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 mixed-generation schema authority failure, implemented the bounded fix, and added regression coverage.

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

Prevent Desktop-owned Work Board and Session copy cleanup stores from changing a Runtime Host State Root schema. Start the Host first, require an already-current schema from Desktop, and advance the compatibility epoch so mixed generations are rejected before domain work.

Generated-by: OpenAI Codex
@github-actions github-actions Bot added the effort/M Under 500 readable lines label Sep 4, 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 68a3295a730f059ea97f528b5c33549311a10a71 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
M4n5ter merged commit 14910a8 into main Sep 4, 2026
2 checks passed
@M4n5ter
M4n5ter deleted the fix/runtime-host-schema-migration-authority branch September 4, 2026 11:02
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