fix(data): complete verified contracts and source maintenance (#114)

This commit is contained in:
2026-10-03 03:49:55 -07:00
committed by GitHub
parent 647d6f0cfd
commit 642985e819
208 changed files with 5313 additions and 2285 deletions

View File

@@ -0,0 +1,39 @@
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync, readdirSync } from 'node:fs'
const read = file => JSON.parse(readFileSync(new URL(`../${file}`, import.meta.url), 'utf8'))
test('Spark X2 must not inherit Ultra endpoint or X1.5 output limits', () => {
const old = read('compute/providers/xunfei.json')
const x2 = read('compute/providers/xunfei-x2.json')
assert.ok(old.models.some(model => model.modelName === '4.0Ultra'))
assert.ok(!old.models.some(model => model.modelName === 'spark-x'))
assert.ok(old.tombstones.includes('spark-x'))
assert.equal(x2.baseUrl, 'https://spark-api-open.xf-yun.com/x2')
const model = x2.models.find(model => model.modelName === 'spark-x')
assert.equal(model.maxOutputTokens, 131072)
assert.ok(model.capabilities.includes('tool_use'))
assert.ok(read('compute/providers/_index.json').order.includes('xunfei-x2'))
})
test('Anthropic API defaults do not retain contradictory legacy flat effort', () => {
for (const config of ['anthropic', 'anthropic-claude']) {
const models = read(`compute/providers/${config}.json`).models
for (const model of models) assert.equal(model.extra?.defaultEffort, undefined)
for (const id of ['claude-opus-5', 'claude-sonnet-5', 'claude-sonnet-5-5']) {
assert.equal(models.find(model => model.modelName === id).extra.reasoning.defaultEffort, 'high')
}
assert.equal(models.find(model => model.modelName === 'claude-opus-5-5').extra.reasoning.defaultEffort, 'medium')
}
})
test('all published reasoning contracts use consumed fields after migration', () => {
for (const folder of ['providers', 'coding-plans', 'model-specs']) {
for (const name of readdirSync(new URL(`../compute/${folder}/`, import.meta.url)).filter(name => name.endsWith('.json') && name !== '_index.json')) {
const config = read(`compute/${folder}/${name}`)
for (const model of config.models ?? config.specs) {
const extra = model.spec?.extra ?? model.extra ?? {}
assert.equal(extra.reasoningEffort, undefined, `${folder}/${name}: ${model.modelName ?? model.id}`)
assert.equal(extra.defaultReasoningEffort, undefined)
}
}
}
})

View File

@@ -0,0 +1,26 @@
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
const read = (name) => JSON.parse(readFileSync(new URL(`../${name}`, import.meta.url), 'utf8'))
test('verified API effort fields are client-readable and Pro defaults remain distinct', () => {
const rows = read('compute/providers/openai.json').models
for (const id of ['gpt-5.5', 'gpt-5.5-pro', 'gpt-5.4', 'gpt-5.4-pro', 'gpt-5.4-mini', 'gpt-5.4-nano']) {
const row = rows.find((x) => x.modelName === id)
assert.deepEqual(row.extra.reasoning.supportedEfforts, id.endsWith('-pro')
? ['medium', 'high', 'xhigh']
: ['none', 'low', 'medium', 'high', 'xhigh'])
assert.equal(row.extra.reasoningEffort, undefined)
assert.equal(row.extra.defaultReasoningEffort, undefined)
if (id.endsWith('-pro')) assert.equal(row.extra.responsesOnly, true)
}
assert.equal(rows.find((x) => x.modelName === 'gpt-5.4-pro').extra.reasoning.defaultEffort, 'medium')
assert.equal(rows.find((x) => x.modelName === 'gpt-5.5-pro').extra.reasoning.defaultEffort, 'high')
})
test('provisional and historical identities cannot become automatic official models', () => {
const reserve = read('compute/model-specs/openai.json').specs.find((x) => x.id === 'gpt-reserve')
assert.ok(reserve)
assert.equal(reserve.routing.eligibleForAgent, false)
const ox = read('compute/model-specs/stealth.json').specs.find((x) => x.id === 'ox-alpha')
assert.deepEqual(ox.match.exact, ['ox-alpha', 'stealth/ox-alpha'])
assert.equal(ox.spec.extra.modelOrigin, undefined)
})

View File

