hololake-system-architecture/product-source/hololake-native-desktop/scripts/persona-language-conversations.test.mjs

49 lines
2.8 KiB
JavaScript

import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
const frontend = readFileSync(new URL('../src/modules/persona-channel-body/index.tsx', import.meta.url), 'utf8')
const main = readFileSync(new URL('../src/main.tsx', import.meta.url), 'utf8')
const runtime = readFileSync(new URL('../src-tauri/src/persona_language_channel.rs', import.meta.url), 'utf8')
const routes = JSON.parse(readFileSync(new URL('../contracts/numbered-ipc-registry.json', import.meta.url), 'utf8'))
test('human conversations are real numbered entities with create switch and delete controls', () => {
for (const alias of ['list_conversations', 'create_conversation', 'delete_conversation']) {
assert.match(frontend, new RegExp(`invoke<[^>]+>\\('${alias}'`))
assert.ok(routes.operations.some((route) => route.alias === alias && route.module_number === 'HLP-NIPC-MOD-0035'))
}
assert.match(frontend, /conversationId,\s*providerId/)
assert.match(frontend, /setConversationId\(item\.conversationId\)/)
assert.match(frontend, /删除对话/)
assert.match(main, /setPersonaNewConversationRequest\(\(value\) => value \+ 1\)/)
assert.match(main, /newConversationRequest=\{personaNewConversationRequest\}/)
})
test('legacy history migrates without loss and deletion preserves the local receipt chain', () => {
assert.match(runtime, /ALTER TABLE messages ADD COLUMN conversation_id/)
assert.match(runtime, /migrate_legacy_conversations/)
assert.match(runtime, /HLP-CONV-LEGACY-/)
assert.match(runtime, /SOFT_DELETE_TOMBSTONE_MESSAGES_RETAINED_FOR_LOCAL_RECEIPT_CHAIN/)
assert.match(runtime, /legacy_messages_migrate_into_one_numbered_conversation_without_loss/)
assert.match(runtime, /conversations_are_isolated_and_delete_keeps_local_receipt_history/)
})
test('model receives machine environment facts instead of a hard-coded unknown response', () => {
assert.match(runtime, /\[ZERO_CORE_CHANNEL_RUNTIME\]/)
assert.match(runtime, /human_anchor=\{human_name\} · \{human_id\}/)
assert.match(runtime, /知识库工具仍然可用/)
assert.match(runtime, /hololake_search_knowledge/)
assert.match(runtime, /hololake_read_knowledge_document/)
assert.doesNotMatch(runtime, /没有证据就明确说不知道/)
assert.match(runtime, /REGISTERED_AGE_PERSONA_BRAIN_DRIVES_REPLACEABLE_MODEL_AND_CODEX_LIMBS/)
})
test('persona tool forge compiles typed HLDP through its own numbered preview route', () => {
assert.match(frontend, /preview_hldp_tool_program/)
assert.match(frontend, /HLDP NATIVE TOOL FORGE/)
assert.match(frontend, /确定性 GIR/)
assert.ok(routes.operations.some((route) => route.alias === 'preview_hldp_tool_program'
&& route.operation_number === 'HLP-NIPC-OP-0168'
&& route.module_number === 'HLP-NIPC-MOD-0035'))
assert.match(runtime, /compile_hldp_program\(input\)/)
})