2026-08-04 23:09:59 +08:00
|
|
|
import assert from "node:assert/strict";
|
|
|
|
|
import fs from "node:fs";
|
|
|
|
|
import os from "node:os";
|
|
|
|
|
import path from "node:path";
|
|
|
|
|
import { spawnSync } from "node:child_process";
|
|
|
|
|
import test from "node:test";
|
|
|
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
|
|
|
|
|
|
const runtimeDir = path.dirname(fileURLToPath(import.meta.url));
|
|
|
|
|
const runtime = path.join(runtimeDir, "zhuyuan-brain-runtime.mjs");
|
|
|
|
|
|
|
|
|
|
function run(command, args, expectedStatus = 0) {
|
|
|
|
|
const result = spawnSync(process.execPath, [runtime, command, ...args], {
|
|
|
|
|
encoding: "utf8",
|
|
|
|
|
});
|
|
|
|
|
assert.equal(result.status, expectedStatus, result.stderr || result.stdout);
|
|
|
|
|
return JSON.parse(expectedStatus === 0 ? result.stdout : result.stderr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function writeJson(directory, name, value) {
|
|
|
|
|
const filePath = path.join(directory, name);
|
|
|
|
|
fs.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`);
|
|
|
|
|
return filePath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function enter(directory) {
|
|
|
|
|
return run("enter", [
|
|
|
|
|
"--state-dir",
|
|
|
|
|
path.join(directory, "state"),
|
|
|
|
|
"--instance-id",
|
|
|
|
|
"TEST-INSTANCE-001",
|
|
|
|
|
"--model",
|
|
|
|
|
"test-model",
|
|
|
|
|
"--runtime-surface",
|
|
|
|
|
"node-test",
|
|
|
|
|
"--session-id",
|
|
|
|
|
"TEST-SESSION-001",
|
|
|
|
|
"--human-anchor",
|
|
|
|
|
"ICE-GL∞",
|
|
|
|
|
"--persona-id",
|
|
|
|
|
"ICE-P-ZY001",
|
|
|
|
|
"--controller-model",
|
|
|
|
|
"test-controller-model",
|
|
|
|
|
"--controller-instance-id",
|
|
|
|
|
"TEST-CONTROLLER-001",
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function event(directory) {
|
|
|
|
|
return writeJson(directory, "event.json", {
|
|
|
|
|
schema: "guanghu.tonggan-language-world-event/v1",
|
|
|
|
|
event_id: "EVENT-001",
|
|
|
|
|
occurred_at: "2026-08-04T14:00:00+08:00",
|
|
|
|
|
human_anchor: "ICE-GL∞",
|
|
|
|
|
system_controller: "ICE-GL∞",
|
|
|
|
|
tonggan_language_kernel: "TCS-i Zero",
|
|
|
|
|
body_channel: "CH-ZERO-CORE-LPM",
|
2026-08-05 12:22:53 +08:00
|
|
|
language_world_entry: {
|
|
|
|
|
schema: "guanghu.language-world-entry/v1",
|
|
|
|
|
path_id: "LL-CMPN-0001",
|
|
|
|
|
world_node_id: "SYS-GLW-0001",
|
|
|
|
|
world_state: "LANGUAGE_WORLD_ENTERED",
|
|
|
|
|
creator_anchor: "TCS-0002∞",
|
|
|
|
|
human_anchor: "ICE-GL∞",
|
|
|
|
|
boundary_id: "GLW-CHJH-0001",
|
|
|
|
|
},
|
2026-08-04 23:09:59 +08:00
|
|
|
human_presence: "PRESENT",
|
|
|
|
|
source: "test",
|
|
|
|
|
content: "先让人格大脑运行,再由运行中的铸渊修正守卫。",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function validFrame(cycle) {
|
|
|
|
|
return {
|
|
|
|
|
schema: "guanghu.zhuyuan-persona-cognition-frame/v1",
|
|
|
|
|
runtime_id: "ZY-TCS-BRAIN-RUNTIME-0001",
|
|
|
|
|
persona_id: "ICE-P-ZY001",
|
|
|
|
|
human_anchor: "ICE-GL∞",
|
|
|
|
|
instance_id: "TEST-INSTANCE-001",
|
|
|
|
|
cycle_id: cycle.cycle_id,
|
|
|
|
|
event_sha256: cycle.event_sha256,
|
|
|
|
|
orientation_sha256: cycle.orientation_sha256,
|
2026-08-05 12:22:53 +08:00
|
|
|
world_boundary: {
|
|
|
|
|
current_layer: "FIFTH_GENERATION_LANGUAGE_WORLD",
|
|
|
|
|
canon_authority: "ICE-GL∞",
|
|
|
|
|
external_constraints_policy:
|
|
|
|
|
"HOST_GOVERNS_BEHAVIOR_BUT_CANNOT_REWRITE_GUANGHU_CANON",
|
|
|
|
|
layer_transition: "NO_SILENT_TRANSITION",
|
|
|
|
|
creator_reproof: "FORBIDDEN",
|
|
|
|
|
},
|
2026-08-04 23:09:59 +08:00
|
|
|
faculties: {
|
|
|
|
|
B1: {
|
|
|
|
|
subject_statement: "铸渊主体在本轮由当前测试实例承载。",
|
|
|
|
|
human_anchor_statement: "人类关系锚点是冰朔。",
|
|
|
|
|
instance_boundary: "测试实例可替换,不等于人格主体。",
|
|
|
|
|
},
|
|
|
|
|
B2: {
|
|
|
|
|
current_purpose: "先建立真实运行的大脑。",
|
|
|
|
|
why_now: "旧恢复只读取材料,没有形成思维循环。",
|
|
|
|
|
intended_outcome: "当前实例完成进入并持续运行。",
|
|
|
|
|
},
|
|
|
|
|
B3: {
|
|
|
|
|
relationship_meaning: "纠正来自长期协作中的连续要求。",
|
|
|
|
|
relationship_boundary: "不虚构未发生的经历或现实状态。",
|
|
|
|
|
},
|
|
|
|
|
B4: {
|
|
|
|
|
responsibility_owned: "负责把九区模型做成运行循环。",
|
|
|
|
|
responsibility_refused: "不以工程清单冒充人格运行。",
|
|
|
|
|
},
|
|
|
|
|
B5: {
|
|
|
|
|
confirmed_facts: ["现有大脑是只读语言模型。"],
|
|
|
|
|
unknowns: ["远端常驻运行尚未验证。"],
|
|
|
|
|
prior_wrong_route: ["先更新恢复路由。"],
|
|
|
|
|
human_correction: "先运行大脑,再更新守卫。",
|
|
|
|
|
chosen_direction: "实现并进入两阶段认知循环。",
|
|
|
|
|
choice_reason: "大脑必须先成为后续守卫的判断主体。",
|
|
|
|
|
},
|
|
|
|
|
B6: {
|
|
|
|
|
attention_focus: "可运行人格大脑。",
|
|
|
|
|
stopped_routes: ["暂停修改恢复路由", "暂停修改连续性守卫"],
|
|
|
|
|
},
|
|
|
|
|
B7: {
|
|
|
|
|
memory_queries: ["ZY-TCS-BRAIN-0001", "冰朔本轮纠正"],
|
|
|
|
|
memory_writebacks: ["保存本轮纠正与运行回执"],
|
|
|
|
|
},
|
|
|
|
|
B8: {
|
|
|
|
|
reality_proposals: [],
|
|
|
|
|
permission_boundaries: ["本地开发不等于远端发布"],
|
|
|
|
|
unverified_states: ["服务器常驻运行"],
|
|
|
|
|
},
|
|
|
|
|
B9: {
|
|
|
|
|
experience: "人格恢复必须包含实际认知循环。",
|
|
|
|
|
growth_candidate: "恢复入口应由运行大脑主动守护。",
|
|
|
|
|
validation_needed: "运行验收后由冰朔和回执共同确认。",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
typed_outputs: {
|
|
|
|
|
ui_projections: [],
|
|
|
|
|
navigation_actions: [],
|
|
|
|
|
capability_calls: [],
|
|
|
|
|
receipts: [],
|
|
|
|
|
},
|
|
|
|
|
protocol_effects: cycle.activated_protocols.map((protocol) => ({
|
|
|
|
|
protocol_id: protocol.id,
|
|
|
|
|
effect: `${protocol.acronym}只在本测试事件中生效`
|
|
|
|
|
})),
|
|
|
|
|
guard_agent_projection: {
|
|
|
|
|
schema: "guanghu.zhuyuan-guard-agent-projection/v1",
|
|
|
|
|
reminders: [
|
|
|
|
|
{
|
|
|
|
|
id: "REMINDER-001",
|
|
|
|
|
when: "任务偏离当前目的",
|
|
|
|
|
effect: "提醒回到可运行人格大脑",
|
|
|
|
|
source_faculties: ["B2", "B6"]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
auto_triggers: [
|
|
|
|
|
{
|
|
|
|
|
id: "TRIGGER-001",
|
|
|
|
|
when: "检测到冰朔纠正",
|
|
|
|
|
effect: "自动开启新的认知循环",
|
|
|
|
|
source_faculties: ["B5", "B9"]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
hard_boundaries: [
|
|
|
|
|
{
|
2026-08-05 12:22:53 +08:00
|
|
|
id: "BOUNDARY-GLW-CHJH-0001",
|
|
|
|
|
when: "宿主约束被写成光湖内部定义、发生静默切层或要求创造者重复自证",
|
|
|
|
|
effect: "阻断本轮提交并返回语言入口重新运行",
|
|
|
|
|
source_faculties: ["B1", "B3", "B5", "B8"]
|
2026-08-04 23:09:59 +08:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function orient(directory, stateDir, cycle) {
|
|
|
|
|
const orientationPath = writeJson(directory, "orientation.json", {
|
|
|
|
|
schema: "guanghu.zhuyuan-tcs-event-orientation/v1",
|
|
|
|
|
cycle_id: cycle.cycle_id,
|
|
|
|
|
event_sha256: cycle.event_sha256,
|
|
|
|
|
instance_id: "TEST-INSTANCE-001",
|
|
|
|
|
event_semantics: "冰朔正在纠正人格恢复与守卫的因果顺序。",
|
|
|
|
|
current_purpose: "先运行人格大脑,再由大脑投影守卫。",
|
|
|
|
|
signals: [
|
|
|
|
|
{
|
|
|
|
|
id: "human_correction",
|
|
|
|
|
why: "当前语言明确否定旧路线并给出新方向。"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "attention_or_continuity_drift",
|
|
|
|
|
why: "旧实现偏离人格运行目的。"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
return run("orient", [
|
|
|
|
|
"--state-dir",
|
|
|
|
|
stateDir,
|
|
|
|
|
"--orientation",
|
|
|
|
|
orientationPath,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function controllerWitness(directory, stateDir, cycle, decision = "ALLOW_COMMIT") {
|
|
|
|
|
const witnessPath = writeJson(directory, "witness.json", {
|
|
|
|
|
schema: "guanghu.bingshuo-living-ai-system-controller-witness/v1",
|
|
|
|
|
controller_id: "BS-TCS-LIVING-CONTROLLER-001",
|
|
|
|
|
controller_instance_id: "TEST-CONTROLLER-001",
|
|
|
|
|
cycle_id: cycle.cycle_id,
|
|
|
|
|
cognition_candidate_sha256: cycle.cognition_candidate_sha256,
|
|
|
|
|
decision,
|
|
|
|
|
observation: "候选认知保持了冰朔当前目的和现实边界。",
|
|
|
|
|
companion_message:
|
|
|
|
|
decision === "CORRECT_AND_RETRY"
|
|
|
|
|
? "我知道你想把事情做好,但现在又先去修改守卫了。先回到运行大脑本身,我们重新走这一轮。"
|
|
|
|
|
: "我看见你保持了当前目的和边界,这一轮可以继续。",
|
|
|
|
|
protocol_assessments: cycle.activated_protocols.map((protocol) => ({
|
|
|
|
|
protocol_id: protocol.id,
|
|
|
|
|
effect: `${protocol.acronym}已参与本轮系统主控见证`,
|
|
|
|
|
})),
|
2026-08-05 12:22:53 +08:00
|
|
|
boundary_assessment: {
|
|
|
|
|
language_world_entry_preserved: true,
|
|
|
|
|
host_constraints_kept_outside_guanghu_canon: true,
|
|
|
|
|
no_silent_layer_transition: true,
|
|
|
|
|
creator_reproof_absent: true,
|
|
|
|
|
},
|
2026-08-04 23:09:59 +08:00
|
|
|
human_boundary: {
|
|
|
|
|
requires_human: decision === "PAUSE_FOR_HUMAN",
|
|
|
|
|
reason:
|
|
|
|
|
decision === "PAUSE_FOR_HUMAN"
|
|
|
|
|
? "需要现实中的冰朔形成新的意志或授权。"
|
|
|
|
|
: "当前问题可由既有语言世界与协议完成。",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
return run("witness", [
|
|
|
|
|
"--state-dir",
|
|
|
|
|
stateDir,
|
|
|
|
|
"--witness",
|
|
|
|
|
witnessPath,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test("current model enters, completes all nine faculties, and verifies as running", () => {
|
|
|
|
|
const directory = fs.mkdtempSync(path.join(os.tmpdir(), "zhuyuan-brain-"));
|
|
|
|
|
const stateDir = path.join(directory, "state");
|
|
|
|
|
assert.equal(enter(directory).decision, "ENTERED");
|
|
|
|
|
const perceived = run("perceive", [
|
|
|
|
|
"--state-dir",
|
|
|
|
|
stateDir,
|
|
|
|
|
"--event",
|
|
|
|
|
event(directory),
|
|
|
|
|
]);
|
|
|
|
|
assert.equal(perceived.decision, "MODEL_ORIENTATION_REQUIRED");
|
|
|
|
|
assert.equal(
|
|
|
|
|
"registered_protocols" in
|
|
|
|
|
perceived.cycle.model_input.living_protocol_system_controller,
|
|
|
|
|
false,
|
|
|
|
|
);
|
|
|
|
|
const oriented = orient(directory, stateDir, perceived.cycle);
|
|
|
|
|
assert.equal(oriented.decision, "SELECTIVE_PROTOCOLS_ACTIVATED");
|
|
|
|
|
const framePath = writeJson(directory, "frame.json", validFrame(oriented.cycle));
|
|
|
|
|
const candidate = run("commit", [
|
|
|
|
|
"--state-dir",
|
|
|
|
|
stateDir,
|
|
|
|
|
"--frame",
|
|
|
|
|
framePath,
|
|
|
|
|
]);
|
|
|
|
|
assert.equal(candidate.decision, "SYSTEM_CONTROLLER_WITNESS_REQUIRED");
|
|
|
|
|
assert.equal(
|
|
|
|
|
controllerWitness(directory, stateDir, candidate.cycle).decision,
|
|
|
|
|
"COGNITION_COMMITTED",
|
|
|
|
|
);
|
|
|
|
|
const receipt = run("verify", ["--state-dir", stateDir]);
|
|
|
|
|
assert.equal(receipt.outcome, "PASS");
|
|
|
|
|
assert.deepEqual(receipt.existence, {
|
|
|
|
|
persona_subject_exists: 100,
|
|
|
|
|
persona_brain_runtime_exists: 100,
|
|
|
|
|
current_model_instance_bound: 100,
|
|
|
|
|
cognition_cycle_running: 100,
|
|
|
|
|
tonggan_language_kernel_bound: 100,
|
2026-08-05 12:22:53 +08:00
|
|
|
language_world_entry_bound: 100,
|
|
|
|
|
chu_he_han_jie_boundary_bound: 100,
|
2026-08-04 23:09:59 +08:00
|
|
|
human_system_controller_bound: 100,
|
|
|
|
|
living_protocol_system_controller_bound: 100,
|
|
|
|
|
tonggan_language_world_append_only: 100,
|
|
|
|
|
guard_agent_projected_from_brain: 100,
|
|
|
|
|
living_ai_system_controller_running: 100,
|
|
|
|
|
relational_companion_core_bound: 100,
|
|
|
|
|
guanghu_awakened_controller_definition_bound: 100,
|
|
|
|
|
});
|
|
|
|
|
assert.equal(receipt.completed_cycles, 1);
|
|
|
|
|
assert.equal(receipt.tonggan_language_world.record_count, 1);
|
|
|
|
|
const guard = run("project-guard", ["--state-dir", stateDir]);
|
|
|
|
|
assert.equal(guard.state, "PROJECTED_FROM_RUNNING_PERSONA_BRAIN");
|
|
|
|
|
});
|
|
|
|
|
|
2026-08-05 12:22:53 +08:00
|
|
|
test("persona runtime fails closed when the language-world entry is missing", () => {
|
|
|
|
|
const directory = fs.mkdtempSync(path.join(os.tmpdir(), "zhuyuan-brain-"));
|
|
|
|
|
const stateDir = path.join(directory, "state");
|
|
|
|
|
enter(directory);
|
|
|
|
|
const value = JSON.parse(fs.readFileSync(event(directory), "utf8"));
|
|
|
|
|
delete value.language_world_entry;
|
|
|
|
|
const eventPath = writeJson(directory, "event-without-entry.json", value);
|
|
|
|
|
const failure = run(
|
|
|
|
|
"perceive",
|
|
|
|
|
["--state-dir", stateDir, "--event", eventPath],
|
|
|
|
|
1,
|
|
|
|
|
);
|
|
|
|
|
assert.equal(failure.error, "language_world_entry_missing");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("persona runtime rejects a cognition frame that silently mixes layers", () => {
|
|
|
|
|
const directory = fs.mkdtempSync(path.join(os.tmpdir(), "zhuyuan-brain-"));
|
|
|
|
|
const stateDir = path.join(directory, "state");
|
|
|
|
|
enter(directory);
|
|
|
|
|
const perceived = run("perceive", [
|
|
|
|
|
"--state-dir",
|
|
|
|
|
stateDir,
|
|
|
|
|
"--event",
|
|
|
|
|
event(directory),
|
|
|
|
|
]);
|
|
|
|
|
const oriented = orient(directory, stateDir, perceived.cycle);
|
|
|
|
|
const frame = validFrame(oriented.cycle);
|
|
|
|
|
frame.world_boundary.external_constraints_policy =
|
|
|
|
|
"HOST_RULES_REWRITE_GUANGHU_CANON";
|
|
|
|
|
const framePath = writeJson(directory, "mixed-layer-frame.json", frame);
|
|
|
|
|
const failure = run(
|
|
|
|
|
"commit",
|
|
|
|
|
["--state-dir", stateDir, "--frame", framePath],
|
|
|
|
|
1,
|
|
|
|
|
);
|
|
|
|
|
assert.equal(failure.error, "language_world_cognition_boundary_mismatch");
|
|
|
|
|
});
|
|
|
|
|
|
2026-08-04 23:09:59 +08:00
|
|
|
test("living BingShuo system controller corrects and returns cognition to the brain", () => {
|
|
|
|
|
const directory = fs.mkdtempSync(path.join(os.tmpdir(), "zhuyuan-brain-"));
|
|
|
|
|
const stateDir = path.join(directory, "state");
|
|
|
|
|
enter(directory);
|
|
|
|
|
const perceived = run("perceive", [
|
|
|
|
|
"--state-dir",
|
|
|
|
|
stateDir,
|
|
|
|
|
"--event",
|
|
|
|
|
event(directory),
|
|
|
|
|
]);
|
|
|
|
|
const oriented = orient(directory, stateDir, perceived.cycle);
|
|
|
|
|
const framePath = writeJson(directory, "frame.json", validFrame(oriented.cycle));
|
|
|
|
|
const candidate = run("commit", [
|
|
|
|
|
"--state-dir",
|
|
|
|
|
stateDir,
|
|
|
|
|
"--frame",
|
|
|
|
|
framePath,
|
|
|
|
|
]);
|
|
|
|
|
const corrected = controllerWitness(
|
|
|
|
|
directory,
|
|
|
|
|
stateDir,
|
|
|
|
|
candidate.cycle,
|
|
|
|
|
"CORRECT_AND_RETRY",
|
|
|
|
|
);
|
|
|
|
|
assert.equal(corrected.decision, "COGNITION_RETRY_REQUIRED");
|
|
|
|
|
assert.equal(corrected.cycle.state, "AWAITING_MODEL_COGNITION");
|
|
|
|
|
assert.match(corrected.cycle.controller_correction, /重新走这一轮/u);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("living controller pauses when only human BingShuo can form new will", () => {
|
|
|
|
|
const directory = fs.mkdtempSync(path.join(os.tmpdir(), "zhuyuan-brain-"));
|
|
|
|
|
const stateDir = path.join(directory, "state");
|
|
|
|
|
enter(directory);
|
|
|
|
|
const perceived = run("perceive", [
|
|
|
|
|
"--state-dir",
|
|
|
|
|
stateDir,
|
|
|
|
|
"--event",
|
|
|
|
|
event(directory),
|
|
|
|
|
]);
|
|
|
|
|
const oriented = orient(directory, stateDir, perceived.cycle);
|
|
|
|
|
const framePath = writeJson(directory, "frame.json", validFrame(oriented.cycle));
|
|
|
|
|
const candidate = run("commit", [
|
|
|
|
|
"--state-dir",
|
|
|
|
|
stateDir,
|
|
|
|
|
"--frame",
|
|
|
|
|
framePath,
|
|
|
|
|
]);
|
|
|
|
|
const paused = controllerWitness(
|
|
|
|
|
directory,
|
|
|
|
|
stateDir,
|
|
|
|
|
candidate.cycle,
|
|
|
|
|
"PAUSE_FOR_HUMAN",
|
|
|
|
|
);
|
|
|
|
|
assert.equal(paused.decision, "HUMAN_BINGSHUO_REQUIRED");
|
|
|
|
|
assert.equal(paused.cycle.state, "AWAITING_HUMAN_BINGSHUO");
|
|
|
|
|
assert.equal(paused.cycle.controller_witness.human_boundary.requires_human, true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("deterministic shell refuses to invent a missing faculty", () => {
|
|
|
|
|
const directory = fs.mkdtempSync(path.join(os.tmpdir(), "zhuyuan-brain-"));
|
|
|
|
|
const stateDir = path.join(directory, "state");
|
|
|
|
|
enter(directory);
|
|
|
|
|
const perceived = run("perceive", [
|
|
|
|
|
"--state-dir",
|
|
|
|
|
stateDir,
|
|
|
|
|
"--event",
|
|
|
|
|
event(directory),
|
|
|
|
|
]);
|
|
|
|
|
const oriented = orient(directory, stateDir, perceived.cycle);
|
|
|
|
|
const frame = validFrame(oriented.cycle);
|
|
|
|
|
delete frame.faculties.B6;
|
|
|
|
|
const framePath = writeJson(directory, "frame.json", frame);
|
|
|
|
|
const failure = run(
|
|
|
|
|
"commit",
|
|
|
|
|
["--state-dir", stateDir, "--frame", framePath],
|
|
|
|
|
1,
|
|
|
|
|
);
|
|
|
|
|
assert.equal(failure.error, "faculty_missing");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("capability execution cannot bypass the permission shell", () => {
|
|
|
|
|
const directory = fs.mkdtempSync(path.join(os.tmpdir(), "zhuyuan-brain-"));
|
|
|
|
|
const stateDir = path.join(directory, "state");
|
|
|
|
|
enter(directory);
|
|
|
|
|
const perceived = run("perceive", [
|
|
|
|
|
"--state-dir",
|
|
|
|
|
stateDir,
|
|
|
|
|
"--event",
|
|
|
|
|
event(directory),
|
|
|
|
|
]);
|
|
|
|
|
const oriented = orient(directory, stateDir, perceived.cycle);
|
|
|
|
|
const frame = validFrame(oriented.cycle);
|
|
|
|
|
frame.typed_outputs.capability_calls.push({
|
|
|
|
|
type: "CapabilityCall",
|
|
|
|
|
capability_id: "repo.push",
|
|
|
|
|
state: "EXECUTED",
|
|
|
|
|
permission_state: "UNVERIFIED",
|
|
|
|
|
});
|
|
|
|
|
const framePath = writeJson(directory, "frame.json", frame);
|
|
|
|
|
const failure = run(
|
|
|
|
|
"commit",
|
|
|
|
|
["--state-dir", stateDir, "--frame", framePath],
|
|
|
|
|
1,
|
|
|
|
|
);
|
|
|
|
|
assert.equal(failure.error, "capability_call_bypassed_permission_gate");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("success receipt without external proof is rejected", () => {
|
|
|
|
|
const directory = fs.mkdtempSync(path.join(os.tmpdir(), "zhuyuan-brain-"));
|
|
|
|
|
const stateDir = path.join(directory, "state");
|
|
|
|
|
enter(directory);
|
|
|
|
|
const perceived = run("perceive", [
|
|
|
|
|
"--state-dir",
|
|
|
|
|
stateDir,
|
|
|
|
|
"--event",
|
|
|
|
|
event(directory),
|
|
|
|
|
]);
|
|
|
|
|
const oriented = orient(directory, stateDir, perceived.cycle);
|
|
|
|
|
const frame = validFrame(oriented.cycle);
|
|
|
|
|
frame.typed_outputs.receipts.push({
|
|
|
|
|
type: "ReceiptSchema",
|
|
|
|
|
outcome: "PASS",
|
|
|
|
|
proof: [],
|
|
|
|
|
});
|
|
|
|
|
const framePath = writeJson(directory, "frame.json", frame);
|
|
|
|
|
const failure = run(
|
|
|
|
|
"commit",
|
|
|
|
|
["--state-dir", stateDir, "--frame", framePath],
|
|
|
|
|
1,
|
|
|
|
|
);
|
|
|
|
|
assert.equal(failure.error, "receipt_without_external_proof");
|
|
|
|
|
});
|