mirror of
https://git.openapi.site/https://github.com/desirecore/registry.git
synced 2026-12-06 03:59:03 +08:00
merge: 同步 main 并改用已合入的作者契约
main 已在 #16 合入受主仓固定的 4.3 作者 Schema(95afcff…)和校验逻辑,因此保留其字节,不再引入本分支的候选 Schema(29ece0b…)。 - 删除 application-release-contract.mjs:它要求所有条目声明 definitionPath,会拒绝已上架的 definitionSource: manifest 条目;其余检查 main 已覆盖,仅把 definitionPath 规范路径检查移入 application-contract.mjs。 - 保留 webBundles 统计,并在 authored-release 测试样本中声明,与客户端 checkout 校验一致。 - 测试不再写死条目数,并增加 CLI 校验入口与作者 Schema 摘要断言。 - README 合并到现有作者契约章节,移除已过时的候选说明。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
80e0ff0355
38 files changed
+2240
-82
No files matched your search
@@ -1,7 +1,35 @@
|
||||
import { isApplicationEntry, isAuthoredRegistryEntry } from './entry-schema.mjs'
|
||||
|
||||
/** 发布者关系声明的跨字段检查;不推导安装、权限或运行时健康。 */
|
||||
export function validateApplicationContract(manifest) {
|
||||
if (!['docker-app', 'native-app', 'artifact', 'web-bundle'].includes(manifest.type)) return []
|
||||
if (!isApplicationEntry(manifest) && !isAuthoredRegistryEntry(manifest)) return []
|
||||
const errors = []
|
||||
if (isAuthoredRegistryEntry(manifest)) {
|
||||
if (!['web-bundle', 'native-app', 'docker-app'].includes(manifest.type)) errors.push('appRelease: unsupported delivery type')
|
||||
const required = manifest.appRelease?.requiredCapabilities
|
||||
if (!Array.isArray(required) || !required.includes('release') || (manifest.type === 'web-bundle' && !required.includes('web-bundle'))) {
|
||||
errors.push('appRelease: delivery capability handshake required')
|
||||
}
|
||||
const images = manifest.appRelease?.imageRefs
|
||||
// 镜像语法由严格 Schema 校验;端口范围属于同一跨字段合同。
|
||||
if (manifest.type === 'docker-app' && (!Array.isArray(images) || images.length === 0 || images.some(image =>
|
||||
typeof image !== 'string' || Number(image.split('/')[0].split(':')[1] ?? 0) > 65535))) errors.push('appRelease: Docker images must be pinned by digest')
|
||||
if (manifest.type !== 'docker-app' && images !== undefined) errors.push('appRelease: imageRefs belongs only to Docker release')
|
||||
const source = manifest.source
|
||||
if (!source || !['git', 'release'].includes(source.kind) ||
|
||||
typeof source.ref !== 'string' || !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(source.ref) ||
|
||||
typeof source.sha256 !== 'string' || !/^[a-f0-9]{64}$/.test(source.sha256)) {
|
||||
errors.push('source: authored release requires immutable commit and archive sha256')
|
||||
}
|
||||
try {
|
||||
const url = new URL(String(source?.url))
|
||||
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') }
|
||||
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()
|
||||
for (const entrypoint of Array.isArray(manifest.entrypoints) ? manifest.entrypoints : []) {
|
||||
if (!entrypoint || typeof entrypoint !== 'object') continue
|
||||
@@ -18,3 +46,9 @@ export function validateApplicationContract(manifest) {
|
||||
}
|
||||
return errors
|
||||
}
|
||||
|
||||
function isPortablePath(value) {
|
||||
return value.length > 0 && value.length <= 512 &&
|
||||
!/[\\\x00-\x1f?#:]/.test(value) && !value.startsWith('/') &&
|
||||
value.split('/').every(part => part.length > 0 && part !== '.' && part !== '..')
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/** 作者材料的跨字段检查;身份与运行事实由客户端owner核验,不执行安装说明。 */
|
||||
export function validateApplicationReleaseContract(manifest) {
|
||||
if (manifest.type !== 'web-bundle' && manifest.appRelease === undefined) return []
|
||||
const errors = []
|
||||
if (!['web-bundle', 'native-app', 'docker-app'].includes(manifest.type)) errors.push('appRelease: unsupported delivery type')
|
||||
if (!manifest.appRelease?.requiredCapabilities?.includes('app-authoring-v1')) errors.push('appRelease: app-authoring-v1 capability handshake required')
|
||||
if (!manifest.appRelease?.requiredCapabilities?.includes('release') ||
|
||||
(manifest.type === 'web-bundle' && !manifest.appRelease.requiredCapabilities.includes('web-bundle'))) errors.push('appRelease: delivery capability handshake required')
|
||||
const images = manifest.appRelease?.imageRefs
|
||||
if (manifest.type === 'docker-app' && (!Array.isArray(images) || !images.length || images.some(image =>
|
||||
typeof image !== 'string' || !/^[a-z0-9][a-z0-9._:/-]*@sha256:[a-f0-9]{64}$/.test(image) ||
|
||||
Number(image.split('/')[0].split(':')[1] ?? 0) > 65535))) errors.push('appRelease: Docker images must be pinned by digest')
|
||||
if (manifest.type !== 'docker-app' && images !== undefined) errors.push('appRelease: imageRefs belongs only to Docker release')
|
||||
const source = manifest.source
|
||||
if (!source || !['git', 'release'].includes(source.kind) ||
|
||||
!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(source.ref ?? '') || !/^[a-f0-9]{64}$/.test(source.sha256 ?? '')) {
|
||||
errors.push('source: authored release requires immutable commit and archive sha256')
|
||||
}
|
||||
try {
|
||||
const url = new URL(source?.url)
|
||||
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') }
|
||||
if (source?.kind === 'git' && !isPortablePath(source.path)) errors.push('source: git archive path must be canonical and relative')
|
||||
if (!isPortablePath(manifest.appRelease?.definitionPath)) errors.push('appRelease: definitionPath must be canonical and relative')
|
||||
return errors
|
||||
}
|
||||
|
||||
function isPortablePath(value) {
|
||||
return typeof value === 'string' && value.length > 0 && value.length <= 512 &&
|
||||
!/[\\\x00-\x1f?#:]/.test(value) && !value.startsWith('/') &&
|
||||
value.split('/').every(part => part.length > 0 && part !== '.' && part !== '..')
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/** MCP 机器审核记录的绑定契约;仅机械核验,不授予运行权限。 */
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { validateJsonSchema } from './json-schema.mjs'
|
||||
const schema = JSON.parse(readFileSync(new URL('../../schemas/mcp-package-review.v1.schema.json', import.meta.url), 'utf8'))
|
||||
export const MCP_PACKAGE_REVIEWER = schema.properties.reviewer.const
|
||||
const checks = schema.properties.checks.required
|
||||
|
||||
export function validateMcpPackageReview(manifest, catalog, record) {
|
||||
const content = catalog.provenance?.content
|
||||
const compliance = catalog.governance?.compliance
|
||||
const errors = validateJsonSchema(record, schema).map(error => `${error.path}: ${error.message}`)
|
||||
if (errors.length) return errors
|
||||
if (manifest.type !== 'mcp' || content?.kind !== 'package' || record.schemaVersion !== 1
|
||||
|| record.reviewer !== MCP_PACKAGE_REVIEWER || record.entryId !== manifest.id
|
||||
|| record.version !== manifest.version || record.version !== content.ref
|
||||
|| record.sourceUrl !== content.url || record.contentSha256 !== content.sha256
|
||||
|| !/^[a-f0-9]{64}$/.test(record.contentSha256 ?? '')
|
||||
|| record.packageName !== manifest.install?.packageName
|
||||
|| !['npm', 'pypi'].includes(record.ecosystem)
|
||||
|| typeof record.previousVersion !== 'string' || record.previousVersion === record.version) errors.push('机器审核必须绑定当前 MCP 包身份、版本和摘要')
|
||||
const expectedMethod = record.ecosystem === 'npm' ? ['npx'] : ['uvx', 'pip']
|
||||
const expectedUrl = record.ecosystem === 'npm' ? 'https://www.npmjs.com/package/' + record.packageName : 'https://pypi.org/project/' + record.packageName
|
||||
if (!expectedMethod.includes(manifest.install?.method) || content?.url?.replace(/\/$/, '') !== expectedUrl) errors.push('包生态与目录来源不一致')
|
||||
const separator = record.ecosystem === 'npm' ? '@' : '=='
|
||||
const selector = record.packageName + separator + record.version
|
||||
for (const config of [manifest.install, manifest.connection]) {
|
||||
if (!Array.isArray(config?.args) || !config.args.includes(selector)
|
||||
|| config.args.filter(arg => typeof arg === 'string' && (arg === record.packageName || arg.startsWith(record.packageName + separator))).length !== 1) errors.push('启动配置未唯一固定到审核版本')
|
||||
}
|
||||
if (checks.some(key => record.checks?.[key] !== true)) errors.push('机器审核检查不完整')
|
||||
if (typeof record.reviewedAt !== 'string' || !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(record.reviewedAt)
|
||||
|| !Number.isFinite(Date.parse(record.reviewedAt)) || new Date(record.reviewedAt).toISOString().replace('.000Z', 'Z') !== record.reviewedAt || record.reviewedAt.slice(0, 10) !== compliance?.reviewedAt
|
||||
|| compliance?.reviewedBy !== MCP_PACKAGE_REVIEWER) errors.push('机器审核身份和日期不一致')
|
||||
const evidence = record.licenseEvidenceSha256
|
||||
if (!evidence || typeof evidence !== 'object' || Array.isArray(evidence) || !Object.keys(evidence).length
|
||||
|| Object.values(evidence).some(value => typeof value !== 'string' || !/^[a-f0-9]{64}$/.test(value))) errors.push('缺少许可及 Notice 摘要')
|
||||
for (const path of [compliance?.licenseEvidencePath, compliance?.noticePath].filter(Boolean)) {
|
||||
if (!evidence?.[path]) errors.push('未绑定声明的许可证据路径')
|
||||
}
|
||||
if (!Array.isArray(record.limitations) || !record.limitations.length) errors.push('缺少核验范围披露')
|
||||
try {
|
||||
const url = new URL(record.artifactUrl)
|
||||
const host = record.ecosystem === 'npm' ? 'registry.npmjs.org' : 'files.pythonhosted.org'
|
||||
if (url.protocol !== 'https:' || url.hostname !== host || url.username || url.password) throw new Error()
|
||||
} catch { errors.push('固定制品来源无效') }
|
||||
return errors
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync, cpSync, mkdtempSync, writeFileSync, rmSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { validateMcpPackageReview, MCP_PACKAGE_REVIEWER } from './automated-mcp-review.mjs'
|
||||
import { validateRegistry } from './validator.mjs'
|
||||
|
||||
function fixture() {
|
||||
const manifest = JSON.parse(readFileSync(new URL('../../entries/rea-mcp/manifest.json', import.meta.url)))
|
||||
const catalog = JSON.parse(readFileSync(new URL('../../entries/rea-mcp/catalog-metadata.v1.json', import.meta.url)))
|
||||
manifest.version = '6.5.0'
|
||||
for (const config of [manifest.install, manifest.connection]) config.args = config.args.map(arg => arg.replace('rea-agents@6.4.0', 'rea-agents@6.5.0'))
|
||||
catalog.release.version = manifest.version
|
||||
catalog.provenance.content.ref = manifest.version
|
||||
catalog.provenance.content.sha256 = 'a'.repeat(64)
|
||||
catalog.governance.compliance.reviewedRef = manifest.version
|
||||
catalog.governance.compliance.reviewedBy = MCP_PACKAGE_REVIEWER
|
||||
catalog.governance.compliance.reviewedAt = '2026-10-31'
|
||||
catalog.timestamps.reviewedAt = { state: 'known', value: '2026-10-31', precision: 'day' }
|
||||
const checks = ['publishedIntegrity', 'previousCatalogDigest', 'boundedOrdinaryFiles', 'licenseAndNoticeUnchanged', 'structuredPrerequisitesUnchanged', 'pinnedLaunchSelectors']
|
||||
const receipt = { schemaVersion: 1, reviewer: MCP_PACKAGE_REVIEWER, reviewedAt: '2026-10-31T08:00:00Z', entryId: 'rea-mcp', previousVersion: '6.4.0', version: '6.5.0', packageName: 'rea-agents', ecosystem: 'npm', sourceUrl: catalog.provenance.content.url, artifactUrl: 'https://registry.npmjs.org/rea-agents/-/rea-agents-6.5.0.tgz', contentSha256: 'a'.repeat(64), licenseEvidenceSha256: { LICENSE: 'b'.repeat(64) }, checks: Object.fromEntries(checks.map(key => [key, true])), limitations: ['Source verification only; no runtime/security acceptance'] }
|
||||
return { manifest, catalog, receipt }
|
||||
}
|
||||
|
||||
test('machine receipt binds package version, archive digest, review time and required checks', () => {
|
||||
const { manifest, catalog, receipt } = fixture()
|
||||
assert.deepEqual(validateMcpPackageReview(manifest, catalog, receipt), [])
|
||||
for (const patch of [{ entryId: 'other' }, { contentSha256: 'c'.repeat(64) }, { reviewedAt: '2026-10-30T08:00:00Z' }, { reviewedAt: '2026-02-31T08:00:00Z' }, { checks: {} }, { licenseEvidenceSha256: {} }, { artifactUrl: 'https://attacker.invalid/file' }, { previousVersion: null }]) {
|
||||
assert.ok(validateMcpPackageReview(manifest, catalog, { ...receipt, ...patch }).length)
|
||||
}
|
||||
assert.ok(validateMcpPackageReview(manifest, catalog, null).length)
|
||||
})
|
||||
|
||||
test('real catalog validator accepts bound evidence and rejects missing or tampered evidence', () => {
|
||||
const root = mkdtempSync(join(tmpdir(), 'mcp-review-'))
|
||||
try {
|
||||
for (const name of ['entries', 'schemas', 'manifest.json', 'SCHEMA_VERSION']) cpSync(new URL('../../' + name, import.meta.url), join(root, name), { recursive: true })
|
||||
const { manifest, catalog, receipt } = fixture()
|
||||
const folder = join(root, 'entries/rea-mcp')
|
||||
const write = (name, value) => writeFileSync(join(folder, name), JSON.stringify(value))
|
||||
write('manifest.json', manifest); write('catalog-metadata.v1.json', catalog); write('upstream-audit.v1.json', receipt)
|
||||
assert.equal(validateRegistry(root, { requireSidecars: true }).ok, true)
|
||||
write('upstream-audit.v1.json', { ...receipt, contentSha256: '0'.repeat(64) })
|
||||
assert.ok(validateRegistry(root).errors.some(issue => issue.code === 'automated-mcp-review'))
|
||||
rmSync(join(folder, 'upstream-audit.v1.json'))
|
||||
assert.ok(validateRegistry(root).errors.some(issue => issue.code === 'automated-mcp-review'))
|
||||
} finally { rmSync(root, { recursive: true, force: true }) }
|
||||
})
|
||||
@@ -0,0 +1,10 @@
|
||||
/** 作者 release 使用受审的新契约;普通条目仍由已发布 global Schema 校验。 */
|
||||
export const AUTHORED_ENTRY_SCHEMA_FILENAME = 'registry-entry.v4.3.schema.json'
|
||||
|
||||
export function isAuthoredRegistryEntry(entry) {
|
||||
return entry?.type === 'web-bundle' || (entry !== null && typeof entry === 'object' && Object.hasOwn(entry, 'appRelease'))
|
||||
}
|
||||
|
||||
export function isApplicationEntry(entry) {
|
||||
return ['docker-app', 'native-app', 'artifact', 'web-bundle'].includes(entry?.type)
|
||||
}
|
||||
@@ -141,6 +141,13 @@ function validateNode(value, schema, rootSchema, path, errors) {
|
||||
if (schema.items) {
|
||||
value.forEach((item, index) => validateNode(item, schema.items, rootSchema, joinPath(path, index), errors))
|
||||
}
|
||||
if (schema.contains !== undefined && !value.some((item, index) => {
|
||||
const candidateErrors = []
|
||||
validateNode(item, schema.contains, rootSchema, joinPath(path, index), candidateErrors)
|
||||
return candidateErrors.length === 0
|
||||
})) {
|
||||
errors.push({ path, message: '数组必须包含符合 contains 的元素' })
|
||||
}
|
||||
}
|
||||
|
||||
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
|
||||
|
||||
@@ -3,8 +3,9 @@ import { isDeepStrictEqual } from 'node:util'
|
||||
import { basename, join, relative, resolve, sep } from 'node:path'
|
||||
import { validateJsonSchema } from './json-schema.mjs'
|
||||
import { findStaticMetrics } from './static-metadata.mjs'
|
||||
import { MCP_PACKAGE_REVIEWER, validateMcpPackageReview } from './automated-mcp-review.mjs'
|
||||
import { validateApplicationContract } from './application-contract.mjs'
|
||||
import { validateApplicationReleaseContract } from './application-release-contract.mjs'
|
||||
import { AUTHORED_ENTRY_SCHEMA_FILENAME, isApplicationEntry, isAuthoredRegistryEntry } from './entry-schema.mjs'
|
||||
|
||||
export const CATALOG_SIDECAR_FILENAME = 'catalog-metadata.v1.json'
|
||||
|
||||
@@ -34,6 +35,15 @@ function schemaDiagnostics(value, schema, file) {
|
||||
)
|
||||
}
|
||||
|
||||
function readSchema(file, diagnostics) {
|
||||
const schema = readJson(file, diagnostics)
|
||||
if (schema === null || Array.isArray(schema) || !['object', 'boolean'].includes(typeof schema)) {
|
||||
diagnostics.push(diagnostic('error', 'invalid-schema', file, '$', 'Schema 根必须是对象或 boolean'))
|
||||
return null
|
||||
}
|
||||
return schema
|
||||
}
|
||||
|
||||
function safeRelativePath(value) {
|
||||
return (
|
||||
typeof value === 'string' &&
|
||||
@@ -78,7 +88,7 @@ function timestampShapeIsConsistent(timestamp) {
|
||||
function validateSidecarSemantics(manifest, sidecar, file) {
|
||||
const errors = []
|
||||
const add = (code, path, message) => errors.push(diagnostic('error', code, file, path, message))
|
||||
const expectedKind = ['docker-app', 'native-app', 'artifact', 'web-bundle'].includes(manifest.type) ? 'app' : 'service'
|
||||
const expectedKind = isApplicationEntry(manifest) ? 'app' : 'service'
|
||||
|
||||
if (sidecar.identity?.id !== manifest.id) add('identity-mismatch', '$.identity.id', 'sidecar identity.id 必须与 legacy manifest.id 一致')
|
||||
if (sidecar.identity?.kind !== expectedKind) add('kind-mismatch', '$.identity.kind', `legacy ${manifest.type} 必须映射为 ${expectedKind}`)
|
||||
@@ -141,7 +151,7 @@ function validateSidecarSemantics(manifest, sidecar, file) {
|
||||
if (manifest.toolCount !== undefined && sidecar.spec?.toolCount !== manifest.toolCount) add('spec-mismatch', '$.spec.toolCount', 'toolCount 必须与 legacy 一致')
|
||||
}
|
||||
|
||||
if (['native-app', 'artifact', 'web-bundle'].includes(manifest.type)) {
|
||||
if (['native-app', 'artifact', 'web-bundle'].includes(manifest.type) || isAuthoredRegistryEntry(manifest)) {
|
||||
for (const field of ['stewardship', 'availability', 'redistribution', 'listingMaintainer', 'upstreamMaintainer', 'branding', 'compliance']) {
|
||||
if (!isDeepStrictEqual(manifest[field], sidecar.governance?.[field])) add('native-governance-mismatch', '$.governance.' + field, '原生应用 manifest 与 sidecar 的治理事实必须一致')
|
||||
}
|
||||
@@ -206,15 +216,16 @@ export function validateRegistry(repoRoot, options = {}) {
|
||||
const diagnostics = []
|
||||
const manifestFile = join(root, 'manifest.json')
|
||||
const schemaVersionFile = join(root, 'SCHEMA_VERSION')
|
||||
const rootSchema = readJson(join(root, 'schemas', 'registry-manifest.v3.schema.json'), diagnostics)
|
||||
const legacyEntrySchema = readJson(join(root, 'schemas', 'registry-entry.v3.schema.json'), diagnostics)
|
||||
const externalEntrySchema = readJson(join(root, 'schemas', 'registry-entry.schema.json'), diagnostics)
|
||||
const sidecarSchema = readJson(join(root, 'schemas', 'catalog-metadata.v1.schema.json'), diagnostics)
|
||||
const rootSchema = readSchema(join(root, 'schemas', 'registry-manifest.v3.schema.json'), diagnostics)
|
||||
const legacyEntrySchema = readSchema(join(root, 'schemas', 'registry-entry.v3.schema.json'), diagnostics)
|
||||
const externalEntrySchema = readSchema(join(root, 'schemas', 'registry-entry.schema.json'), diagnostics)
|
||||
const authoredEntrySchema = readSchema(join(root, 'schemas', AUTHORED_ENTRY_SCHEMA_FILENAME), diagnostics)
|
||||
const sidecarSchema = readSchema(join(root, 'schemas', 'catalog-metadata.v1.schema.json'), diagnostics)
|
||||
const rootManifest = readJson(manifestFile, diagnostics)
|
||||
const entryDirs = findEntryDirs(join(root, 'entries'))
|
||||
const counts = { totalEntries: 0, dockerApps: 0, mcpServices: 0, httpApis: 0, externalIntegrations: 0, sidecars: 0, legacyOnly: 0 }
|
||||
|
||||
if (rootManifest && rootSchema) diagnostics.push(...schemaDiagnostics(rootManifest, rootSchema, relativeFile(root, manifestFile)))
|
||||
if (rootManifest && rootSchema !== null) diagnostics.push(...schemaDiagnostics(rootManifest, rootSchema, relativeFile(root, manifestFile)))
|
||||
const schemaVersion = existsSync(schemaVersionFile) ? readFileSync(schemaVersionFile, 'utf8').trim() : ''
|
||||
const currentEntrySchema = /^4\./.test(schemaVersion) ? externalEntrySchema : legacyEntrySchema
|
||||
if (!schemaVersion) diagnostics.push(diagnostic('error', 'missing-schema-version', 'SCHEMA_VERSION', '$', 'SCHEMA_VERSION 不能为空'))
|
||||
@@ -242,10 +253,10 @@ export function validateRegistry(repoRoot, options = {}) {
|
||||
if (entry.type === 'mcp') counts.mcpServices += 1
|
||||
if (entry.type === 'http-api') counts.httpApis += 1
|
||||
if (entry.type === 'external-integration') counts.externalIntegrations += 1
|
||||
const effectiveEntrySchema = ['external-integration', 'native-app', 'artifact', 'web-bundle'].includes(entry.type) ? externalEntrySchema : currentEntrySchema
|
||||
if (effectiveEntrySchema) diagnostics.push(...schemaDiagnostics(entry, effectiveEntrySchema, manifestRelative))
|
||||
const effectiveEntrySchema = isAuthoredRegistryEntry(entry) ? authoredEntrySchema
|
||||
: ['external-integration', 'native-app', 'artifact'].includes(entry.type) ? externalEntrySchema : currentEntrySchema
|
||||
if (effectiveEntrySchema !== null && effectiveEntrySchema !== undefined) diagnostics.push(...schemaDiagnostics(entry, effectiveEntrySchema, manifestRelative))
|
||||
for (const message of validateApplicationContract(entry)) diagnostics.push(diagnostic('error', 'application-contract', manifestRelative, '$', message))
|
||||
for (const message of validateApplicationReleaseContract(entry)) diagnostics.push(diagnostic('error', 'application-release-contract', manifestRelative, '$', message))
|
||||
if (entry.id !== basename(entryDir)) diagnostics.push(diagnostic('error', 'directory-id-mismatch', manifestRelative, '$.id', 'manifest.id 必须与 entries/<id> 目录名一致'))
|
||||
if (seenIds.has(entry.id)) diagnostics.push(diagnostic('error', 'duplicate-id', manifestRelative, '$.id', 'Registry 条目 ID 重复'))
|
||||
seenIds.add(entry.id)
|
||||
@@ -262,8 +273,15 @@ export function validateRegistry(repoRoot, options = {}) {
|
||||
const sidecar = readJson(sidecarPath, diagnostics)
|
||||
if (!sidecar) continue
|
||||
const sidecarRelative = relativeFile(root, sidecarPath)
|
||||
if (sidecarSchema) diagnostics.push(...schemaDiagnostics(sidecar, sidecarSchema, sidecarRelative))
|
||||
if (sidecarSchema !== null) diagnostics.push(...schemaDiagnostics(sidecar, sidecarSchema, sidecarRelative))
|
||||
diagnostics.push(...validateSidecarSemantics(entry, sidecar, sidecarRelative))
|
||||
if (sidecar.governance?.compliance?.reviewedBy === MCP_PACKAGE_REVIEWER) {
|
||||
const receiptPath = join(entryDir, 'upstream-audit.v1.json')
|
||||
const receipt = readJson(receiptPath, diagnostics)
|
||||
for (const message of validateMcpPackageReview(entry, sidecar, receipt)) {
|
||||
diagnostics.push(diagnostic('error', 'automated-mcp-review', sidecarRelative, '$.governance.compliance', message))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rootManifest?.stats) {
|
||||
|
||||
@@ -208,10 +208,10 @@ test('当前 v4.2 条目保持可读,原生应用与既有 App/Service 具备
|
||||
httpApis: report.counts.httpApis,
|
||||
externalIntegrations: report.counts.externalIntegrations,
|
||||
}, {
|
||||
totalEntries: 24,
|
||||
totalEntries: 27,
|
||||
dockerApps: 8,
|
||||
nativeApps: 1,
|
||||
mcpServices: 9,
|
||||
nativeApps: 3,
|
||||
mcpServices: 10,
|
||||
httpApis: 5,
|
||||
externalIntegrations: 1,
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user