foundation: start native language reality engineering root
This commit is contained in:
commit
0dec0b93fc
154 changed files with 49993 additions and 0 deletions
|
|
@ -0,0 +1,71 @@
|
|||
import assert from 'node:assert/strict'
|
||||
import { createHash } from 'node:crypto'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { basename, join } from 'node:path'
|
||||
import test from 'node:test'
|
||||
|
||||
const root = new URL('..', import.meta.url).pathname
|
||||
const contract = JSON.parse(await readFile(join(root, 'contracts/online-marketplace.json'), 'utf8'))
|
||||
const registry = JSON.parse(await readFile(join(root, 'contracts/numbered-ipc-registry.json'), 'utf8'))
|
||||
const frontend = await readFile(join(root, 'src/main.tsx'), 'utf8')
|
||||
const runtime = await readFile(join(root, 'src-tauri/src/online_marketplace.rs'), 'utf8')
|
||||
|
||||
function canonical(value) {
|
||||
if (Array.isArray(value)) return value.map(canonical)
|
||||
if (value && typeof value === 'object') {
|
||||
return Object.fromEntries(Object.keys(value).sort().map((key) => [key, canonical(value[key])]))
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
test('one online marketplace keeps physical modules and cognitive skills on separate trust chains', () => {
|
||||
assert.equal(contract.humanExperience.oneMarketplaceTwoSections, true)
|
||||
assert.equal(contract.artifactKinds.PHYSICAL_MODULE.installation, 'DOWNLOAD_VERIFY_INSTALL_MOUNT_SELF_TEST')
|
||||
assert.equal(contract.artifactKinds.COGNITIVE_SKILL.installation, 'DOWNLOAD_VERIFY_STORE_ACTIVE_READONLY')
|
||||
assert.equal(contract.artifactKinds.COGNITIVE_SKILL.executionAuthority, false)
|
||||
assert.deepEqual(contract.artifactKinds.COGNITIVE_SKILL.systemPermissions, [])
|
||||
assert.equal(contract.sourceRepositoryBoundary.clientClonesRepository, false)
|
||||
assert.equal(contract.sourceRepositoryBoundary.clientExecutesRepository, false)
|
||||
assert.match(runtime, /entry\.artifact_kind == "PHYSICAL_MODULE"/)
|
||||
assert.match(runtime, /install_skill_at/)
|
||||
})
|
||||
|
||||
test('public five-domain home can open before a private marketplace account exists', () => {
|
||||
assert.match(runtime, /Err\(error\) if error == "HOLOLAKE_AUTHENTICATED_ACCOUNT_REQUIRED" => Ok\(\(\)\)/)
|
||||
})
|
||||
|
||||
test('marketplace lifecycle is reachable only through exact numbered operations', () => {
|
||||
const aliases = registry.operations.filter((operation) => operation.module_number === 'HLP-NIPC-MOD-0033').map((operation) => operation.alias)
|
||||
assert.deepEqual(aliases, [
|
||||
'get_marketplace_snapshot',
|
||||
'sync_marketplace_catalog',
|
||||
'install_marketplace_item',
|
||||
'uninstall_marketplace_item',
|
||||
'rollback_marketplace_item',
|
||||
'get_active_cognitive_skills',
|
||||
])
|
||||
for (const alias of aliases.slice(0, 5)) assert.match(frontend, new RegExp(`['"]${alias}['"]`))
|
||||
assert.match(frontend, /只有零点原核与企业发布双签同时通过/)
|
||||
})
|
||||
|
||||
test('an installed physical marketplace module becomes a directly usable ordinary-channel application', () => {
|
||||
assert.match(frontend, /installMarketplaceItem[\s\S]*await refreshCompositionModule\(\)/)
|
||||
assert.match(frontend, /installMarketplaceItem[\s\S]*await refreshEducationModule\(\)/)
|
||||
assert.match(frontend, /compositionModule\?\.installedState === 'ACTIVE'[\s\S]*title="原生组合视图"[\s\S]*已安装成品模块 · 直接使用/)
|
||||
assert.match(frontend, /educationModule\?\.installedState === 'ACTIVE'[\s\S]*title="教育行业工作台"[\s\S]*已安装成品模块 · 直接使用/)
|
||||
})
|
||||
|
||||
for (const file of [
|
||||
'HLP-SKILL-OFFICIAL-DELIVERY-VERIFICATION-0001-0.1.0.ghskill',
|
||||
'HLP-SKILL-OFFICIAL-MODULE-BOUNDARY-REVIEW-0001-0.1.0.ghskill',
|
||||
]) {
|
||||
test(`${basename(file)} is a read-only skill with an exact canonical payload digest`, async () => {
|
||||
const skill = JSON.parse(await readFile(join(root, 'marketplace/skills', file), 'utf8'))
|
||||
const digest = createHash('sha256').update(JSON.stringify(canonical(skill.payload))).digest('hex')
|
||||
assert.equal(skill.schema, 'hololake.cognitive-skill-package/v1')
|
||||
assert.equal(skill.manifest.executionAuthority, false)
|
||||
assert.equal(skill.manifest.skillReadonlyGuarantee, true)
|
||||
assert.deepEqual(skill.manifest.permissions, [])
|
||||
assert.equal(skill.manifest.contentDigest, digest)
|
||||
})
|
||||
}
|
||||
Loading…
Reference in a new issue