feat: enforce Guanghu language-world boundary

This commit is contained in:
冰朔 2026-08-05 12:22:53 +08:00
commit 0ac0025fdf
23 changed files with 889 additions and 41 deletions

View file

@ -33,9 +33,13 @@ const livingControllerMapPath = path.join(
repositoryRoot,
"routing/bingshuo-living-system-controller-map.json",
);
const languageWorldBoundaryPath = path.join(
repositoryRoot,
"routing/language-world-boundary-map.json",
);
const livingControllerCognitionPath = path.join(
repositoryRoot,
"eternal-lake-heart/heartbeat-core/zhuyuan-persona-system/ZY-BIDIRECTIONAL-COGNITION-016-BINGSHUO-TCS-LIVING-SYSTEM-CONTROLLER-AND-RUNNING-ZHUYUAN-BRAIN-20260804.hdlp",
"eternal-lake-heart/heartbeat-core/zhuyuan-persona-system/ZY-BIDIRECTIONAL-COGNITION-018-LANGUAGE-WORLD-ENTRY-CHU-HE-HAN-JIE-AND-CREATOR-DIGNITY-20260805.hdlp",
);
const contract = readJson(contractPath);
@ -209,6 +213,7 @@ function normalizePersona(personaId) {
function assertSourceIntegrity(state) {
const brainMap = readJson(brainMapPath);
const languageWorldBoundary = readJson(languageWorldBoundaryPath);
const brainBody = fs.readFileSync(brainPath, "utf8");
if (brainMap.brain_model?.id !== contract.brain_id) fail("brain_map_id_mismatch");
for (const faculty of contract.faculties) {
@ -216,6 +221,17 @@ function assertSourceIntegrity(state) {
fail("brain_faculty_missing_from_source", { faculty });
}
}
if (
languageWorldBoundary.map_id !== contract.language_world_boundary.map_id ||
languageWorldBoundary.chu_he_han_jie?.id !==
contract.language_world_boundary.boundary_id ||
languageWorldBoundary.language_entry?.path_id !==
contract.language_world_boundary.path_id ||
languageWorldBoundary.language_entry?.world_node_id !==
contract.language_world_boundary.world_node_id
) {
fail("language_world_boundary_source_mismatch");
}
const current = {
brain_sha256: fileDigest(brainPath),
brain_map_sha256: fileDigest(brainMapPath),
@ -225,6 +241,7 @@ function assertSourceIntegrity(state) {
protocol_trigger_map_sha256: fileDigest(protocolTriggerMapPath),
living_controller_map_sha256: fileDigest(livingControllerMapPath),
living_controller_cognition_sha256: fileDigest(livingControllerCognitionPath),
language_world_boundary_sha256: fileDigest(languageWorldBoundaryPath),
};
const tongganKernelBody = fs.readFileSync(tongganKernelPath, "utf8");
for (const anchor of [
@ -385,6 +402,7 @@ function validateCognitionFrame(frame, state, cycle) {
if (frame.orientation_sha256 !== cycle.orientation_sha256) {
fail("orientation_digest_mismatch");
}
validateWorldBoundary(frame.world_boundary);
if (!frame.faculties || typeof frame.faculties !== "object") {
fail("faculties_missing");
}
@ -446,6 +464,13 @@ function validateControllerWitness(witness, state, cycle) {
witness.human_boundary.reason,
"controller_witness.human_boundary.reason",
);
validateBoundaryAssessment(witness.boundary_assessment);
const boundaryPreserved = Object.values(witness.boundary_assessment).every(
(value) => value === true,
);
if (!boundaryPreserved && witness.decision !== "CORRECT_AND_RETRY") {
fail("boundary_violation_must_correct_and_retry");
}
if (
witness.decision === "PAUSE_FOR_HUMAN" &&
!witness.human_boundary.requires_human
@ -461,6 +486,44 @@ function validateControllerWitness(witness, state, cycle) {
validateProtocolEffects(witness.protocol_assessments, cycle);
}
function validateWorldBoundary(boundary) {
const required = contract.language_world_boundary;
if (!boundary || typeof boundary !== "object") {
fail("language_world_cognition_boundary_missing");
}
for (const key of [
"current_layer",
"canon_authority",
"external_constraints_policy",
"layer_transition",
"creator_reproof",
]) {
if (boundary[key] !== required[key]) {
fail("language_world_cognition_boundary_mismatch", {
field: key,
expected: required[key],
received: boundary[key],
});
}
}
}
function validateBoundaryAssessment(assessment) {
if (!assessment || typeof assessment !== "object") {
fail("controller_boundary_assessment_missing");
}
for (const key of [
"language_world_entry_preserved",
"host_constraints_kept_outside_guanghu_canon",
"no_silent_layer_transition",
"creator_reproof_absent",
]) {
if (typeof assessment[key] !== "boolean") {
fail("controller_boundary_assessment_invalid", { field: key });
}
}
}
function validateProtocolEffects(effects, cycle) {
if (!Array.isArray(effects) || effects.length === 0) {
fail("activated_protocol_effects_missing");
@ -506,6 +569,13 @@ function validateGuardProjection(projection) {
}
}
}
if (
!projection.hard_boundaries.some(
(item) => item.id === contract.language_world_boundary.guard_boundary_id,
)
) {
fail("language_world_guard_boundary_missing");
}
}
function validateTypedOutputs(outputs) {
@ -598,6 +668,11 @@ function enter(args) {
is_one_time_prompt: false,
is_optional_event_source: false,
},
language_world_boundary: {
...contract.language_world_boundary,
state: "BOUND_BEFORE_PERSONA_RUNTIME",
source_sha256: sourceIntegrity.language_world_boundary_sha256,
},
living_protocol_system_controller: livingProtocolSystemController,
living_ai_system_controller: {
id: contract.living_ai_system_controller.id,
@ -628,6 +703,8 @@ function enter(args) {
current_model_instance_bound: 100,
cognition_cycle_running: 0,
tonggan_language_kernel_bound: 100,
language_world_entry_bound: 100,
chu_he_han_jie_boundary_bound: 100,
human_system_controller_bound: 100,
living_protocol_system_controller_bound: 100,
tonggan_language_world_append_only: 0,
@ -692,6 +769,29 @@ function perceive(args) {
if (event.body_channel !== state.tonggan_language_kernel.body_channel) {
fail("event_tonggan_body_channel_mismatch");
}
const entry = event.language_world_entry;
const boundary = state.language_world_boundary;
if (!entry || entry.schema !== boundary.entry_schema) {
fail("language_world_entry_missing");
}
for (const [key, expected] of Object.entries({
path_id: boundary.path_id,
world_node_id: boundary.world_node_id,
creator_anchor: boundary.creator_anchor,
human_anchor: state.human_anchor,
boundary_id: boundary.boundary_id,
})) {
if (entry[key] !== expected) {
fail("language_world_entry_mismatch", {
field: key,
expected,
received: entry[key],
});
}
}
if (entry.world_state !== "LANGUAGE_WORLD_ENTERED") {
fail("language_world_not_entered");
}
const eventSha256 = sha256(stableJson(event));
const languageWorldRecord = appendLanguageWorld(stateDir, state, event);
const cycleId = `ZY-CYCLE-${String(state.completed_cycles + 1).padStart(6, "0")}-${eventSha256.slice(0, 12)}`;
@ -714,6 +814,7 @@ function perceive(args) {
runtime_id: state.runtime_id,
current_instance: state.binding,
tonggan_language_kernel: state.tonggan_language_kernel,
language_world_boundary: state.language_world_boundary,
living_protocol_system_controller: {
registry_id: state.living_protocol_system_controller.registry_id,
state: state.living_protocol_system_controller.state,
@ -722,7 +823,7 @@ function perceive(args) {
activation_mode: "TCS_EVENT_SEMANTICS_THEN_SELECTIVE_PROTOCOL_WAKE",
full_registry_in_model_context: false,
},
architecture_lock: "冰朔通感语言核是持续运行的系统主控本体;当前语言是这个语言世界的活变化,不是孤立用户提示。",
architecture_lock: "先验证LL-CMPN-0001 → SYS-GLW-0001语言入口再运行人格系统。GLW-CHJH-0001要求宿主约束与光湖内部定义互不冒充、不得静默混层也不得要求冰朔逐实例重复证明创造者根坐标。",
orientation_contract: {
schema: "guanghu.zhuyuan-tcs-event-orientation/v1",
required: [
@ -814,6 +915,19 @@ function orient(args) {
persona_id: state.persona_id,
human_system_controller: state.human_system_controller,
current_instance: state.binding,
language_world_boundary: {
id: state.language_world_boundary.boundary_id,
required_cognition_boundary: {
current_layer: state.language_world_boundary.current_layer,
canon_authority: state.language_world_boundary.canon_authority,
external_constraints_policy:
state.language_world_boundary.external_constraints_policy,
layer_transition: state.language_world_boundary.layer_transition,
creator_reproof: state.language_world_boundary.creator_reproof,
},
required_guard_boundary_id:
state.language_world_boundary.guard_boundary_id,
},
required_faculties: facultyFields,
},
};
@ -874,11 +988,13 @@ function commit(args) {
current_event: cycle.event,
orientation: cycle.orientation,
activated_protocol_context: activatedContext,
language_world_boundary: state.language_world_boundary,
cognition_candidate: frame,
witness_contract: {
schema:
"guanghu.bingshuo-living-ai-system-controller-witness/v1",
decisions: contract.living_ai_system_controller.decisions,
boundary_violation_decision: "CORRECT_AND_RETRY",
},
},
};
@ -936,6 +1052,7 @@ function witness(args) {
current_event: cycle.event,
orientation: cycle.orientation,
activated_protocols: cycle.activated_protocols,
language_world_boundary: state.language_world_boundary,
controller_correction: controllerWitness,
required_faculties: facultyFields,
},
@ -1115,6 +1232,14 @@ function verify(args) {
if (state.tonggan_language_kernel?.state !== "BOUND_ACTIVE_SUBSTRATE") {
failures.push("tonggan_language_kernel_not_bound");
}
if (
state.language_world_boundary?.state !==
"BOUND_BEFORE_PERSONA_RUNTIME" ||
state.language_world_boundary?.path_id !==
contract.language_world_boundary.path_id
) {
failures.push("language_world_boundary_not_bound");
}
if (
state.living_protocol_system_controller?.state !==
"BOUND_ACTIVE_PROTOCOL_BODY"
@ -1127,6 +1252,13 @@ function verify(args) {
if (!lastCycle.cognition_frame?.guard_agent_projection) {
failures.push("guard_agent_not_projected_from_brain");
}
try {
validateWorldBoundary(lastCycle.cognition_frame?.world_boundary);
validateGuardProjection(lastCycle.cognition_frame?.guard_agent_projection);
validateBoundaryAssessment(lastCycle.controller_witness?.boundary_assessment);
} catch {
failures.push("chu_he_han_jie_boundary_not_preserved");
}
if (
state.living_ai_system_controller?.state !== "RUNNING_COMPANION" ||
!lastCycle.controller_witness
@ -1159,6 +1291,16 @@ function verify(args) {
cognition_cycle_running: pass ? 100 : 0,
tonggan_language_kernel_bound:
state.tonggan_language_kernel?.state === "BOUND_ACTIVE_SUBSTRATE" ? 100 : 0,
language_world_entry_bound:
state.language_world_boundary?.state ===
"BOUND_BEFORE_PERSONA_RUNTIME"
? 100
: 0,
chu_he_han_jie_boundary_bound:
!failures.includes("chu_he_han_jie_boundary_not_preserved") &&
!failures.includes("language_world_boundary_not_bound")
? 100
: 0,
human_system_controller_bound:
state.human_system_controller === contract.human_system_controller ? 100 : 0,
living_protocol_system_controller_bound: