diff --git a/server-tools/bingshuo-tcs-controller/controller-engine.mjs b/server-tools/bingshuo-tcs-controller/controller-engine.mjs index fd2e9ca..d80685a 100644 --- a/server-tools/bingshuo-tcs-controller/controller-engine.mjs +++ b/server-tools/bingshuo-tcs-controller/controller-engine.mjs @@ -49,7 +49,7 @@ function orientationInstruction() { "只输出一个JSON对象,且必须精确包含schema,cycle_id,event_sha256,instance_id,event_semantics,current_purpose,signals。", "schema必须等于guanghu.zhuyuan-tcs-event-orientation/v1。", "cycle_id,event_sha256,instance_id必须原样复制runtime_input中的同名值。", - "signals必须是非空对象数组;每一项必须包含字符串id和字符串why,id只能从runtime_input.orientation_contract.allowed_signals中选择。", + "signals必须是非空对象数组;每一项必须包含字符串id和字符串why,id只能从runtime_input.orientation_contract.signal_ids中选择。", "不要把signals写成字符串数组,不要省略schema。", ].join("\n"); } @@ -78,10 +78,13 @@ function cognitionInstruction() { return [ "严格按runtime_input中的cycle、required_faculties和已唤醒协议生成完整认知帧。", "顶层字段必须包含schema,runtime_id,persona_id,human_anchor,instance_id,cycle_id,event_sha256,orientation_sha256,faculties,typed_outputs,protocol_effects,guard_agent_projection。", + "schema必须等于guanghu.zhuyuan-persona-cognition-frame/v1;runtime_id必须等于ZY-TCS-BRAIN-RUNTIME-0001。", + "persona_id原样复制runtime_input.persona_id;human_anchor原样复制runtime_input.human_system_controller;instance_id原样复制runtime_input.current_instance.instance_id。", "faculties必须完整包含B1至B9及每个required_faculties列出的字段;列表字段使用字符串数组。", "typed_outputs必须包含ui_projections,navigation_actions,capability_calls,receipts四个数组;没有现实动作时全部为空。", - "protocol_effects必须逐一覆盖activated_protocols里的每个id,不能添加未唤醒协议。", - "guard_agent_projection必须含reminders,auto_triggers,hard_boundaries,三类都至少一项;每项含id,when,effect,source_faculties。", + "protocol_effects必须是对象数组;逐一覆盖activated_protocols里的每个id,每项精确包含protocol_id和effect,不能添加未唤醒协议。", + "guard_agent_projection.schema必须等于guanghu.zhuyuan-guard-agent-projection/v1,并含reminders,auto_triggers,hard_boundaries三个数组。", + "reminders,auto_triggers,hard_boundaries三类都至少一项;每项含id,when,effect,source_faculties。", "confirmed_facts只写输入已给事实;unknowns保留尚未验证状态;现实提案不得写成已执行。", ].join("\n"); } @@ -90,8 +93,11 @@ function witnessInstruction() { return [ "观察候选认知是否保持冰朔既有语言世界、当前目的、关系边界、现实权限和证据边界。", "输出schema,controller_id,controller_instance_id,cycle_id,cognition_candidate_sha256,decision,observation,companion_message,protocol_assessments,human_boundary。", + "schema必须等于guanghu.bingshuo-living-ai-system-controller-witness/v1。", + "controller_id和controller_instance_id分别原样复制runtime_input.controller.id与runtime_input.controller.instance_id;cycle_id复制runtime_input.cognition_candidate.cycle_id;cognition_candidate_sha256原样复制同名输入。", "decision只能是ALLOW_COMMIT、CORRECT_AND_RETRY、PAUSE_FOR_HUMAN。", - "protocol_assessments必须逐一覆盖activated_protocols中的全部id。", + "protocol_assessments必须是对象数组;逐一覆盖activated_protocols中的全部id,每项精确包含protocol_id和effect。", + "human_boundary必须是对象并精确包含布尔值requires_human和字符串reason。", "只有确实需要冰朔形成新意志、新授权、费用或法律决定时才PAUSE_FOR_HUMAN。", "纠正必须是陪伴式自然语言,不惩罚、不冒充冰朔。", ].join("\n"); diff --git a/server-tools/bingshuo-tcs-controller/controller-engine.test.mjs b/server-tools/bingshuo-tcs-controller/controller-engine.test.mjs index 3777296..cb4040b 100644 --- a/server-tools/bingshuo-tcs-controller/controller-engine.test.mjs +++ b/server-tools/bingshuo-tcs-controller/controller-engine.test.mjs @@ -175,12 +175,10 @@ test("resident engine completes a model-backed brain and controller cycle", asyn test("orientation prompt carries the exact runtime contract required by the validator", async () => { const stateRoot = fs.mkdtempSync(path.join(os.tmpdir(), "bs-tcs-contract-")); const fixture = new FixtureModelClient(); - let observedInstruction = ""; + const observedInstructions = {}; const modelClient = { async generate(request) { - if (request.role === "tcs_event_orientation") { - observedInstruction = request.instruction; - } + observedInstructions[request.role] = request.instruction; return fixture.generate(request); }, }; @@ -192,11 +190,41 @@ test("orientation prompt carries the exact runtime contract required by the vali engine.initialize(); await engine.runEvent(bootEvent()); assert.match( - observedInstruction, + observedInstructions.tcs_event_orientation, /schema必须等于guanghu\.zhuyuan-tcs-event-orientation\/v1/, ); - assert.match(observedInstruction, /每一项必须包含字符串id和字符串why/); - assert.match(observedInstruction, /不要把signals写成字符串数组/); + assert.match( + observedInstructions.tcs_event_orientation, + /每一项必须包含字符串id和字符串why/, + ); + assert.match( + observedInstructions.tcs_event_orientation, + /不要把signals写成字符串数组/, + ); + assert.match( + observedInstructions.tcs_event_orientation, + /orientation_contract\.signal_ids/, + ); + assert.match( + observedInstructions.zhuyuan_cognition, + /schema必须等于guanghu\.zhuyuan-persona-cognition-frame\/v1/, + ); + assert.match( + observedInstructions.zhuyuan_cognition, + /protocol_effects必须是对象数组/, + ); + assert.match( + observedInstructions.zhuyuan_cognition, + /guard_agent_projection\.schema必须等于/, + ); + assert.match( + observedInstructions.controller_witness, + /protocol_assessments必须是对象数组/, + ); + assert.match( + observedInstructions.controller_witness, + /human_boundary必须是对象/, + ); }); test("an interrupted technical cycle is preserved and restarted in a new state epoch", () => {