Skip to content

去掉 PROTOCOL,包与宿主的运行时对齐只认 tinyui 版本 - #24

Merged
HarlonWang merged 2 commits into
mainfrom
refactor/drop-protocol
Sep 24, 2026
Merged

HarlonWang merged 2 commits into
mainfrom
refactor/drop-protocol

Conversation

@HarlonWang

@HarlonWang HarlonWang commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

背景

PageHost.PROTOCOL 从 M1 起一直是 1:改 mount 参数、加 __host_call 时都没加,K0 与热下发的核对永远通过,形同虚设。实际守住 JS 运行时 ↔ Kotlin 边界的是"tinyui 版本相等"(宿主快照 → publish 核对、PackageCheck),但客户端 Updates 并不读 manifest 的 tinyui。拍板选 A:删掉 PROTOCOL,只认 tinyui 版本。

改动

  • core:protocol.ts → version.ts(VERSION 移入,index.ts 转导出),删 tinyui-core/protocol 子路径导出;__tinyui.protocol → __tinyui.version
  • PageHost:K0 核对 __tinyui.version == TinyUI.version,不等 E6;核对提前到取入口函数之前(否则缺入口的旧运行时先报类型转换错误);删 PROTOCOL
  • manifest / CLI:删 protocol 字段;bundle 改为要求 tinyui 字段;CLI 读 tinyui-core 版本改从主入口向上找 package.json
  • Updates:内置包与下发包都核对 manifest.tinyui == TinyUI.version;Mismatch.PROTOCOL → Mismatch.TINYUI
  • 测试:签名夹具换钥重签(manifest 里 protocol 换成 tinyui)
  • 文档:patch-protocol.md §6、runtime-api.md、updates.md、ADR-006、build-chain.md 同步;roadmap D 组新增"运行时 ABI 版本",触发条件:宿主升级 tinyui 导致的整批重新发布成为负担

影响

  • 公开 API:删 PageHost.PROTOCOL、BuildManifest.protocol;Mismatch.PROTOCOL 改名 TINYUI(api 快照已更新)。TrendingAI 与 tinyui-updates-server 均未引用
  • 旧 manifest(无 tinyui 字段)在客户端会被判 TINYUI 不兼容;线上包都由 0.4.0+ 的 CLI 产出,均带该字段
  • 发版时 core 的 VERSION 改在 packages/core/src/version.ts

验证

  • pnpm -r test:core 42 / native 5 / cli 78 全过
  • :compose:allTests :updates:allTests :sample:shared:allTests(Android host + iOS 模拟器)、apiCheck、sample APK 全过
  • Android 模拟器装 sample:两个内置包 Running(EMBEDDED),页面正常渲染,无 EmbeddedIncompatible

🤖 Generated with Claude Code

Summary by Sourcery

Replace the obsolete protocol version contract with tinyui version alignment across the runtime, package manifests, host checks, and update flows.

Bug Fixes:

  • Replace the ineffective protocol compatibility check with validation against the tinyui runtime version across hosts, packages, and updates.

Enhancements:

  • Remove the PROTOCOL API and protocol manifest field, exposing the runtime version as __tinyui.version and using it as the sole runtime compatibility key.
  • Align embedded and downloaded package validation, mismatch reporting, CLI manifest generation, and core exports with tinyui version compatibility.

Documentation:

  • Update runtime, update, build-chain, patch protocol, ADR, and roadmap documentation to describe tinyui-version-based compatibility and future ABI versioning.

Tests:

  • Update host, package, core, CLI, and update tests and signed fixtures for tinyui version validation, including stale installed packages.

Summary by CodeRabbit

  • Compatibility
    • Package and runtime compatibility are checked using the TinyUI version instead of a protocol number. A runtime version mismatch prevents a page from loading, and incompatible packages are identified by their TinyUI version.
    • Installed packages with mismatched host, engine, or TinyUI versions are no longer eligible to run. Engine, host version, component, and capability checks remain in place.
  • Documentation
    • Updated compatibility and build guidance to describe TinyUI version checks for packages, runtimes, and updates.

PROTOCOL 从 M1 起一直是 1,改 mount 参数、加 host.call 时都没加,核对永远通过;
真正生效的兼容判据是"tinyui 版本相等"(宿主快照、publish、PackageCheck)。
现在把它作为唯一判据贯穿到底:

- core:protocol.ts 换成 version.ts(VERSION 移入),__tinyui 暴露 version
- PageHost:K0 核对 __tinyui.version == TinyUI.version,先于取入口函数;删 PROTOCOL
- manifest:删 protocol 字段;bundle 改为要求 tinyui 字段
- Updates:客户端核对 manifest.tinyui(此前客户端不读),Mismatch.PROTOCOL → TINYUI
- 签名夹具换钥重签
- 文档同步;roadmap D 组加"运行时 ABI 版本",触发条件为宿主升级 tinyui 导致的重新发布成为负担

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

本 PR 删除形同虚设的 PROTOCOL 兼容层,改由 tinyui-core VERSION 贯穿 JS 运行时、PageHost、manifest、CLI 与 Updates:运行时在 K0 校验 __tinyui.version,客户端在构建、内置包和热下发流程中统一核对 tinyui 版本,并同步 API、测试夹具和文档。

Sequence diagram for tinyui version compatibility checks

sequenceDiagram
    participant Updates
    participant Manifest
    participant PageHost
    participant RuntimeCore
    participant TinyUI

    Updates->>Manifest: readManifest()
    Manifest-->>Updates: manifest.tinyui
    Updates->>TinyUI: compare manifest.tinyui with TinyUI.version
    alt version mismatch
        Updates-->>Updates: Mismatch.TINYUI
    else version matches
        Updates-->>Updates: package is eligible
    end

    PageHost->>RuntimeCore: evaluate("__tinyui")
    RuntimeCore-->>PageHost: __tinyui.version
    PageHost->>TinyUI: compare version with TinyUI.version
    alt version mismatch
        PageHost-->>PageHost: E6
    else version matches
        PageHost->>PageHost: resolve entry functions
        PageHost->>RuntimeCore: mount(...)
    end
Loading

File-Level Changes

Change Details Files
以 tinyui-core 版本统一替代独立的运行时协议版本,并调整核心模块的版本暴露方式。
  • 将 VERSION 移至独立的 version.ts 并从主入口导出
  • 删除 protocol.ts 及 tinyui-core/protocol 子路径导出
  • 将运行时元数据从 __tinyui.protocol 改为 __tinyui.version
packages/core/package.json
packages/core/src/index.ts
packages/core/src/page.ts
packages/core/src/protocol.ts
packages/core/src/version.ts
packages/core/test/async.test.ts
将 PageHost 的运行时兼容性检查改为 tinyui 版本检查,并确保检查发生在入口函数转换之前。
  • 删除 PageHost.PROTOCOL
  • 在 K0 阶段核对运行时版本与 TinyUI.version
  • 更新运行时不匹配测试及 Android 冒烟验证
compose/src/commonMain/kotlin/app/tinyui/PageHost.kt
compose/src/commonTest/kotlin/app/tinyui/PageHostTest.kt
compose/src/androidHostTest/kotlin/app/tinyui/BundleSmokeTest.kt
统一 manifest 和 CLI 的兼容字段,要求构建及打包流程使用 tinyui 字段。
  • 从 BuildManifest 和 PackageCheck 移除 protocol 校验
  • build 生成 tinyui 版本并从主入口解析 tinyui-core 的 package.json
  • bundle 将 tinyui 作为必填字段并拒绝缺失字段的旧产物
compose/src/commonMain/kotlin/app/tinyui/BuildManifest.kt
compose/src/commonMain/kotlin/app/tinyui/PackageCheck.kt
packages/cli/src/build.ts
packages/cli/src/bundle.ts
packages/cli/test/build.test.ts
packages/cli/test/helpers.ts
compose/src/commonTest/kotlin/app/tinyui/BundleTest.kt
compose/src/commonTest/kotlin/app/tinyui/PackageCheckTest.kt
让 Updates 对内置包和热下发包都按 manifest.tinyui 与宿主版本进行兼容判断。
  • 将构造参数和兼容比较从 protocol 改为 tinyui
  • 将 Mismatch.PROTOCOL 重命名为 Mismatch.TINYUI
  • 更新不兼容事件、签名夹具及更新流程测试
updates/src/commonMain/kotlin/app/tinyui/updates/Events.kt
updates/src/commonMain/kotlin/app/tinyui/updates/Updates.kt
updates/src/commonTest/kotlin/app/tinyui/updates/Fixture.kt
updates/src/commonTest/kotlin/app/tinyui/updates/UpdatesTest.kt
updates/api/updates.klib.api
同步公开 API 快照、协议/更新设计文档及版本演进规划。
  • 移除公开的 PageHost.PROTOCOL、BuildManifest.protocol 和 protocol 导出
  • 将运行时 ABI 对齐规则及 manifest 字段说明改为 tinyui 版本
  • 新增未来独立运行时 ABI 版本的 roadmap 项
compose/api/compose.klib.api
docs/patch-protocol.md
docs/runtime-api.md
docs/updates.md
docs/adr-006-hot-updates.md
docs/build-chain.md
docs/roadmap.md
docs/updates-plan.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: a6464df6-b1ce-4b39-89bf-323097730379

📥 Commits

Reviewing files that changed from the base of the PR and between 0cc6a78 and adf0b91.

