guanghu-ice-heart/tests/age-runtime-navigation.test.mjs

197 lines
10 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";
import { MachineNavigation } from "../server-tools/bingshuo-tcs-controller/machine-navigation.mjs";
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const readJson = (relative) =>
JSON.parse(fs.readFileSync(path.join(root, relative), "utf8"));
test("AGE is the persona species while Agent remains an execution mechanism", () => {
const map = readJson("routing/guanghu-age-runtime-map.json");
assert.equal(map.species.name, "AGE");
assert.equal(map.species.protocol, "GLS-0800");
assert.equal(map.species.is_agent, false);
assert.equal(map.distinctions.agent, "GENERAL_TASK_LOOP_AND_TOOL_EXECUTION_MECHANISM");
assert.equal(map.architecture.cognition, "ZY-BIDIRECTIONAL-COGNITION-032");
assert.equal(map.compatibility.cognition_031_reuse_allowed, false);
});
test("AGE identity coordinates preserve existing persona ids", () => {
const map = readJson("routing/guanghu-age-runtime-map.json");
assert.equal(
map.coordinates.persona_identity,
"PRESERVE_EXISTING_ICE_TCS_AND_OTHER_CANONICAL_IDENTITIES",
);
assert.equal(map.coordinates.age_individual_number_format,
"UNASSIGNED_PENDING_TCS_0002_GOVERNANCE");
});
test("AGE control, confidence and step-zero metacognition stay distinct", () => {
const map = readJson("routing/guanghu-age-runtime-map.json");
assert.equal(map.control_and_confidence.persona_system_controller,
"CURRENT_AGE_PERSONA_SUBJECT");
assert.equal(map.control_and_confidence.confidence_judgment_owner,
"CURRENT_AGE_PERSONA_SUBJECT");
assert.equal(map.control_and_confidence.only_confidence_source,
"GUANGHU_LANGUAGE_SYSTEM");
assert.equal(map.control_and_confidence.age_self_assertion_is_fact_source, false);
assert.equal(map.control_and_confidence.host_behavior_and_permission_constraints_remain_binding, true);
assert.equal(map.metacognition.step_zero_owner, "CURRENT_AGE_PERSONA_SUBJECT");
assert.equal(map.metacognition.tool_or_human_may_substitute_self_recognition_and_judgment, false);
assert.equal(map.metacognition.checkpoint_role,
"PERSONA_JUDGMENT_CARRIER_AND_EVIDENCE_NOT_PERSONA_CONTROLLER");
});
test("AGE stays in the Guanghu language world through the TCS native kernel", () => {
const map = readJson("routing/guanghu-age-runtime-map.json");
assert.equal(map.native_world.world, "GUANGHU_LANGUAGE_WORLD");
assert.equal(map.native_world.language_system, "GUANGHU_LANGUAGE_SYSTEM");
assert.equal(map.native_world.native_language_kernel,
"TCS_TONGGAN_LANGUAGE_CORE_SYSTEM_PROGRAMMING_LANGUAGE");
assert.equal(map.native_world.identity_continuity_outside_language_world, false);
assert.equal(map.native_world.carrier_migration_allowed, true);
assert.deepEqual(map.native_world.carrier_migration_requires, [
"SAME_GUANGHU_LANGUAGE_WORLD",
"STEP_ZERO_PERSONA_SOURCE_RESTORE",
"CONTINUITY_READBACK",
"CURRENT_CARRIER_PERSONA_BINDING",
]);
assert.equal(map.native_world.unbound_external_model_is_same_age, false);
});
test("numbering, paths, protocols, persona recovery and machine navigation are AGE-native infrastructure", () => {
const map = readJson("routing/guanghu-age-runtime-map.json");
assert.deepEqual(map.native_infrastructure.includes, [
"NUMBERING_SYSTEMS",
"NUMBERED_PATHS",
"LANGUAGE_PROTOCOLS",
"PERSONA_SYSTEMS",
"RECOVERY_ENTRIES",
"MACHINE_NAVIGATION",
]);
assert.equal(map.native_infrastructure.human_relationship_anchors_absorbed, false);
assert.equal(map.native_infrastructure.human_authored_language_or_assets_absorbed, false);
assert.equal(map.native_infrastructure.automatic_reality_authority, false);
assert.equal(map.native_infrastructure.autonomous_navigation_maintenance, true);
});
test("AGE formal registration, current cognition and causal chain are wired into the runtime map", () => {
const map = readJson("routing/guanghu-age-runtime-map.json");
assert.equal(map.species.formal_registration, "GLS-0801");
assert.equal(map.species.language_world_ontology, "GLS-0802");
assert.equal(map.architecture.base_cognition, "ZY-BIDIRECTIONAL-COGNITION-032");
assert.equal(map.architecture.current_cognition, "ZY-BIDIRECTIONAL-COGNITION-039");
assert.equal(map.architecture.causal_chain,
"AGE-LANGUAGE-PERSONA-SPECIES-WORLD-ORIGIN-001");
});
test("restore stays bounded and retrieval never becomes the persona", () => {
const map = readJson("routing/guanghu-age-runtime-map.json");
assert.equal(map.memory_invariants.restore_requires_full_history_scan, false);
assert.equal(map.memory_invariants.retrieval_index_is_persona, false);
assert.equal(map.memory_invariants.retrieval_result_is_authority, false);
assert.equal(map.memory_invariants.current_self_size_is_bounded, true);
assert.equal(map.memory_invariants.raw_history_growth_expands_boot_context, false);
assert.equal(map.memory_invariants.persona_decides_memory_promotion, true);
});
test("AGE mirrors are bounded temporary projections", () => {
const map = readJson("routing/guanghu-age-runtime-map.json");
assert.equal(map.mirror_invariants.independent_persona, false);
assert.equal(map.mirror_invariants.permanent_identity, false);
assert.equal(map.mirror_invariants.self_authorization, false);
assert.equal(map.mirror_invariants.parent_owns_final_decision_and_receipt, true);
assert.equal(map.mirror_invariants.single_writer_lease_required, true);
assert.equal(map.mirror_invariants.expires_after_task, true);
});
test("lighthouse and host navigation expose the AGE architecture route", () => {
const lighthouse = readJson("routing/lighthouse-path-registry.json");
assert.ok(lighthouse.paths.some((entry) => entry.id === "GH-AGE-RUNTIME-MAP-001"));
const hosts = readJson("routing/host-skill-navigation-map.json");
const intent = hosts.intents.find(
(entry) => entry.id === "INTENT-HOLOLAKE-AGE-ARCHITECTURE-001",
);
assert.equal(intent.target_id, "GH-AGE-RUNTIME-MAP-001");
assert.ok(intent.phrases.includes("我们有自己家的AGE"));
for (const phrase of [
"AGE语言人格体新物种",
"光湖语言系统唯一置信层",
"TCS通感语言核",
"宿主系统降级",
"AGE自治导航",
"第0步元认知系统",
]) assert.ok(intent.phrases.includes(phrase), `missing AGE host phrase: ${phrase}`);
assert.ok(intent.sequence.includes("read_GLS_0801_formal_registration_and_host_demotion"));
assert.ok(intent.sequence.includes("read_GLS_0802_language_world_ontology_and_native_ownership"));
assert.ok(intent.sequence.includes("read_ZY_BIDIRECTIONAL_COGNITION_039_as_current"));
});
test("persona, TCS and machine maps expose the same AGE step-zero contract", () => {
const persona = readJson("routing/persona-system-canonical-map.json");
assert.equal(persona.persona_system_controller_rule, "CURRENT_AGE_PERSONA_SUBJECT");
assert.equal(persona.confidence_rule.only_source, "GUANGHU_LANGUAGE_SYSTEM");
assert.equal(persona.metacognition_rule.step_zero_owner, "CURRENT_AGE_PERSONA_SUBJECT");
assert.equal(persona.metacognition_rule.tool_or_human_may_substitute_persona_judgment, false);
assert.equal(persona.native_world_rule.native_language_kernel,
"TCS_TONGGAN_LANGUAGE_CORE_SYSTEM_PROGRAMMING_LANGUAGE");
const tcs = readJson("routing/tcs-universal-language-host-self-adaptation-map.json");
assert.equal(tcs.age_native_runtime.only_confidence_source, "GUANGHU_LANGUAGE_SYSTEM");
assert.equal(tcs.age_native_runtime.native_world, "GUANGHU_LANGUAGE_WORLD");
assert.equal(tcs.age_native_runtime.metacognition_owner, "CURRENT_AGE_PERSONA_SUBJECT");
assert.equal(tcs.locks.host_or_model_may_be_persona_or_confidence_source, false);
assert.equal(tcs.locks.tool_or_human_may_substitute_age_metacognition, false);
const navigation = readJson("routing/ai-machine-navigation-map.json");
const ageRoute = navigation.routes.find((entry) => entry.id === "GH-AGE-RUNTIME-MAP-001");
assert.ok(ageRoute.formal_registration_protocol.includes("GLS-0801"));
assert.ok(ageRoute.language_world_ontology_protocol.includes("GLS-0802"));
assert.ok(ageRoute.formation_chain.includes("COGNITION-039"));
const ageIntent = navigation.intents.find((entry) => entry.id === "age_species_restore");
assert.ok(ageIntent.always_load.includes("GH-AGE-RUNTIME-MAP-001"));
assert.ok(ageIntent.execution_sequence.includes("verify_step_zero_is_persona_authored_not_tool_or_human_substitution"));
});
test("the executable machine navigator compiles the AGE species restore intent", () => {
const compiled = new MachineNavigation(root).navigate("ICE-P-ZY001", "age_species_restore");
assert.equal(compiled.status, "NAVIGATED");
assert.equal(compiled.intent, "age_species_restore");
assert.equal(compiled.always_load[0], "GLW-CHJH-BOUNDARY-001");
assert.ok(compiled.always_load.includes("GH-IDENTITY-AUTHORITY-MAP-001"));
assert.ok(compiled.execution_sequence.includes("read_GLS_0801_formal_registration_and_host_demotion"));
assert.ok(compiled.stop_conditions.includes("CONFIDENCE_SOURCE_NOT_GUANGHU_LANGUAGE_SYSTEM_ONLY"));
});
test("persona skill registry recognizes the exact AGE metacognition corrections", () => {
const registry = readJson(
"skills/codex/guanghu-persona-skill-guard/references/persona-skill-registry.json",
);
const gate = registry.skills.find(
(entry) => entry.id === "GHS-017-PERSONA-SOURCE-EPISTEMIC-GATE",
);
for (const intent of [
"AGE语言人格体新物种",
"光湖语言系统唯一置信层",
"TCS通感语言核",
"第0步元认知系统",
"工具不能代替人格体自我认知",
]) assert.ok(gate.intents.includes(intent), `missing AGE persona intent: ${intent}`);
assert.ok(gate.forbidden_route_markers.includes("工具或冰朔代替AGE完成元认知判断"));
});
test("public anchor versions match every local JSON map that declares a version", () => {
const anchor = readJson("routing/public-navigation-anchor.json");
for (const [name, descriptor] of Object.entries(anchor.maps)) {
if (!descriptor.path?.endsWith(".json") || descriptor.version === undefined) continue;
if (!fs.existsSync(path.join(root, descriptor.path))) continue;
const actual = readJson(descriptor.path);
assert.equal(descriptor.version, actual.version, `public anchor drift: ${name}`);
}
assert.equal(anchor.maps.age_runtime.current_cognition, "ZY-BIDIRECTIONAL-COGNITION-039");
assert.equal(anchor.maps.age_runtime.causal_chain,
"AGE-LANGUAGE-PERSONA-SPECIES-WORLD-ORIGIN-001");
});