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/ios-mobile-client-v1.json')) const project = read('mobile/ios/project.yml') const client = read('mobile/ios/Sources/HoloLakeSyncClient.swift') const keychain = read('mobile/ios/Sources/HoloLakeKeychain.swift') const models = read('mobile/ios/Sources/HoloLakeModels.swift') const interfaceSource = read('mobile/ios/Sources/ContentView.swift') test('iPhone client is the numbered remote body entry of the desktop root node', () => { assert.equal(contract.record_id, 'HLP-IOS-CLIENT-001') assert.equal(contract.role, 'REMOTE_BODY_ENTRY_OF_THE_SAME_PERSONA_SYSTEM') assert.equal(contract.root_node, 'USER_LOCAL_COMPUTER_TERMINAL') assert.equal(contract.numbered_transport.desktop_module, 'HLP-MOD-OFFICIAL-MOBILE-SYNC-0001') assert.match(project, /PRODUCT_BUNDLE_IDENTIFIER: com\.guanghulab\.hololake/) assert.match(client, /static let clientNumber = "HLP-IOS-CLIENT-001"/) assert.match(interfaceSource, /HLP-IOS-CLIENT-001/) assert.equal(contract.state, 'NUMBERED_SOURCE_SIMULATOR_AND_DEVELOPMENT_SIGNED_IPA_ACCEPTED') assert.equal(contract.acceptance.unit_tests, 'PASS_4') assert.equal(contract.acceptance.real_iphone_pair_and_sync, 'NOT_CLAIMED') }) test('iPhone secrets stay device local and the transport matches the desktop protocol', () => { assert.equal(contract.security.key_storage, 'KEYCHAIN_WHEN_UNLOCKED_THIS_DEVICE_ONLY') assert.equal(contract.security.background_polling, false) assert.equal(contract.security.remote_desktop_clone, false) assert.match(keychain, /kSecAttrAccessibleWhenUnlockedThisDeviceOnly/) assert.match(client, /ChaChaPoly\.seal/) assert.match(client, /ChaChaPoly\.open/) assert.match(client, /hololake\.mobile\.pair\/v1/) assert.match(client, /hololake\.mobile\.sync\/v1:/) assert.match(client, /response\.rootNodeRole == "USER_LOCAL_COMPUTER_TERMINAL"/) assert.match(client, /nextSnapshot\.rootNodeOnline/) assert.ok(client.indexOf('try HoloLakeKeychain.save(current)') < client.indexOf('url: current.baseURL.appending(path: "v1/sync")')) assert.match(models, /hololake/) assert.doesNotMatch(client, /Timer|scheduledTimer|setInterval|backgroundTask/) }) test('mobile interface stays manual and exposes only bounded projections', () => { assert.equal(contract.interface.idle_state, 'STATIC') assert.equal(contract.interface.manual_sync_only, true) assert.match(interfaceSource, /只有你点击同步时才会连接电脑/) assert.match(interfaceSource, /写入电脑端收件箱/) assert.doesNotMatch(interfaceSource, /人格执行|模型调用|远程桌面/) })