@@ -0,0 +1,50 @@
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { selectNodeVersions, selectPackageReleases, verifyRecommended } from '../scripts/update-runtime-catalog.mjs'
const now = '2026-10-03T12:00:00Z'
test('runtime snapshot excludes future, prerelease and monorepo library releases', () => {
const rows = [
{ tag_name: 'config-v11.2.0', published_at: now },
{ tag_name: 'v12.3.0-beta.1', published_at: now },
{ tag_name: 'v12.2.0', published_at: '2026-09-30T00:00:00Z' },
{ tag_name: 'v12.3.0', published_at: '2026-10-04T00:00:00Z' },
{ tag_name: 'v12.1.0', published_at: now, prerelease: true },
]
assert.deepEqual(selectPackageReleases(rows, 'npm', now), [{ tag_name: 'v12.2.0', created_at: '2026-09-30T00:00:00Z' }])
assert.deepEqual(selectPackageReleases([{ tag_name: '@yarnpkg/cli/4.18.1', published_at: now }, { tag_name: '@yarnpkg/core/4.18.1', published_at: now }], 'yarn', now), [{ tag_name: 'v4.18.1', created_at: now }])
})
test('Node snapshot caps each major and excludes future/pre-release entries', () => {
const rows = ['v26.10.0', 'v26.9.0', 'v26.8.2', 'v26.8.1', 'v24.21.0', 'v24.22.0-rc1', 'v15.0.0'].map(version => ({ version, date: '2026-09-30' }))
rows.unshift({ version: 'v27.0.0', date: '2026-10-10' })
assert.deepEqual(selectNodeVersions(rows, now).map(row => row.version), ['v26.10.0', 'v26.9.0', 'v26.8.2', 'v24.21.0'])
})
test('recommended verifier rejects mismatched digest and cross-platform archive', () => {
const r = JSON.parse(readFileSync(new URL('../runtimes/recommended.json', import.meta.url)))
const nodes = [{ version: `v${r.node.version}`, lts: r.node.ltsCodename, date: '2026-09-07' }]
const sums = Object.entries(r.node.archives).map(([key, path]) => `${r.node.sha256[key]} ${path.split('/').at(-1)}`).join('\n')
const release = { published_at: '2026-10-01T22:37:31Z', tag_name: r.python.distTag, assets: Object.entries(r.python.archives).map(([key, path]) => ({ name: path.split('/').at(-1), state: 'uploaded', digest: `sha256:${r.python.sha256[key]}` })) }
verifyRecommended(r, nodes, sums, release, now)
assert.throws(() => verifyRecommended(r, nodes, sums, { ...release, published_at: '2026-10-04T00:00:00Z' }, now), /future publication/)
assert.throws(() => verifyRecommended(r, nodes, sums, { ...release, published_at: undefined }, now), /unpublished/)
assert.throws(() => verifyRecommended(r, [{ ...nodes[0], date: '2026-10-04' }], sums, release, now), /future publication/)
const badDigest = structuredClone(r)
badDigest.node.sha256['linux-x64'] = '0'.repeat(64)
assert.throws(() => verifyRecommended(badDigest, nodes, sums, release, now), /digest mismatch/)
const badPlatform = structuredClone(r)
badPlatform.python.archives['linux-arm64'] = r.python.archives['linux-x64']
assert.throws(() => verifyRecommended(badPlatform, nodes, sums, release, now), /Unsafe Python archive/)
})
test('each refreshed runtime catalog snapshot matches its documented fingerprint', async () => {
const { createHash } = await import('node:crypto')
const fallback = JSON.parse(readFileSync(new URL('../runtimes/versions-fallback.json', import.meta.url)))
for (const name of ['node', 'npm', 'pnpm', 'yarn']) {
const rows = name === 'node' ? fallback.node : fallback.pkgManagers[name]
const path = name === 'node' ? 'node-snapshot.md' : `package-managers/${name}-snapshot.md`
const doc = readFileSync(new URL(`../docs/runtime-sources/${path}`, import.meta.url), 'utf8')
const hash = createHash('sha256').update(JSON.stringify(rows)).digest('hex')
assert.ok(doc.includes(hash), `${name}: stale provenance fingerprint`)
assert.ok(doc.includes(fallback.generatedAt), `${name}: stale provenance date`)
}
})

View File

@@ -0,0 +1,47 @@
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync, readdirSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { join } from 'node:path'
import { parseSourcePage } from '../scripts/validate-sources.mjs'
const root = fileURLToPath(new URL('../', import.meta.url))
const read = path => JSON.parse(readFileSync(join(root, path), 'utf8'))
test('Kimi domestic token prices remain distinct from write TTL and subscription prices', () => {
const provider = read('compute/providers/moonshot.json')
const model = provider.models.find(item => item.modelName === 'kimi-k3')
assert.equal(provider.priceCurrency, 'CNY')
assert.deepEqual([model.inputPrice, model.outputPrice, model.extra.cacheHitPrice], [20, 100, 2])
assert.equal(model.maxOutputTokens, 1048576)
assert.match(model.extra.pricingNotes, /TTL 5min 20, TTL 1h 40/)
const page = parseSourcePage(readFileSync(join(root, 'docs/model-sources/providers/moonshot/models/kimi-k3.md'), 'utf8'))
const proof = page.records.find(item => item.config === 'compute/providers/moonshot.json').fieldSources
for (const field of ['inputPrice', 'outputPrice', 'extra.cacheHitPrice']) assert.ok(proof.some(item => item.field === field && item.source === 'kimi-pricing'))
})
test('Xiaomi normal API prices do not use batch rates or ASR duration as token prices', () => {
const provider = read('compute/providers/xiaomi.json')
const old = provider.models.find(item => item.modelName === 'mimo-v2.5-pro')
assert.deepEqual([old.inputPrice, old.outputPrice, old.extra.cachedInputPrice], [3, 6, 0.025])
const asr = provider.models.find(item => item.modelName === 'mimo-v2.5-asr')
assert.equal(asr.inputPrice, undefined)
assert.equal(asr.outputPrice, undefined)
const fast = provider.models.find(item => item.modelName === 'mimo-v2.6-pro-ultraspeed')
assert.deepEqual([fast.inputPrice, fast.outputPrice], [30, 60])
})
test('Baidu Coding Plan does not inherit native ERNIE vision or obsolete quota multipliers', () => {
const plan = read('compute/coding-plans/baidu-coding.json')
assert.equal(plan.models.some(item => item.capabilities?.includes('vision')), false)
const glm = plan.models.find(item => item.modelName === 'glm-5.1')
assert.match(glm.description, /高峰抵扣 ×4 \/ 低峰 ×3/)
assert.ok(read('compute/providers/baidu.json').models.find(item => item.modelName === 'ernie-5.0').capabilities.includes('vision'))
})
test('JavaScript shell pages cannot silently become verified Volcengine parameters', () => {
const directory = join(root, 'docs/model-sources/providers/volcengine/models')
for (const file of readdirSync(directory)) {
const page = parseSourcePage(readFileSync(join(directory, file), 'utf8'))
for (const record of page.records) {
assert.equal(record.status, 'pending')
assert.deepEqual(record.fieldSources, [])
}
}
})

View File

