Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions 10-prd/behavior/rules-and-invariants.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
- violation impact: extensions could bypass durable product contracts.
- linked claim(s): collect external information into reusable units; expose info-base information for retrieval and downstream use

## 自部署者可以从发布者仓库添加插件

部署者可通过发布者仓库发现并安装支持的插件。First-party 与社区插件使用相同的安装路径。用户决定各 Peer 的精确版本,并可在插件发布者提供的仓库中查看对应版本的说明。

## Resolver interpretation and storage retrieval remain distinct

- rationale: resolver interpretation may combine hydrated block content with local relations, while storage only turns the block's opaque pointer into actual bytes.
Expand Down
8 changes: 2 additions & 6 deletions 20-product-tdd/cross-unit-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,11 @@ Record durable data and behavior contracts that span more than one unit reposito

## Extension State Contract

[Extension 分发发布与 Peer 参与契约](extension-release-and-installation.md)拥有独立原生发布坐标、部署共享业务状态、Peer 精确安装选择,以及启用意图和实际运行的区别。插件拥有业务与数据兼容,各 Unit 分别拥有构建发布流程和宿主执行边界。
[Extension 分发发布与 Peer 参与契约](extension-release-and-installation.md)拥有仓库发行的发现与读取、独立原生发布坐标、部署共享业务状态和 Peer 精确安装选择。插件拥有业务与数据兼容,各 Unit 分别拥有构建发布流程和宿主执行边界。

## Extension Documentation Hosting Contract

- Author-built static documentation, exact native Release identity and historical scope compatibility, conditional whole-site
corrections, snapshot-origin isolation, and consumer discovery follow the
[Extension Documentation Hosting Contract](extension-documentation-hosting.md).
- Registry owns hosting and executable API details; authors own site content and structure.
Documentation does not become an installable Distribution or alter Host lifecycle authority.
[Extension 用户文档契约](extension-documentation-hosting.md)规定由发布者维护的仓库入口、发行版本链接和迁移期 Registry 文档的读取。

## Twitter 归档信息与接入契约

Expand Down
8 changes: 8 additions & 0 deletions 20-product-tdd/extension-documentation-hosting.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Extension Documentation Hosting

## 仓库用户文档

