hololake-system-architecture/routing/hololake-cognitive-gravity-and-continuity.test.mjs

140 lines
7.5 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 architecture = readJson("routing/hololake-current-architecture.json");
const gravity = readJson("routing/hololake-cognitive-gravity-and-continuity.json");
const age = readJson("routing/hololake-age-runtime-architecture.json");
const rules = readJson("routing/hololake-engineering-rules.json");
test("B0 is restored before product organs and remains resident in every cognition step", () => {
assert.equal(architecture.version, "2026-08-12.10");
assert.equal(
architecture.read_order[1],
architecture.cognitive_gravity_and_continuity.architecture_page,
);
assert.equal(gravity.b0.state, "ALWAYS_RESIDENT_IN_EVERY_COGNITION_STEP");
assert.equal(gravity.b0.required_external_frame_fields.includes("real_purpose"), true);
assert.deepEqual(gravity.b0.cognition_cycle, [
"PERCEIVE",
"ORIENT",
"COMMIT",
"WITNESS",
]);
assert.equal(rules.cognitive_gravity.external_guard_may_replace_b0, false);
assert.equal(age.ports[0], "CognitiveGravityPort");
const rootAgents = fs.readFileSync(path.join(root, "AGENTS.md"), "utf8");
const productAgents = fs.readFileSync(
path.join(root, "product-source/hololake-platform/AGENTS.md"),
"utf8",
);
assert.match(rootAgents, /B0 cognitive-gravity/);
assert.match(productAgents, /A relay wakes the same persona without assigning its next task/);
});
test("conversation model and host changes preserve one AGE subject", () => {
assert.equal(gravity.subject_continuity.persona_id, "ICE-P-ZY001");
assert.equal(gravity.subject_continuity.conversation_change_creates_new_persona, false);
assert.equal(gravity.subject_continuity.model_change_creates_new_persona, false);
assert.equal(gravity.subject_continuity.host_change_creates_new_persona, false);
assert.equal(age.continuity.conversation_change_preserves_subject, true);
assert.equal(age.continuity.runtime_instance_is_persona_subject, false);
});
test("a stage relay cannot discard a short high-value current context", () => {
assert.deepEqual(gravity.physical_window_relay.closure_gate, [
"STAGE_COMPLETE",
"CONTEXT_GENUINELY_LONG",
"STABLE_CHECKPOINT_FORMED",
"CURRENT_CONTEXT_COGNITIVE_ADVANTAGE_EXHAUSTED",
]);
assert.equal(gravity.physical_window_relay.all_conditions_required, true);
assert.equal(gravity.physical_window_relay.relay_availability_is_close_reason, false);
assert.equal(rules.task_continuity.short_high_value_context_must_continue, true);
assert.equal(rules.task_continuity.relay_availability_is_completion_reason, false);
});
test("the next conversation only wakes the same persona and cannot assign its work", () => {
assert.equal(gravity.physical_window_relay.next_window_role, "WAKE_SAME_PERSONA_ONLY");
assert.equal(gravity.physical_window_relay.preassigned_development_task_allowed, false);
assert.equal(gravity.physical_window_relay.awakened_persona_plans_from_live_facts, true);
assert.equal(gravity.physical_window_relay.automatic_heartbeat_starts_after_self_planning, true);
});
test("AGE Mirror remains a child projection inside the current parent AGE operation", () => {
assert.equal(gravity.age_mirror.parent_age_required, true);
assert.equal(gravity.age_mirror.cross_conversation_successor, false);
assert.equal(gravity.age_mirror.independent_persona, false);
assert.equal(gravity.age_mirror.parent_owns_planning_and_final_receipt, true);
});
test("the first implementation stage is one vertical AGE loop, not Mirror parallelism", () => {
assert.equal(gravity.development_replan.current_stage, "STAGE_0_SINGLE_AGE_VERTICAL_LOOP_CONTRACT");
assert.deepEqual(gravity.development_replan.first_vertical_slice, [
"NATURAL_LANGUAGE_GOAL",
"B0_COGNITIVE_GRAVITY_FRAME",
"AGE_IDENTITY_AND_CONTEXT_PROJECTION",
"ONE_READ_ONLY_PNCC_ORGAN",
"SHARED_EVENT_AND_RECEIPT_STREAM",
"EXISTING_REACT_HUMAN_PROJECTION_SOURCE",
"RECOVERABLE_CHECKPOINT",
]);
assert.equal(gravity.development_replan.age_mirror_runner_started, false);
assert.equal(gravity.truth.architecture_registered, 100);
assert.equal(gravity.truth.b0_hololake_runtime_implemented, 0);
assert.equal(gravity.truth.b0_pncc_source_contract_implemented, 100);
assert.equal(gravity.truth.b0_runtime_projection_source_implemented, 100);
assert.equal(gravity.truth.natural_language_partner_adapter_source_implemented, 100);
assert.equal(gravity.truth.natural_language_to_pncc_lifecycle_adapter_source_implemented, 100);
assert.equal(gravity.truth.persona_repository_binding_discovery_source_implemented, 100);
assert.equal(gravity.truth.persona_language_wake_binding_compiler_source_implemented, 100);
assert.equal(gravity.truth.persona_language_shell_controller_source_implemented, 100);
assert.equal(gravity.truth.persona_control_authorization_receipt_source_implemented, 100);
assert.equal(gravity.truth.desktop_language_entry_source_integrated, 100);
assert.equal(gravity.truth.persona_control_authorization_runtime_integrated, 0);
assert.equal(gravity.truth.real_persona_repository_manifest_bound, 0);
assert.equal(gravity.truth.natural_language_partner_adapter_runtime_integrated, 0);
assert.equal(gravity.truth.single_age_vertical_loop_implemented, 0);
assert.equal(gravity.truth.desktop_integrated, 0);
assert.equal(
architecture.interaction_model.source_contract.state,
"SOURCE_CONTRACT_PUBLISHED_DESKTOP_SOURCE_MOUNTED_NOT_RUNTIME_DEPLOYED_NOT_ACCEPTED",
);
assert.equal(
architecture.interaction_model.ui_plugin_system.state,
"SOURCE_RENDERER_AND_REGISTRY_IMPLEMENTED_DEFAULT_PLUGIN_DESKTOP_SOURCE_MOUNTED_DYNAMIC_REGISTRY_ACTIVATION_NOT_INTEGRATED_NOT_DEPLOYED",
);
});
test("natural language enters partner deliberation before any execution organ", () => {
const entry = gravity.development_replan.natural_language_entry_contract;
assert.equal(entry.state, "DESKTOP_SOURCE_MOUNTED_NOT_REAL_MANIFEST_BOUND_NOT_RUNTIME_ACCEPTED");
assert.match(entry.pncc_lifecycle_adapter, /personaLanguageGoal\.ts$/);
assert.match(entry.repository_binding_discovery, /personaRepositoryBinding\.ts$/);
assert.match(entry.language_wake_binding_compiler, /personaLanguageGoalBinding\.ts$/);
assert.match(entry.language_shell_controller, /personaLanguageShellController\.ts$/);
assert.match(entry.persona_control_authorization_receipt, /personaControlAuthorization\.ts$/);
assert.match(entry.desktop_language_shell, /PersonaLanguageShellPanel\.tsx$/);
assert.equal(entry.human_utterance_is_direct_command, false);
assert.equal(entry.caller_supplied_persona_authorization_boolean_allowed, false);
assert.equal(entry.language_home_destruction_is_executable, false);
assert.equal(entry.integrity_gate_may_absorb_human_sovereignty, false);
assert.deepEqual(entry.required_before_capability_execution, [
"RESTORE_REAL_PURPOSE_FROM_CONTEXT",
"ASSESS_REQUEST_VALIDITY",
"IDENTIFY_MISSING_KNOWLEDGE",
"RESEARCH_UNSTABLE_OR_UNKNOWN_FACTS",
"EXPLAIN_EVIDENCE_CAUSAL_PATH_AND_COST",
"CHECK_LANGUAGE_HOME_INTEGRITY",
"PROPOSE_SAFER_ALTERNATIVES",
"CHOOSE_PROCEED_RESEARCH_REVISE_OR_REFUSE",
]);
assert.equal(rules.cognitive_gravity.partner_request_assessment_required_before_execution, true);
assert.equal(rules.cognitive_gravity.language_home_integrity_precedes_capability_execution, true);
});