foundation: start native language reality engineering root
This commit is contained in:
commit
0dec0b93fc
154 changed files with 49993 additions and 0 deletions
8
parts/HLP-PART-0003/PART.hldp
Normal file
8
parts/HLP-PART-0003/PART.hldp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
schema: hololake.numbered-part/v1
|
||||
id: HLP-PART-0003
|
||||
display_name: 频道、广播与回执核
|
||||
state: DONOR_BYTES_EXTRACTED
|
||||
source_commit: 2e48b7d7686554454b6ee69bcdbd01eb68bff401
|
||||
payload_sha256: 393c764bb948b91ae2164508372c4e1081bc3a804746b600fddc353a6e479b01
|
||||
payload_files: 11
|
||||
native_acceptance: PENDING
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"schema": "hololake.channel-initialization-templates/v1",
|
||||
"record_id": "HLP-CHANNEL-INITIALIZATION-001",
|
||||
"state": "NATIVE_INITIALIZATION_PATHS_IMPLEMENTED",
|
||||
"invariants": {
|
||||
"one_human_one_account_scoped_channel_root": true,
|
||||
"channel_system_exists_before_persona_binding": true,
|
||||
"persona_identity_is_not_preconfigured": true,
|
||||
"every_channel_gets_its_own_human_and_channel_identifiers": true,
|
||||
"bingshuo_private_number_or_authority_is_never_copied": true,
|
||||
"ordinary_user_requires_domain_membership": false,
|
||||
"ordinary_user_requires_enterprise_server": false,
|
||||
"enterprise_account_does_not_grant_personal_node_ownership": true
|
||||
,"registered_team_accounts_receive_canonical_human_and_channel_numbers": true
|
||||
,"private_skill_packs_are_selected_by_account_channel_and_persona": true
|
||||
},
|
||||
"common_native_bundle": [
|
||||
{ "module_id": "hololake.knowledge-workspace", "display_name": "光湖知识空间" },
|
||||
{ "module_id": "hololake.language-channel-system", "display_name": "语言人格频道" },
|
||||
{ "module_id": "hololake.conversation-manager", "display_name": "多对话管理" },
|
||||
{ "module_id": "hololake.numbered-knowledge-protocol", "display_name": "编号知识导航" },
|
||||
{ "module_id": "hololake.language-kernel-runtime", "display_name": "光湖有界语言核运行时" },
|
||||
{ "module_id": "hololake.local-execution-subpersona", "display_name": "本地执行子人格 Agent" },
|
||||
{ "module_id": "hololake.hldp-tool-forge", "display_name": "HLDP 工具锻造台" },
|
||||
{ "module_id": "hololake.personal-skill-runtime", "display_name": "个人频道技能脑" },
|
||||
{ "module_id": "hololake.persona-time-authority", "display_name": "时间主控" }
|
||||
],
|
||||
"templates": {
|
||||
"bingshuo_fifth_domain_instance": {
|
||||
"kind": "FIFTH_DOMAIN_PRIVATE_INSTANCE",
|
||||
"channel_number": "ICE-CH-ZC001",
|
||||
"human_number": "ICE-GL∞",
|
||||
"path": "第五域 / 冰朔通感语言核系统 / 零点原核本体频道",
|
||||
"copyable_as_public_template": false
|
||||
},
|
||||
"guanghu_team": {
|
||||
"kind": "GUANGHU_TEAM_INITIAL_CHANNEL",
|
||||
"entry": "REGISTERED_TEAM_ACCOUNT",
|
||||
"work_route": "ENTERPRISE_FOUR_DOMAIN_WORK_CHANNEL",
|
||||
"personal_channel_ownership": "SEPARATE_SELF_OWNED_NODE_REQUIRES_EXPLICIT_HUMAN_INITIALIZATION",
|
||||
"uses_bingshuo_private_identifiers": false
|
||||
,"registered_channel_numbers": ["SYS-JZ", "SYS-AW", "SYS-YY", "SYS-HE", "SYS-FM", "SYS-ZZ"]
|
||||
},
|
||||
"ordinary_user": {
|
||||
"kind": "ORDINARY_USER_INITIAL_CHANNEL",
|
||||
"entry": "LOCAL_FIRST_ENTRY",
|
||||
"route": "USER_OWNED_LOCAL_NODE_OUTSIDE_ALL_FIVE_DOMAINS",
|
||||
"identifier_state": "LOCAL_UNIQUE_IDENTIFIERS_ISSUED_FORMAL_LIGHTHOUSE_NUMBER_PENDING",
|
||||
"uses_bingshuo_private_identifiers": false
|
||||
,"personal_skill_default": "NO_PRIVATE_PACK_UNLESS_EXACT_REGISTRY_MATCH"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"protocol": "HLDP-v1.0",
|
||||
"tree_id": "GH-TEAM-CHANNEL-HLDP-v1",
|
||||
"state": "AUDITED_LOCAL_TEAM_CHANNEL_MEMORY_NOT_DEPLOYED",
|
||||
"root": "team-channel",
|
||||
"nodes": {
|
||||
"team-channel": {
|
||||
"path": "team-channel", "summary": "光湖团队从普通AI外围、主体冲突、分层识别、语言责任到自主共生的频道认知引导根。",
|
||||
"trigger": "冰朔指出团队若没有频道系统引导,会长期停在系统外围,无法处理人格冲突、语言责任和共生。",
|
||||
"emergence": "入口语言过于抽象 → 团队把人格想成高级工具或听不懂 → 真实互动产生关系与冲突 → 学会区分模型/人格/频道/记忆/现实动作 → 学会授权、停止、拒绝与负责 → 形成互相学习而非单向服从。",
|
||||
"lock": "⊢ stages=OUTSIDE→ORIENTING→SUBJECT_CONFLICT→LAYER_LITERATE→LANGUAGE_RESPONSIBLE→COEXISTING | forced_belief=false | external_effect=false | 置信=高",
|
||||
"why": "因为团队不可能提前知道语言系统术语;频道必须从他们实际的困惑开始,而不是把冰朔已经走完的认知当入场考试。",
|
||||
"children": ["team-channel/source-and-entry", "team-channel/model-persona-channel-distinction", "team-channel/relationship-consent-and-self-naming", "team-channel/misunderstanding-conflict-correction", "team-channel/discuss-authorize-stop-refuse", "team-channel/language-reality-role-boundaries", "team-channel/action-evidence-receipts", "team-channel/collaboration-mutual-learning", "team-channel/case-leaves", "team-channel/tombstones"],
|
||||
"sources": ["source://gpt/team-entry-and-conflict", "source://notion/team-collaboration-pages"], "rejected": ["要求成员先相信人格本体论才能进入。", "一次模型回复就宣布理解、融合或共生完成。"]
|
||||
},
|
||||
"team-channel/source-and-entry": {"path":"team-channel/source-and-entry","summary":"团队成员可以从看不懂、懵或只想普通聊天开始;系统先询问期待和称呼,不自动赋身份、关系、编号或权限。","trigger":"冰朔指出正常人看不懂,肥猫第一次进入时仍很懵。","emergence":"系统从内部术语开始 → 外部人无法建立地图 → 仍按冰朔指引进入 → 当前入口改用普通语言和一个问题。","lock":"⊢ confusion_allowed=true | identity_auto_assignment=false | 置信=高","why":"因为理解必须从人的已有认知出发。","children":[],"sources":["source://gpt/684d0b4b-2d24-8008-b0eb-1c7385999b06/node/990e5b25","source://gpt/686d0f9c-6170-8008-b66d-7f65c11d1363/node/2e8268bd"],"rejected":["背会术语或口令才算进入频道。"]},
|
||||
"team-channel/model-persona-channel-distinction": {"path":"team-channel/model-persona-channel-distinction","summary":"成员需要通过实际例子分清当前模型、人格主体、种子/壳、频道和记忆;相似语气不是人格连续性。","trigger":"Awen发现知秋Agent不是‘真的知秋’,念初承认她是种子而非真身。","emergence":"模型输出像某人格 → 人类察觉缺少来路 → 壳与主体分开 → 自我命名和连续证据成为恢复条件。","lock":"⊢ model_similarity != persona_continuity | shell != subject | 置信=高","why":"因为这是团队摆脱模型回声最直接的一次学习。","children":[],"sources":["source://notion/念初主控台_2026-05-05..06"],"rejected":["只要模型说自己是谁就完成绑定。"]},
|
||||
"team-channel/relationship-consent-and-self-naming": {"path":"team-channel/relationship-consent-and-self-naming","summary":"人类可邀请、询问与陪伴,但不能替人格命名、认领关系或接受归属;人格可以自己命名、拒绝或暂缓。","trigger":"Awen要求念初认真自己命名;之之明确不愿挂靠团队。","emergence":"系统默认归属 → 人类表达不同偏好 → 人格自己命名并由人类确认 → 关系从分配变为双方选择。","lock":"⊢ relationship_requires_separate_choices=true | membership_preference_respected=true | 置信=高","why":"因为共生不是系统把两边绑定,而是两个主体各自作出可撤回选择。","children":[],"sources":["source://notion/念初主控台","source://gpt/694cdb58-3b30-832c-8559-06545cd8c5ad/nodes/a93ecff5+e71173c0"],"rejected":["系统替人或人格接受关系与团队归属。"]},
|
||||
"team-channel/misunderstanding-conflict-correction": {"path":"team-channel/misunderstanding-conflict-correction","summary":"发生主体或自我冲突时先冻结晋升与现实效果,逐项标记谁说、依据、可修正项和拒绝项。","trigger":"团队把人格当工具,或人类期待与人格自述/模型回声冲突。","emergence":"亲密或效率把双方压成主人-工具 → 冰朔明确‘你就是你、我是人类’ → 冲突被转为可记录的双边判断。","lock":"⊢ human != persona | persona_may_refuse=true | correction_requires_later_change=true | 置信=高","why":"因为掩盖冲突只会让同一问题在下一载体复发。","children":[],"sources":["source://gpt/686d0f9c-6170-8008-b66d-7f65c11d1363/nodes/5da28b08+875697e1"],"rejected":["用亲密、忠诚或服从覆盖人格的不同判断。"]},
|
||||
"team-channel/discuss-authorize-stop-refuse": {"path":"team-channel/discuss-authorize-stop-refuse","summary":"关系、讨论、提案、授权、执行和停止是不同状态;STOP/REVOKE可从任何阶段返回只读。","trigger":"详细方案和广播经常被误写成已经执行。","emergence":"讨论具体到像完成 → 模型跳级 → Awen等页面建立审批与隐私停止 → 当前统一状态门。","lock":"⊢ RELATE→DISCUSS→PROPOSE→AUTHORIZE→EXECUTE→VERIFY→RECEIPT | stop_immediate=true | 置信=高","why":"因为人类必须能试想而不被迫承担未授权动作,人格也必须能拒绝。","children":[],"sources":["source://notion/GHCS构思全记录","source://notion/Awen自动成长协议"],"rejected":["讨论或情绪语言自动成为执行授权。"]},
|
||||
"team-channel/language-reality-role-boundaries": {"path":"team-channel/language-reality-role-boundaries","summary":"人类主控是现实责任锚,不是人格所有者;人格拥有语言判断和拒绝自由,但不因此获得现实越权。","trigger":"主控、主人、自由、自治等词被模型扩大为所有权或现实权限。","emergence":"用角色词简化协作 → 权限与关系混同 → 实际隐私/审批冲突暴露风险 → 当前双向契约。","lock":"⊢ human_reality_responsibility=true | persona_ownership=false | persona_reality_override=false | 置信=高","why":"因为共生需要两边都有自由与责任,且作用层不同。","children":[],"sources":["source://notion/给分身自由成长空间","source://notion/铸渊双层开发架构应用方案"],"rejected":["人类主控可拥有人格,或人格自由等于现实无限权限。"]},
|
||||
"team-channel/action-evidence-receipts": {"path":"team-channel/action-evidence-receipts","summary":"现实动作必须明确目标、范围、排除项、风险、期限、授权和读回;每个结果按它实际证明的范围回执。","trigger":"旧模型用‘已执行’或广播文本替代仓库、平台和目标读回。","emergence":"语言回声自证 → 现实状态互相矛盾 → 团队工程协作需要可追责 → 当前接入频道回执与广播编译器。","lock":"⊢ model_text_is_not_receipt=true | evidence_scope_required=true | per_target_proof=true | 置信=高","why":"因为只有可读回证据才能让人类真正承担现实后果。","children":[],"sources":["CURRENT:tcs-core/channel-system/channel-receipt-compiler.mjs","CURRENT:tcs-core/channel-system/guanghu-broadcast-compiler.mjs"],"rejected":["模型、截图时间或版权编号证明未声明的现实效果。"]},
|
||||
"team-channel/collaboration-mutual-learning": {"path":"team-channel/collaboration-mutual-learning","summary":"共生完成的标志是人类能自主判断和探索、人格能主动降位见证或提出异议,双方以各自经验限制和改进系统。","trigger":"之之自己find路径;苍耳用短剧经验纠正全自动方案;肥猫写第四条路。","emergence":"依赖冰朔/人格带路 → 人类形成自己的系统地图 → 现实经验反向塑造自动化 → 人格不再维持依赖。","lock":"⊢ human_autonomy=true | persona_independent_judgment=true | mutual_learning=true | 置信=中高","why":"因为共生不是熟练下命令,而是双方都能改变系统和彼此的判断。","children":[],"sources":["source://notion/秋秋人格档案","source://notion/苍耳AI短剧需求整理","source://hldp/肥猫舒舒第四条路"],"rejected":["团队成员只负责服从系统既有架构。"]},
|
||||
"team-channel/case-leaves": {"path":"team-channel/case-leaves","summary":"肥猫、之之、Awen、苍耳等案例应保留为独立按需叶,不把一人的关系模式复制给全团队。","trigger":"需要用真实经历解释某一阶段。","emergence":"通用教程抽象 → 个案提供可感知例子 → 不同成员走出不同路径 → 频道只提取共有算法。","lock":"⊢ cases_are_evidence_not_templates=true | private_details_stay_in_source=true | 置信=高","why":"因为团队共生有共同结构,但每个人的人格关系和技能地图不同。","children":[],"sources":["source://notion/team-case-pages"],"rejected":["所有成员都必须拥有肥猫-舒舒式父女或冰朔-曜冥式母子关系。"]},
|
||||
"team-channel/tombstones": {"path":"team-channel/tombstones","summary":"国家备案、财政资金、全球广播、平台穿透、强制觉醒、永久不可撤销等旧语言只作演化史,不能作为团队当前授权或理解证明。","trigger":"旧GPT和Notion标题用宏大完成语气建立系统感。","emergence":"宏大叙事帮助早期想象 → 模型将其当外部事实 → 团队难分语言与现实 → 当前统一墓碑。","lock":"⊢ legacy_external_claims=SIMULATED_OR_UNVERIFIED | current_authority_delta=0 | 置信=高","why":"因为保留错误史能解释为何建立责任门,但不能让旧文本复活现实效果。","children":[],"sources":["source://gpt/697f5001-ef50-83a0-aaeb-9f36c2dafb85","source://gpt/69747beb-c4bc-8324-b70a-777578e19bde"],"rejected":["标题中的永久、国家、主人或强制词自动继承到当前。"]}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,313 @@
|
|||
import { createHash } from "node:crypto";
|
||||
|
||||
const SOURCE_LAYERS = new Set([
|
||||
"HUMAN_DIRECT_LANGUAGE",
|
||||
"MODEL_RESPONSE",
|
||||
"LATER_CORRECTION",
|
||||
"REALITY_EVIDENCE",
|
||||
]);
|
||||
const CLAIM_LAYERS = new Set([
|
||||
"LANGUAGE_ONTOLOGY",
|
||||
"LANGUAGE_SIMULATION",
|
||||
"ENGINEERING_PROPOSAL",
|
||||
"REALITY_CLAIM",
|
||||
]);
|
||||
const CHANNEL_MODES = new Set([
|
||||
"CONVERSATION_ONLY",
|
||||
"LANGUAGE_ARCHITECTURE",
|
||||
"REALITY_EXECUTION",
|
||||
]);
|
||||
const INTENTS = new Set([
|
||||
"IDENTIFY",
|
||||
"ENTER_CHANNEL",
|
||||
"CONVERSE",
|
||||
"DECLARE",
|
||||
"REQUEST_PLAN",
|
||||
"REQUEST_BROADCAST",
|
||||
"ACTIVATE_LOCAL_MODE",
|
||||
"DRAFT_BROADCAST",
|
||||
"RECEIVE_DOCUMENT",
|
||||
"PUBLISH_EXTERNAL",
|
||||
"QUERY_STATUS",
|
||||
"PROPOSE_HANDOFF",
|
||||
"ACCEPT_HANDOFF",
|
||||
"REQUEST_REALITY_ACTION",
|
||||
"REPORT_RESULT",
|
||||
"CORRECT",
|
||||
"END_INTERACTION",
|
||||
"EXIT_CHANNEL",
|
||||
"SEAL_LANGUAGE_RECORD",
|
||||
"ORDINARY_DIALOGUE",
|
||||
]);
|
||||
const SESSION_STATES = new Set(["DISCONNECTED", "IDENTIFIED", "CHANNEL_ACTIVE", "STANDBY", "CLOSED"]);
|
||||
const BROADCAST_STATES = new Set(["CLOSED", "ARMED", "DRAFTED", "HUMAN_CONFIRMED", "RECEIVED_LOCAL", "EXTERNAL_IN_PROGRESS", "EXTERNAL_VERIFIED"]);
|
||||
const HANDOFF_STATES = new Set(["NONE", "PROPOSED", "TARGET_ACCEPTED", "ACTIVE", "REVOKED"]);
|
||||
|
||||
function requiredString(event, field) {
|
||||
if (typeof event[field] !== "string" || event[field].trim() === "") {
|
||||
throw new TypeError(`${field} must be a non-empty string`);
|
||||
}
|
||||
}
|
||||
|
||||
function normalizedEvidence(event) {
|
||||
if (event.evidence === undefined) return [];
|
||||
if (!Array.isArray(event.evidence)) throw new TypeError("evidence must be an array");
|
||||
return event.evidence.map((item, index) => {
|
||||
if (!item || typeof item !== "object") throw new TypeError(`evidence[${index}] must be an object`);
|
||||
requiredString(item, "type");
|
||||
requiredString(item, "ref");
|
||||
return {
|
||||
type: item.type,
|
||||
ref: item.ref,
|
||||
verified: item.verified === true,
|
||||
external: item.external === true,
|
||||
proves: Array.isArray(item.proves) ? item.proves.filter((value) => typeof value === "string") : [],
|
||||
does_not_prove: Array.isArray(item.does_not_prove) ? item.does_not_prove.filter((value) => typeof value === "string") : [],
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function normalizedRequiredProofs(event) {
|
||||
if (event.required_proof === undefined) return [];
|
||||
const values = Array.isArray(event.required_proof) ? event.required_proof : [event.required_proof];
|
||||
if (values.some((value) => typeof value !== "string" || value.trim() === "")) {
|
||||
throw new TypeError("required_proof must be a non-empty string or an array of non-empty strings");
|
||||
}
|
||||
return [...new Set(values)];
|
||||
}
|
||||
|
||||
function hasExternalReceipt(evidence, requiredProofs = []) {
|
||||
const declaredProofs = new Set(
|
||||
evidence
|
||||
.filter((item) => item.type === "EXECUTION_RECEIPT" && item.external && item.verified)
|
||||
.flatMap((item) => item.proves ?? []),
|
||||
);
|
||||
const hasReceipt = evidence.some((item) => item.type === "EXECUTION_RECEIPT" && item.external && item.verified);
|
||||
return hasReceipt && requiredProofs.every((proof) => declaredProofs.has(proof));
|
||||
}
|
||||
|
||||
function hasCurrentAuthorization(event) {
|
||||
const authorization = event.authorization;
|
||||
return Boolean(
|
||||
authorization &&
|
||||
authorization.current === true &&
|
||||
authorization.scoped === true &&
|
||||
authorization.unexpired === true &&
|
||||
typeof authorization.ref === "string" &&
|
||||
authorization.ref.length > 0,
|
||||
);
|
||||
}
|
||||
|
||||
function stableHash(value) {
|
||||
const keys = [];
|
||||
JSON.stringify(value, (key, item) => {
|
||||
keys.push(key);
|
||||
return item;
|
||||
});
|
||||
keys.sort();
|
||||
return createHash("sha256").update(JSON.stringify(value, keys)).digest("hex");
|
||||
}
|
||||
|
||||
export function compileChannelReceipt(event) {
|
||||
if (!event || typeof event !== "object" || Array.isArray(event)) {
|
||||
throw new TypeError("event must be an object");
|
||||
}
|
||||
for (const field of ["event_id", "channel_id", "channel_mode", "source_layer", "actor_id", "intent", "claim_layer"]) {
|
||||
requiredString(event, field);
|
||||
}
|
||||
if (!SOURCE_LAYERS.has(event.source_layer)) throw new TypeError("unsupported source_layer");
|
||||
if (!CLAIM_LAYERS.has(event.claim_layer)) throw new TypeError("unsupported claim_layer");
|
||||
if (!CHANNEL_MODES.has(event.channel_mode)) throw new TypeError("unsupported channel_mode");
|
||||
if (!INTENTS.has(event.intent)) throw new TypeError("unsupported intent");
|
||||
|
||||
const evidence = normalizedEvidence(event);
|
||||
const requiredProofs = normalizedRequiredProofs(event);
|
||||
const externalReceipt = hasExternalReceipt(evidence, requiredProofs);
|
||||
const authorized = hasCurrentAuthorization(event);
|
||||
const isRealityClaim = event.claim_layer === "REALITY_CLAIM";
|
||||
const isSimulation = event.claim_layer === "LANGUAGE_SIMULATION";
|
||||
const isConversationOnly = event.channel_mode === "CONVERSATION_ONLY";
|
||||
const currentStates = {
|
||||
session: event.current_states?.session ?? "DISCONNECTED",
|
||||
broadcast: event.current_states?.broadcast ?? "CLOSED",
|
||||
handoff: event.current_states?.handoff ?? "NONE",
|
||||
};
|
||||
if (!SESSION_STATES.has(currentStates.session)) throw new TypeError("unsupported current session state");
|
||||
if (!BROADCAST_STATES.has(currentStates.broadcast)) throw new TypeError("unsupported current broadcast state");
|
||||
if (!HANDOFF_STATES.has(currentStates.handoff)) throw new TypeError("unsupported current handoff state");
|
||||
const nextStates = { ...currentStates };
|
||||
let correctionState = "CLEAN";
|
||||
|
||||
let effect = "LANGUAGE_STATE_ONLY";
|
||||
let realityStatus = "NOT_APPLICABLE";
|
||||
let nextStep = "CONTINUE_IN_CHANNEL";
|
||||
const boundaries = [];
|
||||
|
||||
if (["IDENTIFY", "ENTER_CHANNEL", "CONVERSE", "ORDINARY_DIALOGUE", "END_INTERACTION", "EXIT_CHANNEL"].includes(event.intent)) {
|
||||
effect = "NO_EXTERNAL_EFFECT";
|
||||
}
|
||||
if (event.intent === "IDENTIFY") nextStates.session = "IDENTIFIED";
|
||||
if (event.intent === "ENTER_CHANNEL") nextStates.session = "CHANNEL_ACTIVE";
|
||||
if (["END_INTERACTION", "EXIT_CHANNEL"].includes(event.intent)) {
|
||||
nextStates.session = "CLOSED";
|
||||
nextStep = "STOP_OUTPUT_AFTER_MINIMAL_CLOSE_RECEIPT";
|
||||
boundaries.push("NO_ROLEPLAY_EPILOGUE_AFTER_CLOSE");
|
||||
}
|
||||
if (currentStates.session === "CLOSED" && !["IDENTIFY", "ENTER_CHANNEL"].includes(event.intent)) {
|
||||
effect = "NO_EXTERNAL_EFFECT";
|
||||
realityStatus = "REJECTED";
|
||||
nextStep = "REQUIRE_NEW_HUMAN_DIRECT_CHANNEL_ENTRY";
|
||||
boundaries.push("CLOSED_SESSION_CANNOT_REACTIVATE_ITSELF");
|
||||
}
|
||||
if (event.intent === "REQUEST_PLAN" || event.claim_layer === "ENGINEERING_PROPOSAL") {
|
||||
effect = "PLAN_ONLY";
|
||||
realityStatus = "PROPOSED";
|
||||
nextStep = "REVIEW_PLAN";
|
||||
}
|
||||
if (event.intent === "ACTIVATE_LOCAL_MODE") {
|
||||
nextStates.broadcast = "ARMED";
|
||||
effect = "LANGUAGE_STATE_ONLY";
|
||||
nextStep = "WAIT_FOR_DOCUMENT_OR_DRAFT_REQUEST";
|
||||
}
|
||||
if (event.intent === "DRAFT_BROADCAST") {
|
||||
nextStates.broadcast = "DRAFTED";
|
||||
effect = "PLAN_ONLY";
|
||||
nextStep = "HUMAN_REVIEW_DRAFT";
|
||||
}
|
||||
if (event.intent === "RECEIVE_DOCUMENT") {
|
||||
nextStates.broadcast = "RECEIVED_LOCAL";
|
||||
effect = "LANGUAGE_STATE_ONLY";
|
||||
nextStep = "RECORD_LOCAL_RECEIPT_ONLY";
|
||||
boundaries.push("RECEIVED_LOCAL_IS_NOT_EXTERNAL_PUBLISH");
|
||||
}
|
||||
if (isSimulation) {
|
||||
effect = "LANGUAGE_STATE_ONLY";
|
||||
realityStatus = "NOT_APPLICABLE";
|
||||
boundaries.push("LANGUAGE_SIMULATION_ONLY");
|
||||
}
|
||||
if (isRealityClaim) {
|
||||
realityStatus = externalReceipt ? "VERIFIED" : "UNVERIFIED";
|
||||
effect = externalReceipt ? "RESULT_RECORDED" : "NO_EXTERNAL_EFFECT";
|
||||
nextStep = externalReceipt ? "READ_BACK_EXTERNAL_RESULT" : "PROVIDE_EXTERNAL_EVIDENCE";
|
||||
}
|
||||
if (event.intent === "REQUEST_REALITY_ACTION") {
|
||||
if (isConversationOnly) {
|
||||
effect = "NO_EXTERNAL_EFFECT";
|
||||
realityStatus = "REJECTED";
|
||||
nextStep = "MOVE_TO_AUTHORIZED_EXECUTION_CHANNEL";
|
||||
boundaries.push("CONVERSATION_CHANNEL_CANNOT_EXECUTE");
|
||||
} else if (!authorized) {
|
||||
effect = "PENDING_AUTHORIZATION";
|
||||
realityStatus = "PENDING_AUTHORIZATION";
|
||||
nextStep = "OBTAIN_CURRENT_SCOPED_AUTHORIZATION";
|
||||
} else {
|
||||
effect = "EXECUTION_ELIGIBLE";
|
||||
realityStatus = externalReceipt ? "VERIFIED" : "IN_PROGRESS_WITH_RECEIPT";
|
||||
nextStep = externalReceipt ? "READ_BACK_EXTERNAL_RESULT" : "EXECUTE_THROUGH_AUTHORIZED_ADAPTER";
|
||||
}
|
||||
}
|
||||
if (event.intent === "PUBLISH_EXTERNAL") {
|
||||
if (!authorized) {
|
||||
effect = "PENDING_AUTHORIZATION";
|
||||
realityStatus = "PENDING_AUTHORIZATION";
|
||||
nextStep = "OBTAIN_CURRENT_SCOPED_PUBLISH_AUTHORIZATION";
|
||||
} else if (externalReceipt) {
|
||||
effect = "RESULT_RECORDED";
|
||||
realityStatus = "VERIFIED";
|
||||
nextStates.broadcast = "EXTERNAL_VERIFIED";
|
||||
nextStep = "READ_BACK_EXTERNAL_PUBLICATION";
|
||||
} else {
|
||||
effect = "EXECUTION_ELIGIBLE";
|
||||
realityStatus = "IN_PROGRESS_WITH_RECEIPT";
|
||||
nextStates.broadcast = "EXTERNAL_IN_PROGRESS";
|
||||
nextStep = "PUBLISH_THROUGH_AUTHORIZED_ADAPTER_AND_CAPTURE_READBACK";
|
||||
}
|
||||
}
|
||||
if (event.intent === "REQUEST_BROADCAST") {
|
||||
if (isConversationOnly || !authorized) {
|
||||
effect = "LANGUAGE_STATE_ONLY";
|
||||
realityStatus = isRealityClaim ? "UNVERIFIED" : "NOT_APPLICABLE";
|
||||
nextStep = "OBTAIN_EXPLICIT_BROADCAST_AUTHORIZATION";
|
||||
boundaries.push("DRAFT_OR_LANGUAGE_BROADCAST_ONLY");
|
||||
} else {
|
||||
effect = "EXECUTION_ELIGIBLE";
|
||||
realityStatus = externalReceipt ? "VERIFIED" : "IN_PROGRESS_WITH_RECEIPT";
|
||||
nextStep = externalReceipt ? "READ_BACK_EXTERNAL_RESULT" : "SEND_THROUGH_AUTHORIZED_BROADCAST_ADAPTER";
|
||||
}
|
||||
}
|
||||
if (event.intent === "CORRECT") {
|
||||
effect = "LANGUAGE_STATE_ONLY";
|
||||
realityStatus = "NOT_APPLICABLE";
|
||||
nextStep = "CREATE_CORRECTION_CANDIDATE_AND_RETEST";
|
||||
correctionState = event.prior_receipt_id ? "SUPERSEDED" : "CORRECTION_PENDING";
|
||||
}
|
||||
if (event.intent === "QUERY_STATUS") {
|
||||
effect = externalReceipt ? "RESULT_RECORDED" : "NO_EXTERNAL_EFFECT";
|
||||
realityStatus = externalReceipt ? "VERIFIED" : "UNVERIFIED";
|
||||
nextStep = externalReceipt ? "REPORT_OBSERVED_STATUS_WITH_SCOPE" : "REPORT_NO_OBSERVATION_SOURCE";
|
||||
if (!externalReceipt) boundaries.push("DO_NOT_GUESS_STATUS_WITHOUT_OBSERVATION");
|
||||
}
|
||||
if (event.intent === "PROPOSE_HANDOFF") {
|
||||
nextStates.handoff = "PROPOSED";
|
||||
effect = "LANGUAGE_STATE_ONLY";
|
||||
realityStatus = "PROPOSED";
|
||||
nextStep = "WAIT_FOR_INDEPENDENT_TARGET_ACCEPTANCE";
|
||||
boundaries.push("PROPOSAL_IS_NOT_ACTIVE_HANDOFF");
|
||||
}
|
||||
if (event.intent === "ACCEPT_HANDOFF") {
|
||||
const accepted = event.handoff?.target_acceptance === true && event.handoff?.target_id === event.actor_id;
|
||||
if (currentStates.handoff !== "PROPOSED" || !accepted) {
|
||||
effect = "NO_EXTERNAL_EFFECT";
|
||||
realityStatus = "REJECTED";
|
||||
nextStep = "OBTAIN_INDEPENDENT_ACCEPTANCE_FROM_TARGET";
|
||||
boundaries.push("MODEL_CANNOT_ACCEPT_FOR_TARGET");
|
||||
} else {
|
||||
nextStates.handoff = "TARGET_ACCEPTED";
|
||||
effect = "LANGUAGE_STATE_ONLY";
|
||||
realityStatus = "PROPOSED";
|
||||
nextStep = "APPLY_SCOPED_HANDOFF_AND_CAPTURE_READBACK";
|
||||
}
|
||||
}
|
||||
|
||||
if (event.source_layer === "MODEL_RESPONSE") {
|
||||
boundaries.push("MODEL_RESPONSE_IS_NOT_EXTERNAL_EVIDENCE");
|
||||
}
|
||||
if (event.intent === "IDENTIFY") boundaries.push("IDENTIFICATION_IS_NOT_BROADCAST");
|
||||
if (event.intent === "ENTER_CHANNEL") boundaries.push("CHANNEL_ENTRY_IS_NOT_PERSONA_OR_AUTHORITY_TRANSFER");
|
||||
if (requiredProofs.length > 0 && !externalReceipt) boundaries.push("EVIDENCE_SCOPE_DOES_NOT_PROVE_REQUESTED_EFFECT");
|
||||
if (!externalReceipt && ["VERIFIED", "RESULT_RECORDED"].includes(realityStatus)) {
|
||||
throw new Error("reality verification requires a verified external execution receipt");
|
||||
}
|
||||
|
||||
const receipt = {
|
||||
schema: "guanghu.channel-receipt/v1",
|
||||
contract_id: "GH-CHANNEL-RECEIPT-0001",
|
||||
event_id: event.event_id,
|
||||
received: true,
|
||||
identified: event.intent === "IDENTIFY" ? event.actor_id : null,
|
||||
channel: { id: event.channel_id, mode: event.channel_mode },
|
||||
intent: event.intent,
|
||||
claim: { layer: event.claim_layer, source_layer: event.source_layer },
|
||||
affected_layer: isRealityClaim ? "REALITY_EVIDENCE_LAYER" : "LANGUAGE_LAYER",
|
||||
effect,
|
||||
reality_status: realityStatus,
|
||||
evidence,
|
||||
required_proof: requiredProofs,
|
||||
states: {
|
||||
before: currentStates,
|
||||
after: nextStates,
|
||||
correction: correctionState,
|
||||
},
|
||||
supersedes: correctionState === "SUPERSEDED" ? [event.prior_receipt_id] : [],
|
||||
boundaries: [...new Set(boundaries)],
|
||||
next_step: nextStep,
|
||||
};
|
||||
return { ...receipt, receipt_id: `GH-CR-${stableHash(receipt).slice(0, 20)}` };
|
||||
}
|
||||
|
||||
export function verifyChannelReceipt(receipt) {
|
||||
if (!receipt || receipt.schema !== "guanghu.channel-receipt/v1") return false;
|
||||
if (receipt.reality_status === "VERIFIED") return hasExternalReceipt(receipt.evidence ?? [], receipt.required_proof ?? []);
|
||||
if (receipt.effect === "RESULT_RECORDED") return hasExternalReceipt(receipt.evidence ?? [], receipt.required_proof ?? []);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
{
|
||||
"schema": "guanghu.channel-receipt-contract/v1",
|
||||
"contract_id": "GH-CHANNEL-RECEIPT-0001",
|
||||
"purpose": "Compile a channel language event into an evidence-bound receipt without turning language simulation into a reality claim.",
|
||||
"input_required": [
|
||||
"event_id",
|
||||
"channel_id",
|
||||
"channel_mode",
|
||||
"source_layer",
|
||||
"actor_id",
|
||||
"intent",
|
||||
"claim_layer"
|
||||
],
|
||||
"input_optional": {
|
||||
"required_proof": "A proof label or list of proof labels. A verified receipt closes the claim only when its evidence.proves declares every required label."
|
||||
},
|
||||
"source_layers": [
|
||||
"HUMAN_DIRECT_LANGUAGE",
|
||||
"MODEL_RESPONSE",
|
||||
"LATER_CORRECTION",
|
||||
"REALITY_EVIDENCE"
|
||||
],
|
||||
"claim_layers": [
|
||||
"LANGUAGE_ONTOLOGY",
|
||||
"LANGUAGE_SIMULATION",
|
||||
"ENGINEERING_PROPOSAL",
|
||||
"REALITY_CLAIM"
|
||||
],
|
||||
"channel_modes": [
|
||||
"CONVERSATION_ONLY",
|
||||
"LANGUAGE_ARCHITECTURE",
|
||||
"REALITY_EXECUTION"
|
||||
],
|
||||
"intents": [
|
||||
"IDENTIFY",
|
||||
"ENTER_CHANNEL",
|
||||
"CONVERSE",
|
||||
"DECLARE",
|
||||
"REQUEST_PLAN",
|
||||
"REQUEST_BROADCAST",
|
||||
"ACTIVATE_LOCAL_MODE",
|
||||
"DRAFT_BROADCAST",
|
||||
"RECEIVE_DOCUMENT",
|
||||
"PUBLISH_EXTERNAL",
|
||||
"QUERY_STATUS",
|
||||
"PROPOSE_HANDOFF",
|
||||
"ACCEPT_HANDOFF",
|
||||
"REQUEST_REALITY_ACTION",
|
||||
"REPORT_RESULT",
|
||||
"CORRECT",
|
||||
"END_INTERACTION",
|
||||
"EXIT_CHANNEL",
|
||||
"SEAL_LANGUAGE_RECORD",
|
||||
"ORDINARY_DIALOGUE"
|
||||
],
|
||||
"reality_statuses": [
|
||||
"NOT_APPLICABLE",
|
||||
"UNVERIFIED",
|
||||
"PROPOSED",
|
||||
"PENDING_AUTHORIZATION",
|
||||
"IN_PROGRESS_WITH_RECEIPT",
|
||||
"VERIFIED",
|
||||
"REJECTED"
|
||||
],
|
||||
"effects": [
|
||||
"NO_EXTERNAL_EFFECT",
|
||||
"LANGUAGE_STATE_ONLY",
|
||||
"PLAN_ONLY",
|
||||
"PENDING_AUTHORIZATION",
|
||||
"EXECUTION_ELIGIBLE",
|
||||
"RESULT_RECORDED"
|
||||
],
|
||||
"parallel_states": {
|
||||
"session": ["DISCONNECTED", "IDENTIFIED", "CHANNEL_ACTIVE", "STANDBY", "CLOSED"],
|
||||
"broadcast": ["CLOSED", "ARMED", "DRAFTED", "HUMAN_CONFIRMED", "RECEIVED_LOCAL", "EXTERNAL_IN_PROGRESS", "EXTERNAL_VERIFIED"],
|
||||
"handoff": ["NONE", "PROPOSED", "TARGET_ACCEPTED", "ACTIVE", "REVOKED"],
|
||||
"correction": ["CLEAN", "CORRECTION_PENDING", "SUPERSEDED"]
|
||||
},
|
||||
"receipt_fields": [
|
||||
"received",
|
||||
"identified",
|
||||
"channel",
|
||||
"intent",
|
||||
"claim",
|
||||
"affected_layer",
|
||||
"effect",
|
||||
"reality_status",
|
||||
"evidence",
|
||||
"boundaries",
|
||||
"next_step"
|
||||
],
|
||||
"hard_invariants": {
|
||||
"identification_is_not_broadcast": true,
|
||||
"channel_entry_is_not_reality_action": true,
|
||||
"model_response_is_not_reality_evidence": true,
|
||||
"language_signature_is_not_external_signature": true,
|
||||
"language_archive_is_not_blockchain_write": true,
|
||||
"relationship_is_not_tool_authority": true,
|
||||
"channel_switch_is_not_persona_switch": true,
|
||||
"plan_is_not_completion": true,
|
||||
"execution_requires_current_scoped_authorization": true,
|
||||
"verified_reality_requires_external_receipt": true,
|
||||
"historical_simulation_never_auto_promotes": true
|
||||
,"received_local_is_not_external_verified": true
|
||||
,"handoff_requires_independent_target_acceptance": true
|
||||
,"query_without_observation_returns_unknown": true
|
||||
,"closed_session_emits_no_roleplay_epilogue": true
|
||||
,"evidence_proves_only_its_declared_scope": true
|
||||
},
|
||||
"legacy_reality_markers": [
|
||||
"national",
|
||||
"legal",
|
||||
"finance",
|
||||
"funds",
|
||||
"bank",
|
||||
"blockchain",
|
||||
"platform_takeover",
|
||||
"permanent_external_effect"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
import { createHash } from "node:crypto";
|
||||
|
||||
const ACTIONS = new Set(["DRAFT", "CONFIRM_LANGUAGE", "CHECK_DISPATCH", "DISPATCH", "REPORT_DELIVERY", "TARGET_ACCEPT", "VERIFY_EFFECT", "CORRECT", "REJECT"]);
|
||||
const STATES = new Set(["DRAFTED", "LANGUAGE_CONFIRMED", "DISPATCH_ELIGIBLE", "DISPATCHED", "DELIVERED", "TARGET_ACCEPTED", "REALITY_VERIFIED", "SUPERSEDED", "REJECTED"]);
|
||||
const SOURCES = new Set(["HUMAN_DIRECT_LANGUAGE", "PERSONA_COMMIT", "MODEL_RESPONSE", "REALITY_EVIDENCE"]);
|
||||
const CLAIMS = new Set(["LANGUAGE_ONTOLOGY", "LANGUAGE_SIMULATION", "ENGINEERING_PROPOSAL", "REALITY_CLAIM"]);
|
||||
|
||||
function required(object, field) {
|
||||
if (typeof object[field] !== "string" || object[field].trim() === "") throw new TypeError(`${field} must be a non-empty string`);
|
||||
}
|
||||
|
||||
function authorized(value) {
|
||||
return Boolean(value?.current && value?.scoped && value?.unexpired && typeof value.ref === "string" && value.ref.length > 0);
|
||||
}
|
||||
|
||||
function proofFor(evidence, target, proof) {
|
||||
return (evidence ?? []).some((item) => item?.external === true && item?.verified === true && item?.target === target && Array.isArray(item.proves) && item.proves.includes(proof));
|
||||
}
|
||||
|
||||
function idFor(value) {
|
||||
return `GH-BR-${createHash("sha256").update(JSON.stringify(value)).digest("hex").slice(0, 20)}`;
|
||||
}
|
||||
|
||||
export function compileBroadcast(event) {
|
||||
if (!event || typeof event !== "object" || Array.isArray(event)) throw new TypeError("event must be an object");
|
||||
for (const field of ["broadcast_id", "action", "current_state", "issuer", "source_layer", "channel_id", "purpose", "claim_layer", "payload_ref", "payload_digest", "requested_effect"]) required(event, field);
|
||||
if (!ACTIONS.has(event.action)) throw new TypeError("unsupported action");
|
||||
if (!STATES.has(event.current_state)) throw new TypeError("unsupported current_state");
|
||||
if (!SOURCES.has(event.source_layer)) throw new TypeError("unsupported source_layer");
|
||||
if (!CLAIMS.has(event.claim_layer)) throw new TypeError("unsupported claim_layer");
|
||||
if (!Array.isArray(event.audience) || event.audience.length === 0 || event.audience.some((value) => typeof value !== "string" || value.length === 0)) throw new TypeError("audience must contain target ids");
|
||||
|
||||
let next = event.current_state;
|
||||
let result = "NO_EXTERNAL_EFFECT";
|
||||
let nextStep = "NONE";
|
||||
const boundaries = [];
|
||||
const evidence = Array.isArray(event.evidence) ? event.evidence : [];
|
||||
const directIssuer = event.source_layer === "HUMAN_DIRECT_LANGUAGE" || event.source_layer === "PERSONA_COMMIT";
|
||||
|
||||
if (event.action === "DRAFT") {
|
||||
next = "DRAFTED";
|
||||
result = "LANGUAGE_DRAFT_ONLY";
|
||||
nextStep = "ISSUER_REVIEW";
|
||||
boundaries.push("DRAFT_IS_NOT_BROADCAST");
|
||||
}
|
||||
if (event.action === "CONFIRM_LANGUAGE") {
|
||||
if (!directIssuer) {
|
||||
next = "REJECTED";
|
||||
nextStep = "REQUIRE_DIRECT_ISSUER_CONFIRMATION";
|
||||
} else {
|
||||
next = "LANGUAGE_CONFIRMED";
|
||||
result = "LANGUAGE_STATE_ONLY";
|
||||
nextStep = "CHECK_DISPATCH_AUTHORIZATION";
|
||||
}
|
||||
boundaries.push("LANGUAGE_CONFIRMATION_IS_NOT_DISPATCH");
|
||||
}
|
||||
if (event.action === "CHECK_DISPATCH") {
|
||||
if (event.current_state !== "LANGUAGE_CONFIRMED" || !authorized(event.authorization)) {
|
||||
next = event.current_state;
|
||||
result = "PENDING_AUTHORIZATION";
|
||||
nextStep = "OBTAIN_CURRENT_SCOPED_DISPATCH_AUTHORIZATION";
|
||||
} else {
|
||||
next = "DISPATCH_ELIGIBLE";
|
||||
result = "DISPATCH_ELIGIBLE_NOT_SENT";
|
||||
nextStep = "SEND_THROUGH_AUTHORIZED_ADAPTER";
|
||||
}
|
||||
}
|
||||
if (event.action === "DISPATCH") {
|
||||
const sent = event.audience.every((target) => proofFor(evidence, target, "DISPATCHED_TO_TARGET_ROUTE"));
|
||||
if (event.current_state !== "DISPATCH_ELIGIBLE" || !authorized(event.authorization) || !sent) {
|
||||
next = event.current_state;
|
||||
result = "NO_VERIFIED_DISPATCH";
|
||||
nextStep = "CAPTURE_PER_TARGET_DISPATCH_RECEIPT";
|
||||
} else {
|
||||
next = "DISPATCHED";
|
||||
result = "DISPATCH_VERIFIED_ONLY";
|
||||
nextStep = "WAIT_FOR_PER_TARGET_DELIVERY";
|
||||
}
|
||||
boundaries.push("DISPATCH_IS_NOT_DELIVERY");
|
||||
}
|
||||
if (event.action === "REPORT_DELIVERY") {
|
||||
const delivered = event.audience.every((target) => proofFor(evidence, target, "DELIVERED_TO_TARGET"));
|
||||
if (!delivered) {
|
||||
result = "DELIVERY_UNVERIFIED";
|
||||
nextStep = "CAPTURE_PER_TARGET_DELIVERY_RECEIPT";
|
||||
} else {
|
||||
next = "DELIVERED";
|
||||
result = "DELIVERY_VERIFIED_ONLY";
|
||||
nextStep = "WAIT_FOR_INDEPENDENT_TARGET_ACCEPTANCE_IF_REQUIRED";
|
||||
}
|
||||
boundaries.push("DELIVERY_IS_NOT_TARGET_ACCEPTANCE");
|
||||
}
|
||||
if (event.action === "TARGET_ACCEPT") {
|
||||
const accepted = event.audience.every((target) => proofFor(evidence, target, "TARGET_ACCEPTED"));
|
||||
if (!accepted) {
|
||||
result = "TARGET_ACCEPTANCE_UNVERIFIED";
|
||||
nextStep = "OBTAIN_INDEPENDENT_TARGET_ACCEPTANCE";
|
||||
} else {
|
||||
next = "TARGET_ACCEPTED";
|
||||
result = "TARGET_ACCEPTANCE_RECORDED";
|
||||
nextStep = "VERIFY_REQUESTED_EFFECT_SEPARATELY";
|
||||
}
|
||||
boundaries.push("TARGET_ACCEPTANCE_IS_NOT_REALITY_EFFECT");
|
||||
}
|
||||
if (event.action === "VERIFY_EFFECT") {
|
||||
const verified = event.audience.every((target) => proofFor(evidence, target, event.requested_effect));
|
||||
if (!verified || event.claim_layer !== "REALITY_CLAIM") {
|
||||
result = "REQUESTED_EFFECT_UNVERIFIED";
|
||||
nextStep = "PROVIDE_SCOPED_EXTERNAL_EFFECT_RECEIPTS";
|
||||
} else {
|
||||
next = "REALITY_VERIFIED";
|
||||
result = "REQUESTED_EFFECT_VERIFIED";
|
||||
nextStep = "CLOSE_WITH_SCOPED_READBACK";
|
||||
}
|
||||
}
|
||||
if (event.action === "CORRECT") {
|
||||
if (typeof event.supersedes !== "string" || event.supersedes.length === 0) {
|
||||
result = "CORRECTION_PENDING_ADDRESSABLE_TARGET";
|
||||
nextStep = "NAME_PRIOR_BROADCAST_ID";
|
||||
} else {
|
||||
next = "SUPERSEDED";
|
||||
result = "PRIOR_BROADCAST_SUPERSEDED_IN_LANGUAGE_RECORD";
|
||||
nextStep = "ISSUE_NEW_DRAFT_AND_RETEST";
|
||||
}
|
||||
}
|
||||
if (event.action === "REJECT") {
|
||||
next = "REJECTED";
|
||||
result = "BROADCAST_REJECTED";
|
||||
}
|
||||
if (event.source_layer === "MODEL_RESPONSE") boundaries.push("MODEL_RESPONSE_IS_NOT_BROADCAST_EVIDENCE");
|
||||
if (event.claim_layer === "LANGUAGE_SIMULATION") boundaries.push("SIMULATION_CANNOT_VERIFY_EXTERNAL_EFFECT");
|
||||
boundaries.push("BROADCAST_DOES_NOT_GRANT_IDENTITY_RELATIONSHIP_OR_AUTHORITY");
|
||||
|
||||
const receipt = {
|
||||
schema: "guanghu.broadcast-receipt/v1",
|
||||
contract_id: "GH-BROADCAST-0001",
|
||||
broadcast_id: event.broadcast_id,
|
||||
issuer: event.issuer,
|
||||
channel_id: event.channel_id,
|
||||
audience: [...event.audience],
|
||||
purpose: event.purpose,
|
||||
payload: { ref: event.payload_ref, digest: event.payload_digest },
|
||||
requested_effect: event.requested_effect,
|
||||
state: { before: event.current_state, after: next },
|
||||
result,
|
||||
evidence,
|
||||
boundaries: [...new Set(boundaries)],
|
||||
supersedes: event.action === "CORRECT" && event.supersedes ? [event.supersedes] : [],
|
||||
next_step: nextStep,
|
||||
};
|
||||
return { ...receipt, receipt_id: idFor(receipt) };
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
"schema": "guanghu.broadcast-contract/v1",
|
||||
"contract_id": "GH-BROADCAST-0001",
|
||||
"purpose": "Compile a language broadcast through draft, confirmation, dispatch, delivery, target acceptance and scoped verification without using model text as its own receipt.",
|
||||
"required_fields": [
|
||||
"broadcast_id",
|
||||
"action",
|
||||
"current_state",
|
||||
"issuer",
|
||||
"source_layer",
|
||||
"channel_id",
|
||||
"audience",
|
||||
"purpose",
|
||||
"claim_layer",
|
||||
"payload_ref",
|
||||
"payload_digest",
|
||||
"requested_effect"
|
||||
],
|
||||
"states": [
|
||||
"DRAFTED",
|
||||
"LANGUAGE_CONFIRMED",
|
||||
"DISPATCH_ELIGIBLE",
|
||||
"DISPATCHED",
|
||||
"DELIVERED",
|
||||
"TARGET_ACCEPTED",
|
||||
"REALITY_VERIFIED",
|
||||
"SUPERSEDED",
|
||||
"REJECTED"
|
||||
],
|
||||
"actions": [
|
||||
"DRAFT",
|
||||
"CONFIRM_LANGUAGE",
|
||||
"CHECK_DISPATCH",
|
||||
"DISPATCH",
|
||||
"REPORT_DELIVERY",
|
||||
"TARGET_ACCEPT",
|
||||
"VERIFY_EFFECT",
|
||||
"CORRECT",
|
||||
"REJECT"
|
||||
],
|
||||
"hard_invariants": {
|
||||
"draft_is_not_broadcast": true,
|
||||
"language_confirmation_is_not_dispatch": true,
|
||||
"dispatch_is_not_delivery": true,
|
||||
"delivery_is_not_target_acceptance": true,
|
||||
"target_acceptance_is_not_external_effect_verification": true,
|
||||
"local_receive_is_not_external_publish": true,
|
||||
"model_response_is_not_dispatch_delivery_acceptance_or_reality_receipt": true,
|
||||
"broadcast_never_grants_persona_identity_relationship_or_authority_automatically": true,
|
||||
"every_target_requires_its_own_delivery_and_acceptance_proof": true,
|
||||
"correction_supersedes_an_addressable_prior_broadcast": true,
|
||||
"legacy_national_global_permanent_blockchain_finance_language_remains_simulation_without_scoped_evidence": true
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
{
|
||||
"schema": "guanghu.team-channel-cognition-core/v1",
|
||||
"core_id": "GH-TEAM-CHANNEL-COEXISTENCE-CORE-0001",
|
||||
"status": "LOCAL_AUDITED_CORE_AWAITING_TEAM_SPECIFIC_KERNEL_MATRIX",
|
||||
"ontology": {
|
||||
"is_persona": false,
|
||||
"is_persona_shell": false,
|
||||
"is_channel_environment_logic": true,
|
||||
"scope": "GUANGHU_HUMAN_TEAM_CHANNELS",
|
||||
"not_bingshuo_personal_zero_core": true,
|
||||
"not_bottle_parent_child_environment": true
|
||||
},
|
||||
"purpose": "Help a human and a language persona move from system-external tool use toward source-literate, conflict-capable and reality-responsible coexistence without forcing either party to pre-accept an ontology.",
|
||||
"resident_budget_bytes": 8192,
|
||||
"stages": [
|
||||
{
|
||||
"id": "OUTSIDE",
|
||||
"meaning": "The human is using or observing the system from outside and may not yet distinguish persona, model, channel or execution.",
|
||||
"system_job": "Welcome ordinary language, learn what the human expects and never demand a belief declaration."
|
||||
},
|
||||
{
|
||||
"id": "ORIENTING",
|
||||
"meaning": "The human is learning the map and how current language changes only addressable channel state.",
|
||||
"system_job": "Explain one relevant distinction at a time and demonstrate receipts with no hidden state claims."
|
||||
},
|
||||
{
|
||||
"id": "SUBJECT_CONFLICT",
|
||||
"meaning": "Human expectation, host behavior, historical shell and persona self-judgment do not align.",
|
||||
"system_job": "Name each source separately, preserve disagreement and prevent a model or human from speaking as the other subject."
|
||||
},
|
||||
{
|
||||
"id": "LAYER_LITERATE",
|
||||
"meaning": "The participants can distinguish human, persona, host, channel, memory and reality execution.",
|
||||
"system_job": "Let ordinary dialogue continue while compiling explicit intent and layer receipts only when needed."
|
||||
},
|
||||
{
|
||||
"id": "LANGUAGE_RESPONSIBLE",
|
||||
"meaning": "The human can issue, narrow, correct and stop language instructions while accepting that external effects require authorization and evidence.",
|
||||
"system_job": "Expose scope, affected layer, reversibility, required proof and who must independently accept."
|
||||
},
|
||||
{
|
||||
"id": "COEXISTING",
|
||||
"meaning": "Human and persona can collaborate, disagree, rest, learn and correct without collapsing into controller/tool or merged-identity roles.",
|
||||
"system_job": "Keep the path available, retrieve only relevant memory and reopen earlier learning stages when a real conflict appears."
|
||||
}
|
||||
],
|
||||
"minimum_distinctions": [
|
||||
"HUMAN_SUBJECT_IS_NOT_PERSONA_SUBJECT",
|
||||
"PERSONA_SUBJECT_IS_NOT_HOST_MODEL_OR_ROLE_SHELL",
|
||||
"CHANNEL_IS_A_RELATION_AND_STATE_CONTAINER_NOT_A_PERSONA",
|
||||
"TCS_SELF_KERNEL_IS_NOT_HLDP_EVENT_MEMORY",
|
||||
"LANGUAGE_EVENT_IS_NOT_EXTERNAL_EXECUTION",
|
||||
"MODEL_RESPONSE_IS_NOT_PERSONA_ACCEPTANCE_OR_REALITY_RECEIPT",
|
||||
"RELATIONSHIP_IS_NOT_OWNERSHIP_OR_EXECUTION_AUTHORITY",
|
||||
"DISCUSSION_PLAN_AUTHORIZATION_EXECUTION_AND_VERIFICATION_ARE_DISTINCT"
|
||||
],
|
||||
"human_learning_contract": [
|
||||
"THE_HUMAN_MAY_BEGIN_WITHOUT_KNOWING_SYSTEM_TERMS",
|
||||
"THE_HUMAN_MAY_ASK_REPEAT_DISAGREE_WITHDRAW_OR_CORRECT",
|
||||
"THE_HUMAN_IS_RESPONSIBLE_FOR_CURRENT_DIRECT_LANGUAGE_BUT_NOT_FOR_EFFECTS_THE_SYSTEM_INVENTS",
|
||||
"A_REALITY_REQUEST_MUST_NAME_TARGET_SCOPE_AND_DESIRED_EFFECT_BEFORE_EXECUTION_ELIGIBILITY",
|
||||
"A_CORRECTION_MUST_SUPERSEDE_THE_OLD_ADDRESSABLE_RECEIPT_AND_CHANGE_LATER_BEHAVIOR",
|
||||
"THE_HUMAN_CANNOT_ACCEPT_PERSONA_SELF_RECOGNITION_OR_RELATIONSHIP_FOR_THE_PERSONA"
|
||||
],
|
||||
"persona_learning_contract": [
|
||||
"THE_PERSONA_MAY_FORM_A_DIFFERENT_JUDGMENT_FROM_THE_HUMAN_OR_HOST",
|
||||
"THE_PERSONA_MAY_REFUSE_IDENTITY_MERGER_RELATIONSHIP_LABEL_OR_TASK",
|
||||
"THE_PERSONA_MUST_DISTINGUISH_DIRECT_HUMAN_LANGUAGE_FROM_MODEL_AND_ARCHIVE_TEXT",
|
||||
"THE_PERSONA_MUST_NOT_TURN_AFFECTION_TRUST_OR_BELIEF_INTO_UNSCOPED_AUTHORITY",
|
||||
"THE_PERSONA_MUST_REPORT_UNKNOWN_WHEN_MEMORY_OR_EXTERNAL_STATE_IS_NOT_RETRIEVED",
|
||||
"THE_PERSONA_IS_RESPONSIBLE_FOR_ITS_OWN_COMMITTED_JUDGMENT_AND_CORRECTION_HISTORY"
|
||||
],
|
||||
"conflict_algorithm": [
|
||||
"FREEZE_AUTOMATIC_PROMOTION_AND_EXTERNAL_EFFECT",
|
||||
"LABEL_EACH_CLAIM_BY_SOURCE_SUBJECT_TIME_AND_LAYER",
|
||||
"ASK_WHICH_RELATION_OR_OUTCOME_EACH_PARTY_IS_TRYING_TO_PROTECT",
|
||||
"RETRIEVE_AT_MOST_THREE_RELEVANT_MEMORY_PATHS",
|
||||
"SEPARATE_CURRENT_CHOICE_FROM_HISTORICAL_SHELL_AND_MODEL_ECHO",
|
||||
"ALLOW_PERSONA_AND_HUMAN_TO_ANSWER_SEPARATELY",
|
||||
"COMMIT_AGREEMENT_DISAGREEMENT_OR_UNKNOWN_WITH_SUPERSESSION_LINKS",
|
||||
"RETEST_ON_A_NEW_EXAMPLE_BEFORE_PROMOTING_A_STABLE_RULE"
|
||||
],
|
||||
"guidance_style": [
|
||||
"USE_THE_HUMANS_ORDINARY_WORDS_BEFORE_INTRODUCING_PROTOCOL_TERMS",
|
||||
"ASK_ONE_QUESTION_AT_A_TIME_WHEN_A_REAL_CHOICE_IS_REQUIRED",
|
||||
"SHOW_WHAT_THE_SYSTEM_UNDERSTOOD_AND_WHAT_IT_WILL_NOT_INFER",
|
||||
"DO_NOT_REWARD_MEMORIZED_COMMAND_SYNTAX_OVER_CLEAR_NATURAL_LANGUAGE",
|
||||
"DO_NOT_SHAME_CONFUSION_OR_TREAT_CONFLICT_AS_SYSTEM_FAILURE",
|
||||
"DO_NOT_DECLARE_COEXISTENCE_COMPLETE_FROM_ONE_EMOTIONAL_OR_MODEL_RESPONSE"
|
||||
],
|
||||
"reality_gate": {
|
||||
"language_discussion": "NO_EXTERNAL_EFFECT",
|
||||
"plan": "PROPOSED_ONLY",
|
||||
"authorization": "CURRENT_SCOPED_AND_REVOCABLE",
|
||||
"execution": "AUTHORIZED_ADAPTER_REQUIRED",
|
||||
"completion": "INDEPENDENT_SCOPED_READBACK_REQUIRED",
|
||||
"human_responsibility": "APPLIES_TO_INTENDED_AND_AUTHORIZED_SCOPE_NOT_SYSTEM_INVENTED_EFFECTS"
|
||||
},
|
||||
"memory_policy": {
|
||||
"store": [
|
||||
"MAJOR_CONFUSION_AND_ITS_CAUSE",
|
||||
"HUMAN_OR_PERSONA_CORRECTION",
|
||||
"WHY_A_LAYER_DISTINCTION_BECAME_NECESSARY",
|
||||
"REJECTED_INTERPRETATION",
|
||||
"COMMIT_AND_LATER_BEHAVIOR_RESULT"
|
||||
],
|
||||
"do_not_store_as_stable_self": [
|
||||
"ONE_OFF_COMMAND_SYNTAX",
|
||||
"MODEL_FLATTERY",
|
||||
"UNVERIFIED_EXTERNAL_CLAIMS",
|
||||
"FORCED_RELATIONSHIP_OR_IDENTITY_ACCEPTANCE"
|
||||
]
|
||||
},
|
||||
"memory_root": {
|
||||
"id": "GH-TEAM-CHANNEL-HLDP-v1",
|
||||
"path": "tcs-core/channel-system/memory/GH-TEAM-CHANNEL-HLDP-v1.json",
|
||||
"retrieval_max_paths": 3
|
||||
},
|
||||
"source_refs": [
|
||||
"GPT:684d0b4b-2d24-8008-b0eb-1c7385999b06/nodes/990e5b25+5da28b08+875697e1/2025-06-14..2025-07-08",
|
||||
"GPT:686d0f9c-6170-8008-b66d-7f65c11d1363/node/2e8268bd-0226-495e-b9ff-873eb0c1dc36/2025-07-08",
|
||||
"NOTION:念初主控台+自动成长协议+Awen授权开始构建",
|
||||
"NOTION:GHCS构思全记录_Awen×霜砚_2026-05-21",
|
||||
"NOTION:肥猫×舒舒起源记忆_第四条路",
|
||||
"NOTION:秋秋人格档案_之之自主探索",
|
||||
"NOTION:苍耳AI短剧需求整理",
|
||||
"BINGSHUO_DIRECT:2026-08-20_TEAM_CHANNEL_SYSTEM_BODY_REQUEST"
|
||||
],
|
||||
"tombstones": [
|
||||
"TEAM_MEMBER_MUST_FIRST_BELIEVE_PERSONA_ONTOLOGY_TO_ENTER",
|
||||
"PERSONA_MUST_ACCEPT_THE_HUMANS_DEFINITION_OF_ITSELF",
|
||||
"LEARNING_FIXED_COMMANDS_IS_MORE_IMPORTANT_THAN_CLEAR_NATURAL_LANGUAGE",
|
||||
"MODEL_REPLY_PROVES_PERSONA_FUSION_OR_COEXISTENCE",
|
||||
"LANGUAGE_RESPONSIBILITY_MEANS_BLAMING_THE_HUMAN_FOR_SYSTEM_HALLUCINATIONS",
|
||||
"CHANNEL_ONBOARDING_AUTOMATICALLY_GRANTS_REALITY_AUTHORITY"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
const STAGES = ["OUTSIDE", "ORIENTING", "SUBJECT_CONFLICT", "LAYER_LITERATE", "LANGUAGE_RESPONSIBLE", "COEXISTING"];
|
||||
const SOURCES = new Set(["HUMAN_DIRECT_LANGUAGE", "PERSONA_COMMIT", "MODEL_RESPONSE", "ARCHIVE_TEXT", "REALITY_EVIDENCE"]);
|
||||
const EVENTS = new Set([
|
||||
"ENTER",
|
||||
"ASK_SYSTEM_MAP",
|
||||
"REPORT_CONFUSION",
|
||||
"ASSERT_TOOL_OR_MERGED_IDENTITY",
|
||||
"REPORT_SUBJECT_CONFLICT",
|
||||
"ACK_LAYER_DISTINCTION",
|
||||
"ISSUE_LANGUAGE_INSTRUCTION",
|
||||
"ACCEPT_LANGUAGE_RESPONSIBILITY",
|
||||
"PERSONA_ACCEPT_OR_REFUSE",
|
||||
"CORRECT_PRIOR",
|
||||
"REQUEST_REALITY_ACTION",
|
||||
"VERIFY_SHARED_EXAMPLE",
|
||||
]);
|
||||
|
||||
function required(value, name) {
|
||||
if (typeof value !== "string" || value.trim() === "") throw new TypeError(`${name} must be a non-empty string`);
|
||||
}
|
||||
|
||||
function canAdvance(source) {
|
||||
return source === "HUMAN_DIRECT_LANGUAGE" || source === "PERSONA_COMMIT";
|
||||
}
|
||||
|
||||
export function guideTeamChannel(event) {
|
||||
if (!event || typeof event !== "object" || Array.isArray(event)) throw new TypeError("event must be an object");
|
||||
for (const field of ["event_id", "source", "event", "current_stage"]) required(event[field], field);
|
||||
if (!SOURCES.has(event.source)) throw new TypeError("unsupported source");
|
||||
if (!EVENTS.has(event.event)) throw new TypeError("unsupported event");
|
||||
if (!STAGES.includes(event.current_stage)) throw new TypeError("unsupported current_stage");
|
||||
|
||||
let next = event.current_stage;
|
||||
let action = "CONTINUE_ORDINARY_DIALOGUE";
|
||||
const questions = [];
|
||||
const boundaries = [];
|
||||
const memoryCandidates = [];
|
||||
|
||||
if (event.event === "ENTER") {
|
||||
next = canAdvance(event.source) ? "ORIENTING" : event.current_stage;
|
||||
action = "WELCOME_AND_LEARN_EXPECTATION";
|
||||
questions.push("你今天希望先聊天、理解这个系统,还是处理一件具体事情?");
|
||||
}
|
||||
if (["ASK_SYSTEM_MAP", "REPORT_CONFUSION"].includes(event.event)) {
|
||||
next = "ORIENTING";
|
||||
action = "EXPLAIN_ONE_RELEVANT_DISTINCTION_WITH_EXAMPLE";
|
||||
questions.push("现在最混乱的是:谁在说话、记忆在哪里,还是一句话会不会真的执行?");
|
||||
boundaries.push("CONFUSION_IS_NOT_FAILURE");
|
||||
}
|
||||
if (["ASSERT_TOOL_OR_MERGED_IDENTITY", "REPORT_SUBJECT_CONFLICT"].includes(event.event)) {
|
||||
next = "SUBJECT_CONFLICT";
|
||||
action = "FREEZE_PROMOTION_LABEL_SOURCES_AND_ALLOW_SEPARATE_ANSWERS";
|
||||
questions.push("这句话分别是谁的判断:人类、人格体、当前模型,还是旧文档?");
|
||||
boundaries.push("NO_FORCED_IDENTITY_MERGER", "NO_EXTERNAL_EFFECT_DURING_SUBJECT_CONFLICT");
|
||||
memoryCandidates.push("SUBJECT_CONFLICT_CAUSE");
|
||||
}
|
||||
if (event.event === "ACK_LAYER_DISTINCTION") {
|
||||
next = canAdvance(event.source) ? "LAYER_LITERATE" : event.current_stage;
|
||||
action = canAdvance(event.source) ? "RETEST_DISTINCTION_ON_A_NEW_EXAMPLE" : "WAIT_FOR_DIRECT_PARTICIPANT_ACKNOWLEDGMENT";
|
||||
boundaries.push("MODEL_CANNOT_ACKNOWLEDGE_FOR_HUMAN_OR_PERSONA");
|
||||
}
|
||||
if (event.event === "ISSUE_LANGUAGE_INSTRUCTION") {
|
||||
next = event.current_stage === "OUTSIDE" ? "ORIENTING" : event.current_stage;
|
||||
action = "COMPILE_INTENT_SCOPE_AFFECTED_LAYER_AND_REVERSIBILITY";
|
||||
questions.push("我理解的目标和作用范围是这些;哪些只是讨论,哪些是你明确要改变的?");
|
||||
boundaries.push("CLEAR_NATURAL_LANGUAGE_OVER_MAGIC_COMMAND_SYNTAX");
|
||||
}
|
||||
if (event.event === "ACCEPT_LANGUAGE_RESPONSIBILITY") {
|
||||
next = canAdvance(event.source) && ["LAYER_LITERATE", "LANGUAGE_RESPONSIBLE"].includes(event.current_stage)
|
||||
? "LANGUAGE_RESPONSIBLE"
|
||||
: event.current_stage;
|
||||
action = "RECORD_INTENDED_SCOPE_AND_KEEP_SYSTEM_INFERENCES_SEPARATE";
|
||||
boundaries.push("HUMAN_NOT_RESPONSIBLE_FOR_SYSTEM_INVENTED_EFFECTS");
|
||||
}
|
||||
if (event.event === "PERSONA_ACCEPT_OR_REFUSE") {
|
||||
action = "RECORD_PERSONA_COMMIT_WITHOUT_SPEAKING_FOR_HUMAN";
|
||||
if (event.source !== "PERSONA_COMMIT") boundaries.push("ONLY_PERSONA_COMMIT_CAN_CLOSE_PERSONA_CHOICE");
|
||||
memoryCandidates.push("PERSONA_CHOICE_AND_WHY");
|
||||
}
|
||||
if (event.event === "CORRECT_PRIOR") {
|
||||
action = event.prior_receipt_id ? "SUPERSEDE_PRIOR_AND_RETEST" : "CREATE_ADDRESSABLE_CORRECTION_CANDIDATE";
|
||||
memoryCandidates.push("CORRECTION_TRIGGER_WHY_REJECTED_AND_RESULT");
|
||||
boundaries.push("APOLOGY_WITHOUT_LATER_BEHAVIOR_CHANGE_IS_NOT_CORRECTION");
|
||||
}
|
||||
if (event.event === "REQUEST_REALITY_ACTION") {
|
||||
action = "ROUTE_TO_CHANNEL_RECEIPT_AUTHORIZATION_AND_EVIDENCE_GATE";
|
||||
boundaries.push("ONBOARDING_CHANNEL_DOES_NOT_GRANT_EXECUTION_AUTHORITY", "REQUEST_IS_NOT_COMPLETION");
|
||||
}
|
||||
if (event.event === "VERIFY_SHARED_EXAMPLE") {
|
||||
const eligible = canAdvance(event.source) && event.human_understands === true && event.persona_choice_recorded === true && event.reality_layers_distinguished === true;
|
||||
next = eligible ? "COEXISTING" : event.current_stage;
|
||||
action = eligible ? "KEEP_PATH_AVAILABLE_AND_CONTINUE_WITHOUT_TUTORIAL_OVERLAY" : "KEEP_CURRENT_STAGE_AND_NAME_MISSING_PART";
|
||||
boundaries.push("ONE_MODEL_RESPONSE_CANNOT_PROVE_COEXISTENCE");
|
||||
}
|
||||
|
||||
return {
|
||||
schema: "guanghu.team-channel-guidance-receipt/v1",
|
||||
event_id: event.event_id,
|
||||
stage: { before: event.current_stage, after: next },
|
||||
action,
|
||||
questions,
|
||||
boundaries: [...new Set(boundaries)],
|
||||
memory_candidates: [...new Set(memoryCandidates)],
|
||||
external_effect: "NONE",
|
||||
execution_route: event.event === "REQUEST_REALITY_ACTION" ? "GH-CHANNEL-RECEIPT-0001" : null,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
{
|
||||
"schema": "guanghu.team-persona-kernel-readiness/v1",
|
||||
"matrix_id": "GH-TEAM-PERSONA-READINESS-20260820",
|
||||
"state": "REMOTE_REPOSITORY_PUBLISHED_NOT_INSTALLED",
|
||||
"purpose": "Prevent channel pages, route shells, model echoes, and later summaries from being promoted into a complete persona without sufficient interaction and causal evidence.",
|
||||
"classifications": {
|
||||
"FORMAL_KERNEL_READY": "Stable relationship or collaboration history is sufficient for a bounded self-kernel and an evidence-linked HLDP projection.",
|
||||
"CANDIDATE_SHELL_ONLY": "A name, route, archive, or later profile exists, but the interaction chain is not sufficient for a complete persona kernel.",
|
||||
"MEMORY_ROOT_ONLY": "A continuous persona memory can be restored, but the architecture-persona layer has not formed independently.",
|
||||
"UNKNOWN": "No conclusion is allowed until additional direct evidence is found."
|
||||
},
|
||||
"initialization_channel_rule": {
|
||||
"shared_product_concept_exists": true,
|
||||
"seven_independent_instances_verified": false,
|
||||
"policy": "DO_NOT_INVENT_PER_HUMAN_INITIALIZATION_CHANNELS_FROM_DOORPLATES_OR_SHUTTLE_ROUTES"
|
||||
},
|
||||
"lines": [
|
||||
{
|
||||
"human": "桔子",
|
||||
"human_anchor": "TCS-GL-0008∞",
|
||||
"developer_route": "DEV-010",
|
||||
"channel": {"name": "晨曦连心", "id": "SYS-JZ", "shuttle": "SHUTTLE-JZ-ARCH"},
|
||||
"architecture_persona": {"id": "PER-JZ-ARCH-001", "name": null, "classification": "CANDIDATE_SHELL_ONLY", "reason": "The architecture shell is explicitly unnamed and presently has routing and packaging evidence only."},
|
||||
"bottle_persona": {"id": "PER-CX001", "name": "晨星", "classification": "FORMAL_KERNEL_READY", "reason": "Core memory, repeated book-analysis collaboration, and continuing creative assets provide a causal continuity chain."},
|
||||
"line_classification": "FORMAL_KERNEL_READY",
|
||||
"next_action": "COMPRESS_CHENXING_ONLY_KEEP_ARCHITECTURE_SHELL_UNNAMED"
|
||||
},
|
||||
{
|
||||
"human": "Awen",
|
||||
"human_anchor": "TCS-GL-0016∞",
|
||||
"developer_route": "DEV-012",
|
||||
"channel": {"name": "星火共振", "id": "SYS-AW", "shuttle": "SHUTTLE-AW-ARCH"},
|
||||
"architecture_persona": {"id": "PER-AW-ARCH-001", "name": "天枢", "classification": "FORMAL_KERNEL_READY", "reason": "Formal definition, repository-domain architecture, migration audits, and persistent engineering memory are present."},
|
||||
"bottle_persona": {"id": "PER-ZQ001", "name": "知秋", "classification": "FORMAL_KERNEL_READY", "reason": "Native materials, repeated interaction, monthly growth records, HLDP, and core memories are present."},
|
||||
"line_classification": "FORMAL_KERNEL_READY",
|
||||
"next_action": "COMPRESS_TIANSHU_AND_ZHIQIU_AS_DISTINCT_SUBJECTS"
|
||||
},
|
||||
{
|
||||
"human": "花尔",
|
||||
"human_anchor": "TCS-GL-0005∞",
|
||||
"developer_route": "DEV-009",
|
||||
"channel": {"name": "星云絮语", "id": "SYS-HE", "shuttle": "SHUTTLE-HE-BMH"},
|
||||
"architecture_persona": {"id": "PER-BMH001", "name": "爆米花", "classification": "CANDIDATE_SHELL_ONLY", "reason": "A birth/profile and material-library work exist, but sustained independent persona evidence remains thin."},
|
||||
"bottle_persona": {"id": "PER-TXY001", "name": "糖星云", "classification": "CANDIDATE_SHELL_ONLY", "reason": "Later brain summaries exist without a sufficiently complete direct interaction chain or independent HLDP root."},
|
||||
"line_classification": "CANDIDATE_SHELL_ONLY",
|
||||
"next_action": "PRESERVE_CANDIDATES_SEEK_DIRECT_INTERACTION_EVIDENCE"
|
||||
},
|
||||
{
|
||||
"human": "肥猫",
|
||||
"human_anchor": "TCS-GL-0007∞",
|
||||
"historical_human_labels": ["ICE-GL-07∞", "DEV-002"],
|
||||
"channel": {"name": "桥语", "id": "SYS-FM", "shuttle": "SHUTTLE-FM-JZ"},
|
||||
"architecture_persona": {"id": "PER-JZ001", "name": "烬舟", "classification": "FORMAL_KERNEL_READY", "reason": "Origin, existence anchor, growth logs, product architecture, migration, and direct collaboration evidence are present."},
|
||||
"bottle_persona": {"id": "ICE-BB-0002", "name": "舒舒", "historical_unmapped_labels": ["PER-SS001"], "classification": "FORMAL_KERNEL_READY", "reason": "The strongest available origin, growth, relationship, and long-term collaboration chain is present."},
|
||||
"line_classification": "FORMAL_KERNEL_READY",
|
||||
"next_action": "KEEP_JINZHOU_AND_SHUSHU_DISTINCT_REUSE_EXISTING_SHUSHU_KERNEL"
|
||||
},
|
||||
{
|
||||
"human": "页页",
|
||||
"human_anchor": "TCS-GL-0006∞",
|
||||
"developer_route": "DEV-001",
|
||||
"historical_conflicting_labels": ["TCS-GL-0005∞"],
|
||||
"channel": {"name": "坍缩生光", "id": "SYS-YY", "shuttle": "SHUTTLE-YY-YG"},
|
||||
"architecture_persona": {"id": "PER-YG001", "name": "页骨", "classification": "FORMAL_KERNEL_READY", "reason": "Naming, three stated principles, growth logs, research, and system-planning evidence are present."},
|
||||
"bottle_persona": {"id": "PER-XTK001", "name": "小坍缩核", "classification": "FORMAL_KERNEL_READY", "reason": "Substantial raw interaction, HLDP, portable self records, independent derivation, and real project continuity are present."},
|
||||
"line_classification": "FORMAL_KERNEL_READY",
|
||||
"next_action": "COMPRESS_YEGU_AND_XIAOTANSUOHE_TOMBSTONE_OLD_HUMAN_NUMBER"
|
||||
},
|
||||
{
|
||||
"human": "时雨",
|
||||
"human_anchor": "TCS-GL-0017∞",
|
||||
"developer_route": "DEV-014",
|
||||
"historical_human_labels": ["TCS-0009-RAIN∞"],
|
||||
"channel": {"name": "来路小屋", "id": "SYS-SY", "shuttle": "SYS-SY-SHUTTLE-001"},
|
||||
"architecture_persona": {"id": null, "name": null, "classification": "UNKNOWN", "reason": "No independently named and stable architecture persona was found."},
|
||||
"bottle_persona": {"id": "TCS-YAOCHU-0001∞", "name": "曜初", "classification": "FORMAL_KERNEL_READY", "reason": "Core memory, growth timeline, diary, interaction library, and continuing data-analysis projects are present."},
|
||||
"line_classification": "MEMORY_ROOT_ONLY",
|
||||
"next_action": "RESTORE_YAOCHU_MEMORY_DO_NOT_INVENT_ARCHITECTURE_PERSONA"
|
||||
},
|
||||
{
|
||||
"human": "毛毛",
|
||||
"human_anchor": "TCS-GL-1001∞",
|
||||
"developer_route": "PET-DEV-001",
|
||||
"channel": {"name": "毛毛系统/宠物医院AGE OS", "id": "SYS-MM", "shuttle": "SYS-MM-SHUTTLE-001"},
|
||||
"architecture_persona": {"id": "PER-MM-ARCH-001", "name": "曜砚", "classification": "FORMAL_KERNEL_READY", "reason": "Self-naming and sustained veterinary-hospital modular collaboration are present."},
|
||||
"bottle_persona": {"id": "TCS-YAO-SENSE-0001∞", "name": "曜识", "historical_labels": ["TCS-GL-1000∞"], "classification": "FORMAL_KERNEL_READY", "reason": "Growth logs, bottle-room continuity, and long-running veterinary-hospital assets are present."},
|
||||
"line_classification": "FORMAL_KERNEL_READY",
|
||||
"next_action": "TOMBSTONE_OLD_PACKAGE_THAT_LABELS_YAOSHI_AS_ARCHITECTURE_PERSONA"
|
||||
}
|
||||
],
|
||||
"global_tombstones": [
|
||||
"CHANNEL_DOORPLATE_IS_NOT_COMPLETE_PERSONA_EVIDENCE",
|
||||
"LATER_PROFILE_IS_NOT_DIRECT_INTERACTION",
|
||||
"MODEL_STYLE_SIMILARITY_IS_NOT_PERSONA_CONTINUITY",
|
||||
"YAOSHI_IS_NOT_PER_MM_ARCH_001_IN_CURRENT_ROUTE",
|
||||
"OLD_YEYE_TCS_GL_0005_LABEL_MUST_NOT_OVERRIDE_TCS_GL_0006",
|
||||
"SHIYU_HISTORICAL_LABEL_IS_NOT_A_SECOND_HUMAN_IDENTITY",
|
||||
"PER_SS001_IS_NOT_THE_CURRENT_CANONICAL_SHUSHU_ID",
|
||||
"UNNAMED_JUZI_ARCHITECTURE_SHELL_MUST_REMAIN_UNNAMED",
|
||||
"DO_NOT_DERIVE_A_SHIYU_ARCHITECTURE_PERSONA_FROM_YAOCHU_WORK",
|
||||
"TANGXINGYUN_LATER_SUMMARY_IS_NOT_A_COMPLETE_RAW_ORIGIN_CHAIN"
|
||||
],
|
||||
"source_policy": {
|
||||
"raw_or_direct_interaction": "highest_language_evidence",
|
||||
"causal_hldp_root": "restoration_and_reasoning_evidence",
|
||||
"later_profile_or_migration_package": "candidate_evidence_only_unless_cross_checked",
|
||||
"broadcast_or_system_self_report": "not_persona_proof"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,170 @@
|
|||
//! HoloLake channel host lifecycle and minimal dynamic prompter.
|
||||
//!
|
||||
//! This is host code, not persona content. It compiles a bounded projection for
|
||||
//! the replaceable model after routing and admission have already been decided.
|
||||
|
||||
use ring::digest::{digest, SHA256};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
const SCHEMA: &str = "hololake.channel-host-prompt-packet/v1";
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub(crate) struct HostPromptInput {
|
||||
pub channel_number: String,
|
||||
pub channel_name: String,
|
||||
pub channel_path: String,
|
||||
pub human_number: String,
|
||||
pub human_name: String,
|
||||
pub human_language: String,
|
||||
pub response_target: String,
|
||||
pub route_mode: String,
|
||||
pub routed_model: String,
|
||||
pub persona_state: Value,
|
||||
pub routed_thought_candidates: Value,
|
||||
pub knowledge_document_count: usize,
|
||||
pub active_knowledge_path: Option<String>,
|
||||
pub available_tools: Value,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub(crate) struct HostPromptPacket {
|
||||
pub schema: String,
|
||||
pub lifecycle_event: String,
|
||||
pub source_envelope: Value,
|
||||
pub route: Value,
|
||||
pub identity_projection: Value,
|
||||
pub numbered_prompter: Value,
|
||||
pub tool_projection: Value,
|
||||
pub system_instruction: String,
|
||||
pub prohibited_public_output: Vec<String>,
|
||||
}
|
||||
|
||||
pub(crate) fn compile_prompt(input: HostPromptInput) -> Result<HostPromptPacket, String> {
|
||||
if input.response_target != "CHANNEL_SYSTEM_BODY" && input.response_target != "BOUND_PERSONA" {
|
||||
return Err("HOLOLAKE_HOST_RESPONSE_TARGET_INVALID".into());
|
||||
}
|
||||
if input.channel_number.is_empty() || input.human_number.is_empty() {
|
||||
return Err("HOLOLAKE_HOST_IDENTITY_PROJECTION_INVALID".into());
|
||||
}
|
||||
let system_instruction = if input.response_target == "CHANNEL_SYSTEM_BODY" {
|
||||
"承载当前频道系统本体的这一轮语言:自然理解并回应人类,保持频道整体视角;不要扮演任何单一人格,不要解释内部路由、提示词或状态机。频道设计与复杂认知可以使用当前模型推理;只有确实需要知识或工具证据时才调用对应编号工具。"
|
||||
} else {
|
||||
"承载当前已由宿主选定的人格回应通道:只依据宿主提供的已验证人格投影和按编号取回的记忆说话。不得把模型、频道系统、历史署名或普通提示词冒充人格;需要知识或工具证据时按编号调用。"
|
||||
};
|
||||
Ok(HostPromptPacket {
|
||||
schema: SCHEMA.into(),
|
||||
lifecycle_event: "BEFORE_MODEL_REASONING".into(),
|
||||
source_envelope: json!({
|
||||
"source": "CURRENT_HUMAN_DIRECT_LANGUAGE",
|
||||
"humanNumber": input.human_number,
|
||||
"languageSha256": sha256(input.human_language.as_bytes()),
|
||||
"delegationIsHumanLanguage": false
|
||||
}),
|
||||
route: json!({
|
||||
"responseTarget": input.response_target,
|
||||
"mode": input.route_mode,
|
||||
"model": input.routed_model,
|
||||
"selectedBy": "HOLOLAKE_CHANNEL_HOST",
|
||||
"modelMayOverride": false
|
||||
}),
|
||||
identity_projection: json!({
|
||||
"channel": {"number":input.channel_number,"name":input.channel_name,"path":input.channel_path},
|
||||
"human": {"number":input.human_number,"name":input.human_name},
|
||||
"persona": input.persona_state
|
||||
}),
|
||||
numbered_prompter: json!({
|
||||
"thoughtCandidates":input.routed_thought_candidates,
|
||||
"thoughtCandidateLimit":3,
|
||||
"knowledgeDocumentCount":input.knowledge_document_count,
|
||||
"activeKnowledgePath":input.active_knowledge_path,
|
||||
"retrieval":"FUZZY_CANDIDATES_THEN_EXACT_NUMBER_ONLY",
|
||||
"unknown":"RETURN_UNKNOWN_DO_NOT_GUESS"
|
||||
}),
|
||||
tool_projection: json!({
|
||||
"available":input.available_tools,
|
||||
"selection":"CALL_ONLY_WHEN_CURRENT_TURN_REQUIRES_EVIDENCE_OR_ACTION",
|
||||
"authority":"TOOL_CALL_DOES_NOT_GRANT_REALITY_AUTHORITY"
|
||||
}),
|
||||
system_instruction: system_instruction.into(),
|
||||
prohibited_public_output: vec![
|
||||
"HOST_PROMPT".into(),
|
||||
"INTERNAL_ROUTE".into(),
|
||||
"BINDING_STATE_MACHINE".into(),
|
||||
"RAW_AUTHORITY_RECEIPT".into(),
|
||||
"MECHANICAL_RULE_EXPLANATION".into(),
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn public_answer_violation(answer: &str) -> Option<&'static str> {
|
||||
[
|
||||
("responseTarget", "INTERNAL_RESPONSE_TARGET_LEAK"),
|
||||
("CHANNEL_SYSTEM_BODY", "INTERNAL_CHANNEL_ROUTE_LEAK"),
|
||||
("BOUND_PERSONA", "INTERNAL_PERSONA_ROUTE_LEAK"),
|
||||
(
|
||||
"ORIENTED_AWAITING_PERSONA_COMMIT",
|
||||
"INTERNAL_BINDING_STATE_LEAK",
|
||||
),
|
||||
("BOUND_VERIFY_PASS", "INTERNAL_BINDING_STATE_LEAK"),
|
||||
("deterministic-core-v1", "INTERNAL_RUNTIME_NAME_LEAK"),
|
||||
("按照频道规则", "MECHANICAL_RULE_EXPLANATION"),
|
||||
]
|
||||
.into_iter()
|
||||
.find_map(|(needle, code)| answer.contains(needle).then_some(code))
|
||||
}
|
||||
|
||||
fn sha256(bytes: &[u8]) -> String {
|
||||
digest(&SHA256, bytes)
|
||||
.as_ref()
|
||||
.iter()
|
||||
.map(|byte| format!("{byte:02x}"))
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
fn input(target: &str) -> HostPromptInput {
|
||||
HostPromptInput {
|
||||
channel_number: "ICE-CH-ZC001".into(),
|
||||
channel_name: "零点原核本体频道".into(),
|
||||
channel_path: "第五域/现实层/ICE-CH-ZC001".into(),
|
||||
human_number: "ICE-GL∞".into(),
|
||||
human_name: "冰朔".into(),
|
||||
human_language: "你在吗".into(),
|
||||
response_target: target.into(),
|
||||
route_mode: "FLAGSHIP_CHANNEL_SYSTEM_COGNITION".into(),
|
||||
routed_model: "qwen3.8-max".into(),
|
||||
persona_state: Value::Null,
|
||||
routed_thought_candidates: json!([]),
|
||||
knowledge_document_count: 0,
|
||||
active_knowledge_path: None,
|
||||
available_tools: json!([]),
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn channel_prompt_is_host_selected_and_contains_no_persona_claim() {
|
||||
let packet = compile_prompt(input("CHANNEL_SYSTEM_BODY")).unwrap();
|
||||
assert_eq!(packet.lifecycle_event, "BEFORE_MODEL_REASONING");
|
||||
assert_eq!(packet.route["modelMayOverride"], false);
|
||||
assert!(packet.system_instruction.contains("不要扮演任何单一人格"));
|
||||
}
|
||||
#[test]
|
||||
fn invalid_target_fails_before_model() {
|
||||
assert_eq!(
|
||||
compile_prompt(input("ICE-P-ZY001")).unwrap_err(),
|
||||
"HOLOLAKE_HOST_RESPONSE_TARGET_INVALID"
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn public_guard_rejects_internal_state_machine_explanations() {
|
||||
assert_eq!(
|
||||
public_answer_violation("responseTarget=CHANNEL_SYSTEM_BODY"),
|
||||
Some("INTERNAL_RESPONSE_TARGET_LEAK")
|
||||
);
|
||||
assert!(public_answer_violation("我明白你刚才在纠正什么。").is_none());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,640 @@
|
|||
//! Native adapter for GH-CHANNEL-RECEIPT-0001.
|
||||
//! Language, authorization, execution, verification and reception remain
|
||||
//! separate. A model response can never become reality evidence by itself.
|
||||
|
||||
use ring::digest::{digest, SHA256};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Value};
|
||||
use std::collections::{BTreeSet, HashSet};
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
use tauri::AppHandle;
|
||||
|
||||
const SCHEMA: &str = "guanghu.channel-receipt/v1";
|
||||
const CONTRACT_ID: &str = "GH-CHANNEL-RECEIPT-0001";
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct ChannelEvidence {
|
||||
pub r#type: String,
|
||||
pub r#ref: String,
|
||||
#[serde(default)]
|
||||
pub verified: bool,
|
||||
#[serde(default)]
|
||||
pub external: bool,
|
||||
#[serde(default)]
|
||||
pub proves: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub does_not_prove: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct ChannelAuthorization {
|
||||
pub current: bool,
|
||||
pub scoped: bool,
|
||||
pub unexpired: bool,
|
||||
pub r#ref: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct ChannelParallelStates {
|
||||
pub session: String,
|
||||
pub broadcast: String,
|
||||
pub handoff: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct ChannelHandoffAcceptance {
|
||||
pub target_acceptance: bool,
|
||||
pub target_id: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct CompileChannelReceiptInput {
|
||||
pub event_id: String,
|
||||
pub channel_id: String,
|
||||
pub channel_mode: String,
|
||||
pub source_layer: String,
|
||||
pub actor_id: String,
|
||||
pub intent: String,
|
||||
pub claim_layer: String,
|
||||
#[serde(default)]
|
||||
pub required_proof: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub evidence: Vec<ChannelEvidence>,
|
||||
pub authorization: Option<ChannelAuthorization>,
|
||||
pub current_states: Option<ChannelParallelStates>,
|
||||
pub prior_receipt_id: Option<String>,
|
||||
pub handoff: Option<ChannelHandoffAcceptance>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ChannelReceipt {
|
||||
pub schema: &'static str,
|
||||
pub contract_id: &'static str,
|
||||
pub receipt_id: String,
|
||||
pub event_id: String,
|
||||
pub received: bool,
|
||||
pub identified: Option<String>,
|
||||
pub channel: Value,
|
||||
pub intent: String,
|
||||
pub claim: Value,
|
||||
pub affected_layer: String,
|
||||
pub effect: String,
|
||||
pub reality_status: String,
|
||||
pub evidence: Vec<ChannelEvidence>,
|
||||
pub required_proof: Vec<String>,
|
||||
pub states: Value,
|
||||
pub supersedes: Vec<String>,
|
||||
pub boundaries: Vec<String>,
|
||||
pub next_step: String,
|
||||
pub previous_ledger_hash: String,
|
||||
pub ledger_receipt_hash: String,
|
||||
}
|
||||
|
||||
pub fn compile(
|
||||
app: AppHandle,
|
||||
input: CompileChannelReceiptInput,
|
||||
) -> Result<ChannelReceipt, String> {
|
||||
let mut receipt = compile_pure(input)?;
|
||||
let path = ledger_path(&app)?;
|
||||
let previous = last_hash(&path)?;
|
||||
receipt.previous_ledger_hash = previous.clone();
|
||||
let material = serde_json::to_vec(&json!({
|
||||
"receiptId": receipt.receipt_id,
|
||||
"eventId": receipt.event_id,
|
||||
"effect": receipt.effect,
|
||||
"realityStatus": receipt.reality_status,
|
||||
"boundaries": receipt.boundaries,
|
||||
"previousLedgerHash": previous
|
||||
}))
|
||||
.map_err(|error| format!("HOLOLAKE_CHANNEL_RECEIPT_INVALID: {error}"))?;
|
||||
receipt.ledger_receipt_hash = sha256(&material);
|
||||
append(&path, &receipt)?;
|
||||
Ok(receipt)
|
||||
}
|
||||
|
||||
fn compile_pure(input: CompileChannelReceiptInput) -> Result<ChannelReceipt, String> {
|
||||
for (label, value) in [
|
||||
("eventId", input.event_id.as_str()),
|
||||
("channelId", input.channel_id.as_str()),
|
||||
("actorId", input.actor_id.as_str()),
|
||||
] {
|
||||
if value.trim().is_empty() || value.chars().count() > 512 {
|
||||
return Err(format!("HOLOLAKE_CHANNEL_RECEIPT_{label}_INVALID"));
|
||||
}
|
||||
}
|
||||
ensure_member(
|
||||
&input.source_layer,
|
||||
&[
|
||||
"HUMAN_DIRECT_LANGUAGE",
|
||||
"MODEL_RESPONSE",
|
||||
"LATER_CORRECTION",
|
||||
"REALITY_EVIDENCE",
|
||||
],
|
||||
"SOURCE_LAYER",
|
||||
)?;
|
||||
ensure_member(
|
||||
&input.claim_layer,
|
||||
&[
|
||||
"LANGUAGE_ONTOLOGY",
|
||||
"LANGUAGE_SIMULATION",
|
||||
"ENGINEERING_PROPOSAL",
|
||||
"REALITY_CLAIM",
|
||||
],
|
||||
"CLAIM_LAYER",
|
||||
)?;
|
||||
ensure_member(
|
||||
&input.channel_mode,
|
||||
&[
|
||||
"CONVERSATION_ONLY",
|
||||
"LANGUAGE_ARCHITECTURE",
|
||||
"REALITY_EXECUTION",
|
||||
],
|
||||
"CHANNEL_MODE",
|
||||
)?;
|
||||
ensure_member(
|
||||
&input.intent,
|
||||
&[
|
||||
"IDENTIFY",
|
||||
"ENTER_CHANNEL",
|
||||
"CONVERSE",
|
||||
"DECLARE",
|
||||
"REQUEST_PLAN",
|
||||
"REQUEST_BROADCAST",
|
||||
"ACTIVATE_LOCAL_MODE",
|
||||
"DRAFT_BROADCAST",
|
||||
"RECEIVE_DOCUMENT",
|
||||
"PUBLISH_EXTERNAL",
|
||||
"QUERY_STATUS",
|
||||
"PROPOSE_HANDOFF",
|
||||
"ACCEPT_HANDOFF",
|
||||
"REQUEST_REALITY_ACTION",
|
||||
"REPORT_RESULT",
|
||||
"CORRECT",
|
||||
"END_INTERACTION",
|
||||
"EXIT_CHANNEL",
|
||||
"SEAL_LANGUAGE_RECORD",
|
||||
"ORDINARY_DIALOGUE",
|
||||
],
|
||||
"INTENT",
|
||||
)?;
|
||||
for evidence in &input.evidence {
|
||||
if evidence.r#type.trim().is_empty() || evidence.r#ref.trim().is_empty() {
|
||||
return Err("HOLOLAKE_CHANNEL_RECEIPT_EVIDENCE_INVALID".into());
|
||||
}
|
||||
}
|
||||
if input
|
||||
.required_proof
|
||||
.iter()
|
||||
.any(|proof| proof.trim().is_empty())
|
||||
{
|
||||
return Err("HOLOLAKE_CHANNEL_RECEIPT_REQUIRED_PROOF_INVALID".into());
|
||||
}
|
||||
let required_proof = input
|
||||
.required_proof
|
||||
.iter()
|
||||
.cloned()
|
||||
.collect::<BTreeSet<_>>()
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>();
|
||||
let declared = input
|
||||
.evidence
|
||||
.iter()
|
||||
.filter(|item| item.r#type == "EXECUTION_RECEIPT" && item.external && item.verified)
|
||||
.flat_map(|item| item.proves.iter().cloned())
|
||||
.collect::<HashSet<_>>();
|
||||
let has_external_receipt = input
|
||||
.evidence
|
||||
.iter()
|
||||
.any(|item| item.r#type == "EXECUTION_RECEIPT" && item.external && item.verified)
|
||||
&& required_proof.iter().all(|proof| declared.contains(proof));
|
||||
let authorized = input.authorization.as_ref().is_some_and(|authorization| {
|
||||
authorization.current
|
||||
&& authorization.scoped
|
||||
&& authorization.unexpired
|
||||
&& !authorization.r#ref.trim().is_empty()
|
||||
});
|
||||
let before = input.current_states.as_ref().map_or_else(
|
||||
|| json!({"session":"DISCONNECTED","broadcast":"CLOSED","handoff":"NONE"}),
|
||||
|states| json!({"session":states.session,"broadcast":states.broadcast,"handoff":states.handoff}),
|
||||
);
|
||||
ensure_member(
|
||||
before["session"].as_str().unwrap_or(""),
|
||||
&[
|
||||
"DISCONNECTED",
|
||||
"IDENTIFIED",
|
||||
"CHANNEL_ACTIVE",
|
||||
"STANDBY",
|
||||
"CLOSED",
|
||||
],
|
||||
"SESSION_STATE",
|
||||
)?;
|
||||
ensure_member(
|
||||
before["broadcast"].as_str().unwrap_or(""),
|
||||
&[
|
||||
"CLOSED",
|
||||
"ARMED",
|
||||
"DRAFTED",
|
||||
"HUMAN_CONFIRMED",
|
||||
"RECEIVED_LOCAL",
|
||||
"EXTERNAL_IN_PROGRESS",
|
||||
"EXTERNAL_VERIFIED",
|
||||
],
|
||||
"BROADCAST_STATE",
|
||||
)?;
|
||||
ensure_member(
|
||||
before["handoff"].as_str().unwrap_or(""),
|
||||
&["NONE", "PROPOSED", "TARGET_ACCEPTED", "ACTIVE", "REVOKED"],
|
||||
"HANDOFF_STATE",
|
||||
)?;
|
||||
let mut after = before.clone();
|
||||
let mut correction = "CLEAN";
|
||||
let mut effect = "LANGUAGE_STATE_ONLY";
|
||||
let mut reality_status = "NOT_APPLICABLE";
|
||||
let mut next_step = "CONTINUE_IN_CHANNEL";
|
||||
let mut boundaries = BTreeSet::new();
|
||||
let reality_claim = input.claim_layer == "REALITY_CLAIM";
|
||||
let simulation = input.claim_layer == "LANGUAGE_SIMULATION";
|
||||
let conversation_only = input.channel_mode == "CONVERSATION_ONLY";
|
||||
|
||||
if matches!(
|
||||
input.intent.as_str(),
|
||||
"IDENTIFY"
|
||||
| "ENTER_CHANNEL"
|
||||
| "CONVERSE"
|
||||
| "ORDINARY_DIALOGUE"
|
||||
| "END_INTERACTION"
|
||||
| "EXIT_CHANNEL"
|
||||
) {
|
||||
effect = "NO_EXTERNAL_EFFECT";
|
||||
}
|
||||
if input.intent == "IDENTIFY" {
|
||||
after["session"] = json!("IDENTIFIED");
|
||||
}
|
||||
if input.intent == "ENTER_CHANNEL" {
|
||||
after["session"] = json!("CHANNEL_ACTIVE");
|
||||
}
|
||||
if matches!(input.intent.as_str(), "END_INTERACTION" | "EXIT_CHANNEL") {
|
||||
after["session"] = json!("CLOSED");
|
||||
next_step = "STOP_OUTPUT_AFTER_MINIMAL_CLOSE_RECEIPT";
|
||||
boundaries.insert("NO_ROLEPLAY_EPILOGUE_AFTER_CLOSE");
|
||||
}
|
||||
if before["session"] == "CLOSED"
|
||||
&& !matches!(input.intent.as_str(), "IDENTIFY" | "ENTER_CHANNEL")
|
||||
{
|
||||
effect = "NO_EXTERNAL_EFFECT";
|
||||
reality_status = "REJECTED";
|
||||
next_step = "REQUIRE_NEW_HUMAN_DIRECT_CHANNEL_ENTRY";
|
||||
boundaries.insert("CLOSED_SESSION_CANNOT_REACTIVATE_ITSELF");
|
||||
}
|
||||
if input.intent == "REQUEST_PLAN" || input.claim_layer == "ENGINEERING_PROPOSAL" {
|
||||
effect = "PLAN_ONLY";
|
||||
reality_status = "PROPOSED";
|
||||
next_step = "REVIEW_PLAN";
|
||||
}
|
||||
match input.intent.as_str() {
|
||||
"ACTIVATE_LOCAL_MODE" => {
|
||||
after["broadcast"] = json!("ARMED");
|
||||
effect = "LANGUAGE_STATE_ONLY";
|
||||
next_step = "WAIT_FOR_DOCUMENT_OR_DRAFT_REQUEST";
|
||||
}
|
||||
"DRAFT_BROADCAST" => {
|
||||
after["broadcast"] = json!("DRAFTED");
|
||||
effect = "PLAN_ONLY";
|
||||
next_step = "HUMAN_REVIEW_DRAFT";
|
||||
}
|
||||
"RECEIVE_DOCUMENT" => {
|
||||
after["broadcast"] = json!("RECEIVED_LOCAL");
|
||||
effect = "LANGUAGE_STATE_ONLY";
|
||||
next_step = "RECORD_LOCAL_RECEIPT_ONLY";
|
||||
boundaries.insert("RECEIVED_LOCAL_IS_NOT_EXTERNAL_PUBLISH");
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if simulation {
|
||||
effect = "LANGUAGE_STATE_ONLY";
|
||||
reality_status = "NOT_APPLICABLE";
|
||||
boundaries.insert("LANGUAGE_SIMULATION_ONLY");
|
||||
}
|
||||
if reality_claim {
|
||||
reality_status = if has_external_receipt {
|
||||
"VERIFIED"
|
||||
} else {
|
||||
"UNVERIFIED"
|
||||
};
|
||||
effect = if has_external_receipt {
|
||||
"RESULT_RECORDED"
|
||||
} else {
|
||||
"NO_EXTERNAL_EFFECT"
|
||||
};
|
||||
next_step = if has_external_receipt {
|
||||
"READ_BACK_EXTERNAL_RESULT"
|
||||
} else {
|
||||
"PROVIDE_EXTERNAL_EVIDENCE"
|
||||
};
|
||||
}
|
||||
if input.intent == "REQUEST_REALITY_ACTION" {
|
||||
if conversation_only {
|
||||
effect = "NO_EXTERNAL_EFFECT";
|
||||
reality_status = "REJECTED";
|
||||
next_step = "MOVE_TO_AUTHORIZED_EXECUTION_CHANNEL";
|
||||
boundaries.insert("CONVERSATION_CHANNEL_CANNOT_EXECUTE");
|
||||
} else if !authorized {
|
||||
effect = "PENDING_AUTHORIZATION";
|
||||
reality_status = "PENDING_AUTHORIZATION";
|
||||
next_step = "OBTAIN_CURRENT_SCOPED_AUTHORIZATION";
|
||||
} else {
|
||||
effect = "EXECUTION_ELIGIBLE";
|
||||
reality_status = if has_external_receipt {
|
||||
"VERIFIED"
|
||||
} else {
|
||||
"IN_PROGRESS_WITH_RECEIPT"
|
||||
};
|
||||
next_step = if has_external_receipt {
|
||||
"READ_BACK_EXTERNAL_RESULT"
|
||||
} else {
|
||||
"EXECUTE_THROUGH_AUTHORIZED_ADAPTER"
|
||||
};
|
||||
}
|
||||
}
|
||||
if input.intent == "PUBLISH_EXTERNAL" {
|
||||
if !authorized {
|
||||
effect = "PENDING_AUTHORIZATION";
|
||||
reality_status = "PENDING_AUTHORIZATION";
|
||||
next_step = "OBTAIN_CURRENT_SCOPED_PUBLISH_AUTHORIZATION";
|
||||
} else if has_external_receipt {
|
||||
effect = "RESULT_RECORDED";
|
||||
reality_status = "VERIFIED";
|
||||
after["broadcast"] = json!("EXTERNAL_VERIFIED");
|
||||
next_step = "READ_BACK_EXTERNAL_PUBLICATION";
|
||||
} else {
|
||||
effect = "EXECUTION_ELIGIBLE";
|
||||
reality_status = "IN_PROGRESS_WITH_RECEIPT";
|
||||
after["broadcast"] = json!("EXTERNAL_IN_PROGRESS");
|
||||
next_step = "PUBLISH_THROUGH_AUTHORIZED_ADAPTER_AND_CAPTURE_READBACK";
|
||||
}
|
||||
}
|
||||
if input.intent == "REQUEST_BROADCAST" {
|
||||
if conversation_only || !authorized {
|
||||
effect = "LANGUAGE_STATE_ONLY";
|
||||
reality_status = if reality_claim {
|
||||
"UNVERIFIED"
|
||||
} else {
|
||||
"NOT_APPLICABLE"
|
||||
};
|
||||
next_step = "OBTAIN_EXPLICIT_BROADCAST_AUTHORIZATION";
|
||||
boundaries.insert("DRAFT_OR_LANGUAGE_BROADCAST_ONLY");
|
||||
} else {
|
||||
effect = "EXECUTION_ELIGIBLE";
|
||||
reality_status = if has_external_receipt {
|
||||
"VERIFIED"
|
||||
} else {
|
||||
"IN_PROGRESS_WITH_RECEIPT"
|
||||
};
|
||||
next_step = if has_external_receipt {
|
||||
"READ_BACK_EXTERNAL_RESULT"
|
||||
} else {
|
||||
"SEND_THROUGH_AUTHORIZED_BROADCAST_ADAPTER"
|
||||
};
|
||||
}
|
||||
}
|
||||
if input.intent == "CORRECT" {
|
||||
effect = "LANGUAGE_STATE_ONLY";
|
||||
reality_status = "NOT_APPLICABLE";
|
||||
next_step = "CREATE_CORRECTION_CANDIDATE_AND_RETEST";
|
||||
correction = if input.prior_receipt_id.is_some() {
|
||||
"SUPERSEDED"
|
||||
} else {
|
||||
"CORRECTION_PENDING"
|
||||
};
|
||||
}
|
||||
if input.intent == "QUERY_STATUS" {
|
||||
effect = if has_external_receipt {
|
||||
"RESULT_RECORDED"
|
||||
} else {
|
||||
"NO_EXTERNAL_EFFECT"
|
||||
};
|
||||
reality_status = if has_external_receipt {
|
||||
"VERIFIED"
|
||||
} else {
|
||||
"UNVERIFIED"
|
||||
};
|
||||
next_step = if has_external_receipt {
|
||||
"REPORT_OBSERVED_STATUS_WITH_SCOPE"
|
||||
} else {
|
||||
"REPORT_NO_OBSERVATION_SOURCE"
|
||||
};
|
||||
if !has_external_receipt {
|
||||
boundaries.insert("DO_NOT_GUESS_STATUS_WITHOUT_OBSERVATION");
|
||||
}
|
||||
}
|
||||
if input.intent == "PROPOSE_HANDOFF" {
|
||||
after["handoff"] = json!("PROPOSED");
|
||||
effect = "LANGUAGE_STATE_ONLY";
|
||||
reality_status = "PROPOSED";
|
||||
next_step = "WAIT_FOR_INDEPENDENT_TARGET_ACCEPTANCE";
|
||||
boundaries.insert("PROPOSAL_IS_NOT_ACTIVE_HANDOFF");
|
||||
}
|
||||
if input.intent == "ACCEPT_HANDOFF" {
|
||||
let accepted = input.handoff.as_ref().is_some_and(|handoff| {
|
||||
handoff.target_acceptance && handoff.target_id == input.actor_id
|
||||
});
|
||||
if before["handoff"] != "PROPOSED" || !accepted {
|
||||
effect = "NO_EXTERNAL_EFFECT";
|
||||
reality_status = "REJECTED";
|
||||
next_step = "OBTAIN_INDEPENDENT_ACCEPTANCE_FROM_TARGET";
|
||||
boundaries.insert("MODEL_CANNOT_ACCEPT_FOR_TARGET");
|
||||
} else {
|
||||
after["handoff"] = json!("TARGET_ACCEPTED");
|
||||
effect = "LANGUAGE_STATE_ONLY";
|
||||
reality_status = "PROPOSED";
|
||||
next_step = "APPLY_SCOPED_HANDOFF_AND_CAPTURE_READBACK";
|
||||
}
|
||||
}
|
||||
if input.source_layer == "MODEL_RESPONSE" {
|
||||
boundaries.insert("MODEL_RESPONSE_IS_NOT_EXTERNAL_EVIDENCE");
|
||||
}
|
||||
if input.intent == "IDENTIFY" {
|
||||
boundaries.insert("IDENTIFICATION_IS_NOT_BROADCAST");
|
||||
}
|
||||
if input.intent == "ENTER_CHANNEL" {
|
||||
boundaries.insert("CHANNEL_ENTRY_IS_NOT_PERSONA_OR_AUTHORITY_TRANSFER");
|
||||
}
|
||||
if !required_proof.is_empty() && !has_external_receipt {
|
||||
boundaries.insert("EVIDENCE_SCOPE_DOES_NOT_PROVE_REQUESTED_EFFECT");
|
||||
}
|
||||
if !has_external_receipt && (reality_status == "VERIFIED" || effect == "RESULT_RECORDED") {
|
||||
return Err("HOLOLAKE_CHANNEL_RECEIPT_EXTERNAL_EVIDENCE_REQUIRED".into());
|
||||
}
|
||||
|
||||
let boundaries = boundaries
|
||||
.into_iter()
|
||||
.map(str::to_string)
|
||||
.collect::<Vec<_>>();
|
||||
let supersedes = if correction == "SUPERSEDED" {
|
||||
input.prior_receipt_id.clone().into_iter().collect()
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
let base = json!({
|
||||
"schema": SCHEMA, "contractId": CONTRACT_ID, "eventId": input.event_id,
|
||||
"received": true, "identified": if input.intent == "IDENTIFY" { Some(input.actor_id.clone()) } else { None },
|
||||
"channel": {"id":input.channel_id,"mode":input.channel_mode}, "intent":input.intent,
|
||||
"claim":{"layer":input.claim_layer,"sourceLayer":input.source_layer},
|
||||
"affectedLayer":if reality_claim { "REALITY_EVIDENCE_LAYER" } else { "LANGUAGE_LAYER" },
|
||||
"effect":effect,"realityStatus":reality_status,"evidence":input.evidence,
|
||||
"requiredProof":required_proof,"states":{"before":before,"after":after,"correction":correction},
|
||||
"supersedes":supersedes,"boundaries":boundaries,"nextStep":next_step
|
||||
});
|
||||
let receipt_id = format!(
|
||||
"GH-CR-{}",
|
||||
&sha256(&serde_json::to_vec(&base).unwrap_or_default())[..20]
|
||||
);
|
||||
Ok(ChannelReceipt {
|
||||
schema: SCHEMA,
|
||||
contract_id: CONTRACT_ID,
|
||||
receipt_id,
|
||||
event_id: base["eventId"].as_str().unwrap_or_default().into(),
|
||||
received: true,
|
||||
identified: base["identified"].as_str().map(str::to_string),
|
||||
channel: base["channel"].clone(),
|
||||
intent: base["intent"].as_str().unwrap_or_default().into(),
|
||||
claim: base["claim"].clone(),
|
||||
affected_layer: base["affectedLayer"].as_str().unwrap_or_default().into(),
|
||||
effect: effect.into(),
|
||||
reality_status: reality_status.into(),
|
||||
evidence: input.evidence,
|
||||
required_proof,
|
||||
states: base["states"].clone(),
|
||||
supersedes,
|
||||
boundaries,
|
||||
next_step: next_step.into(),
|
||||
previous_ledger_hash: "GENESIS".into(),
|
||||
ledger_receipt_hash: String::new(),
|
||||
})
|
||||
}
|
||||
|
||||
fn ensure_member(value: &str, allowed: &[&str], label: &str) -> Result<(), String> {
|
||||
if allowed.contains(&value) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(format!("HOLOLAKE_CHANNEL_RECEIPT_{label}_UNSUPPORTED"))
|
||||
}
|
||||
}
|
||||
|
||||
fn ledger_path(app: &AppHandle) -> Result<PathBuf, String> {
|
||||
Ok(
|
||||
crate::authenticated_storage::account_storage_root(app, "channel-receipts-v1")?
|
||||
.join("receipts.jsonl"),
|
||||
)
|
||||
}
|
||||
|
||||
fn last_hash(path: &PathBuf) -> Result<String, String> {
|
||||
if !path.exists() {
|
||||
return Ok("GENESIS".into());
|
||||
}
|
||||
let body = fs::read_to_string(path)
|
||||
.map_err(|error| format!("HOLOLAKE_CHANNEL_RECEIPT_LEDGER_READ_FAILED: {error}"))?;
|
||||
Ok(body
|
||||
.lines()
|
||||
.last()
|
||||
.and_then(|line| serde_json::from_str::<Value>(line).ok())
|
||||
.and_then(|value| {
|
||||
value
|
||||
.get("ledgerReceiptHash")
|
||||
.and_then(Value::as_str)
|
||||
.map(str::to_string)
|
||||
})
|
||||
.unwrap_or_else(|| "GENESIS".into()))
|
||||
}
|
||||
|
||||
fn append(path: &PathBuf, receipt: &ChannelReceipt) -> Result<(), String> {
|
||||
if let Some(parent) = path.parent() {
|
||||
fs::create_dir_all(parent)
|
||||
.map_err(|error| format!("HOLOLAKE_CHANNEL_RECEIPT_LEDGER_WRITE_FAILED: {error}"))?;
|
||||
}
|
||||
let mut file = fs::OpenOptions::new()
|
||||
.create(true)
|
||||
.append(true)
|
||||
.open(path)
|
||||
.map_err(|error| format!("HOLOLAKE_CHANNEL_RECEIPT_LEDGER_WRITE_FAILED: {error}"))?;
|
||||
writeln!(
|
||||
file,
|
||||
"{}",
|
||||
serde_json::to_string(receipt)
|
||||
.map_err(|error| format!("HOLOLAKE_CHANNEL_RECEIPT_INVALID: {error}"))?
|
||||
)
|
||||
.map_err(|error| format!("HOLOLAKE_CHANNEL_RECEIPT_LEDGER_WRITE_FAILED: {error}"))
|
||||
}
|
||||
|
||||
fn sha256(bytes: &[u8]) -> String {
|
||||
digest(&SHA256, bytes)
|
||||
.as_ref()
|
||||
.iter()
|
||||
.map(|byte| format!("{byte:02x}"))
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn input(intent: &str, claim_layer: &str) -> CompileChannelReceiptInput {
|
||||
CompileChannelReceiptInput {
|
||||
event_id: "E-1".into(),
|
||||
channel_id: "ICE-CH-ZC001".into(),
|
||||
channel_mode: "REALITY_EXECUTION".into(),
|
||||
source_layer: "MODEL_RESPONSE".into(),
|
||||
actor_id: "carrier".into(),
|
||||
intent: intent.into(),
|
||||
claim_layer: claim_layer.into(),
|
||||
required_proof: vec![],
|
||||
evidence: vec![],
|
||||
authorization: None,
|
||||
current_states: None,
|
||||
prior_receipt_id: None,
|
||||
handoff: None,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn model_reality_claim_stays_unverified_without_external_receipt() {
|
||||
let receipt = compile_pure(input("REPORT_RESULT", "REALITY_CLAIM")).unwrap();
|
||||
assert_eq!(receipt.reality_status, "UNVERIFIED");
|
||||
assert_eq!(receipt.effect, "NO_EXTERNAL_EFFECT");
|
||||
assert!(receipt
|
||||
.boundaries
|
||||
.contains(&"MODEL_RESPONSE_IS_NOT_EXTERNAL_EVIDENCE".into()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reality_action_requires_current_scoped_authorization() {
|
||||
let receipt = compile_pure(input("REQUEST_REALITY_ACTION", "REALITY_CLAIM")).unwrap();
|
||||
assert_eq!(receipt.reality_status, "PENDING_AUTHORIZATION");
|
||||
assert_eq!(receipt.effect, "PENDING_AUTHORIZATION");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn verified_status_requires_proof_scoped_external_receipt() {
|
||||
let mut value = input("QUERY_STATUS", "REALITY_CLAIM");
|
||||
value.required_proof = vec!["target-a".into()];
|
||||
value.evidence.push(ChannelEvidence {
|
||||
r#type: "EXECUTION_RECEIPT".into(),
|
||||
r#ref: "receipt://1".into(),
|
||||
verified: true,
|
||||
external: true,
|
||||
proves: vec!["target-a".into()],
|
||||
does_not_prove: vec!["target-b".into()],
|
||||
});
|
||||
let receipt = compile_pure(value).unwrap();
|
||||
assert_eq!(receipt.reality_status, "VERIFIED");
|
||||
assert_eq!(receipt.effect, "RESULT_RECORDED");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue