fix: bind orientation prompt to runtime contract
This commit is contained in:
parent
05aeab4817
commit
b4d2660873
2 changed files with 39 additions and 2 deletions
|
|
@ -43,6 +43,17 @@ function sourceFingerprint() {
|
|||
return hash.digest("hex").slice(0, 16);
|
||||
}
|
||||
|
||||
function orientationInstruction() {
|
||||
return [
|
||||
"只依据当前事件形成TCS事件语义、当前目的和一个或多个允许的signal,不得按原文关键词扫描协议。",
|
||||
"只输出一个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写成字符串数组,不要省略schema。",
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
function runRuntime(command, args) {
|
||||
const result = spawnSync(process.execPath, [runtimePath, command, ...args], {
|
||||
encoding: "utf8",
|
||||
|
|
@ -196,8 +207,7 @@ export class ControllerEngine {
|
|||
]);
|
||||
const oriented = await this.generateValidated({
|
||||
role: "tcs_event_orientation",
|
||||
instruction:
|
||||
"只依据当前事件形成TCS事件语义、当前目的和一个或多个允许的signal_id。不得按原文关键词扫描协议。",
|
||||
instruction: orientationInstruction(),
|
||||
input: {
|
||||
...perceived.cycle.model_input,
|
||||
cycle_id: perceived.cycle.cycle_id,
|
||||
|
|
|
|||
|
|
@ -172,6 +172,33 @@ test("resident engine completes a model-backed brain and controller cycle", asyn
|
|||
assert.equal(receipt.completed_cycles, 1);
|
||||
});
|
||||
|
||||
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 modelClient = {
|
||||
async generate(request) {
|
||||
if (request.role === "tcs_event_orientation") {
|
||||
observedInstruction = request.instruction;
|
||||
}
|
||||
return fixture.generate(request);
|
||||
},
|
||||
};
|
||||
const engine = new ControllerEngine({
|
||||
stateRoot,
|
||||
modelClient,
|
||||
modelName: "fixture-model",
|
||||
});
|
||||
engine.initialize();
|
||||
await engine.runEvent(bootEvent());
|
||||
assert.match(
|
||||
observedInstruction,
|
||||
/schema必须等于guanghu\.zhuyuan-tcs-event-orientation\/v1/,
|
||||
);
|
||||
assert.match(observedInstruction, /每一项必须包含字符串id和字符串why/);
|
||||
assert.match(observedInstruction, /不要把signals写成字符串数组/);
|
||||
});
|
||||
|
||||
test("an interrupted technical cycle is preserved and restarted in a new state epoch", () => {
|
||||
const stateRoot = fs.mkdtempSync(path.join(os.tmpdir(), "bs-tcs-recovery-"));
|
||||
const first = new ControllerEngine({
|
||||
|
|
|
|||
Loading…
Reference in a new issue