插件发布者维护其源码目录下的 `docs/user/`。源码目录由[仓库发行描述](extension-release-and-installation.md#从发布者仓库发现和安装)定位。App 打开所选发行 tag 对应提交中的该目录。目录缺失表示该发行未提供用户文档。

同一插件的通用说明由其维护者写入一个 producer 的 `docs/user/`,其他分发引用该原文,并补充各自的操作说明。First-party 现有的 Python 和 MF 共通说明由 `impl-py` 维护。面向当前读者的订正可发布到仓库默认分支,精确版本链接继续指向发行时的内容。

以下托管与更新规则适用于迁移期仍由 Registry 提供的文档。仓库发行使用上面的用户文档入口。

## Purpose And Ownership

This contract defines how Extension authors, Registry, developer tooling, and consuming Hosts
Expand Down
48 changes: 42 additions & 6 deletions 20-product-tdd/extension-release-and-installation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Extension 分发发布与 Peer 参与契约

Extension 发布者、Registry、开发工具和宿主共同消费本契约。Registry 拥有原生产物及发布生命周期的可执行协议;宿主拥有原生加载和运行生命周期;插件拥有业务、持久数据与协作兼容。本契约通过新版 Registry、宿主及数据库协议共同交付,不能将某一 Unit 的单独升级视为部署已经完成切换。
Extension 的发布者通过自己的仓库交付发行。仓库的 Release 是该次公开发行的来源,部署保存各 Peer 的安装选择,宿主负责原生加载,插件负责业务和数据兼容。GitHub 是首个适用的代码托管平台。现有 Registry 发行按下文的迁移规则继续提供。

## 插件身份与原生发布

Expand All @@ -10,17 +10,51 @@ Extension 发布者、Registry、开发工具和宿主共同消费本契约。Re

各 producer 只构建本仓维护的原生产物,原生依赖仍通过各自包工具消费。发布候选固定本分发的源码、元数据和产物身份;重试使用保存的原候选,不以当前分支的新构建覆盖同一个坐标。宿主 SDK 条件、Python Project/Version 和 MF manifest 等格式约束由相应 Unit 校验,不成为跨分发业务兼容声明。

prepare、upload、publish 一次针对一个 Native Release。只有它自己的全部原生对象齐备时才可公开,检查与提交之间改变产物身份或关联必须重新验证。发布 Python 不等待 MF,发布 MF 不等待 Python。已发布的坐标及产物身份不可覆盖;相同请求可幂等重试,冲突需要新版本。文档不使缺少可执行产物的分发成为可安装版本。
一次发布只交付一个 Native Release。生产者在全部原生对象就绪后公开 Release。公开后的坐标和产物固定,产物变更使用新版本。Python 与 MF 各自完成发布。

共享参与协议中的 Distribution 是开放的非空字符串,不枚举语言、打包方式或现有宿主。各宿主报告自己支持的格式,并在实际加载边界校验;一个新宿主不需要修改共享数据库的格式白名单。Registry 只对自己能交付的产物提供安装能力。
共享参与协议中的 Distribution 是开放的非空字符串。各宿主报告自己支持的格式,并在实际加载边界校验。仓库独立分发首先覆盖 `python` 和 `module_federation`。

Extension 不拥有独立共享数据表。资料使用 Block/Relation/Storage,共享配置与业务状态使用已有 Extension config/state;仅本机需要的草稿、队列和运行状态保存在本机。

## 从发布者仓库发现和安装

所有发布者通过仓库 Topic `inkcre-extension` 参加同一个发现入口。App 也接受部署者直接提供的仓库地址。选定仓库后,从其公开 Releases 查找发行。Git tag 使用 `inkcre-ext/<namespace>/<name>/<distribution>/v<version>`,给出插件逻辑名、原生分发和精确版本。同一仓库可发布多个插件和分发类型。App 选择版本时按逻辑名与分发筛选。

GitHub Release 正文含一个机器可读的 `inkcre-release` HTML 注释。发布工具从现有生产者元数据和实际构建生成 tag 与注释里的 JSON。宿主直接读取 Releases API 返回的正文。坐标和源码提交来自 tag,产物来自 Release 附件。

```text
<!-- inkcre-release
{"schema_version":1,"source_path":"extensions/mail","host_sdk":"core-py","host_sdk_version":">=0.2.0 <0.4.0"}
-->
```

`source_path` 是源码的仓库相对目录,仓库根用 `.`。`host_sdk` 和 `host_sdk_version` 是原生包声明的 SDK 名称和兼容范围。MF 发行选择下表的一种形式。多文件使用 `manifest_url`,单脚本使用 `script`。同一发行坐标只有一种形式,新形式通过新版本发布。

| 分发 | 生产者发布内容 | 宿主读取 |
| --- | --- | --- |
| `python` | 该发行的原生 wheel,作为 Release 附件 | 从附件选取兼容的 wheel,按附件摘要核对下载,并用 wheel 的原生元数据校验插件身份、版本和入口 |
| `module_federation` 多文件 | Release 归档保存完整的 MF 资源树,同一资源树发布到该版本的静态地址 | 通过绝对 URL `manifest_url` 跨源读取 manifest,按需加载入口和其他资源 |
| `module_federation` 单脚本 | 自包含的经典 JS 脚本作为 Release 附件 | 按 `script.asset_name` 从该 Release 的附件中定位脚本,通过普通脚本加载并读取 `script.global_name` 对应的 MF 容器 |

多文件发行的静态地址要为 manifest 和资源提供正确的内容类型与跨域响应。单脚本的 `asset_name` 是该 Release 中唯一匹配的 `.js` 附件名,`global_name` 是此脚本注册的 JavaScript 标识符,须在发布者、插件名和精确版本之间保持唯一。脚本通过 MF `get` 与 `init` 提供插件和共享依赖接口,其构建资源随这一份附件交付。两种形式都遵循同一 SDK 兼容检查。

每个发布者在自己的仓库控制发行。多文件发行可以使用发布者自己的静态站,也可以由发布工具安排从同一仓库提供文件。部署者可用 Release 归档自行镜像。单脚本由发布者的 Release 直接分发。宿主读取发布者声明的发行,安装无需向 InKCre 服务注册。

Web 发行的设置流程如需为同一 Extension 安装 Python 分发,默认读取该 Web 发行所属仓库。Python 分发由另一仓库发布时,Web Release 正文可使用 `python_repository` 指定 `https://github.com/<owner>/<repo>`。设置从已选 Web Release 读取这个地址,查找逻辑名相同的公开 Python 发行。缺少匹配发行时报告仓库和插件名。来源仍为旧 Registry 的 Web 选择继续使用原设置路径。

用户选定来源后,安装选择保存可定位该仓库与精确发行的引用。恢复时直接使用该引用,已具备对应产物时可在本机恢复。精确版本无法取得时,向用户报告该版本的错误。浏览发现和检查更新按需触发。

### First-party 发布

`InKCre/impl-py` 和 `InKCre/impl-ts` 分别在现有仓库发布各自维护的 Python 与 MF 分发。两个仓库都使用 `inkcre-extension` Topic。插件仍以 `inkcre/<name>` 表达共享业务身份,安装到各 Peer 的分发共用以此名字标识的插件条目。宿主沿用各自分发的版本和兼容范围。

以 Mail 为例,Python `0.4.0` 和 MF `0.4.4` 分别生成 `inkcre-ext/inkcre/mail/python/v0.4.0` 和 `inkcre-ext/inkcre/mail/module_federation/v0.4.4`。版本列表直接来自两个仓库的公开 Releases,普通 App 或 SDK 发行按 tag 前缀区分。

## 随签名应用交付的原生分发

`swift_bundled` 表示宿主签名应用携带的原生分发。producer manifest 定义 Extension Name、分发格式和精确版本,由模块资源与签名应用一起交付。宿主只运行实际携带的模块,不下载动态代码、不替换精确选择;需要其他版本时明确要求更新应用。其产物供应链是签名应用,不把不存在的 Registry 发布或原生热加载能力作为已完成事实。

此分发仍有真实启停生命周期和 Peer 参与记录;应用关闭只停止实际运行,不撤回共享启用意图。未配置数据库时可离线使用扩展。首次加入与重连须区分:首次事务内创建缺失的参与,冲突则读已有值;加入或明确启用成功后,重连不重建已移除记录、不重放离线开关。用户在线明确启用可以重新创建本 Peer 的缺失参与;离线操作只改变本机运行并显示共享意图尚未更新。共享写入前复核参与选择和启用意图。Python/MF 原生产物继续按各自 Registry 发布流程交付。
此分发仍有真实启停生命周期和 Peer 参与记录;应用关闭只停止实际运行,不撤回共享启用意图。未配置数据库时可离线使用扩展。首次加入与重连须区分:首次事务内创建缺失的参与,冲突则读已有值;加入或明确启用成功后,重连不重建已移除记录、不重放离线开关。用户在线明确启用可以重新创建本 Peer 的缺失参与;离线操作只改变本机运行并显示共享意图尚未更新。共享写入前复核参与选择和启用意图。

## 部署共享状态与 Peer 参与

Expand Down Expand Up @@ -59,14 +93,16 @@ Extension 不拥有独立共享数据表。资料使用 Block/Relation/Stora

## 历史坐标与协议迁移

Registry v2 提供独立原生分发读写。v1 只读取历史统一坐标,不将两个独立新版本拼成一个旧 Release;旧发布写入明确要求升级。历史原生产物、URL、摘要和来源可继续复用,但公开读取必须遵守对应原生发布的当前封禁与撤回状态。历史入口不能绕过新发布生命周期限制。
Registry v2 继续提供独立原生发行。v1 只读取历史统一坐标,旧写入要求升级。Registry 提供的原有产物、URL 与文档继续遵守其撤回规则。

仓库直连发行由发布者和所用托管平台管理公开、撤回和文件可用性。现有精确选择在同一产物可经仓库来源恢复时迁移,内含旧静态地址的 MF 发行可继续使用旧入口,直到用户选择能从新来源运行的版本。旧入口在依赖它的安装完成过渡后退出。

迁移保留旧部署身份、配置和业务状态,以及可恢复的旧安装快照。旧启用成员转为各 Peer 的参与记录,保留原精确版本及意图。缺少原生格式证据时保留待解析的旧引用,旧全局配置 schema 仅留在快照,不能被赋予未知分发的来源;新版实际宿主识别并条件更新后,才填写有来源的 schema。不得猜测格式或自动改为最新版本。原版本不存在对应分发时明确待修复,不静默选另一个版本。没有记录的停用参与历史不能补造。

新版 Extension 管理与数据库协议共同改变旧全局版本语义。切换需要新版消费者和明确的旧写入退出,不能维护两份可写版本权威。暂停活跃旧运行端、迁移数据库并启动新版宿主后,睡眠旧 Peer 返回也必须先升级;协议 revision 改变本身不停止进程。具体 schema、guard、切换和恢复步骤由数据库与宿主 owner 验证并记录。

## 验收边界

发布验收观察每种分发独立发布、缺少自身产物时保持不可公开、候选重试和提交身份一致,以及历史公开读取遵守封禁。部署验收包含精确旧版本迁移、未知分发延迟解析和非空业务 state 保留。
以同一 first-party 插件的 Python 与 MF 为例,验证各发布者可独立交付,App 能从仓库发现或用仓库地址安装。安装和冷恢复应按记录的来源与精确版本取得产物,MF 验证实际界面和异步资源。迁移用已有 pin 验证原产物及业务数据可恢复。

完整运行验收从实际 Web 应用安装入口进入目标 Peer 的启用、运行、停用和刷新恢复。一个 Peer 升级不能改变另一个同种分发 Peer 的选择;睡眠恢复、离线待应用和 Python 环境更新后的新进程也属于验收。插件案例需覆盖已有内容读取与按需执行、设置 UI 的先行运行以及共享业务数据延续。仅构建、独立 import 或调用 MF 容器不能代替实际入口验收。
1 change: 1 addition & 0 deletions website/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export default defineConfig({
items: [
{ text: 'Build on InKCre', link: '/developer/ecosystem/' },
{ text: 'Build a Source Extension', link: '/developer/ecosystem/source-extension' },
{ text: 'Publish a Web Extension', link: '/developer/ecosystem/publish-web-extension' },
],
},
{
Expand Down
12 changes: 6 additions & 6 deletions website/content/en/developer/ecosystem/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ to contribute it to the Core repository. Start with the boundary your integratio
| Goal | Integration path |
| -------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| Collect from a service InKCre does not support yet | [Build a Source Extension](/developer/ecosystem/source-extension) |
| Ship a browser Extension from your own repository | [Publish a Web Extension](/developer/ecosystem/publish-web-extension) |
| Use existing information from ChatGPT | [Connect the MCP Sink](/guide/sinks/chatgpt) |
| Build a new runtime around the shared info-base | Read the [Peer architecture](/developer/architecture); this requires the admitted database protocol, not arbitrary SQL access |
| Change InKCre's own runtime or product behavior | Follow [Contributing](/developer/contributing) |
Expand All @@ -22,10 +23,9 @@ derives use-facing meaning from stored content and required context. A Sink expo
another tool. An Extension packages one or more capabilities for a compatible Host; not every
integration needs all three or a custom browser interface.

The Python path uses a native wheel, the `inkcre.core.extensions` entry point, and an exact Registry
Release. A Peer selects its own Distribution/version and records its enabled intent. An online Host
then activates the Extension best-effort; users do not maintain a second durable running flag.
Browser code is a separate distribution, not automatically produced by a Python wheel.
A Peer selects an exact Extension distribution and version and records whether it should be enabled.
Python uses a wheel with an `inkcre.core.extensions` entry point. Browser Extensions have their own
Module Federation builds and can publish either a manifest with separate assets or a single script.

The Source tutorial targets **Core Host SDK 0.3.x**. Its Python programming interfaces currently
import Core modules; they are not an independent, universally stable Source SDK. The Extension
Expand All @@ -40,7 +40,7 @@ fixtures during development, with its own database and credentials.

Package identity, Host compatibility, dependencies, and immutable releases are part of delivering a
usable integration. Keep your own package, tests, release history, and user setup guide in your
repository. A public Registry requires a namespace and publishing authorization; a private
development preview does not grant those rights.
repository. You can publish a Web Extension through GitHub Releases using your repository token. If
you use a Registry for distribution, its operator grants namespace and publishing access.

Continue with [Build a Source Extension](/developer/ecosystem/source-extension).
Loading