@@ -0,0 +1,67 @@
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { cpSync, mkdtempSync, readFileSync, writeFileSync, rmSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { spawnSync } from 'node:child_process'
import { validateDataSources } from '../scripts/validate-data-sources.mjs'
const repo = fileURLToPath(new URL('../', import.meta.url))
function fixture(run) {
const root = mkdtempSync(join(tmpdir(), 'data-contract-'))
for (const path of ['docs/data-sources', 'api-providers', 'compute/providers']) cpSync(join(repo, path), join(root, path), { recursive: true })
for (const file of ['pricing.json', 'service-map.json']) cpSync(join(repo, 'compute', file), join(root, 'compute', file))
try { run(root) } finally { rmSync(root, { recursive: true, force: true }) }
}
function change(root, path, mutate) {
const file = join(root, path), data = JSON.parse(readFileSync(file, 'utf8'))
mutate(data)
writeFileSync(file, JSON.stringify(data))
}
test('non-model source records cover current policy and API configuration', () => {
assert.deepEqual(validateDataSources(repo), { errors: [], records: 8 })
})
test('API authentication and result mapping changes require contract review', () => fixture(root => {
change(root, 'api-providers/web-search/tavily.json', data => { data.auth.type = 'none'; data.response.resultsPath = 'wrong' })
assert.match(validateDataSources(root).errors.join('\n'), /contract drift: auth/)
}))
test('new API provider must have its own source record', () => fixture(root => {
cpSync(join(root, 'api-providers/web-search/tavily.json'), join(root, 'api-providers/web-search/new.json'))
assert.match(validateDataSources(root).errors.join('\n'), /missing source record: api-providers\/web-search\/new.json/)
}))
test('pricing assumptions cannot drift without policy record update', () => fixture(root => {
change(root, 'compute/pricing.json', data => { data.usdToCny = 8 })
assert.match(validateDataSources(root).errors.join('\n'), /contract drift: usdToCny/)
}))
test('default mappings cannot reference absent models', () => fixture(root => {
change(root, 'compute/service-map.json', data => { data.chat.modelName = 'nonexistent' })
assert.match(validateDataSources(root).errors.join('\n'), /unresolved route chat/)
}))
test('changing a default to an existing model still requires a policy record update', () => fixture(root => {
change(root, 'compute/service-map.json', data => { data.chat.modelName = 'gpt-5.5' })
assert.match(validateDataSources(root).errors.join('\n'), /routing policy drift/)
}))
test('third-party hosts cannot be presented as official evidence', () => fixture(root => {
const path = join(root, 'docs/data-sources/api-providers/tavily.md')
writeFileSync(path, readFileSync(path, 'utf8').replace('https://docs.tavily.com/', 'https://third-party.example/'))
assert.match(validateDataSources(root).errors.join('\n'), /unapproved source URL/)
}))
test('an official entry cannot redirect verification to a third-party site', () => fixture(root => {
const path = join(root, 'docs/data-sources/api-providers/tavily.md')
writeFileSync(path, readFileSync(path, 'utf8').replace('"resolvedUrl": "https://docs.tavily.com/', '"resolvedUrl": "https://third-party.example/'))
assert.match(validateDataSources(root).errors.join('\n'), /unapproved resolved source URL/)
}))
test('a page shell cannot prove verified API fields', () => fixture(root => {
const path = join(root, 'docs/data-sources/api-providers/tavily.md')
writeFileSync(path, readFileSync(path, 'utf8').replace('"retrieval": "fetched"', '"retrieval": "shell"'))
assert.match(validateDataSources(root).errors.join('\n'), /verified field without fetched source/)
}))
test('retired ZenMux tools fail before reading or writing data', () => {
for (const entry of ['batch_update_model_jsons', 'apply_all_updates_and_build_diff_report', 'generate_current_audit_artifacts', 'generate_field_tables_per_json']) {
const result = spawnSync(process.execPath, [join(repo, 'tools', `${entry}.mjs`)], { encoding: 'utf8', env: { ...process.env, CONFIG_CENTER_ROOT: '/nonexistent-root', ZENMUX_FILE: '/nonexistent-snapshot' } })
assert.equal(result.status, 1)
assert.match(result.stderr, /retired/)
assert.doesNotMatch(result.stderr, /ENOENT/)
}
})

View File

@@ -0,0 +1,43 @@
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { cpSync, mkdtempSync, readFileSync, writeFileSync, rmSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { validateRuntimeSources } from '../scripts/validate-runtime-sources.mjs'
const repo = fileURLToPath(new URL('../', import.meta.url))
function fixture(run) {
const root = mkdtempSync(join(tmpdir(), 'runtime-provenance-'))
for (const path of ['docs/runtime-sources', 'runtimes']) cpSync(join(repo, path), join(root, path), { recursive: true })
try { run(root) } finally { rmSync(root, { recursive: true, force: true }) }
}
function change(root, path, mutate) {
const file = join(root, path), data = JSON.parse(readFileSync(file, 'utf8'))
mutate(data)
writeFileSync(file, JSON.stringify(data))
}
test('runtime documentation matches current recommended archives and fallback rows', () => {
assert.deepEqual(validateRuntimeSources(repo), { errors: [] })
})
test('recommended checksum or version cannot change without source table review', () => fixture(root => {
change(root, 'runtimes/recommended.json', data => { data.node.sha256['linux-x64'] = '0'.repeat(64); data.python.version = '3.14.9' })
const errors = validateRuntimeSources(root).errors.join('\n')
assert.match(errors, /node: recommended archive\/hash table drift/)
assert.match(errors, /python: recommended version drift/)
}))
test('offline snapshot data and Hatch pin cannot drift from source records', () => fixture(root => {
change(root, 'runtimes/versions-fallback.json', data => { data.node[0].version = 'v26.11.0'; data.python[0].version = '3.7.10' })
const errors = validateRuntimeSources(root).errors.join('\n')
assert.match(errors, /node: snapshot fingerprint drift/)
assert.match(errors, /node: first version drift/)
assert.match(errors, /python: Hatch pin table drift/)
}))
test('runtime metadata guards dates, counts, LTS and standalone tag', () => fixture(root => {
change(root, 'runtimes/versions-fallback.json', data => { data.generatedAt = '2099-01-01T00:00:00Z'; data.pkgManagers.npm.pop() })
change(root, 'runtimes/recommended.json', data => { data.node.ltsCodename = 'Future'; data.python.distTag = '20990101' })
const errors = validateRuntimeSources(root).errors.join('\n')
assert.match(errors, /future generatedAt/)
assert.match(errors, /npm: snapshot count drift/)
assert.match(errors, /node: recommended LTS drift/)
assert.match(errors, /python: recommended distTag drift/)
}))

View File

@@ -937,7 +937,9 @@ describe('真实数据全量校验', () => {
assert.equal(kimi.extra.reasoning.defaultEffort, 'max')
assert.deepEqual(kimiSpec.routing.reasoning.supportedModes, ['auto', 'low', 'high', 'max'])
assert.equal(kimi.maxOutputTokens, 1048576)
assert.equal(kimi.inputPrice, undefined, '不把国际美元价混写到国内人民币 Provider')
assert.equal(kimi.inputPrice, 20, '采用国内官网人民币单价,不换算国际美元价')
assert.equal(kimi.outputPrice, 100)
assert.equal(kimi.extra.cacheHitPrice, 2)
const previewId = 'MiniMax-M3.1-Flash-Preview'
const preview = findModel('coding-plans', 'minimax-coding', previewId)
assert.equal(preview.extra.thinkingOnly, true)
@@ -1064,7 +1066,7 @@ describe('真实数据全量校验', () => {
)
}
assert.deepEqual(actualProviders.sort(), Object.keys(expectedCurrencies).sort())
assert.deepEqual([...new Set(actualProviders)].sort(), Object.keys(expectedCurrencies).sort())
})
it('MiniMax 应使用国内开放平台人民币价', () => {

View File

@@ -0,0 +1,31 @@
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
const read = (path) => JSON.parse(readFileSync(new URL(`../${path}`, import.meta.url), 'utf8'))
test('Cohere compatibility provider excludes native rerank and tombstones old preset', () => {
const d = read('compute/providers/cohere.json')
assert.ok(d.tombstones.includes('rerank-v3.5'))
assert.equal(d.models.some((r) => r.serviceType.includes('rerank')), false)
assert.equal(read('compute/model-specs/cohere.json').specs.find((r) => r.id === 'rerank-v3.5').spec.contextWindow, 4096)
})
test('MiniMax SDK text-only M2 models cannot advertise image/video input', () => {
for (const path of ['compute/providers/minimax.json', 'compute/coding-plans/minimax-coding.json', 'compute/model-specs/minimax.json']) {
const d = read(path)
for (const row of d.models ?? d.specs) {
if (!/^MiniMax-M2(?:\.|$)/.test(row.modelName ?? row.id)) continue
const caps = (row.spec ?? row).capabilities
assert.equal(caps.some((v) => ['vision', 'image_understanding', 'video_understanding'].includes(v)), false)
}
}
assert.equal(read('compute/model-specs/minimax.json').specs.find((r) => r.id === 'MiniMax-M3').spec.contextWindow, 1000000)
})
test('North canonical IDs match official API IDs without broad alias inheritance', () => {
const rows = read('compute/model-specs/cohere.json').specs
assert.equal(rows.some((r) => r.id === 'north-mini-code'), false)
const mini = rows.find((r) => r.id === 'north-mini-code-1-0')
assert.deepEqual(mini.match.exact, ['north-mini-code-1-0', 'north-mini-code'])
assert.equal(mini.match.patterns, undefined)
assert.equal(mini.spec.supportsReasoning, undefined)
assert.deepEqual(rows.find((r) => r.id === 'north-small-translate-1-0').match.exact, ['north-small-translate-1-0'])
assert.equal(read('compute/providers/cohere.json').models.some((r) => r.modelName.startsWith('north-')), false)
})