📒 Files selected for processing (3)
  • docs/updates.md
  • updates/src/commonMain/kotlin/app/tinyui/updates/Updates.kt
  • updates/src/commonTest/kotlin/app/tinyui/updates/UpdatesTest.kt

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The change replaces the numeric protocol identifier with the TinyUI version across runtime startup checks, build manifests, package compatibility checks, and update mismatch reporting. It also removes the protocol constant and updates related tests and documentation.

Changes

TinyUI version compatibility

Layer / File(s) Summary
Runtime version contract
compose/api/compose.klib.api, compose/src/commonMain/kotlin/app/tinyui/PageHost.kt, packages/core/*, compose/src/commonTest/kotlin/app/tinyui/PageHostTest.kt, compose/src/androidHostTest/kotlin/app/tinyui/BundleSmokeTest.kt, docs/runtime-api.md, docs/patch-protocol.md, docs/roadmap.md, docs/updates-plan.md
The core runtime exposes version, and PageHost.start compares it with TinyUI.version. A mismatch follows the existing E6 load-failure path. The protocol constant and runtime protocol check are removed.
Manifest version fields
compose/src/commonMain/kotlin/app/tinyui/BuildManifest.kt, compose/src/commonMain/kotlin/app/tinyui/PackageCheck.kt, compose/src/commonTest/kotlin/app/tinyui/BundleTest.kt, compose/src/commonTest/kotlin/app/tinyui/PackageCheckTest.kt, packages/cli/src/*, packages/cli/test/*, docs/adr-006-hot-updates.md, docs/build-chain.md
Build manifests no longer include protocol. The CLI records tinyui and requires it as a string when reading a manifest. Package protocol mismatch reporting is removed.
Update compatibility checks
updates/api/updates.klib.api, updates/src/commonMain/kotlin/app/tinyui/updates/*, updates/src/commonTest/kotlin/app/tinyui/updates/*, docs/updates.md
Embedded and downloaded package checks compare tinyui with the host TinyUI version and report Mismatch.TINYUI. Update fixtures, tests, and documentation use the new field and mismatch name.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant PageHost
  participant TinyUICore
  participant TinyUI
  participant LoadFailure
  PageHost->>TinyUICore: Read entries.version
  PageHost->>TinyUI: Compare with TinyUI.version
  PageHost->>LoadFailure: Report E6 when versions differ
Loading

Merge Risk: ⚪ Minimal · up to adf0b

No new merge-blocking risk is established; the compatibility change is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 27 functions across 16 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更:移除 PROTOCOL,并统一使用 tinyui 版本进行包与宿主的运行时兼容检查。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 27 functions across 16 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@codeseerbot codeseerbot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CodeSeer 审查

结论:不批准(本轮 1 条严重或建议级意见)

摘要

本次改动将运行时兼容性从 PROTOCOL 切换为 tinyui 版本,并同步更新了 core 导出、manifest、CLI、PageHost、Updates 与文档。下发新包时已经会核对 manifest.tinyui,但启动时恢复已安装包的路径遗漏了同一核对。因而旧 manifest 或宿主升级前遗留的已安装包仍可能被选中并在页面启动后才以 E6 失败。

其他意见

不在改动行上,无法挂为行内评论:

  • updates/src/commonMain/kotlin/app/tinyui/updates/Updates.kt:170 [严重] loadInstalled 只检查包名、hostVersion、失败记录和创建时间,未核对 manifest.tinyui == tinyui(也未重核对 engine)。因此本次升级前落盘的旧 manifest(tinyui 为空)或不同 tinyui 版本的已安装包,在宿主未变更 hostVersion 时仍会被选为 current,随后页面只能在 PageHost 中报 E6;这与“旧 manifest 在客户端判 TINYUI 不兼容”不符。应在此处将 engine/tinyui 不匹配视为不可加载,清除该 installed 版本并回退到 embedded 包。

整个 PR 至 0cc6a78 · gpt-5.6-terra

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. This changes the persisted bundle manifest format and the compatibility gate used before installing or running runtime modules. A wrong version-alignment decision could make packages fail with E6 or be skipped until a compatible bundle is published; reverting the code would not repair manifests or packages already produced under the new format, though those can be replaced or re-run.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

宿主换了引擎或 tinyui 而沿用 hostVersion 时,旧的 installed 包会被选中、进页面才 E6;
现在与下载前的核对一致,不符即当场删除、回到内置包。

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@codeseerbot codeseerbot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CodeSeer 审查

结论:批准

摘要

本次增量在 Updates 启动恢复已安装包时补充了 engine 和 tinyui 的兼容性校验,并增加了相应测试。主要风险在文档:同一段同时保留了旧的启动筛选规则和新的规则,读者会得到互相不完整的行为说明。

增量 0cc6a78..adf0b91 · gpt-5.6-terra

Comment thread docs/updates.md
@HarlonWang
HarlonWang merged commit 23b2203 into main Sep 24, 2026
5 checks passed
@HarlonWang
HarlonWang deleted the refactor/drop-protocol branch September 24, 2026 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant