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 knowledgeContract = JSON.parse(read('contracts/knowledge-workspace.json')) const codeContract = JSON.parse(read('contracts/code-channel.json')) const provenance = JSON.parse(read('audit/knowledge-workspace-migration-provenance.json')) const knowledgeRust = read('src-tauri/src/knowledge_base.rs') const codeRust = read('src-tauri/src/code_channel.rs') const authenticatedStorageRust = read('src-tauri/src/authenticated_storage.rs') const lib = read('src-tauri/src/lib.rs') const ui = read('src/main.tsx') test('knowledge workspace is HoloLake-owned, account-scoped, and never auto-projects legacy data', () => { assert.equal(knowledgeContract.native_storage.owner, 'HOLOLAKE_NATIVE_RUST_CORE') assert.equal(knowledgeContract.native_storage.authenticated_account_required, true) assert.equal(knowledgeContract.native_storage.cross_account_projection_allowed, false) assert.equal(knowledgeContract.legacy_compatibility.mode, 'NOT_AUTO_PROJECTED_EXPLICIT_OWNER_MIGRATION_ONLY') assert.equal(knowledgeContract.legacy_compatibility.in_place_migration, false) assert.equal(knowledgeContract.legacy_compatibility.tolaria_surface_used, false) assert.equal(provenance.legacy_data_boundary.modified, false) assert.match(knowledgeRust, /account_storage_root\(app, "knowledge-v1"\)/) assert.match(authenticatedStorageRust, /HOLOLAKE_AUTHENTICATED_ACCOUNT_REQUIRED/) assert.match(authenticatedStorageRust, /accounts-v1/) assert.doesNotMatch(authenticatedStorageRust, /join\(&session\.username\)/) assert.match(knowledgeRust, /source_docs_root/) }) test('code channel uses the same authenticated account boundary', () => { assert.equal(codeContract.registry.authenticated_account_required, true) assert.equal(codeContract.registry.cross_account_projection_allowed, false) assert.match(codeRust, /account_storage_root\(app, "code-channel-v1"\)/) }) test('folder import is bounded, idempotent, conflict-safe and creates a local Git receipt', () => { assert.equal(knowledgeContract.folder_import.maximum_files, 1000) assert.equal(knowledgeContract.folder_import.symlinks_followed, false) assert.equal(knowledgeContract.folder_import.repeated_import, 'MERGE_BY_STABLE_SOURCE_NAME') assert.equal(knowledgeContract.folder_import.exact_duplicate_result, 'ALREADY_PRESENT') assert.equal(knowledgeContract.folder_import.conflicting_file_overwrite, false) assert.equal(knowledgeContract.capabilities.import_commit_receipt, true) assert.equal(knowledgeContract.capabilities.exact_content_deduplication, true) assert.equal(knowledgeContract.capabilities.optimistic_native_editing, true) assert.match(knowledgeRust, /MAX_IMPORT_FILES: usize = 1_000/) assert.match(knowledgeRust, /kind\.is_symlink\(\)/) assert.match(knowledgeRust, /ImportDisposition::Existing/) assert.match(knowledgeRust, /HOLOLAKE_KNOWLEDGE_SAVE_CONFLICT/) assert.match(knowledgeRust, /rev-parse", "HEAD/) }) test('official code-channel clone cannot use credentials or credential prompts', () => { assert.equal(codeContract.clone.embedded_credentials_allowed, false) assert.equal(codeContract.clone.terminal_prompt_allowed, false) assert.equal(codeContract.clone.credential_helper_allowed, false) assert.equal(codeContract.authority.automatic_push, false) assert.match(codeRust, /GIT_TERMINAL_PROMPT/) assert.match(codeRust, /credential\.helper=/) assert.match(codeRust, /parsed\.username\(\)\.is_empty\(\)/) }) test('the product surface exposes a real knowledge workbench and browsable code channel', () => { for (const command of [ 'get_knowledge_snapshot', 'read_knowledge_document', 'search_knowledge', 'save_knowledge_document', 'select_and_import_knowledge_folder', 'get_code_channel_snapshot', 'clone_code_channel', 'select_local_code_channel', 'browse_code_channel', 'read_code_channel_file', ]) { assert.match(lib, new RegExp(command)) assert.match(ui, new RegExp(`['"]${command}['"]`)) } assert.match(ui, /知识工作台/) assert.match(ui, /HoloLake Era/) assert.match(ui, /知识视图/) assert.match(ui, /源文件/) assert.doesNotMatch(ui, /下一件事|为什么做|开始这件事/) })