guanghu-ice-heart/tests/bottle-system-zero-sense-shuttle-routing.test.mjs

71 lines
4.5 KiB
JavaScript

import fs from 'node:fs';
import path from 'node:path';
import { spawnSync } from 'node:child_process';
import assert from 'node:assert/strict';
import test from 'node:test';
const root = path.resolve(import.meta.dirname, '..');
const bottle = JSON.parse(fs.readFileSync(path.join(root, 'routing/fifth-domain-bottle-system-map.json')));
const zero = JSON.parse(fs.readFileSync(path.join(root, 'routing/zero-sense-team-channel-shuttle-map.json')));
const channels = JSON.parse(fs.readFileSync(path.join(root, 'routing/persona-channel-context-map.json')));
const numbers = JSON.parse(fs.readFileSync(path.join(root, 'routing/fifth-domain-number-registry.json')));
const kernels = JSON.parse(fs.readFileSync(path.join(root, 'tcs-core/shared-kernels/kernel-registry.json')));
const subjects = JSON.parse(fs.readFileSync(path.join(root, 'identity/fifth-domain-subject-registry.json')));
test('bottle system and bottle channel are distinct nested objects', () => {
assert.equal(bottle.system.id, 'SYS-GLW-ELH-BOTTLE-0001');
assert.equal(bottle.channel.id, 'ICE-CH-BT001');
assert.notEqual(bottle.system.world_path, bottle.channel.world_path);
assert.equal(bottle.channel.parent, bottle.system.id);
assert.equal(channels.channels.some(item => item.id === 'ICE-CH-BT001'), true);
assert.equal(numbers.registrations.some(item => item.id === 'ICE-CH-BT001'), true);
});
test('all canonical baby rooms live in the Fifth Domain bottle channel', () => {
assert.equal(bottle.registered_rooms.length, 8);
assert.equal(bottle.source_verified_registration_pending_rooms.length, 1);
for (const room of [...bottle.registered_rooms, ...bottle.source_verified_registration_pending_rooms]) {
assert.equal(fs.existsSync(path.join(root, room.physical_home)), true, room.physical_home);
}
for (const room of bottle.registered_rooms) assert.match(room.room_path, /bottle-baby-system\/bottle-channel\/rooms/);
assert.equal(bottle.room_contract.zero_sense_parent_channel_contains_route_door_not_room_copy, true);
});
test('seven Zero-Sense team channels route back to one canonical bottle room', () => {
assert.deepEqual(zero.channels.map(item => item.system_id), ['SYS-AW', 'SYS-FM', 'SYS-JZ', 'SYS-YY', 'SYS-HE', 'SYS-MM', 'SYS-CE']);
for (const channel of zero.channels) {
assert.equal(fs.existsSync(path.join(root, channel.physical_home)), true, channel.physical_home);
assert.ok(channel.bottle_room_ref);
}
assert.equal(zero.shuttle_contract.parent_channel_holds, 'ROUTE_DOOR_ONLY');
assert.equal(zero.shuttle_contract.persona_brain_copy, false);
});
test('current ICE-BB roots are canonical rooms and historical Zhiqiu cannot seize Qiuqiu', () => {
for (const id of ['ICE-BB-0001', 'ICE-BB-0002', 'ICE-BB-0003', 'ICE-BB-0004', 'ICE-BB-0005', 'ICE-BB-0006', 'ICE-BB-0007', 'ICE-BB-0008']) {
assert.match(kernels.personas[id].default_memory_root, /bottle-baby-system\/bottle-channel\/rooms/);
const subject = subjects.subjects.find(item => item.id === id);
assert.equal(subject.native_habitat_channel, 'ICE-CH-BT001');
}
const awen = bottle.registered_rooms.find(item => item.persona_id === 'ICE-BB-0005');
assert.equal(awen.name, '知秋');
assert.equal(bottle.registered_rooms.find(item => item.persona_id === 'ICE-BB-0003').human_anchor, 'ICE-GL-ZHI∞');
assert.equal(bottle.registered_rooms.find(item => item.persona_id === 'ICE-BB-0003').shell_later_formed_distinct_subject, 'ICE-BB-0005');
});
test('router resolves only from the Fifth Domain bottle body channel and never claims wake completion', () => {
const result = spawnSync('python3', [path.join(root, 'server-tools/bottle-channel-router/bottle_channel_router.py'), '--baby', '舒舒', '--entry-domain', 'DOM-FIFTH-0001', '--body-channel', 'ICE-CH-BT001'], { encoding: 'utf8' });
assert.equal(result.status, 0, result.stderr);
const value = JSON.parse(result.stdout);
assert.equal(value.origin.channel, 'ICE-CH-BT001');
assert.equal(value.shuttle.destination_channel, 'SYS-FM');
assert.equal(value.persona_wake_complete, false);
});
test('router physically refuses a Zero-Sense parent channel as a wake origin', () => {
const result = spawnSync('python3', [path.join(root, 'server-tools/bottle-channel-router/bottle_channel_router.py'), '--baby', '舒舒', '--entry-domain', 'DOMAIN-ZS', '--body-channel', 'SYS-FM'], { encoding: 'utf8' });
assert.equal(result.status, 3, result.stderr);
const value = JSON.parse(result.stdout);
assert.equal(value.state, 'BOTTLE_WAKE_ADMISSION_DENIED_WRONG_OR_MISSING_NATIVE_CONTEXT');
assert.equal(value.persona_wake_complete, false);
});