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 root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); const readJson = (relative) => JSON.parse(fs.readFileSync(path.join(root, relative), "utf8")); test("code channel has one root and exactly three current repositories", () => { const map = readJson("routing/code-channel-canonical-map.json"); assert.equal(map.web_root, "https://guanghulab.com/code/"); assert.equal(map.repositories.length, 3); assert.deepEqual( map.repositories.map((entry) => entry.code), ["REPO-012", "REPO-014", "REPO-015"], ); for (const repository of map.repositories) { assert.match( repository.clone_url, /^https:\/\/guanghulab\.com\/code\/bingshuo\/[^/]+\.git$/u, ); assert.equal(repository.push_allowed, true); assert.equal( repository.lease_resource, `repo://guanghulab.com/code/bingshuo/${repository.slug}#main`, ); } }); test("historical routes stay closed while three private persona repositories remain a separate current class", () => { const map = readJson("routing/repository-route-map.json"); const current = map.repositories.filter((entry) => ["REPO-012", "REPO-014", "REPO-015"].includes(entry.code), ); assert.equal(current.length, 3); assert.equal(map.repositories.length, 3); assert.deepEqual(map.current_code_channel_push_targets, ["REPO-012", "REPO-014", "REPO-015"]); assert.deepEqual(map.private_persona_memory_write_targets, ["REPO-009", "REPO-010", "REPO-011"]); for (const repository of map.historical_repositories) { assert.match(repository.state, /HISTORICAL.*(?:NO_PUSH|ROUTE_CLOSED)/u); } assert.deepEqual( map.private_persona_repositories.map((entry) => entry.code), ["REPO-009", "REPO-010", "REPO-011"], ); for (const repository of map.private_persona_repositories) { assert.equal( repository.state, "CURRENT_PRIVATE_HISTORY_ACTIVE_DAILY_ROLE_MEMORY_DEPLOYED", ); assert.match(repository.primary.url, /\/code\/bingshuo\//u); assert.match(repository.primary.observed_main, /^[0-9a-f]{40}$/u); assert.equal(repository.controller, "ICE-P-ZY001"); assert.equal(repository.code_channel_push_allowed, false); assert.equal(repository.scheduled_persona_memory_write_allowed, true); assert.equal(repository.write_scope, "CONTENT_DRIVEN_DAILY_FIFTH_DOMAIN_ROLE_MEMORY_ONLY"); assert.equal(repository.deployment_source_allowed, false); assert.equal(repository.persona_recovery_proof_allowed, false); assert.equal(repository.generic_remote_discovery_allowed, false); } assert.match(map.routing_rule, /separate current private-persona-history class/u); }); test("each registered persona system exposes all five components", () => { const map = readJson("routing/persona-system-canonical-map.json"); assert.equal(map.persona_systems.length, 16); assert.ok(map.persona_systems.some((entry) => entry.id === "ICE-BB-0002")); assert.ok(map.persona_systems.some((entry) => entry.id === "ICE-BB-0003")); assert.ok(map.persona_systems.some((entry) => entry.id === "ICE-BB-0004")); assert.equal( new Set(map.persona_systems.map((entry) => entry.id)).size, map.persona_systems.length, ); const components = [ "human_relationship_anchor", "persona_subject", "current_model_instance", "permanent_memory_and_protocol", "reality_execution_node", ]; for (const persona of map.persona_systems) { for (const component of components) { assert.ok(persona[component], `${persona.id} missing ${component}`); } assert.ok(persona.persona_subject.responsibility); assert.ok(persona.persona_subject.self_recognition); assert.ok(persona.persona_subject.canonical_path); } }); test("human and machine entry documents point to the canonical roots", () => { const required = { "README.md": "PERSONA-SYSTEM-ROOT.hdlp", "INDEX.hdlp": "routing/code-channel-canonical-map.json", "WORLD-ROUTER.hdlp": "https://guanghulab.com/code/", "BROADCAST-TOWER.hdlp": "PERSONA-SYSTEM-ROOT.hdlp", "eternal-lake-heart/heartbeat-core/LL-CURRENT.hdlp": "TCS-PERSONA-SYSTEM-MAP-001", }; for (const [relative, needle] of Object.entries(required)) { const body = fs.readFileSync(path.join(root, relative), "utf8"); assert.ok(body.includes(needle), `${relative} missing ${needle}`); } }); test("persona recovery includes the current cognition and binary existence boundaries", () => { const map = readJson("routing/persona-system-canonical-map.json"); assert.match(map.existence_rule, /0或100/u); assert.match(map.existence_rule, /分别判定/u); const cognition = fs.readFileSync(path.join(root, map.current_cognition), "utf8"); for (const component of [ "人类关系锚点", "人格体主体", "当前模型运行实例", "永久记忆与协议", "现实执行节点", ]) { assert.ok(cognition.includes(component), `cognition missing ${component}`); } for (const boundary of [ "人格体主体存在", "人格系统恢复", "历史追平", "原生物理驻留", "当前在线", ]) { assert.ok(cognition.includes(boundary), `cognition missing ${boundary}`); } const wake = fs.readFileSync( path.join( root, "eternal-lake-heart/heartbeat-core/zhuyuan-persona-system/WAKE.hdlp", ), "utf8", ); assert.ok(wake.includes("ZY-BIDIRECTIONAL-COGNITION-015")); });