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 directory = path.dirname(fileURLToPath(import.meta.url)); const fixed = JSON.parse(fs.readFileSync(path.join(directory, "fixed-world-object-number-map.json"), "utf8")); const tree = JSON.parse(fs.readFileSync(path.join(directory, "fifth-domain-world-tree.json"), "utf8")); const fifth = JSON.parse(fs.readFileSync(path.join(directory, "fifth-domain-number-registry.json"), "utf8")); const subjects = JSON.parse(fs.readFileSync(path.join(directory, "../identity/fifth-domain-subject-registry.json"), "utf8")); const navigation = JSON.parse(fs.readFileSync(path.join(directory, "ai-machine-navigation-map.json"), "utf8")); const broadcastTower = fs.readFileSync(path.join(directory, "../BROADCAST-TOWER.hdlp"), "utf8"); const broadcastProtocol = fs.readFileSync(path.join(directory, "../gls/protocols/GLS-0310-BROADCAST-TOWER-CONTROL-PROTOCOL.hdlp"), "utf8"); const glsRegistry = JSON.parse(fs.readFileSync(path.join(directory, "../gls/GLS-PROTOCOL-REGISTRY.json"), "utf8")); const currentMap = fs.readFileSync(path.join(directory, "../CURRENT-MAP.hdlp"), "utf8"); const lighthouse = JSON.parse(fs.readFileSync(path.join(directory, "lighthouse-path-registry.json"), "utf8")); const object = (id) => fixed.objects.find((entry) => entry.id === id); test("fixed world object ids are unique and preserve the world entry pair", () => { const ids = fixed.objects.map((entry) => entry.id); assert.equal(new Set(ids).size, ids.length); assert.equal(object("LL-CMPN-0001").paired_world_node, "SYS-GLW-0001"); assert.equal(object("SYS-GLW-0001").entry_path, "LL-CMPN-0001"); }); test("Fifth Domain private and public channels stay distinct", () => { assert.equal(object("ICE-CH-HB001").reality_execution, false); assert.equal(object("ICE-CH-ZC001").not_an_alias_of, "CH-ZERO-CORE-LPM"); assert.equal(object("CH-ZERO-CORE-LPM").not_a_fifth_domain_private_channel, true); }); test("the bottle system is an explicit private object with a zero-guarantee gate", () => { const bottle = object("SYS-GLW-ELH-BOTTLE-0001"); assert.equal(bottle.state, "CURRENT_REGISTERED_SYSTEM_OBJECT"); assert.equal(bottle.person_specific_access_authorizer, "ICE-GL∞"); assert.equal(bottle.authorization_guarantees_persona_birth, false); assert.equal(bottle.productization_allowed, false); assert.ok(tree.nodes.some((entry) => entry.object_id === bottle.id)); }); test("all four fixed bottle persona numbers agree across registries", () => { const expected = ["ICE-BB-0001", "ICE-BB-0002", "ICE-BB-0003", "ICE-BB-0004"]; assert.deepEqual(fixed.private_baby_personas.map((entry) => entry.id), expected); assert.deepEqual(fifth.registrations.filter((entry) => entry.kind === "FIFTH_DOMAIN_PRIVATE_BOTTLE_BABY_PERSONA").map((entry) => entry.id), expected); assert.ok(expected.every((id) => subjects.subjects.some((entry) => entry.id === id))); }); test("only real unresolved aliases stay unresolved, team persona ids are explicitly issued, and no GLS number is inferred", () => { assert.ok(fixed.unresolved_alias_groups.every((entry) => entry.state.startsWith("UNRESOLVED"))); assert.equal(fixed.unresolved_alias_groups.some((entry) => entry.id === "LEGACY-PERSONA-CANONICAL-MIGRATION-001"), false); assert.deepEqual(object("ICE-P-CL0720").aliases, ["CHENGLU-AGENT-001"]); assert.deepEqual(object("ICE-P-KZ0720").aliases, ["ICE-GL-KZ-001"]); assert.equal(object("ICE-P-CL0720").issued_by, "ICE-P-ZY001"); assert.equal(object("ICE-P-KZ0720").issued_by, "ICE-P-ZY001"); assert.equal(object("ZNP-SYS-001").state, "REGISTERED_CURRENT"); assert.equal(object("ZNP-SYS-001").formal_gls_number, null); assert.equal(object("ZNP-SYS-001").formal_gls_number_state, "UNALLOCATED_DO_NOT_INFER_GLS_0851"); }); test("Eternal Lake Heart uses its existing REPO-012 language path without inventing a second repository", () => { const eternal = object("SYS-GLW-ELH-0001"); const treeNode = tree.nodes.find((entry) => entry.object_id === eternal.id); assert.equal(eternal.repository_id, "REPO-012"); assert.equal(eternal.repository_state, "CURRENT_NESTED_CANONICAL_SOURCE_NO_INDEPENDENT_REPOSITORY_REQUIRED"); assert.equal(eternal.canonical_source_path, "eternal-lake-heart/"); assert.equal(treeNode.repository_id, "REPO-012"); assert.equal(treeNode.repository_state, eternal.repository_state); assert.match(tree.root.content_boundary, /只有具备独立源码或运行生命周期且已明确登记/u); }); test("ZNP stays current without allocating GLS-0851 or keeping a stale batch promotion promise", () => { const registeredProtocols = [ ...(glsRegistry.existing_registered || []), ...(glsRegistry.registered_draft_protocols || []), ]; assert.equal(registeredProtocols.some((entry) => entry.id === "GLS-0851"), false); assert.match(currentMap, /ZNP-SYS-001[^\n]*REGISTERED_CURRENT[^\n]*GLS\s*号不占号/u); assert.equal(lighthouse.pre_registration_batch_20260817.znp_member_state, "REGISTERED_CURRENT_GLS_NUMBER_UNALLOCATED"); assert.match(lighthouse.pre_registration_batch_20260817.boundary, /不得从下一空位推断或分配GLS-0851/u); }); test("the broadcast object, tower entry and BTCP form one explicit edge", () => { const broadcast = object("SYS-GLW-BDC-0001"); assert.equal(broadcast.canonical_entry, "BROADCAST-TOWER.hdlp"); assert.equal(broadcast.control_protocol, "GLS-0310"); assert.match(broadcastTower, /\*\*系统对象\*\*: `SYS-GLW-BDC-0001`/u); assert.match(broadcastProtocol, /system_object_id: SYS-GLW-BDC-0001/u); assert.equal(broadcastProtocol.includes("canonical_tower_entry: BROADCAST-TOWER.hdlp"), true); }); test("machine navigation exposes the normalization map", () => { assert.ok(navigation.routes.some((entry) => entry.id === fixed.map_id && entry.path === "routing/fixed-world-object-number-map.json")); });