From 8918a8f6d7dddbce7877c844832ef40c7e25c260 Mon Sep 17 00:00:00 2001 From: Yige Date: Thu, 3 Dec 2026 10:41:20 +0800 Subject: [PATCH] =?UTF-8?q?feat(registry):=20=E5=90=8C=E6=AD=A5=E7=AE=97?= =?UTF-8?q?=E5=8A=9B=E6=8F=92=E4=BB=B6=E5=9B=BA=E5=AE=9A=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E5=A5=91=E7=BA=A6=20(#42)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +- schemas/catalog-metadata.v1.schema.json | 3 +- schemas/registry-entry.v4.3.schema.json | 294 +++++++++++++++++++++++- scripts/application-authoring.test.mjs | 2 +- scripts/authored-release.test.mjs | 28 +++ 5 files changed, 325 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 90884df..4608f63 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ English: Video Editing 0.1.5 pins a reviewed release and retains the FableCut co `extension` 区分提供与消费: -- `contributes` 指明本产品提供的贡献 ID、贡献点、契约版本及包内 `definitionRef.path/sha256`。当前贡献点限于 `document.parsers`、`session.panels`、`session.widgets`、`session.actions`、`tools`、`skills`。 +- `contributes` 指明本产品提供的贡献 ID、贡献点、契约版本及包内 `definitionRef.path/sha256`。当前贡献点限于 `document.parsers`、`session.panels`、`session.widgets`、`session.actions`、`tools`、`skills`。通过下节固定发布物分发的 `native-app` 插件也可声明 `compute.providers`。 - `requires` 指明必需或可选的直接能力依赖,使用精确 `sourceId/appId/contributionId/contractVersion`,可加版本范围。普通应用可以只声明依赖;插件即使有依赖也必须提供贡献。两项同时为空无实际关系,校验拒绝。 - 产品引用不携带安装实例 ID、凭据、启用状态或权限。客户端运行时解析精确安装实例,由目标宿主维护接入、配置和撤销;目录声明不会自动安装、启用或授权依赖。 @@ -87,7 +87,7 @@ English: Plugins are App products with host contributions, sharing the canonical English: The published root format and global 4.2 Schema remain unchanged. Both validators select the separate reviewed authoring Schema only for `web-bundle` or an explicit `appRelease`; ordinary listings retain their existing Schema. Inline definitions use `definitionSource: manifest`, while legacy payload definitions use `definitionPath`, exclusively. Fixed source commits, the downloaded archive SHA-256 and the canonical release digest are separate identities. Validation does not establish client support, source trust, installation, authorization or runtime ownership. -作者 Schema 保留全部 4.2 旧分支,新增 `web-bundle` 与带 `appRelease` 的 `native-app`/`docker-app` 严格分支;其字节由主仓生成并固定,SHA-256 为 `95afcffce0c985215685554ec8b3f5e3012036bf2c4ecc4214c23e4eff895b10`,修改须先更新主仓并经 review。网页包不冒充无执行声明 artifact;宿主/容器服务应用的运行知识与依赖在固定清单中,不限定 Node 技术栈,也不自动执行说明文字。Docker 显式声明固定 `imageRefs`,每项是 `repository@sha256`,复用原容器/执行/服务 owner;没有真实身份 adapter 时保留 Agent 管理,不因为 Schema 合法声称直开。descriptor 在安装时按来源物化并单独核验。最低版本字符串不能代替握手,旧客户端继续读取旧条目并忽略未知类型,不允许改交付类型绕过。 +作者 Schema 保留全部 4.2 旧分支,新增 `web-bundle` 与带 `appRelease` 的 `native-app`/`docker-app` 严格分支;其字节由主仓生成并固定,SHA-256 为 `27a7f86b82f5d88bfe1eae2d083540359ed8f2fccffa8f3d040fdc58d0cf3900`,修改须先更新主仓并经 review。DesireCore 10.0.217 已携带此作者 Schema。发布型算力插件以 `productKind: plugin`、固定 `appRelease` 和 `extension.contributes` 登记,条目与 sidecar 的声明必须一致。网页包不冒充无执行声明 artifact;宿主/容器服务应用的运行知识与依赖在固定清单中,不限定 Node 技术栈,也不自动执行说明文字。Docker 显式声明固定 `imageRefs`,每项是 `repository@sha256`,复用原容器/执行/服务 owner;没有真实身份 adapter 时保留 Agent 管理,不因为 Schema 合法声称直开。descriptor 在安装时按来源物化并单独核验。最低版本字符串不能代替握手,旧客户端继续读取旧条目并忽略未知类型,不允许改交付类型绕过。 根 `SCHEMA_VERSION` 与 global Schema 升级到 4.3 须另提 PR,并等待兼容客户端实际发行验收;知识正式启用及 seed 交付同样须等待该验收。每一步取实际提交/发行/目录回执,不把未合入 commit 固定成官方 seed。 @@ -97,7 +97,7 @@ English: The published root format and global 4.2 Schema remain unchanged. Both GitHub/Gitea 私有来源依真实 ACL 和连接;客户端 private 来源不走公开镜像回退,认证失败拒绝新获取。团队移除不自动改来源 ACL,需实际源管理员处理;已下载字节不能收回。离线已安装应用按保存事实维护,不把目录缓存当新安装的完整运行环境。 -English: The authoring Schema preserves legacy branches and adds strict web-bundle and authored native/Docker release branches; its bytes are generated and pinned by the main repository. Upgrading the root format to 4.3 takes a separate PR after a compatible client release is accepted. Synthetic listing-only fixtures under `fixtures/authoring/` are not published artifacts and stay out of the catalog and its statistics. Private-source access depends on actual Git ACL; team membership does not automatically revoke source access, and catalog withdrawal does not delete installed data. +English: The authoring Schema preserves legacy branches and adds strict web-bundle and authored native/Docker release branches. DesireCore 10.0.217 shipped the reviewed authoring Schema that allows authored native plugin releases to contribute `compute.providers`. Upgrading the root format to 4.3 takes a separate PR after a compatible client release is accepted. Synthetic listing-only fixtures under `fixtures/authoring/` are not published artifacts and stay out of the catalog and its statistics. Private-source access depends on actual Git ACL; team membership does not automatically revoke source access, and catalog withdrawal does not delete installed data. ## 条目格式 diff --git a/schemas/catalog-metadata.v1.schema.json b/schemas/catalog-metadata.v1.schema.json index 317c154..288ed96 100644 --- a/schemas/catalog-metadata.v1.schema.json +++ b/schemas/catalog-metadata.v1.schema.json @@ -364,7 +364,8 @@ "session.widgets", "session.actions", "tools", - "skills" + "skills", + "compute.providers" ], "description": "具有实际宿主消费者的贡献点;未知贡献点不得接入。" }, diff --git a/schemas/registry-entry.v4.3.schema.json b/schemas/registry-entry.v4.3.schema.json index 505ebf5..843cdfd 100644 --- a/schemas/registry-entry.v4.3.schema.json +++ b/schemas/registry-entry.v4.3.schema.json @@ -4055,7 +4055,7 @@ }, "authoredNativeApp": { "type": "object", - "description": "带运行说明的固定宿主应用:可信执行owner核验身份,目录不保存启动命令或当前端口。", + "description": "带运行说明的固定宿主应用或插件:可信执行owner核验身份,目录不保存启动命令或当前端口;插件的常驻服务启动声明只在受核验安装材料中。", "required": [ "id", "name", @@ -4455,8 +4455,258 @@ "additionalProperties": false }, "productKind": { - "const": "application", - "description": "用户自建应用;不是平台声明插件。" + "enum": [ + "application", + "plugin" + ], + "description": "产品归属:application 是用户自建应用;plugin 是为宿主增加能力的插件,必须声明 extension 且至少一项贡献(ADR-218、ADR-376)。" + }, + "extension": { + "type": "object", + "required": [ + "apiVersion", + "hosts", + "runtime", + "contributes" + ], + "additionalProperties": false, + "properties": { + "apiVersion": { + "const": "1.0.0", + "description": "宿主扩展协议版本;当前支持 1.0.0。" + }, + "hosts": { + "type": "array", + "minItems": 1, + "maxItems": 2, + "uniqueItems": true, + "items": { + "type": "string", + "enum": [ + "agent-service", + "desktop-host" + ] + }, + "description": "执行宿主;未实现的宿主只作声明并显示不兼容,客户端展示面在 UI 定义中另行声明。" + }, + "runtime": { + "oneOf": [ + { + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "const": "declarative", + "description": "仅由宿主读取声明,不创建执行进程。" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "kind", + "protocol", + "descriptorRef" + ], + "properties": { + "kind": { + "const": "service", + "description": "既有服务 owner 管理的协议连接;贡献调用继续走原授权和审批。" + }, + "protocol": { + "type": "string", + "enum": [ + "mcp", + "http" + ], + "description": "服务通信协议,不代表连接已经建立。" + }, + "descriptorRef": { + "type": "object", + "required": [ + "path", + "sha256" + ], + "additionalProperties": false, + "properties": { + "path": { + "type": "string", + "minLength": 1, + "maxLength": 512, + "pattern": "^(?!/)(?!.*\\\\)(?!.*:)(?!.*\\u0000)(?!.*(?:^|/)(?:\\.|\\.\\.)(?:/|$))(?!.*//)[^/]+(?:/[^/]+)*$", + "description": "固定在核验制品根下的规范 POSIX 相对文件路径;拒绝绝对路径、反斜杠、盘符、空段、点段及 NUL。解析时仍须核验 realpath containment。" + }, + "sha256": { + "type": "string", + "pattern": "^[a-f0-9]{64}$", + "description": "固定文件字节的 SHA-256;消费前核验,编辑须提交新安装修订。" + } + }, + "description": "安装制品根下内容固定的材料引用;相对路径和摘要必须共同匹配。" + } + }, + "additionalProperties": false + } + ], + "description": "贡献执行承载;descriptor 只定位受核验材料,不能直接把任意 endpoint 当运行事实。" + }, + "contributes": { + "type": "array", + "maxItems": 64, + "items": { + "type": "object", + "required": [ + "id", + "point", + "contractVersion", + "definitionRef" + ], + "additionalProperties": false, + "properties": { + "id": { + "type": "string", + "minLength": 1, + "maxLength": 200, + "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$", + "description": "产品内稳定贡献 ID;与来源、产品及精确安装实例共同定位运行绑定。" + }, + "point": { + "type": "string", + "enum": [ + "document.parsers", + "session.panels", + "session.widgets", + "session.actions", + "tools", + "skills", + "compute.providers" + ], + "description": "具有实际宿主消费者的贡献点;未知贡献点不得接入。" + }, + "contractVersion": { + "const": 1, + "description": "该贡献点的消费契约版本;不兼容版本不激活。" + }, + "definitionRef": { + "type": "object", + "required": [ + "path", + "sha256" + ], + "additionalProperties": false, + "properties": { + "path": { + "type": "string", + "minLength": 1, + "maxLength": 512, + "pattern": "^(?!/)(?!.*\\\\)(?!.*:)(?!.*\\u0000)(?!.*(?:^|/)(?:\\.|\\.\\.)(?:/|$))(?!.*//)[^/]+(?:/[^/]+)*$", + "description": "固定在核验制品根下的规范 POSIX 相对文件路径;拒绝绝对路径、反斜杠、盘符、空段、点段及 NUL。解析时仍须核验 realpath containment。" + }, + "sha256": { + "type": "string", + "pattern": "^[a-f0-9]{64}$", + "description": "固定文件字节的 SHA-256;消费前核验,编辑须提交新安装修订。" + } + }, + "description": "安装制品根下内容固定的材料引用;相对路径和摘要必须共同匹配。" + } + }, + "description": "包内贡献定义引用;业务层补充贡献 ID 唯一性及内容摘要核验。" + }, + "description": "本产品提供的宿主贡献;仅消费能力的普通应用允许空数组,独立插件必须至少一项。每项定义从安装材料读取并核验。" + }, + "configurationSchemaRef": { + "type": "object", + "required": [ + "path", + "sha256" + ], + "additionalProperties": false, + "properties": { + "path": { + "type": "string", + "minLength": 1, + "maxLength": 512, + "pattern": "^(?!/)(?!.*\\\\)(?!.*:)(?!.*\\u0000)(?!.*(?:^|/)(?:\\.|\\.\\.)(?:/|$))(?!.*//)[^/]+(?:/[^/]+)*$", + "description": "固定在核验制品根下的规范 POSIX 相对文件路径;拒绝绝对路径、反斜杠、盘符、空段、点段及 NUL。解析时仍须核验 realpath containment。" + }, + "sha256": { + "type": "string", + "pattern": "^[a-f0-9]{64}$", + "description": "固定文件字节的 SHA-256;消费前核验,编辑须提交新安装修订。" + } + }, + "description": "安装制品根下内容固定的材料引用;相对路径和摘要必须共同匹配。" + }, + "requires": { + "type": "array", + "maxItems": 64, + "items": { + "type": "object", + "required": [ + "sourceId", + "appId", + "contributionId", + "contractVersion", + "optional" + ], + "additionalProperties": false, + "properties": { + "sourceId": { + "type": "string", + "minLength": 1, + "maxLength": 200, + "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$", + "description": "直接依赖的受信产品来源,禁止按同名产品猜测。" + }, + "appId": { + "type": "string", + "minLength": 1, + "maxLength": 200, + "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$", + "description": "所依赖的应用或插件产品 ID;静态定义不携带安装实例 ID。" + }, + "contributionId": { + "type": "string", + "minLength": 1, + "maxLength": 200, + "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$", + "description": "消费方需要的具体贡献 ID。" + }, + "contractVersion": { + "const": 1, + "description": "消费方支持的贡献契约版本。" + }, + "optional": { + "type": "boolean", + "description": "true 为可选增强;false 缺失时阻断受影响功能,不自动安装或卸载。" + }, + "versionRange": { + "type": "string", + "minLength": 1, + "maxLength": 120, + "description": "可选发布版本 semver 范围,由满足性检查器校验。" + } + }, + "description": "直接能力依赖;运行时须显式解析兼容的精确安装实例,不建设递归依赖求解器。" + }, + "description": "本产品消费的必需或可选直接能力依赖;不产生使用授权。" + } + }, + "not": { + "properties": { + "contributes": { + "maxItems": 0 + }, + "requires": { + "maxItems": 0 + } + } + }, + "description": "产品提供或消费宿主能力的关系契约;至少声明一项贡献或依赖。普通应用可仅消费,独立插件仍须提供实际贡献。" }, "entrypoints": { "type": "array", @@ -4638,6 +4888,44 @@ "upstreamMaintainer" ] } + }, + { + "if": { + "properties": { + "productKind": { + "const": "plugin" + } + }, + "required": [ + "productKind" + ] + }, + "then": { + "required": [ + "extension" + ], + "properties": { + "extension": { + "properties": { + "contributes": { + "minItems": 1 + } + } + } + } + }, + "else": { + "not": { + "required": [ + "extension" + ] + }, + "properties": { + "entrypoints": { + "minItems": 1 + } + } + } } ] }, diff --git a/scripts/application-authoring.test.mjs b/scripts/application-authoring.test.mjs index f3e12f2..2279fb1 100644 --- a/scripts/application-authoring.test.mjs +++ b/scripts/application-authoring.test.mjs @@ -22,7 +22,7 @@ test('根格式仍为4.2,作者Schema保持主仓固定字节,合成fixtures assert.equal(root.version,'4.2.0') assert.equal(readFileSync(join(source,'SCHEMA_VERSION'),'utf8').trim(),'4.2.0') assert.equal(root.stats.webBundles,undefined) - assert.equal(createHash('sha256').update(readFileSync(join(source,'schemas/registry-entry.v4.3.schema.json'))).digest('hex'),'95afcffce0c985215685554ec8b3f5e3012036bf2c4ecc4214c23e4eff895b10') + assert.equal(createHash('sha256').update(readFileSync(join(source,'schemas/registry-entry.v4.3.schema.json'))).digest('hex'),'27a7f86b82f5d88bfe1eae2d083540359ed8f2fccffa8f3d040fdc58d0cf3900') for (const id of readdirSync(join(source,'fixtures/authoring/entries'))) assert.equal(existsSync(join(source,'entries',id)),false,id) }) test('静态与带服务合成目录三文件保持App语义,两个validator同样通过',() => { diff --git a/scripts/authored-release.test.mjs b/scripts/authored-release.test.mjs index 1446c4f..420525e 100644 --- a/scripts/authored-release.test.mjs +++ b/scripts/authored-release.test.mjs @@ -88,6 +88,34 @@ test('官方根仍为4.2且global Schema保留已发布原字节', () => { assert.equal(createHash('sha256').update(readFileSync(join(source, 'schemas/registry-entry.schema.json'))).digest('hex'), 'ea63d6305ae17994e595aea009a131c41300d2b7fdb07ec83cc2c19c37b32038') }) for (const type of ['native-app', 'web-bundle']) test('两个入口接受固定内联定义 ' + type, () => { expectValid(fixture(type)) }) +test('两个入口接受固定发布的算力插件并校验 sidecar 声明', () => { + const root = fixture() + const extension = { + apiVersion: '1.0.0', + hosts: ['agent-service'], + runtime: { + kind: 'service', + protocol: 'mcp', + descriptorRef: { path: 'runtime.json', sha256: 'a'.repeat(64) }, + }, + contributes: [{ + id: 'provider', + point: 'compute.providers', + contractVersion: 1, + definitionRef: { path: 'provider.json', sha256: 'b'.repeat(64) }, + }], + } + const placementPolicy = { showInMyApps: false, allowNavPin: false, allowAgentBinding: false } + mutate(root, entryFile, entry => { + Object.assign(entry, { productKind: 'plugin', extension, entrypoints: [], placementPolicy }) + }) + mutate(root, sidecarFile, sidecar => { + Object.assign(sidecar.spec, { productKind: 'plugin', extension, entrypointKinds: [], placementPolicy }) + }) + expectValid(root) + mutate(root, sidecarFile, sidecar => { sidecar.spec.extension.contributes[0].definitionRef.sha256 = 'c'.repeat(64) }) + assert.ok(validateRegistry(root).errors.some(error => error.code === 'extension-mismatch')) +}) test('旧独立definitionPath分支继续通过', () => { const root = fixture() mutate(root, entryFile, entry => { delete entry.appRelease.definitionSource; entry.appRelease.definitionPath = 'definition.json' })