feat: 补充固定工作台合成样本与 webBundles 校验 (#12)

新增静态、原生服务、Docker 三组合成的 listing-only 作者契约样本,补充 webBundles 目录统计与 definitionPath 规范路径检查。受主仓固定的 4.3 作者 Schema、正式 4.2 Schema、根 manifest 和 27 个条目均不变。

Add synthetic listing-only authoring fixtures, webBundles catalog statistics and a canonical definitionPath check. The pinned 4.3 authoring Schema, formal 4.2 Schema, root manifest and 27 entries are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
yigeandClaude Opus 5.5 authored and GitHub committed 2026-11-03 09:54:00 +08:00
1 parent 5247054b7a
commit 13986db85e
17 files changed
+630 -5

No files matched your search

+14 -1
View File
@@ -15,6 +15,7 @@ DesireCore 客户端启动时会克隆此仓库,并定期同步更新。用户
├── schemas/ # legacy entry、仓库 manifest 与 catalog sidecar Schema ├── schemas/ # legacy entry、仓库 manifest 与 catalog sidecar Schema
├── scripts/ # Registry v4 校验入口与回归测试 ├── scripts/ # Registry v4 校验入口与回归测试
├── scripts/catalog/ # 零依赖离线 validator 与 node:test ├── scripts/catalog/ # 零依赖离线 validator 与 node:test
├── fixtures/authoring/ # 合成的作者契约样本(listing-only,不进入正式目录)
├── entries/ # 🔑 所有注册表条目(统一格式) ├── entries/ # 🔑 所有注册表条目(统一格式)
│ ├── n8n/ # 示例:Docker 应用 │ ├── n8n/ # 示例:Docker 应用
│ │ ├── manifest.json # 条目元数据(必需) │ │ ├── manifest.json # 条目元数据(必需)
@@ -86,6 +87,18 @@ 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. 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_VERSION` 与 global Schema 升级到 4.3 须另提 PR,并等待兼容客户端实际发行验收;知识正式启用及 seed 交付同样须等待该验收。每一步取实际提交/发行/目录回执,不把未合入 commit 固定成官方 seed。
`fixtures/authoring/` 只有合成的 listing-only 契约样本,不进入 `entries/` 或目录统计;example.test 地址不是可获取的应用发行物,不表示上传、审核、运行或第二用户安装已完成。
作者从同一固定导出生成 manifest.json、catalog-metadata.v1.json、install.md 三文件,产品 ID/版本/入口保持一致。证据不足保持 listing-only;installable 需真实来源、许可和审核记录。用户实例/数据/平台 secret/开发机路径不写目录。目录 PR、来源上传、准入和安装各自核验;同版本异内容创建新修订,目录更新不热替换已安装快照,撤回不自动卸载或删除数据。
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.
## 条目格式 ## 条目格式
每个条目是 `entries/<id>/` 下的一个目录,目录名即条目 ID。 每个条目是 `entries/<id>/` 下的一个目录,目录名即条目 ID。
@@ -100,7 +113,7 @@ English: The published root format and global 4.2 Schema remain unchanged. Both
|------|------|------|------| |------|------|------|------|
| `id` | string | ✅ | 唯一标识,与目录名一致 | | `id` | string | ✅ | 唯一标识,与目录名一致 |
| `name` | string | ✅ | 显示名称 | | `name` | string | ✅ | 显示名称 |
| `type` | string | ✅ | 条目类型:`native-app` / `docker-app` / `artifact` / `mcp` / `http-api` / `external-integration` | | `type` | string | ✅ | 条目类型:`native-app` / `docker-app` / `artifact` / `web-bundle` / `mcp` / `http-api` / `external-integration` |
| `version` | string | ✅ | 上游原始版本字符串;可为 SemVer、CalVer 或不透明版本 | | `version` | string | ✅ | 上游原始版本字符串;可为 SemVer、CalVer 或不透明版本 |
| `description` | string | ✅ | 一行功能摘要 | | `description` | string | ✅ | 一行功能摘要 |
| `author` | string | | 作者或组织 | | `author` | string | | 作者或组织 |
@@ -0,0 +1,82 @@
{
"$schema": "../../schemas/catalog-metadata.v1.schema.json",
"schemaVersion": 1,
"identity": {
"kind": "app",
"id": "docker-workbench-example"
},
"presentation": {
"defaultLocale": "zh-CN",
"i18n": {
"zh-CN": {
"name": "容器工作台示例",
"summary": "仅用于契约核验的合成工作台材料。",
"description": "仅用于契约核验的合成工作台材料。"
}
},
"tags": [
"workbench",
"example"
]
},
"release": {
"state": "known",
"version": "1.0.0",
"versionScheme": "semver"
},
"timestamps": {
"catalogUpdatedAt": {
"state": "unknown"
},
"releasePublishedAt": {
"state": "unknown"
},
"reviewedAt": {
"state": "unknown"
},
"upstreamObservedAt": {
"state": "unknown"
}
},
"provenance": {
"content": {
"kind": "release",
"url": "https://git.example.test/examples/releases/download/1.0.0/workbench.zip",
"ref": "1111111111111111111111111111111111111111",
"sha256": "ed9b876d3162d09d5d7264cf552079d44e8a17d14665a00fb97bffb94c121284"
}
},
"governance": {
"stewardship": "community",
"availability": "listing-only",
"license": {
"state": "known",
"value": "MIT"
},
"redistribution": "verify-package-terms"
},
"compatibility": {
"platforms": {
"state": "known",
"values": [
"macos",
"windows",
"linux"
]
},
"requiredClientVersion": "10.0.180"
},
"spec": {
"kind": "app",
"category": "tools",
"productKind": "application",
"entrypointKinds": [
"embedded-web"
],
"placementPolicy": {
"showInMyApps": true,
"allowNavPin": true,
"allowAgentBinding": true
}
}
}
@@ -0,0 +1,26 @@
# 容器工作台示例 1.0.0
目录材料对应固定应用release,上传、目录审阅和实例安装分别核验。
- 来源:https://git.example.test/examples/releases/download/1.0.0/workbench.zip
- 固定来源ref:1111111111111111111111111111111111111111
- 归档响应体SHA-256:ed9b876d3162d09d5d7264cf552079d44e8a17d14665a00fb97bffb94c121284
- releaseDigest:ebe36976b3bf3f3af1eb833162fe61a1509bdbdb373000da1e2c067dada17540
- 作者定义:application.json
- 所需能力:app-authoring-v1, release, runtime-binding
先读取应用安装管理技能 app-install-manager,解析当前请求、精确目标与占用。实际能力握手必须满足以上要求,版本号不能代替握手。
使用用户已授权的Git/HTTP工具取得此固定材料,核对归档原始字节摘要;安全解包后核读app-release.json和全部文件摘要、作者定义与版本。releaseDigest按app-release-c14n-v1计算,不能换成归档摘要。
通过已有release prepare接口取得owned固定候选与来源物化descriptor,分别核验descriptor原始字节;沿唯一安装writer提交CAS,登记成功后再检查启动和功能,不能把材料存在或端口响应说成已完成安装。
运行和依赖说明位于runtime/说明.md;Agent选择实际执行方式并走已有执行owner。网页直接打开须取得真实运行身份与代际绑定,不能用旧PID/端口/核验记录代替。
固定镜像依赖为registry.example.test/example/app@sha256:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd;镜像许可、真实Docker环境和来源鉴权分别核验。使用原容器/执行/服务owner,缺可信身份adapter时保持Agent管理,不能因为Schema通过声称容器已运行。
此release未声明平台业务文件合同;安装说明不授予宿主文件或共享数据库权限。持久数据和备份要求须在实际应用中核读。
同版本异内容必须创建新修订。目录更新只产生候选,不能改写已安装快照。目录撤回阻止新获取,不自动卸载或删除本机数据;离线只能继续使用已经核验且本地依赖完整的版本。
私有来源由真实Git/Gitea ACL和连接鉴权;凭据不写入本目录、归档或URL。团队成员移除不会自动撤销来源端访问,需源管理员处理;已下载字节不能收回。
@@ -0,0 +1,68 @@
{
"id": "docker-workbench-example",
"name": "容器工作台示例",
"type": "docker-app",
"productKind": "application",
"version": "1.0.0",
"author": "Example Author",
"description": "仅用于契约核验的合成工作台材料。",
"tags": [
"workbench",
"example"
],
"icon": "AppWindow",
"iconLetter": "容",
"platformSupport": [
"macos",
"windows",
"linux"
],
"category": "tools",
"shortDesc": "仅用于契约核验的合成工作台材料。",
"fullDesc": "仅用于契约核验的合成工作台材料。",
"install": {
"method": "release",
"requirements": {
"docker": true,
"ports": []
}
},
"appRelease": {
"schemaVersion": 1,
"releaseDigest": "ebe36976b3bf3f3af1eb833162fe61a1509bdbdb373000da1e2c067dada17540",
"manifestPath": "app-release.json",
"definitionPath": "application.json",
"requiredCapabilities": [
"app-authoring-v1",
"release",
"runtime-binding"
],
"imageRefs": [
"registry.example.test/example/app@sha256:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
]
},
"source": {
"kind": "release",
"url": "https://git.example.test/examples/releases/download/1.0.0/workbench.zip",
"ref": "1111111111111111111111111111111111111111",
"sha256": "ed9b876d3162d09d5d7264cf552079d44e8a17d14665a00fb97bffb94c121284"
},
"requiredClientVersion": "10.0.180",
"entrypoints": [
{
"id": "main",
"name": "工作台",
"kind": "embedded-web",
"serviceRef": "workbench:main"
}
],
"placementPolicy": {
"showInMyApps": true,
"allowNavPin": true,
"allowAgentBinding": true
},
"stewardship": "community",
"availability": "listing-only",
"license": "MIT",
"redistribution": "verify-package-terms"
}
@@ -0,0 +1,82 @@
{
"$schema": "../../schemas/catalog-metadata.v1.schema.json",
"schemaVersion": 1,
"identity": {
"kind": "app",
"id": "service-workbench-example"
},
"presentation": {
"defaultLocale": "zh-CN",
"i18n": {
"zh-CN": {
"name": "服务工作台示例",
"summary": "仅用于契约核验的合成工作台材料。",
"description": "仅用于契约核验的合成工作台材料。"
}
},
"tags": [
"workbench",
"example"
]
},
"release": {
"state": "known",
"version": "1.0.0",
"versionScheme": "semver"
},
"timestamps": {
"catalogUpdatedAt": {
"state": "unknown"
},
"releasePublishedAt": {
"state": "unknown"
},
"reviewedAt": {
"state": "unknown"
},
"upstreamObservedAt": {
"state": "unknown"
}
},
"provenance": {
"content": {
"kind": "release",
"url": "https://git.example.test/examples/releases/download/1.0.0/workbench.zip",
"ref": "1111111111111111111111111111111111111111",
"sha256": "ed9b876d3162d09d5d7264cf552079d44e8a17d14665a00fb97bffb94c121284"
}
},
"governance": {
"stewardship": "community",
"availability": "listing-only",
"license": {
"state": "known",
"value": "MIT"
},
"redistribution": "verify-package-terms"
},
"compatibility": {
"platforms": {
"state": "known",
"values": [
"macos",
"windows",
"linux"
]
},
"requiredClientVersion": "10.0.180"
},
"spec": {
"kind": "app",
"category": "tools",
"productKind": "application",
"entrypointKinds": [
"embedded-web"
],
"placementPolicy": {
"showInMyApps": true,
"allowNavPin": true,
"allowAgentBinding": true
}
}
}
@@ -0,0 +1,24 @@
# 服务工作台示例 1.0.0
目录材料对应固定应用release,上传、目录审阅和实例安装分别核验。
- 来源:https://git.example.test/examples/releases/download/1.0.0/workbench.zip
- 固定来源ref:1111111111111111111111111111111111111111
- 归档响应体SHA-256:ed9b876d3162d09d5d7264cf552079d44e8a17d14665a00fb97bffb94c121284
- releaseDigest:73393f784bede68657be54fdfcbb9dcb083a5a15f8e272d01dce453152cc966f
- 作者定义:application.json
- 所需能力:app-authoring-v1, release, runtime-binding
先读取应用安装管理技能 app-install-manager,解析当前请求、精确目标与占用。实际能力握手必须满足以上要求,版本号不能代替握手。
使用用户已授权的Git/HTTP工具取得此固定材料,核对归档原始字节摘要;安全解包后核读app-release.json和全部文件摘要、作者定义与版本。releaseDigest按app-release-c14n-v1计算,不能换成归档摘要。
通过已有release prepare接口取得owned固定候选与来源物化descriptor,分别核验descriptor原始字节;沿唯一安装writer提交CAS,登记成功后再检查启动和功能,不能把材料存在或端口响应说成已完成安装。
运行和依赖说明位于runtime/说明.md;Agent选择实际执行方式并走已有执行owner。网页直接打开须取得真实运行身份与代际绑定,不能用旧PID/端口/核验记录代替。
此release未声明平台业务文件合同;安装说明不授予宿主文件或共享数据库权限。持久数据和备份要求须在实际应用中核读。
同版本异内容必须创建新修订。目录更新只产生候选,不能改写已安装快照。目录撤回阻止新获取,不自动卸载或删除本机数据;离线只能继续使用已经核验且本地依赖完整的版本。
私有来源由真实Git/Gitea ACL和连接鉴权;凭据不写入本目录、归档或URL。团队成员移除不会自动撤销来源端访问,需源管理员处理;已下载字节不能收回。
@@ -0,0 +1,65 @@
{
"id": "service-workbench-example",
"name": "服务工作台示例",
"type": "native-app",
"productKind": "application",
"version": "1.0.0",
"author": "Example Author",
"description": "仅用于契约核验的合成工作台材料。",
"tags": [
"workbench",
"example"
],
"icon": "AppWindow",
"iconLetter": "服",
"platformSupport": [
"macos",
"windows",
"linux"
],
"category": "tools",
"shortDesc": "仅用于契约核验的合成工作台材料。",
"fullDesc": "仅用于契约核验的合成工作台材料。",
"install": {
"method": "release",
"requirements": {
"docker": false,
"ports": []
}
},
"appRelease": {
"schemaVersion": 1,
"releaseDigest": "73393f784bede68657be54fdfcbb9dcb083a5a15f8e272d01dce453152cc966f",
"manifestPath": "app-release.json",
"definitionPath": "application.json",
"requiredCapabilities": [
"app-authoring-v1",
"release",
"runtime-binding"
]
},
"source": {
"kind": "release",
"url": "https://git.example.test/examples/releases/download/1.0.0/workbench.zip",
"ref": "1111111111111111111111111111111111111111",
"sha256": "ed9b876d3162d09d5d7264cf552079d44e8a17d14665a00fb97bffb94c121284"
},
"requiredClientVersion": "10.0.180",
"entrypoints": [
{
"id": "main",
"name": "工作台",
"kind": "embedded-web",
"serviceRef": "workbench:main"
}
],
"placementPolicy": {
"showInMyApps": true,
"allowNavPin": true,
"allowAgentBinding": true
},
"stewardship": "community",
"availability": "listing-only",
"license": "MIT",
"redistribution": "verify-package-terms"
}
@@ -0,0 +1,83 @@
{
"$schema": "../../schemas/catalog-metadata.v1.schema.json",
"schemaVersion": 1,
"identity": {
"kind": "app",
"id": "static-workbench-example"
},
"presentation": {
"defaultLocale": "zh-CN",
"i18n": {
"zh-CN": {
"name": "静态工作台示例",
"summary": "仅用于契约核验的合成工作台材料。",
"description": "仅用于契约核验的合成工作台材料。"
}
},
"tags": [
"workbench",
"example"
]
},
"release": {
"state": "known",
"version": "1.0.0",
"versionScheme": "semver"
},
"timestamps": {
"catalogUpdatedAt": {
"state": "unknown"
},
"releasePublishedAt": {
"state": "unknown"
},
"reviewedAt": {
"state": "unknown"
},
"upstreamObservedAt": {
"state": "unknown"
}
},
"provenance": {
"content": {
"kind": "release",
"url": "https://git.example.test/examples/releases/download/1.0.0/workbench.zip",
"ref": "1111111111111111111111111111111111111111",
"sha256": "ed9b876d3162d09d5d7264cf552079d44e8a17d14665a00fb97bffb94c121284"
}
},
"governance": {
"stewardship": "community",
"availability": "listing-only",
"license": {
"state": "known",
"value": "MIT"
},
"redistribution": "verify-package-terms"
},
"compatibility": {
"platforms": {
"state": "known",
"values": [
"macos",
"windows",
"linux",
"web"
]
},
"requiredClientVersion": "10.0.180"
},
"spec": {
"kind": "app",
"category": "tools",
"productKind": "application",
"entrypointKinds": [
"embedded-web"
],
"placementPolicy": {
"showInMyApps": true,
"allowNavPin": true,
"allowAgentBinding": true
}
}
}
@@ -0,0 +1,24 @@
# 静态工作台示例 1.0.0
目录材料对应固定应用release,上传、目录审阅和实例安装分别核验。
- 来源:https://git.example.test/examples/releases/download/1.0.0/workbench.zip
- 固定来源ref:1111111111111111111111111111111111111111
- 归档响应体SHA-256:ed9b876d3162d09d5d7264cf552079d44e8a17d14665a00fb97bffb94c121284
- releaseDigest:fe8290e42731a0132753b0c99bc0c08c82e039845ac7a489e3ee8c1e36515044
- 作者定义:application.json
- 所需能力:app-authoring-v1, release, web-bundle
先读取应用安装管理技能 app-install-manager,解析当前请求、精确目标与占用。实际能力握手必须满足以上要求,版本号不能代替握手。
使用用户已授权的Git/HTTP工具取得此固定材料,核对归档原始字节摘要;安全解包后核读app-release.json和全部文件摘要、作者定义与版本。releaseDigest按app-release-c14n-v1计算,不能换成归档摘要。
通过已有release prepare接口取得owned固定候选与来源物化descriptor,分别核验descriptor原始字节;沿唯一安装writer提交CAS,登记成功后再检查启动和功能,不能把材料存在或端口响应说成已完成安装。
静态文件只能沿release.delivery.entrypoints映射承载,不运行构建/宿主程序,不注册虚假的全局API服务。
此release未声明平台业务文件合同;安装说明不授予宿主文件或共享数据库权限。持久数据和备份要求须在实际应用中核读。
同版本异内容必须创建新修订。目录更新只产生候选,不能改写已安装快照。目录撤回阻止新获取,不自动卸载或删除本机数据;离线只能继续使用已经核验且本地依赖完整的版本。
私有来源由真实Git/Gitea ACL和连接鉴权;凭据不写入本目录、归档或URL。团队成员移除不会自动撤销来源端访问,需源管理员处理;已下载字节不能收回。
@@ -0,0 +1,66 @@
{
"id": "static-workbench-example",
"name": "静态工作台示例",
"type": "web-bundle",
"productKind": "application",
"version": "1.0.0",
"author": "Example Author",
"description": "仅用于契约核验的合成工作台材料。",
"tags": [
"workbench",
"example"
],
"icon": "AppWindow",
"iconLetter": "静",
"platformSupport": [
"macos",
"windows",
"linux",
"web"
],
"category": "tools",
"shortDesc": "仅用于契约核验的合成工作台材料。",
"fullDesc": "仅用于契约核验的合成工作台材料。",
"install": {
"method": "web-bundle",
"requirements": {
"docker": false,
"ports": []
}
},
"appRelease": {
"schemaVersion": 1,
"releaseDigest": "fe8290e42731a0132753b0c99bc0c08c82e039845ac7a489e3ee8c1e36515044",
"manifestPath": "app-release.json",
"definitionPath": "application.json",
"requiredCapabilities": [
"app-authoring-v1",
"release",
"web-bundle"
]
},
"source": {
"kind": "release",
"url": "https://git.example.test/examples/releases/download/1.0.0/workbench.zip",
"ref": "1111111111111111111111111111111111111111",
"sha256": "ed9b876d3162d09d5d7264cf552079d44e8a17d14665a00fb97bffb94c121284"
},
"requiredClientVersion": "10.0.180",
"entrypoints": [
{
"id": "main",
"name": "工作台",
"kind": "embedded-web",
"serviceRef": "workbench:main"
}
],
"placementPolicy": {
"showInMyApps": true,
"allowNavPin": true,
"allowAgentBinding": true
},
"stewardship": "community",
"availability": "listing-only",
"license": "MIT",
"redistribution": "verify-package-terms"
}
+1 -1
View File
@@ -6,7 +6,7 @@
"type": "module", "type": "module",
"scripts": { "scripts": {
"validate": "node scripts/validate-registry.mjs", "validate": "node scripts/validate-registry.mjs",
"test": "node --test scripts/validate-registry.test.mjs scripts/native-app.test.mjs scripts/plugin-contract.test.mjs scripts/authored-release.test.mjs && npm run validate" "test": "node --test scripts/validate-registry.test.mjs scripts/native-app.test.mjs scripts/plugin-contract.test.mjs scripts/authored-release.test.mjs scripts/application-authoring.test.mjs && npm run validate"
}, },
"devDependencies": { "devDependencies": {
"ajv": "8.20.0" "ajv": "8.20.0"
+1
View File
@@ -23,6 +23,7 @@
"dockerApps": { "type": "integer", "minimum": 0 }, "dockerApps": { "type": "integer", "minimum": 0 },
"nativeApps": { "type": "integer", "minimum": 0 }, "nativeApps": { "type": "integer", "minimum": 0 },
"artifactApps": { "type": "integer", "minimum": 0, "description": "纯声明制品的 App 条目数,包括插件;不是安装数。" }, "artifactApps": { "type": "integer", "minimum": 0, "description": "纯声明制品的 App 条目数,包括插件;不是安装数。" },
"webBundles": { "type": "integer", "minimum": 0, "description": "固定网页包App条目数;不是安装数或验证成功数量。" },
"mcpServices": { "type": "integer", "minimum": 0 }, "mcpServices": { "type": "integer", "minimum": 0 },
"httpApis": { "type": "integer", "minimum": 0 }, "httpApis": { "type": "integer", "minimum": 0 },
"externalIntegrations": { "type": "integer", "minimum": 0 } "externalIntegrations": { "type": "integer", "minimum": 0 }
+86
View File
@@ -0,0 +1,86 @@
import assert from 'node:assert/strict'
import { spawnSync } from 'node:child_process'
import { createHash } from 'node:crypto'
import { readFileSync, readdirSync, existsSync, cpSync, mkdtempSync, writeFileSync, rmSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { tmpdir } from 'node:os'
import { test, afterEach } from 'node:test'
import Ajv from 'ajv'
import { validateRegistry } from './catalog/validator.mjs'
import { validateApplicationContract } from './catalog/application-contract.mjs'
const source = join(dirname(fileURLToPath(import.meta.url)),'..')
const temporary = []
afterEach(() => { for (const root of temporary.splice(0)) rmSync(root,{recursive:true,force:true}) })
const schema = JSON.parse(readFileSync(join(source,'schemas/registry-entry.v4.3.schema.json'),'utf8'))
const validate = new Ajv({allErrors:true,strict:true,strictTypes:false,strictRequired:false,validateFormats:false}).compile(schema)
const load = id => JSON.parse(readFileSync(join(source,'fixtures/authoring/entries',id,'manifest.json'),'utf8'))
test('根格式仍为4.2,作者Schema保持主仓固定字节,合成fixtures不进入正式目录',() => {
const root = JSON.parse(readFileSync(join(source,'manifest.json'),'utf8'))
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')
for (const id of readdirSync(join(source,'fixtures/authoring/entries'))) assert.equal(existsSync(join(source,'entries',id)),false,id)
})
test('静态与带服务合成目录三文件保持App语义,两个validator同样通过',() => {
const root = mkdtempSync(join(tmpdir(),'registry-authoring-'));temporary.push(root)
cpSync(join(source,'schemas'),join(root,'schemas'),{recursive:true})
cpSync(join(source,'schemas/registry-entry.v4.3.schema.json'),join(root,'schemas/registry-entry.schema.json'))
cpSync(join(source,'fixtures/authoring/entries'),join(root,'entries'),{recursive:true})
const manifest = JSON.parse(readFileSync(join(source,'manifest.json'),'utf8'))
manifest.version='4.3.0';manifest.dataVersion='4.3.0'
manifest.stats={totalEntries:3,dockerApps:1,nativeApps:1,webBundles:1,mcpServices:0,httpApis:0,externalIntegrations:0}
writeFileSync(join(root,'manifest.json'),JSON.stringify(manifest));writeFileSync(join(root,'SCHEMA_VERSION'),'4.3.0\n')
const report = validateRegistry(root)
assert.equal(report.ok,true,JSON.stringify(report.errors))
assert.equal(report.counts.webBundles,1)
const cli = spawnSync(process.execPath,[join(source,'scripts/validate-registry.mjs'),'--root',root],{encoding:'utf8'})
assert.equal(cli.status,0,cli.stdout+cli.stderr)
for (const id of ['static-workbench-example','service-workbench-example','docker-workbench-example']) {
const item=load(id);assert.equal(validate(item),true,JSON.stringify(validate.errors))
assert.deepEqual(validateApplicationContract(item),[])
assert.equal(item.sourceId,undefined)
assert.notEqual(item.appRelease.releaseDigest,item.source.sha256)
assert.equal(item.availability,'listing-only')
}
})
test('不能把完整HTML伪装成artifact、native-node或内部MCP服务',() => {
const item=load('static-workbench-example')
for (const change of [copy=>{copy.type='artifact'},copy=>{copy.install.method='native-node'},copy=>{copy.connection={transport:'stdio',command:'node'}},copy=>{copy.appRelease.materialRoot='/private'}]) {
const copy=structuredClone(item);change(copy);assert.equal(validate(copy),false)
}
})
test('未知能力、可变ref和私有凭据不成为正式分发事实',() => {
const item=load('static-workbench-example')
for (const change of [copy=>{copy.source.ref='latest'},copy=>{copy.source.url='https://credential@git.example.test/private.zip'},copy=>{copy.appRelease.requiredCapabilities=['app-authoring-v1']}]) {
const copy=structuredClone(item);change(copy);assert.ok(validateApplicationContract(copy).length>0)
}
})
test('definitionPath声明时必须是规范相对路径,内联定义不要求该字段',() => {
const item=load('service-workbench-example')
for (const path of ['C:/application.json','runtime//application.json','../application.json']) {
const copy=structuredClone(item);copy.appRelease.definitionPath=path
assert.ok(validateApplicationContract(copy).length>0,path)
}
const inline=structuredClone(item);delete inline.appRelease.definitionPath;inline.appRelease.definitionSource='manifest'
assert.equal(validate(inline),true,JSON.stringify(validate.errors))
assert.deepEqual(validateApplicationContract(inline),[])
})
test('保留既有native-node条目,新native release字段不污染旧分支',() => {
const old=JSON.parse(readFileSync(join(source,'entries/desirecore-control/manifest.json'),'utf8'))
assert.equal(validate(old),true,JSON.stringify(validate.errors))
old.appRelease=load('service-workbench-example').appRelease
assert.equal(validate(old),false)
})
test('Docker发布固定真实镜像内容引用,不把浮动tag或错误端口当成固定材料',() => {
const item=load('docker-workbench-example')
assert.equal(validate(item),true,JSON.stringify(validate.errors))
assert.equal(item.install.method,'release');assert.equal(item.install.requirements.docker,true)
for (const image of ['node:latest','registry.example.test/example/app:1.0.0','localhost:70000/app@sha256:'+'d'.repeat(64)]) {
const copy=structuredClone(item);copy.appRelease.imageRefs=[image]
assert.ok(!validate(copy) || validateApplicationContract(copy).length>0)
}
})
+1 -1
View File
@@ -28,7 +28,7 @@ function fixture(type = 'native-app') {
cpSync(join(source, 'schemas'), join(root, 'schemas'), { recursive: true }) cpSync(join(source, 'schemas'), join(root, 'schemas'), { recursive: true })
cpSync(join(source, 'entries/desirecore-control'), join(root, 'entries/desirecore-control'), { recursive: true }) cpSync(join(source, 'entries/desirecore-control'), join(root, 'entries/desirecore-control'), { recursive: true })
const manifest = JSON.parse(readFileSync(join(source, 'manifest.json'), 'utf8')) const manifest = JSON.parse(readFileSync(join(source, 'manifest.json'), 'utf8'))
manifest.stats = { totalEntries: 1, dockerApps: 0, nativeApps: type === 'native-app' ? 1 : 0, mcpServices: 0, httpApis: 0, externalIntegrations: 0 } manifest.stats = { totalEntries: 1, dockerApps: 0, nativeApps: type === 'native-app' ? 1 : 0, ...(type === 'web-bundle' ? { webBundles: 1 } : {}), mcpServices: 0, httpApis: 0, externalIntegrations: 0 }
writeFileSync(join(root, 'manifest.json'), JSON.stringify(manifest)) writeFileSync(join(root, 'manifest.json'), JSON.stringify(manifest))
writeFileSync(join(root, 'SCHEMA_VERSION'), manifest.version + '\n') writeFileSync(join(root, 'SCHEMA_VERSION'), manifest.version + '\n')
// 测试 release 引用仅用于校验分支;不代表线上 Control 已发布此 release。 // 测试 release 引用仅用于校验分支;不代表线上 Control 已发布此 release。
+3
View File
@@ -26,6 +26,9 @@ export function validateApplicationContract(manifest) {
if (url.protocol !== 'https:' || url.username || url.password || url.hash || url.search) errors.push('source: credential-free fixed HTTPS URL required') if (url.protocol !== 'https:' || url.username || url.password || url.hash || url.search) errors.push('source: credential-free fixed HTTPS URL required')
} catch { errors.push('source: invalid URL') } } catch { errors.push('source: invalid URL') }
if (source?.kind === 'git' && (typeof source.path !== 'string' || !isPortablePath(source.path))) errors.push('source: git archive path must be canonical and relative') if (source?.kind === 'git' && (typeof source.path !== 'string' || !isPortablePath(source.path))) errors.push('source: git archive path must be canonical and relative')
// 内联定义不声明 definitionPath;声明时才要求规范相对路径。
const definitionPath = manifest.appRelease?.definitionPath
if (definitionPath !== undefined && (typeof definitionPath !== 'string' || !isPortablePath(definitionPath))) errors.push('appRelease: definitionPath must be canonical and relative')
} }
const ids = new Set() const ids = new Set()
for (const entrypoint of Array.isArray(manifest.entrypoints) ? manifest.entrypoints : []) { for (const entrypoint of Array.isArray(manifest.entrypoints) ? manifest.entrypoints : []) {
+3 -2
View File
@@ -249,6 +249,7 @@ export function validateRegistry(repoRoot, options = {}) {
if (entry.type === 'docker-app') counts.dockerApps += 1 if (entry.type === 'docker-app') counts.dockerApps += 1
if (entry.type === 'native-app') counts.nativeApps = (counts.nativeApps ?? 0) + 1 if (entry.type === 'native-app') counts.nativeApps = (counts.nativeApps ?? 0) + 1
if (entry.type === 'artifact') counts.artifactApps = (counts.artifactApps ?? 0) + 1 if (entry.type === 'artifact') counts.artifactApps = (counts.artifactApps ?? 0) + 1
if (entry.type === 'web-bundle') counts.webBundles = (counts.webBundles ?? 0) + 1
if (entry.type === 'mcp') counts.mcpServices += 1 if (entry.type === 'mcp') counts.mcpServices += 1
if (entry.type === 'http-api') counts.httpApis += 1 if (entry.type === 'http-api') counts.httpApis += 1
if (entry.type === 'external-integration') counts.externalIntegrations += 1 if (entry.type === 'external-integration') counts.externalIntegrations += 1
@@ -284,8 +285,8 @@ export function validateRegistry(repoRoot, options = {}) {
} }
if (rootManifest?.stats) { if (rootManifest?.stats) {
for (const key of ['totalEntries', 'dockerApps', 'nativeApps', 'artifactApps', 'mcpServices', 'httpApis', 'externalIntegrations']) { for (const key of ['totalEntries', 'dockerApps', 'nativeApps', 'artifactApps', 'webBundles', 'mcpServices', 'httpApis', 'externalIntegrations']) {
if (['nativeApps', 'artifactApps'].includes(key) && rootManifest.stats[key] === undefined && !counts[key]) continue if (['nativeApps', 'artifactApps', 'webBundles'].includes(key) && rootManifest.stats[key] === undefined && !counts[key]) continue
if (rootManifest.stats[key] === undefined && key === 'externalIntegrations' && counts[key] === 0) continue if (rootManifest.stats[key] === undefined && key === 'externalIntegrations' && counts[key] === 0) continue
if (rootManifest.stats[key] !== (counts[key] ?? 0)) diagnostics.push(diagnostic('error', 'stats-mismatch', 'manifest.json', `$.stats.${key}`, `声明 ${rootManifest.stats[key]},实际 ${counts[key] ?? 0}`)) if (rootManifest.stats[key] !== (counts[key] ?? 0)) diagnostics.push(diagnostic('error', 'stats-mismatch', 'manifest.json', `$.stats.${key}`, `声明 ${rootManifest.stats[key]},实际 ${counts[key] ?? 0}`))
} }
+1
View File
@@ -368,6 +368,7 @@ if (rootManifest) {
dockerApps: manifests.filter((entry) => entry.type === 'docker-app').length, dockerApps: manifests.filter((entry) => entry.type === 'docker-app').length,
...(manifests.some((entry) => entry.type === 'native-app') || rootManifest.stats?.nativeApps !== undefined ? { nativeApps: manifests.filter((entry) => entry.type === 'native-app').length } : {}), ...(manifests.some((entry) => entry.type === 'native-app') || rootManifest.stats?.nativeApps !== undefined ? { nativeApps: manifests.filter((entry) => entry.type === 'native-app').length } : {}),
...(manifests.some((entry) => entry.type === 'artifact') || rootManifest.stats?.artifactApps !== undefined ? { artifactApps: manifests.filter((entry) => entry.type === 'artifact').length } : {}), ...(manifests.some((entry) => entry.type === 'artifact') || rootManifest.stats?.artifactApps !== undefined ? { artifactApps: manifests.filter((entry) => entry.type === 'artifact').length } : {}),
...(manifests.some((entry) => entry.type === 'web-bundle') || rootManifest.stats?.webBundles !== undefined ? { webBundles: manifests.filter((entry) => entry.type === 'web-bundle').length } : {}),
mcpServices: manifests.filter((entry) => entry.type === 'mcp').length, mcpServices: manifests.filter((entry) => entry.type === 'mcp').length,
httpApis: manifests.filter((entry) => entry.type === 'http-api').length, httpApis: manifests.filter((entry) => entry.type === 'http-api').length,
externalIntegrations: manifests.filter((entry) => entry.type === 'external-integration').length, externalIntegrations: manifests.filter((entry) => entry.type === 'external-integration').length,