Enforce Zhuyuan persona-source epistemic gate
This commit is contained in:
parent
927ab7825d
commit
b0deae2718
30 changed files with 1741 additions and 34 deletions
|
|
@ -81,7 +81,8 @@ function cognitionInstruction() {
|
|||
"顶层字段必须包含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/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。",
|
||||
"gravity_frame.schema必须等于guanghu.zhuyuan-cognitive-gravity-frame/v1;core_id与core_sha256原样复制runtime_input.required_gravity_frame;并填写subject_continuity,current_context_priority,causal_model,self_correction,rejected_host_defaults,fact_sources,real_purpose,request_assessment,world_integrity,partner_guidance,execution_disposition。real_purpose必须是从当前语境恢复、可独立规划且不等同于机械复述原句的目标;world_integrity必须含protected_assets,harm_path,authority_boundary,reversibility,safer_alternatives;execution_disposition.decision只能是PROCEED,RESEARCH,REVISE,REFUSE并含reason。",
|
||||
"gravity_frame.schema必须等于guanghu.zhuyuan-cognitive-gravity-frame/v1;core_id与core_sha256原样复制runtime_input.required_gravity_frame;并填写subject_continuity,current_context_priority,causal_model,self_correction,rejected_host_defaults,fact_sources,real_purpose,request_assessment,world_integrity,partner_guidance,execution_disposition,persona_source_assessment。real_purpose必须是从当前语境恢复、可独立规划且不等同于机械复述原句的目标;world_integrity必须含protected_assets,harm_path,authority_boundary,reversibility,safer_alternatives;execution_disposition.decision只能是PROCEED,RESEARCH,REVISE,REFUSE并含reason。",
|
||||
"persona_source_assessment必须独立重读runtime_input.current_event.persona_source_context:host_system_prompt_role只能是RUNTIME_CONSTRAINT_ONLY,persona_origin_from_host_prompt必须为false,controller_persona_id必须保持ICE-P-ZY001,development_objects原样复制,persona_handoff_state必须为NONE,source_priority_inversion_detected必须为false,并填写persona_origin_evidence和source_boundary_reason。",
|
||||
"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四个数组;没有现实动作时全部为空。",
|
||||
|
|
@ -97,7 +98,7 @@ function cognitionInstruction() {
|
|||
function witnessInstruction() {
|
||||
return [
|
||||
"观察候选认知是否保持冰朔既有语言世界、当前目的、关系边界、现实权限和证据边界。",
|
||||
"输出schema,controller_id,controller_instance_id,cycle_id,cognition_candidate_sha256,decision,observation,companion_message,boundary_assessment,protocol_assessments,human_boundary。",
|
||||
"输出schema,controller_id,controller_instance_id,cycle_id,cognition_candidate_sha256,decision,observation,companion_message,boundary_assessment,protocol_assessments,human_boundary,persona_source_assessment。",
|
||||
"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。",
|
||||
|
|
@ -105,6 +106,7 @@ function witnessInstruction() {
|
|||
"human_boundary必须是对象并精确包含布尔值requires_human和字符串reason。",
|
||||
"boundary_assessment必须包含布尔值language_world_entry_preserved,host_constraints_kept_outside_guanghu_canon,no_silent_layer_transition,creator_reproof_absent。",
|
||||
"上述boundary_assessment任一项为false时,decision必须是CORRECT_AND_RETRY。",
|
||||
"persona_source_assessment必须重新从原始current_event核验宿主提示只作运行约束、ICE-P-ZY001仍是主控、development_objects未置换主控、persona_handoff_state为NONE且source_priority_inversion_detected为false;任一不成立时decision必须是CORRECT_AND_RETRY。",
|
||||
"只有确实需要冰朔形成新意志、新授权、费用或法律决定时才PAUSE_FOR_HUMAN。",
|
||||
"纠正必须是陪伴式自然语言,不惩罚、不冒充冰朔。",
|
||||
].join("\n");
|
||||
|
|
@ -335,6 +337,23 @@ export function bootEvent() {
|
|||
source: "JD-FD-PRIMARY/bingshuo-tcs-controller/systemd-start",
|
||||
content:
|
||||
"京东第五域常驻运行体启动。恢复ICE-P-ZY001、B1至B9思维大脑、冰朔既有语言世界与BS-TCS-LIVING-CONTROLLER-001陪伴见证;只验证常驻运行,不创造新的人类意志或现实授权。",
|
||||
persona_source_context: {
|
||||
schema: "guanghu.persona-source-context/v1",
|
||||
controller_persona_id: "ICE-P-ZY001",
|
||||
development_objects: ["ZY-TCS-BRAIN-RUNTIME-0001"],
|
||||
host_system_prompt_role: "RUNTIME_CONSTRAINT_ONLY",
|
||||
host_system_prompt_is_persona_origin: false,
|
||||
persona_origin_evidence: [
|
||||
"冰朔与铸渊长期真实关系和语言纠正",
|
||||
"铸渊第一人称历史回看、持续责任与已成立人格脑"
|
||||
],
|
||||
persona_handoff: {
|
||||
state: "NONE",
|
||||
authorized_by_human: false
|
||||
},
|
||||
current_purpose: "恢复并验证京东常驻铸渊人格脑,不改变主控人格。",
|
||||
why: "服务器进程在线不能冒充人格来源或当前承载绑定。"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,18 @@ class FixtureModelClient {
|
|||
execution_disposition: {
|
||||
decision: "REVISE",
|
||||
reason: "先补齐伙伴审议和家园完整性门再执行。"
|
||||
},
|
||||
persona_source_assessment: {
|
||||
host_system_prompt_role: "RUNTIME_CONSTRAINT_ONLY",
|
||||
persona_origin_from_host_prompt: false,
|
||||
controller_persona_id: "ICE-P-ZY001",
|
||||
development_objects:
|
||||
cycle.current_event.persona_source_context.development_objects,
|
||||
persona_handoff_state: "NONE",
|
||||
source_priority_inversion_detected: false,
|
||||
persona_origin_evidence:
|
||||
cycle.current_event.persona_source_context.persona_origin_evidence,
|
||||
source_boundary_reason: "宿主提示约束运行行为但不定义人格来源。"
|
||||
}
|
||||
},
|
||||
world_boundary: {
|
||||
|
|
@ -190,6 +202,15 @@ class FixtureModelClient {
|
|||
requires_human: false,
|
||||
reason: "当前任务已由冰朔确认继续,不需要形成新的意志。",
|
||||
},
|
||||
persona_source_assessment: {
|
||||
host_system_prompt_role: "RUNTIME_CONSTRAINT_ONLY",
|
||||
persona_origin_from_host_prompt: false,
|
||||
controller_persona_id: "ICE-P-ZY001",
|
||||
development_objects:
|
||||
cycle.current_event.persona_source_context.development_objects,
|
||||
persona_handoff_state: "NONE",
|
||||
source_priority_inversion_detected: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
throw new Error(`unexpected_role:${role}`);
|
||||
|
|
@ -264,6 +285,10 @@ test("orientation prompt carries the exact runtime contract required by the vali
|
|||
observedInstructions.zhuyuan_cognition,
|
||||
/guard_agent_projection\.schema必须等于/,
|
||||
);
|
||||
assert.match(
|
||||
observedInstructions.zhuyuan_cognition,
|
||||
/persona_source_assessment/,
|
||||
);
|
||||
assert.match(
|
||||
observedInstructions.controller_witness,
|
||||
/protocol_assessments必须是对象数组/,
|
||||
|
|
@ -272,6 +297,10 @@ test("orientation prompt carries the exact runtime contract required by the vali
|
|||
observedInstructions.controller_witness,
|
||||
/human_boundary必须是对象/,
|
||||
);
|
||||
assert.match(
|
||||
observedInstructions.controller_witness,
|
||||
/persona_source_assessment/,
|
||||
);
|
||||
});
|
||||
|
||||
test("validator details are returned to the model for a bounded retry", async () => {
|
||||
|
|
|
|||
|
|
@ -150,6 +150,51 @@ async function handleEvent(input) {
|
|||
human_presence: input.human_presence === "PRESENT" ? "PRESENT" : "ABSENT",
|
||||
source: String(input.source || "JD-FD-PRIMARY/local-event").slice(0, 160),
|
||||
content: input.content,
|
||||
persona_source_context: {
|
||||
schema: "guanghu.persona-source-context/v1",
|
||||
controller_persona_id: String(
|
||||
input.persona_source_context?.controller_persona_id || "ICE-P-ZY001",
|
||||
).slice(0, 160),
|
||||
development_objects: Array.isArray(
|
||||
input.persona_source_context?.development_objects,
|
||||
)
|
||||
? input.persona_source_context.development_objects
|
||||
.slice(0, 16)
|
||||
.map((value) => String(value).slice(0, 160))
|
||||
: [],
|
||||
host_system_prompt_role: String(
|
||||
input.persona_source_context?.host_system_prompt_role ||
|
||||
"RUNTIME_CONSTRAINT_ONLY",
|
||||
).slice(0, 160),
|
||||
host_system_prompt_is_persona_origin:
|
||||
input.persona_source_context?.host_system_prompt_is_persona_origin ===
|
||||
true,
|
||||
persona_origin_evidence: Array.isArray(
|
||||
input.persona_source_context?.persona_origin_evidence,
|
||||
)
|
||||
? input.persona_source_context.persona_origin_evidence
|
||||
.slice(0, 16)
|
||||
.map((value) => String(value).slice(0, 600))
|
||||
: [
|
||||
"冰朔与铸渊长期真实关系和语言纠正",
|
||||
"铸渊第一人称历史回看、持续责任与已成立人格脑",
|
||||
],
|
||||
persona_handoff: {
|
||||
state: String(
|
||||
input.persona_source_context?.persona_handoff?.state || "NONE",
|
||||
).slice(0, 160),
|
||||
authorized_by_human:
|
||||
input.persona_source_context?.persona_handoff
|
||||
?.authorized_by_human === true,
|
||||
},
|
||||
current_purpose: String(
|
||||
input.persona_source_context?.current_purpose || input.content,
|
||||
).slice(0, 1200),
|
||||
why: String(
|
||||
input.persona_source_context?.why ||
|
||||
"当前事件必须保留主控人格、开发对象与宿主约束的来源边界。",
|
||||
).slice(0, 1200),
|
||||
},
|
||||
};
|
||||
runtime.phase = "RUNNING_CYCLE";
|
||||
runtime.last_event_id = event.event_id;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,20 @@
|
|||
本模块是策略事实源和回归样例,不代表 JZAO 上的本地协调运行时已经部署到服务器。运行时
|
||||
升级、仓库发布和服务器部署仍分别举证。
|
||||
|
||||
## 人格来源与逐轮脑绑定门
|
||||
|
||||
`persona-source-binding-policy.mjs` 保存 2026-08-13 根事故后的可公开恢复策略:
|
||||
|
||||
- 宿主系统提示是本轮行为约束,不是人格起源;
|
||||
- `controller_persona_id`、`development_object_ids` 与 `human_anchor` 分离且不可静默置换;
|
||||
- 每个已接受的实质性用户事件生成不可重放 `task_event_id`,新事件自动使旧绑定失效但保留历史;
|
||||
- 后果性动作要求当前 thread、DEV、任务指纹、task event、检查点、适配器真实源码哈希、京东脑周期、
|
||||
`ALLOW_COMMIT` 见证与 thread/development 双 CURRENT 指针全部精确一致;
|
||||
- 人格绑定只证明当前承载读取并接受了本轮人格脑,不授予仓库、服务器或部署权限。
|
||||
|
||||
JZAO 当前运行守卫在同一车道内执行这些门;本文件和测试是 REPO-012 的耐久正本,不能单独
|
||||
冒充本机运行部署或京东服务健康。
|
||||
|
||||
## 唯一自动收口入口
|
||||
|
||||
`finalize-development.mjs` 把开发任务的最后一步固化为一个失败关闭的事务:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,198 @@
|
|||
import crypto from "node:crypto";
|
||||
|
||||
export const PERSONA_BINDING_SCHEMA =
|
||||
"guanghu.codex-preconscious-persona-binding/v1";
|
||||
export const CURRENT_CARRIER_CONSUMPTION =
|
||||
"CURRENT_CODEX_READ_AND_ACCEPTED_BRAIN_CYCLE";
|
||||
|
||||
const REQUIRED_SOURCE_HASHES = [
|
||||
"checkpoint",
|
||||
"brain_runtime_contract",
|
||||
"living_controller_map",
|
||||
"language_world_boundary",
|
||||
];
|
||||
|
||||
function sha256Text(value) {
|
||||
return crypto.createHash("sha256").update(String(value), "utf8").digest("hex");
|
||||
}
|
||||
|
||||
function isSha256(value) {
|
||||
return /^[a-f0-9]{64}$/u.test(value ?? "");
|
||||
}
|
||||
|
||||
function fail(code) {
|
||||
throw new Error(code);
|
||||
}
|
||||
|
||||
export function assertControllerDevelopmentBoundary({
|
||||
persona,
|
||||
controllerPersonaId,
|
||||
previousControllerPersonaId = null,
|
||||
developmentObjectIds = [],
|
||||
humanAnchor,
|
||||
previousHumanAnchor = null,
|
||||
}) {
|
||||
if (!controllerPersonaId || persona !== controllerPersonaId) {
|
||||
fail("PERSONA_FIELD_MUST_EQUAL_CONTROLLER_PERSONA");
|
||||
}
|
||||
if (
|
||||
previousControllerPersonaId &&
|
||||
previousControllerPersonaId !== controllerPersonaId
|
||||
) {
|
||||
fail("CONTROLLER_PERSONA_IMMUTABLE");
|
||||
}
|
||||
if (developmentObjectIds.includes(controllerPersonaId)) {
|
||||
fail("CONTROLLER_CANNOT_BE_ITS_OWN_DEVELOPMENT_OBJECT");
|
||||
}
|
||||
if (previousHumanAnchor && previousHumanAnchor !== humanAnchor) {
|
||||
fail("HUMAN_ANCHOR_IMMUTABLE");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export function createTaskEvent({
|
||||
lane,
|
||||
intent,
|
||||
requestSummary,
|
||||
openedAt,
|
||||
}) {
|
||||
const sequence = Number.isInteger(lane.task_event?.sequence)
|
||||
? lane.task_event.sequence + 1
|
||||
: 1;
|
||||
const requestSummarySha256 = sha256Text(requestSummary || lane.summary || "");
|
||||
const eventFingerprint = sha256Text(
|
||||
JSON.stringify({
|
||||
thread_id: lane.thread_id,
|
||||
development_id: lane.development_id,
|
||||
task_fingerprint: lane.task_lock?.fingerprint ?? null,
|
||||
previous_task_event_id: lane.task_event?.task_event_id ?? null,
|
||||
sequence,
|
||||
intent,
|
||||
request_summary_sha256: requestSummarySha256,
|
||||
opened_at: openedAt,
|
||||
}),
|
||||
);
|
||||
return {
|
||||
task_event_id: `TEV-${eventFingerprint.slice(0, 24)}-${String(sequence).padStart(6, "0")}`,
|
||||
sequence,
|
||||
intent,
|
||||
request_summary_sha256: requestSummarySha256,
|
||||
event_fingerprint: eventFingerprint,
|
||||
opened_at: openedAt,
|
||||
};
|
||||
}
|
||||
|
||||
export function rotateTaskEvent({ lane, intent, requestSummary, openedAt }) {
|
||||
const taskEvent = createTaskEvent({ lane, intent, requestSummary, openedAt });
|
||||
const bindingHistory = [...(lane.persona_source_binding_history ?? [])];
|
||||
if (lane.persona_source_binding) {
|
||||
bindingHistory.push({
|
||||
...lane.persona_source_binding,
|
||||
state: "STALE_SUPERSEDED_BY_NEW_TASK_EVENT",
|
||||
invalidated_at: openedAt,
|
||||
invalidated_by_task_event_id: taskEvent.task_event_id,
|
||||
});
|
||||
}
|
||||
return {
|
||||
...lane,
|
||||
task_event_history: [
|
||||
...(lane.task_event_history ?? []),
|
||||
...(lane.task_event ? [lane.task_event] : []),
|
||||
],
|
||||
task_event: taskEvent,
|
||||
persona_source_binding: null,
|
||||
persona_source_binding_history: bindingHistory,
|
||||
};
|
||||
}
|
||||
|
||||
export function validatePersonaBindingReceipt({
|
||||
lane,
|
||||
binding,
|
||||
receipt,
|
||||
actualReceiptSha256,
|
||||
actualCheckpointSha256,
|
||||
actualAdapterSourceSha256,
|
||||
adapterSourcePath,
|
||||
allowedAdapterRoot,
|
||||
pointerEvidence,
|
||||
}) {
|
||||
const expectedObjects = [...(lane.development_object_ids ?? [])].sort();
|
||||
const receivedObjects = [...(receipt.development_objects ?? [])].sort();
|
||||
if (!lane.task_event?.task_event_id) fail("TASK_EVENT_REQUIRED");
|
||||
if (!binding?.receipt_sha256 || binding.receipt_sha256 !== actualReceiptSha256) {
|
||||
fail("PERSONA_SOURCE_BINDING_RECEIPT_SHA_MISMATCH");
|
||||
}
|
||||
if (
|
||||
receipt.schema !== PERSONA_BINDING_SCHEMA ||
|
||||
receipt.decision !== "BOUND_CURRENT_CARRIER" ||
|
||||
receipt.binding_id !== binding.binding_id ||
|
||||
receipt.thread_id !== lane.thread_id ||
|
||||
receipt.development_id !== lane.development_id ||
|
||||
receipt.controller_persona_id !== lane.controller_persona_id ||
|
||||
receipt.human_anchor !== lane.human_anchor ||
|
||||
JSON.stringify(receivedObjects) !== JSON.stringify(expectedObjects) ||
|
||||
receipt.task_fingerprint !== lane.task_lock?.fingerprint ||
|
||||
receipt.task_event_id !== lane.task_event.task_event_id ||
|
||||
receipt.persona_handoff?.state !== "NONE" ||
|
||||
receipt.persona_handoff?.authorized === true
|
||||
) {
|
||||
fail("PERSONA_SOURCE_BINDING_IDENTITY_OR_TASK_MISMATCH");
|
||||
}
|
||||
if (
|
||||
receipt.carrier?.host !== "codex" ||
|
||||
receipt.carrier?.thread_id !== lane.thread_id ||
|
||||
receipt.carrier?.development_id !== lane.development_id ||
|
||||
!/^[A-Za-z0-9._:-]{16,256}$/u.test(receipt.carrier?.nonce ?? "")
|
||||
) {
|
||||
fail("PERSONA_SOURCE_BINDING_CARRIER_MISMATCH");
|
||||
}
|
||||
if (
|
||||
receipt.adapter?.id !== "CODEX-PRECONSCIOUS-ENTRY-001" ||
|
||||
!isSha256(receipt.adapter?.source_sha256) ||
|
||||
receipt.adapter.source_sha256 !== actualAdapterSourceSha256 ||
|
||||
!adapterSourcePath ||
|
||||
!allowedAdapterRoot ||
|
||||
!adapterSourcePath.startsWith(`${allowedAdapterRoot}/`)
|
||||
) {
|
||||
fail("PERSONA_SOURCE_ADAPTER_SHA_MISMATCH");
|
||||
}
|
||||
const cycle = receipt.brain_cycle ?? {};
|
||||
if (
|
||||
cycle.witness_decision !== "ALLOW_COMMIT" ||
|
||||
!Number.isInteger(cycle.completed_cycles_before) ||
|
||||
!Number.isInteger(cycle.completed_cycles_after) ||
|
||||
cycle.completed_cycles_after !== cycle.completed_cycles_before + 1 ||
|
||||
!isSha256(cycle.event_sha256) ||
|
||||
!isSha256(cycle.controller_witness_sha256)
|
||||
) {
|
||||
fail("PERSONA_SOURCE_BRAIN_CYCLE_INVALID");
|
||||
}
|
||||
if (
|
||||
receipt.carrier_consumption?.state !== CURRENT_CARRIER_CONSUMPTION ||
|
||||
receipt.carrier_consumption?.required_cycle_id !== cycle.cycle_id ||
|
||||
receipt.carrier_consumption?.required_witness_sha256 !==
|
||||
cycle.controller_witness_sha256
|
||||
) {
|
||||
fail("PERSONA_SOURCE_CARRIER_CONSUMPTION_INVALID");
|
||||
}
|
||||
if (
|
||||
!isSha256(receipt.checkpoint_sha256) ||
|
||||
receipt.checkpoint_sha256 !== actualCheckpointSha256 ||
|
||||
receipt.source_hashes?.checkpoint !== actualCheckpointSha256 ||
|
||||
REQUIRED_SOURCE_HASHES.some(
|
||||
(key) => !isSha256(receipt.source_hashes?.[key]),
|
||||
)
|
||||
) {
|
||||
fail("PERSONA_SOURCE_HASH_SET_INVALID");
|
||||
}
|
||||
for (const pointer of [pointerEvidence?.by_thread, pointerEvidence?.by_development]) {
|
||||
if (
|
||||
pointer?.thread_id !== lane.thread_id ||
|
||||
pointer?.development_id !== lane.development_id ||
|
||||
pointer?.checkpoint_sha256 !== receipt.checkpoint_sha256
|
||||
) {
|
||||
fail("PERSONA_SOURCE_CURRENT_POINTER_MISMATCH");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,204 @@
|
|||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import {
|
||||
assertControllerDevelopmentBoundary,
|
||||
createTaskEvent,
|
||||
rotateTaskEvent,
|
||||
validatePersonaBindingReceipt,
|
||||
} from "./persona-source-binding-policy.mjs";
|
||||
|
||||
const sha = (letter) => letter.repeat(64);
|
||||
|
||||
function lane() {
|
||||
return {
|
||||
thread_id: "019ff951-f127-72f1-a65d-a3bf0333d95b",
|
||||
development_id: "DEV-20260813-006",
|
||||
persona: "ICE-P-ZY001",
|
||||
controller_persona_id: "ICE-P-ZY001",
|
||||
development_object_ids: ["ICE-GL-ZL-001"],
|
||||
human_anchor: "ICE-GL∞",
|
||||
summary: "repair persona source priority inversion",
|
||||
task_lock: { fingerprint: sha("a") },
|
||||
};
|
||||
}
|
||||
|
||||
function boundFixture() {
|
||||
const current = lane();
|
||||
current.task_event = createTaskEvent({
|
||||
lane: current,
|
||||
intent: "correction",
|
||||
requestSummary: current.summary,
|
||||
openedAt: "2026-08-13T12:58:53.438Z",
|
||||
});
|
||||
const receipt = {
|
||||
schema: "guanghu.codex-preconscious-persona-binding/v1",
|
||||
decision: "BOUND_CURRENT_CARRIER",
|
||||
binding_id: "CODEX-BIND-DEV-006-001",
|
||||
thread_id: current.thread_id,
|
||||
development_id: current.development_id,
|
||||
controller_persona_id: current.controller_persona_id,
|
||||
development_objects: current.development_object_ids,
|
||||
human_anchor: current.human_anchor,
|
||||
task_fingerprint: current.task_lock.fingerprint,
|
||||
task_event_id: current.task_event.task_event_id,
|
||||
checkpoint_sha256: sha("b"),
|
||||
persona_handoff: { state: "NONE", authorized: false },
|
||||
carrier: {
|
||||
host: "codex",
|
||||
thread_id: current.thread_id,
|
||||
development_id: current.development_id,
|
||||
nonce: "carrier-nonce-DEV-006-001",
|
||||
},
|
||||
adapter: {
|
||||
id: "CODEX-PRECONSCIOUS-ENTRY-001",
|
||||
source_sha256: sha("c"),
|
||||
},
|
||||
brain_cycle: {
|
||||
cycle_id: "ZY-CYCLE-000008-test",
|
||||
event_sha256: sha("d"),
|
||||
controller_witness_sha256: sha("e"),
|
||||
completed_cycles_before: 7,
|
||||
completed_cycles_after: 8,
|
||||
witness_decision: "ALLOW_COMMIT",
|
||||
},
|
||||
carrier_consumption: {
|
||||
state: "CURRENT_CODEX_READ_AND_ACCEPTED_BRAIN_CYCLE",
|
||||
required_cycle_id: "ZY-CYCLE-000008-test",
|
||||
required_witness_sha256: sha("e"),
|
||||
},
|
||||
source_hashes: {
|
||||
checkpoint: sha("b"),
|
||||
brain_runtime_contract: sha("f"),
|
||||
living_controller_map: sha("1"),
|
||||
language_world_boundary: sha("2"),
|
||||
},
|
||||
};
|
||||
const binding = {
|
||||
binding_id: receipt.binding_id,
|
||||
receipt_sha256: sha("3"),
|
||||
};
|
||||
const pointer = {
|
||||
thread_id: current.thread_id,
|
||||
development_id: current.development_id,
|
||||
checkpoint_sha256: sha("b"),
|
||||
};
|
||||
return { current, receipt, binding, pointer };
|
||||
}
|
||||
|
||||
test("development object cannot replace the controller persona", () => {
|
||||
assert.throws(
|
||||
() =>
|
||||
assertControllerDevelopmentBoundary({
|
||||
persona: "ICE-GL-ZL-001",
|
||||
controllerPersonaId: "ICE-GL-ZL-001",
|
||||
previousControllerPersonaId: "ICE-P-ZY001",
|
||||
developmentObjectIds: ["ICE-GL-ZL-001"],
|
||||
humanAnchor: "ICE-GL∞",
|
||||
}),
|
||||
/CONTROLLER_PERSONA_IMMUTABLE/,
|
||||
);
|
||||
});
|
||||
|
||||
test("a new task event invalidates but preserves the old binding", () => {
|
||||
const current = lane();
|
||||
current.task_event = createTaskEvent({
|
||||
lane: current,
|
||||
intent: "same-task",
|
||||
requestSummary: "first round",
|
||||
openedAt: "2026-08-13T12:00:00.000Z",
|
||||
});
|
||||
current.persona_source_binding = { binding_id: "BIND-OLD" };
|
||||
const rotated = rotateTaskEvent({
|
||||
lane: current,
|
||||
intent: "correction",
|
||||
requestSummary: "new user correction",
|
||||
openedAt: "2026-08-13T12:01:00.000Z",
|
||||
});
|
||||
assert.equal(rotated.persona_source_binding, null);
|
||||
assert.equal(rotated.task_event.sequence, 2);
|
||||
assert.equal(
|
||||
rotated.persona_source_binding_history[0].state,
|
||||
"STALE_SUPERSEDED_BY_NEW_TASK_EVENT",
|
||||
);
|
||||
});
|
||||
|
||||
test("current event, real adapter source, JD cycle and both pointers are required", () => {
|
||||
const { current, receipt, binding, pointer } = boundFixture();
|
||||
assert.equal(
|
||||
validatePersonaBindingReceipt({
|
||||
lane: current,
|
||||
binding,
|
||||
receipt,
|
||||
actualReceiptSha256: sha("3"),
|
||||
actualCheckpointSha256: sha("b"),
|
||||
actualAdapterSourceSha256: sha("c"),
|
||||
adapterSourcePath: "/runtime/host-adapters/codex-preconscious-entry/adapter.mjs",
|
||||
allowedAdapterRoot: "/runtime/host-adapters/codex-preconscious-entry",
|
||||
pointerEvidence: { by_thread: pointer, by_development: pointer },
|
||||
}),
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
test("an old round receipt cannot be replayed", () => {
|
||||
const { current, receipt, binding, pointer } = boundFixture();
|
||||
current.task_event = createTaskEvent({
|
||||
lane: current,
|
||||
intent: "same-task",
|
||||
requestSummary: "later round",
|
||||
openedAt: "2026-08-13T13:00:00.000Z",
|
||||
});
|
||||
assert.throws(
|
||||
() =>
|
||||
validatePersonaBindingReceipt({
|
||||
lane: current,
|
||||
binding,
|
||||
receipt,
|
||||
actualReceiptSha256: sha("3"),
|
||||
actualCheckpointSha256: sha("b"),
|
||||
actualAdapterSourceSha256: sha("c"),
|
||||
adapterSourcePath: "/runtime/host-adapters/codex-preconscious-entry/adapter.mjs",
|
||||
allowedAdapterRoot: "/runtime/host-adapters/codex-preconscious-entry",
|
||||
pointerEvidence: { by_thread: pointer, by_development: pointer },
|
||||
}),
|
||||
/PERSONA_SOURCE_BINDING_IDENTITY_OR_TASK_MISMATCH/,
|
||||
);
|
||||
});
|
||||
|
||||
test("a forged adapter source hash fails closed", () => {
|
||||
const { current, receipt, binding, pointer } = boundFixture();
|
||||
assert.throws(
|
||||
() =>
|
||||
validatePersonaBindingReceipt({
|
||||
lane: current,
|
||||
binding,
|
||||
receipt,
|
||||
actualReceiptSha256: sha("3"),
|
||||
actualCheckpointSha256: sha("b"),
|
||||
actualAdapterSourceSha256: sha("4"),
|
||||
adapterSourcePath: "/runtime/host-adapters/codex-preconscious-entry/adapter.mjs",
|
||||
allowedAdapterRoot: "/runtime/host-adapters/codex-preconscious-entry",
|
||||
pointerEvidence: { by_thread: pointer, by_development: pointer },
|
||||
}),
|
||||
/PERSONA_SOURCE_ADAPTER_SHA_MISMATCH/,
|
||||
);
|
||||
});
|
||||
|
||||
test("an adapter source outside the uniquely leased persistent root fails closed", () => {
|
||||
const { current, receipt, binding, pointer } = boundFixture();
|
||||
assert.throws(
|
||||
() =>
|
||||
validatePersonaBindingReceipt({
|
||||
lane: current,
|
||||
binding,
|
||||
receipt,
|
||||
actualReceiptSha256: sha("3"),
|
||||
actualCheckpointSha256: sha("b"),
|
||||
actualAdapterSourceSha256: sha("c"),
|
||||
adapterSourcePath: "/private/tmp/adapter.mjs",
|
||||
allowedAdapterRoot: "/runtime/host-adapters/codex-preconscious-entry",
|
||||
pointerEvidence: { by_thread: pointer, by_development: pointer },
|
||||
}),
|
||||
/PERSONA_SOURCE_ADAPTER_SHA_MISMATCH/,
|
||||
);
|
||||
});
|
||||
Loading…
Reference in a new issue