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,71 @@
import assert from 'node:assert/strict'
import fs from 'node:fs'
import test from 'node:test'
const read = (relative) => fs.readFileSync(new URL(`../${relative}`, import.meta.url), 'utf8')
const contract = JSON.parse(read('contracts/personal-channel-kernel.json'))
const foundation = JSON.parse(read('foundation.json'))
const stageOne = JSON.parse(read('contracts/stage-one-platform.json'))
const rust = read('src-tauri/src/personal_channel.rs')
const lib = read('src-tauri/src/lib.rs')
const numberedDispatcher = read('src-tauri/src/numbered_ipc_dispatch.rs')
const ui = read('src/main.tsx')
test('personal channel kernel has one private SQLite owner and no server authority', () => {
assert.equal(contract.storage.owner, 'HOLOLAKE_NATIVE_RUST_CORE')
assert.equal(contract.storage.engine, 'EMBEDDED_SQLITE')
assert.equal(contract.storage.webview_direct_database_access, false)
assert.equal(contract.identity.platform_account_authentication_claimed, false)
assert.equal(contract.identity.server_or_repository_authority_granted, false)
assert.equal(contract.acceptance.server_deployment, false)
})
test('identity and task mutations create one-to-one chained events and receipts', () => {
assert.equal(contract.event_and_receipt.identity_and_task_mutations_are_single_sqlite_transactions, true)
assert.equal(contract.event_and_receipt.every_mutation_has_event, true)
assert.equal(contract.event_and_receipt.every_event_has_receipt, true)
assert.equal(contract.event_and_receipt.tampering_fails_closed, true)
assert.match(rust, /CREATE TABLE IF NOT EXISTS events/)
assert.match(rust, /CREATE TABLE IF NOT EXISTS receipts/)
assert.match(rust, /verify_integrity\(&connection\)/)
})
test('every initialized channel receives the native knowledge, language, conversation, number and time bundle', () => {
assert.equal(contract.initial_channel_bundle.atomic_with_identity_initialization, true)
assert.deepEqual(contract.initial_channel_bundle.module_ids, [
'hololake.knowledge-workspace',
'hololake.language-channel-system',
'hololake.conversation-manager',
'hololake.numbered-knowledge-protocol',
'hololake.persona-time-authority',
])
assert.match(rust, /install_initial_channel_modules/)
})
test('the human projection establishes identity once and keeps task mutation below the default surface', () => {
for (const command of [
'get_personal_channel_snapshot',
'initialize_personal_channel',
'create_personal_channel_task',
'transition_personal_channel_task',
]) {
assert.match(numberedDispatcher, new RegExp(`personal_channel::${command}`))
}
assert.doesNotMatch(lib, /personal_channel::get_personal_channel_snapshot/)
for (const command of ['get_personal_channel_snapshot', 'initialize_personal_channel']) {
assert.match(ui, new RegExp(`['"]${command}['"]`))
}
assert.doesNotMatch(ui, /['"]create_personal_channel_task['"]/)
assert.doesNotMatch(ui, /['"]transition_personal_channel_task['"]/)
assert.doesNotMatch(ui, /下一件事|为什么做|开始这件事/)
assert.equal(stageOne.personal_channel_kernel.native_source_implemented, true)
assert.equal(stageOne.personal_channel_kernel.installed_runtime_acceptance, true)
assert.equal(foundation.personal_channel_identity_task_event_receipt_kernel_implemented, true)
assert.equal(foundation.personal_channel_installed_runtime_acceptance, true)
})
test('full stage-one completion stays false after the first source slice', () => {
assert.equal(stageOne.implementation_complete, false)
assert.equal(foundation.stage_one_next_slice, 'HUMAN_APPROVAL_CENTER_AND_GIT_EVIDENCE_READBACK')
assert.match(foundation.stage_one_visible_body_state, /PRODUCT_INCOMPLETE/)
})

View file

@ -0,0 +1,36 @@
import assert from 'node:assert/strict'
import fs from 'node:fs'
import path from 'node:path'
import test from 'node:test'
import { fileURLToPath } from 'node:url'
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
const readText = (relative) => fs.readFileSync(path.join(root, relative), 'utf8')
const readJson = (relative) => JSON.parse(readText(relative))
test('the native user PNCC contract binds verified number, signed-in account and embedded Git', () => {
const contract = readJson('contracts/user-pncc-channel.json')
assert.equal(contract.engine, 'GIT')
assert.equal(contract.human_projection, 'HOLOLAKE_NATIVE')
assert.equal(contract.forgejo_role, 'OPTIONAL_REMOTE_COLLABORATION_ADAPTER')
assert.equal(contract.binding.requires_verified_user_number, true)
assert.equal(contract.binding.domain_resolved_before_login, true)
assert.equal(contract.binding.domain_specific_login_and_node_entry_required, true)
assert.equal(contract.binding.requires_authenticated_repository_account, true)
assert.equal(contract.binding.password_written_to_repository, false)
assert.equal(contract.binding.persona_binding_claimed, false)
assert.equal(contract.local_repository.automatic_idempotent_initialization, true)
})
test('the user PNCC is a native command and first-class HoloLake projection', () => {
const native = readText('src-tauri/src/lib.rs')
const numberedDispatcher = readText('src-tauri/src/numbered_ipc_dispatch.rs')
const frontend = readText('src/main.tsx')
assert.match(numberedDispatcher, /user_pncc_channel::get_user_pncc_channel/)
assert.match(numberedDispatcher, /user_pncc_channel::ensure_user_pncc_channel/)
assert.doesNotMatch(native, /user_pncc_channel::get_user_pncc_channel/)
assert.match(frontend, /GH-PNCC · 人格原生代码频道/)
assert.match(frontend, /Forgejo 协作适配器/)
assert.match(frontend, /ensure_user_pncc_channel/)
assert.doesNotMatch(frontend, /Forgejo 页面/)
})