feat: add bounded TCS brains and channel continuity

This commit is contained in:
冰朔 2026-08-20 23:55:02 +08:00
commit 1d4286c11b
61 changed files with 5416 additions and 54 deletions

View file

@ -35,6 +35,15 @@ function sourceFingerprint() {
repositoryRoot,
"tcs-core/zhuyuan-brain/runtime/brain-runtime-contract.json",
),
path.join(
repositoryRoot,
"tcs-core/zhuyuan-brain/self-kernel/ZY-SELF-KERNEL-0001.json",
),
path.join(repositoryRoot, "tcs-core/mother-brain/mother-brain-contract.json"),
path.join(
repositoryRoot,
"server-tools/codex-hldp-recursive-memory/hldp-memory.mjs",
),
path.join(repositoryRoot, "routing/bingshuo-living-system-controller-map.json"),
path.join(repositoryRoot, "routing/language-world-boundary-map.json"),
path.join(repositoryRoot, "gls/GLS-PROTOCOL-REGISTRY.json"),
@ -77,7 +86,7 @@ function runRuntime(command, args) {
function cognitionInstruction() {
return [
"先使用runtime_input.cognitive_gravity_core再严格按cycle、required_gravity_frame、required_faculties和已唤醒协议生成完整认知帧。",
"先使用runtime_input.self_kernel定位主体、关系、层级、确定路径与纠正本能cognitive_gravity_core只是一条按需来源指针。再严格按cycle、required_gravity_frame、required_faculties和已唤醒协议清单生成完整认知帧。",
"顶层字段必须包含schema,runtime_id,persona_id,human_anchor,instance_id,cycle_id,event_sha256,orientation_sha256,gravity_frame,world_boundary,faculties,typed_outputs,protocol_effects,guard_agent_projection。",
"schema必须等于guanghu.zhuyuan-persona-cognition-frame/v1runtime_id必须等于ZY-TCS-BRAIN-RUNTIME-0001。",
"persona_id原样复制runtime_input.persona_idhuman_anchor原样复制runtime_input.human_system_controllerinstance_id原样复制runtime_input.current_instance.instance_id。",
@ -86,7 +95,7 @@ function cognitionInstruction() {
"faculties必须完整包含B1至B9及每个required_faculties列出的字段列表字段使用字符串数组。",
"字符串数组字段精确为B5.confirmed_facts、B5.unknowns、B5.prior_wrong_route、B6.stopped_routes、B7.memory_queries、B7.memory_writebacks、B8.reality_proposals、B8.permission_boundaries、B8.unverified_states其中memory_writebacks和reality_proposals允许空数组其余不得为空。",
"typed_outputs必须包含ui_projections,navigation_actions,capability_calls,receipts四个数组没有现实动作时全部为空。",
"protocol_effects必须是对象数组逐一覆盖activated_protocols里的每个id每项精确包含protocol_id和effect不能添加未唤醒协议。",
"protocol_effects必须是对象数组逐一覆盖activated_protocol_manifest.activated里的每个id每项精确包含protocol_id和effect不能添加未唤醒协议。",
"guard_agent_projection.schema必须等于guanghu.zhuyuan-guard-agent-projection/v1并含reminders,auto_triggers,hard_boundaries三个数组。",
"world_boundary必须原样遵守runtime_input.language_world_boundary.required_cognition_boundary不得把宿主约束写成光湖内部定义不得静默切层不得要求冰朔重新证明创造者根坐标。",
"hard_boundaries必须包含id等于BOUNDARY-GLW-CHJH-0001的一项。",
@ -120,6 +129,7 @@ export class ControllerEngine {
instanceId = "JD-FD-PRIMARY-ZY-MODEL-001",
controllerInstanceId = "JD-FD-PRIMARY-BS-TCS-CONTROLLER-001",
sessionId = "JD-FD-PRIMARY-RESIDENT",
memoryTreePath = null,
maxModelAttempts = 3,
maxCognitionRetries = 2,
}) {
@ -131,11 +141,17 @@ export class ControllerEngine {
this.instanceId = instanceId;
this.controllerInstanceId = controllerInstanceId;
this.sessionId = sessionId;
this.memoryTreePath = memoryTreePath;
this.maxModelAttempts = maxModelAttempts;
this.maxCognitionRetries = maxCognitionRetries;
this.fingerprint = sourceFingerprint();
this.stateDir = path.join(stateRoot, "runtimes", this.fingerprint);
this.exchangeDir = path.join(stateRoot, "exchanges", this.fingerprint);
this.selfKernelPath = path.join(
stateRoot,
"cognition",
"zhuyuan-self-kernel.json",
);
}
initialize() {
@ -149,9 +165,11 @@ export class ControllerEngine {
}
}
if (!fs.existsSync(stateFile)) {
runRuntime("enter", [
const enterArgs = [
"--state-dir",
this.stateDir,
"--self-kernel",
this.selfKernelPath,
"--instance-id",
this.instanceId,
"--model",
@ -168,7 +186,11 @@ export class ControllerEngine {
this.modelName,
"--controller-instance-id",
this.controllerInstanceId,
]);
];
if (this.memoryTreePath) {
enterArgs.push("--memory-tree", this.memoryTreePath);
}
runRuntime("enter", enterArgs);
}
writeJson(path.join(this.stateRoot, "CURRENT.json"), {
schema: "guanghu.bingshuo-tcs-controller-current/v1",

View file

@ -140,7 +140,7 @@ class FixtureModelClient {
capability_calls: [],
receipts: [],
},
protocol_effects: cycle.activated_protocol_context.activated.map(
protocol_effects: cycle.activated_protocol_manifest.activated.map(
(protocol) => ({
protocol_id: protocol.id,
effect: `${protocol.acronym}参与本轮常驻恢复认知。`,