2026-08-17 18:59:37 +08:00
|
|
|
import assert from 'node:assert/strict'
|
|
|
|
|
import { readFileSync } from 'node:fs'
|
|
|
|
|
import test from 'node:test'
|
|
|
|
|
|
|
|
|
|
const contract = JSON.parse(readFileSync(new URL('../contracts/programming-ai-terminal-link.json', import.meta.url)))
|
|
|
|
|
const broker = readFileSync(new URL('../src-tauri/src/direct_local_broker.rs', import.meta.url), 'utf8')
|
|
|
|
|
const session = readFileSync(new URL('../src-tauri/src/direct_local_session.rs', import.meta.url), 'utf8')
|
|
|
|
|
const lib = readFileSync(new URL('../src-tauri/src/lib.rs', import.meta.url), 'utf8')
|
2026-08-18 23:04:18 +08:00
|
|
|
const numberedDispatcher = readFileSync(new URL('../src-tauri/src/numbered_ipc_dispatch.rs', import.meta.url), 'utf8')
|
2026-08-17 18:59:37 +08:00
|
|
|
|
|
|
|
|
test('terminal link has native local transports for macOS Linux and Windows', () => {
|
|
|
|
|
assert.equal(contract.protocol, 'HOLOLAKE_TERMINAL_LINK/2')
|
|
|
|
|
assert.equal(contract.platform_transports.macos, 'USER_PRIVATE_UNIX_SOCKET')
|
|
|
|
|
assert.equal(contract.platform_transports.linux, 'USER_PRIVATE_UNIX_SOCKET')
|
|
|
|
|
assert.equal(contract.platform_transports.windows, 'USER_PRIVATE_NAMED_PIPE')
|
|
|
|
|
assert.match(broker, /GenericFilePath/)
|
|
|
|
|
assert.match(broker, /GenericNamespaced/)
|
|
|
|
|
assert.match(broker, /WINDOWS_NAMED_PIPE_JSON_LINES/)
|
|
|
|
|
assert.match(broker, /D:P\(A;;GA;;;SY\)\(A;;GA;;;OW\)/)
|
|
|
|
|
assert.doesNotMatch(lib, /direct_local_broker_windows/)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('HoloLake owns continuity and supplies a bounded work-environment fact frame', () => {
|
|
|
|
|
assert.equal(contract.continuity.owner, 'HOLOLAKE')
|
|
|
|
|
assert.equal(contract.environment_frame.protocol_restoration_by_model_required, false)
|
|
|
|
|
assert.equal(contract.environment_frame.required_before_mutation, true)
|
|
|
|
|
assert.match(broker, /VERIFIED_HOLOLAKE_WORK_ENVIRONMENT/)
|
|
|
|
|
assert.match(broker, /GLS_RUNTIME_MANIFEST_V2_AND_NATIVE_KERNEL/)
|
|
|
|
|
assert.match(broker, /refresh_before_mutation_required/)
|
|
|
|
|
assert.match(broker, /protocol_restoration_by_model_required: false/)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('heartbeats refresh the session and environment without granting a shell', () => {
|
|
|
|
|
assert.equal(contract.continuity.heartbeat_interval_ms, 15000)
|
|
|
|
|
assert.equal(contract.phase_boundary.supervised_shell_execution, false)
|
|
|
|
|
assert.match(session, /HEARTBEAT_ACK/)
|
|
|
|
|
assert.match(broker, /HEARTBEAT_ACK_ENVIRONMENT_REFRESHED/)
|
2026-08-18 23:04:18 +08:00
|
|
|
assert.match(numberedDispatcher, /heartbeat_direct_local_session/)
|
|
|
|
|
assert.doesNotMatch(lib, /direct_local_session::heartbeat_direct_local_session/)
|
2026-08-17 18:59:37 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('transport recovery never blindly replays an uncertain mutation', () => {
|
|
|
|
|
assert.equal(contract.continuity.uncertain_mutation_is_never_blindly_replayed, true)
|
|
|
|
|
assert.match(broker, /HOLOLAKE_TERMINAL_LINK_RESPONSE_UNCERTAIN/)
|
|
|
|
|
assert.match(broker, /safeToRetryAfterStatusRead/)
|
|
|
|
|
})
|