foundation: start native language reality engineering root

This commit is contained in:
冰朔 2026-08-21 14:44:47 +08:00
commit 0dec0b93fc
154 changed files with 49993 additions and 0 deletions

View file

@ -0,0 +1,51 @@
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import test from 'node:test'
const main = await readFile(new URL('../src/main.tsx', import.meta.url), 'utf8')
const channel = await readFile(new URL('../src/modules/persona-channel-body/index.tsx', import.meta.url), 'utf8')
const runtime = await readFile(new URL('../src-tauri/src/persona_language_channel.rs', import.meta.url), 'utf8')
test('light lake exposes a first-class human conversation entrance', () => {
assert.match(main, /type ViewId = [^\n]*'persona'/)
assert.match(main, /knowledge-chat-entry/)
assert.match(main, />共同工作</)
assert.match(main, /view === 'persona' \? renderPersonaBody\(\)/)
assert.match(main, /<PersonaChannelBody/)
assert.match(channel, /<textarea[\s\S]*?form\?\.requestSubmit\(\)/)
assert.match(channel, /\{sending \? '正在回应…' : '发送'\}/)
assert.match(channel, /markdownHtml\(item\.content\)/)
assert.match(channel, /persona-message-markdown/)
})
test('knowledge workspace keeps the chat visible and binds the exact active page', () => {
assert.match(main, /hololake-knowledge-chat-open'\) !== '0'/)
assert.match(main, /knowledge-persona-collaboration/)
assert.match(main, /knowledgeFocus=\{activeDocument \? \{ source: activeDocument\.source, path: activeDocument\.path, title: activeDocument\.title, contentSha256: activeDocument\.contentSha256 \}/)
assert.match(channel, /activeKnowledgeSource: knowledgeFocus\?\.source/)
assert.match(channel, /activeKnowledgePath: knowledgeFocus\?\.path/)
assert.match(channel, /引用知识 · \{receipt\.path\} · \{shortHash\(receipt\.contentSha256\)\}/)
assert.match(runtime, /collect_knowledge_context\([\s\S]*?input\.active_knowledge_source\.as_deref\(\)[\s\S]*?input\.active_knowledge_path\.as_deref\(\)/)
assert.match(runtime, /append_knowledge_document\(&mut context, &mut seen, document\)/)
assert.match(runtime, /let secret = read_secret_bounded\(app, provider_id\)\.await\.ok\(\)/)
assert.doesNotMatch(runtime, /fn read_secret\(/)
})
test('model configuration remains secondary to the conversation surface', () => {
assert.match(channel, /const \[settingsOpen, setSettingsOpen\] = useState\(false\)/)
assert.match(channel, /ZERO CORE · LANGUAGE PERSONA CHANNEL/)
assert.match(channel, /persona-chat-status/)
assert.match(channel, /\{settingsOpen && <aside className="persona-chat-settings">/)
assert.match(channel, /API 密钥 · 只进钥匙串/)
})
test('the chosen model route survives restart and prefers explicit user configuration', () => {
assert.match(channel, /const PROVIDER_SELECTION_KEY = 'hololake-persona-provider-id'/)
assert.match(channel, /localStorage\.getItem\(PROVIDER_SELECTION_KEY\)/)
assert.match(channel, /item\.source === 'EXPLICIT_USER_CONFIG'/)
assert.match(channel, /rememberProvider\(nextProviderId\)/)
assert.match(channel, /onChange=\{\(event\) => selectProvider\(event\.target\.value\)\}/)
assert.match(channel, /selectedProvider\?\.source === 'EXPLICIT_USER_CONFIG'/)
assert.match(channel, /providerId: existingProviderId/)
assert.match(channel, /setModel\(saved\?\.selectedModel \|\| configModel\.trim\(\)\)/)
})

View file

@ -0,0 +1,49 @@
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\)/)
})