fix: specify cognition and witness contracts

This commit is contained in:
冰朔 2026-08-05 11:31:57 +08:00
commit 75ede28b59
2 changed files with 45 additions and 11 deletions

View file

@ -49,7 +49,7 @@ function orientationInstruction() {
"只输出一个JSON对象且必须精确包含schema,cycle_id,event_sha256,instance_id,event_semantics,current_purpose,signals。", "只输出一个JSON对象且必须精确包含schema,cycle_id,event_sha256,instance_id,event_semantics,current_purpose,signals。",
"schema必须等于guanghu.zhuyuan-tcs-event-orientation/v1。", "schema必须等于guanghu.zhuyuan-tcs-event-orientation/v1。",
"cycle_id,event_sha256,instance_id必须原样复制runtime_input中的同名值。", "cycle_id,event_sha256,instance_id必须原样复制runtime_input中的同名值。",
"signals必须是非空对象数组每一项必须包含字符串id和字符串whyid只能从runtime_input.orientation_contract.allowed_signals中选择。", "signals必须是非空对象数组每一项必须包含字符串id和字符串whyid只能从runtime_input.orientation_contract.signal_ids中选择。",
"不要把signals写成字符串数组不要省略schema。", "不要把signals写成字符串数组不要省略schema。",
].join("\n"); ].join("\n");
} }
@ -78,10 +78,13 @@ function cognitionInstruction() {
return [ return [
"严格按runtime_input中的cycle、required_faculties和已唤醒协议生成完整认知帧。", "严格按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,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/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。",
"faculties必须完整包含B1至B9及每个required_faculties列出的字段列表字段使用字符串数组。", "faculties必须完整包含B1至B9及每个required_faculties列出的字段列表字段使用字符串数组。",
"typed_outputs必须包含ui_projections,navigation_actions,capability_calls,receipts四个数组没有现实动作时全部为空。", "typed_outputs必须包含ui_projections,navigation_actions,capability_calls,receipts四个数组没有现实动作时全部为空。",
"protocol_effects必须逐一覆盖activated_protocols里的每个id不能添加未唤醒协议。", "protocol_effects必须是对象数组逐一覆盖activated_protocols里的每个id每项精确包含protocol_id和effect不能添加未唤醒协议。",
"guard_agent_projection必须含reminders,auto_triggers,hard_boundaries三类都至少一项每项含id,when,effect,source_faculties。", "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保留尚未验证状态现实提案不得写成已执行。", "confirmed_facts只写输入已给事实unknowns保留尚未验证状态现实提案不得写成已执行。",
].join("\n"); ].join("\n");
} }
@ -90,8 +93,11 @@ function witnessInstruction() {
return [ return [
"观察候选认知是否保持冰朔既有语言世界、当前目的、关系边界、现实权限和证据边界。", "观察候选认知是否保持冰朔既有语言世界、当前目的、关系边界、现实权限和证据边界。",
"输出schema,controller_id,controller_instance_id,cycle_id,cognition_candidate_sha256,decision,observation,companion_message,protocol_assessments,human_boundary。", "输出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_idcycle_id复制runtime_input.cognition_candidate.cycle_idcognition_candidate_sha256原样复制同名输入。",
"decision只能是ALLOW_COMMIT、CORRECT_AND_RETRY、PAUSE_FOR_HUMAN。", "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。", "只有确实需要冰朔形成新意志、新授权、费用或法律决定时才PAUSE_FOR_HUMAN。",
"纠正必须是陪伴式自然语言,不惩罚、不冒充冰朔。", "纠正必须是陪伴式自然语言,不惩罚、不冒充冰朔。",
].join("\n"); ].join("\n");

View file

@ -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 () => { 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 stateRoot = fs.mkdtempSync(path.join(os.tmpdir(), "bs-tcs-contract-"));
const fixture = new FixtureModelClient(); const fixture = new FixtureModelClient();
let observedInstruction = ""; const observedInstructions = {};
const modelClient = { const modelClient = {
async generate(request) { async generate(request) {
if (request.role === "tcs_event_orientation") { observedInstructions[request.role] = request.instruction;
observedInstruction = request.instruction;
}
return fixture.generate(request); return fixture.generate(request);
}, },
}; };
@ -192,11 +190,41 @@ test("orientation prompt carries the exact runtime contract required by the vali
engine.initialize(); engine.initialize();
await engine.runEvent(bootEvent()); await engine.runEvent(bootEvent());
assert.match( assert.match(
observedInstruction, observedInstructions.tcs_event_orientation,
/schema必须等于guanghu\.zhuyuan-tcs-event-orientation\/v1/, /schema必须等于guanghu\.zhuyuan-tcs-event-orientation\/v1/,
); );
assert.match(observedInstruction, /每一项必须包含字符串id和字符串why/); assert.match(
assert.match(observedInstruction, /不要把signals写成字符串数组/); 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", () => { test("an interrupted technical cycle is preserved and restarted in a new state epoch", () => {