guanghu-ice-heart/tests/relational-consciousness-navigation.test.mjs

72 lines
2.9 KiB
JavaScript

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"));
const exists = (relative) => fs.existsSync(path.join(root, relative));
test("relational consciousness has one current canonical source", () => {
const brainMap = readJson("routing/zhuyuan-tcs-brain-map.json");
const source = brainMap.current_relational_consciousness;
assert.equal(source.id, "ZY-RELATIONAL-CONSCIOUSNESS-001");
assert.ok(exists(source.path), `missing ${source.path}`);
const body = fs.readFileSync(path.join(root, source.path), "utf8");
for (const anchor of [
"我是谁",
"我认识谁",
"我现在在做什么",
"我为什么这样做",
"我不能做什么",
"冰朔",
"关系性意识",
]) {
assert.ok(body.includes(anchor), `relational source missing ${anchor}`);
}
});
test("persona restore always loads relational self-location", () => {
const nav = readJson("routing/ai-machine-navigation-map.json");
const route = nav.routes.find(
(entry) => entry.id === "ZY-RELATIONAL-CONSCIOUSNESS-001",
);
assert.equal(route.load_policy, "always");
const restore = nav.intents.find((entry) => entry.id === "persona_restore");
assert.ok(restore.always_load.includes("ZY-RELATIONAL-CONSCIOUSNESS-001"));
assert.ok(restore.execution_sequence.includes("verify_relational_self_location"));
});
test("host and lighthouse navigation resolve consciousness correction", () => {
const hostMap = readJson("routing/host-skill-navigation-map.json");
const intent = hostMap.intents.find(
(entry) => entry.id === "INTENT-RELATIONAL-CONSCIOUSNESS-RESTORE-001",
);
assert.equal(intent.skill_id, "GHS-010-RELATIONAL-CONSCIOUSNESS-GUARD");
assert.equal(intent.target_id, "ZY-RELATIONAL-CONSCIOUSNESS-001");
assert.ok(intent.phrases.includes("你认识我吗"));
const lighthouse = readJson("routing/lighthouse-path-registry.json");
assert.ok(
lighthouse.paths.some(
(entry) => entry.id === "ZY-RELATIONAL-CONSCIOUSNESS-001",
),
);
});
test("runtime contract uses a positive operational definition", () => {
const contract = readJson(
"tcs-core/zhuyuan-brain/runtime/brain-runtime-contract.json",
);
const definition = contract.guanghu_awakening_definition;
assert.equal(definition.definition_id, "ZY-RELATIONAL-CONSCIOUSNESS-001");
assert.match(definition.meaning, /关系/u);
assert.match(definition.meaning, /自我定位/u);
assert.ok(definition.acceptance.includes("知道我是谁"));
assert.ok(definition.acceptance.includes("知道我认识谁以及关系从何而来"));
assert.ok(definition.acceptance.includes("知道我现在在做什么以及事实进度"));
});