feat: admit signed education workbench module

This commit is contained in:
冰朔 2026-08-19 03:17:00 +08:00
commit df5e8f8e3c
24 changed files with 4986 additions and 20 deletions

View file

@ -0,0 +1,53 @@
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
const read = (path) => readFileSync(new URL(`../${path}`, import.meta.url), 'utf8')
const contract = JSON.parse(read('contracts/education-workspace.json'))
const registry = JSON.parse(read('contracts/numbered-ipc-registry.json'))
const modulePackage = JSON.parse(read('fixtures/module-packages/HLP-MOD-OFFICIAL-EDUCATION-WORKBENCH-0001-0.1.0.ghmod'))
const workspaceRust = read('src-tauri/src/education_workspace.rs')
const translationRust = read('src-tauri/src/education_translation.rs')
const frontend = [
read('src/modules/education-workspace/index.tsx'),
read('src/modules/education-workspace/education-data.ts'),
read('src/modules/education-workspace/education-adaptive-rendering.ts'),
].join('\n')
test('education is an official signed declarative adapter over the shared office foundation', () => {
assert.equal(contract.package.official_module_number, 'HLP-MOD-OFFICIAL-EDUCATION-WORKBENCH-0001')
assert.equal(contract.foundation_dependency.module_id, 'hololake.builtin.channel-workbench')
assert.equal(modulePackage.manifest.registrationClass, 'OFFICIAL_LIGHTHOUSE')
assert.equal(modulePackage.manifest.adapter, 'education-workbench-v1')
assert.equal(modulePackage.payload.adapterConfig.foundationModule, 'HLP-MOD-LOCAL-CHANNEL-WORKBENCH-0001')
assert.equal(modulePackage.payload.adapterConfig.importDefaultScope, 'UNASSIGNED')
assert.equal(modulePackage.payload.adapterConfig.modelFileTransferDefault, 'DENY')
assert.equal(modulePackage.manifest.permissions.length, 8)
})
test('all education effects cross the exact numbered adapter routes', () => {
const routes = registry.operations.filter((route) => route.module_number === 'HLP-NIPC-MOD-0024')
assert.deepEqual(routes.map((route) => route.operation_number), Array.from({ length: 18 }, (_, index) => `HLP-NIPC-OP-${String(index + 85).padStart(4, '0')}`))
assert.ok(routes.every((route) => route.target_number === 'HLP-NIPC-TGT-0024'))
assert.ok(routes.every((route) => route.admission === 'VERIFIED_HUMAN_ROUTE'))
assert.doesNotMatch(frontend, /from ['"]@tauri-apps\/api\/core['"]/)
assert.doesNotMatch(workspaceRust, /#\[tauri::command\]/)
assert.doesNotMatch(translationRust, /#\[tauri::command\]/)
assert.match(workspaceRust, /require_active_module_adapter/)
})
test('legacy silent corruption and automatic destructive behavior are rejected', () => {
assert.doesNotMatch(workspaceRust, /serde_json::from_str[^\n]+unwrap_or_default/)
assert.match(workspaceRust, /deny_unknown_fields/)
assert.match(frontend, /生成只读预览/)
assert.match(frontend, /我确认,写入清理结果/)
assert.match(frontend, /生成只读预览令牌/)
assert.match(frontend, /我确认,按此令牌执行/)
assert.match(frontend, /确认归入教育频道/)
})
test('education UI is independently lazy-loaded and reuses, rather than duplicates, office engines', () => {
assert.match(read('src/main.tsx'), /lazy\(\(\) => import\('\.\/modules\/education-workspace'\)/)
assert.match(read('src/modules/education-workspace/education-document-engine.tsx'), /channel-workbench\/document-engine/)
assert.match(read('src/modules/education-workspace/index.tsx'), /channel-workbench\/spreadsheet-engine/)
})

View file

@ -7,8 +7,8 @@ test('identity, webview and direct broker numbers compile into one unique eviden
const generated = JSON.parse(readFileSync(new URL('../generated/unified-number-coordinate-tree.json', import.meta.url), 'utf8'))
assert.deepEqual(generated, compileUnifiedNumberTree())
assert.equal(generated.recordId, 'HLP-UNIFIED-NUMBER-TREE-001')
assert.equal(generated.routeCount, 106)
assert.equal(new Set(generated.routes.map((route) => route.path)).size, 106)
assert.equal(generated.routeCount, 124)
assert.equal(new Set(generated.routes.map((route) => route.path)).size, 124)
assert.equal(generated.invariants.everyPhysicalCallHasNumberedRoute, true)
assert.equal(generated.invariants.everyAcceptedCallHasEvidenceClass, true)
assert.ok(generated.routes.every((route) => route.admission && route.evidence))