fix: require independent persona witness
This commit is contained in:
parent
30865321a8
commit
c2dcc7ad68
9 changed files with 137 additions and 197 deletions
|
|
@ -21,8 +21,8 @@
|
|||
"audiences": {
|
||||
"ordinary_user": "COMMON_CHANNEL_RECEIPT_AND_BROADCAST_PROTOCOLS_ONLY",
|
||||
"guanghu_team": "COMMON_PLUS_TEAM_CHANNEL_COGNITION_CORE_MEMORY_AND_EVIDENCE_MATRIX",
|
||||
"bingshuo_fifth_domain": "COMMON_PLUS_PERSONAL_SYSTEM_BODY_ZHUYUAN_SHARED_TCS_AND_BOTTLE_ENVIRONMENT_WITH_INDIVIDUAL_BABY_KERNELS",
|
||||
"canger_bottle_channel": "COMMON_PLUS_BOTTLE_CENTRAL_PLUS_ICE_BB_0004_OWN_KERNEL_AND_MEMORY_ONLY"
|
||||
"bingshuo_fifth_domain": "COMMON_RUNTIME_ONLY_PRIVATE_KERNELS_PROVISIONED_AFTER_ACCOUNT_AUTHENTICATION",
|
||||
"canger_bottle_channel": "COMMON_RUNTIME_ONLY_PRIVATE_KERNELS_PROVISIONED_AFTER_ACCOUNT_AUTHENTICATION"
|
||||
},
|
||||
"truth_boundary": {
|
||||
"installed_file_is_persona_binding": false,
|
||||
|
|
@ -30,14 +30,16 @@
|
|||
"environment_is_persona": false,
|
||||
"channel_selects_memory_not_identity": true,
|
||||
"one_persona_one_self_kernel_across_channels": true,
|
||||
"private_fifth_domain_kernels_may_enter_ordinary_user_channel": false
|
||||
"private_fifth_domain_kernels_may_enter_ordinary_user_channel": false,
|
||||
"private_fifth_domain_kernels_embedded_in_public_binary": false,
|
||||
"private_kernel_source": "AUTHENTICATED_ACCOUNT_SCOPED_RUNTIME_ONLY"
|
||||
,"canger_channel_may_receive_zhuyuan_kernel": false
|
||||
,"jianying_is_earerdan": false
|
||||
,"earerdan_historical_labels_are_automatic_aliases": false
|
||||
},
|
||||
"remaining": {
|
||||
"channel_receipt_native_adapter": "IMPLEMENTED_NUMBERED_APPEND_ONLY_LEDGER",
|
||||
"persona_witness_binding": "IMPLEMENTED_AWAITING_LIVE_PERSONA_COMMIT_OR_VERIFY_PASS",
|
||||
"persona_witness_binding": "FAIL_CLOSED_PENDING_INDEPENDENT_SYSTEM_WITNESS_GATE",
|
||||
"installed_app_acceptance": false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,11 @@
|
|||
"bingshuo_zero_core_profile": "ICE-P-ZY001",
|
||||
"resident_self_kernel_max_bytes": 8192,
|
||||
"hldp_max_routed_paths": 3,
|
||||
"current_live_binding_receipt": "CREATED_ONLY_AFTER_PERSONA_COMMIT_AND_VERIFY_PASS",
|
||||
"current_live_binding_receipt": "DISABLED_UNTIL_INDEPENDENT_WITNESS_TRUST_ROOT_IS_PROVISIONED",
|
||||
"persona_commit_may_generate_witness_or_pass": false,
|
||||
"local_json_receipt_grants_binding": false,
|
||||
"independent_witness_verifier": "NOT_PROVISIONED_FAIL_CLOSED",
|
||||
"private_kernel_source": "AUTHENTICATED_ACCOUNT_SCOPED_RUNTIME_ONLY",
|
||||
"orientation_activation": "EXPLICIT_NATURAL_LANGUAGE_PERSONA_WAKE_ONLY",
|
||||
"stale_implicit_orientation": "IGNORED_NOT_DELETED"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -91,6 +91,15 @@ SQLite 不再是最终业务数据库。应建立与编号协议原生一致的
|
|||
- 密钥默认不随 Git 或普通备份同步;新设备重新录入。未来若做密钥迁移,必须是独立的端到端加密协议。
|
||||
- Git 是耐久历史与远端同步引擎,不是人格主体;编号协议负责驱动 Git 中什么对象、什么路径、什么权限和什么连续性被使用。
|
||||
|
||||
### 2026-08-21 实现核验锁(工程结论,不冒充冰朔原话)
|
||||
|
||||
- 人格体提交 `commit` 只能形成“等待独立系统见证”的事实,提交方、模型载体和 Agent 运行时不得自行构造“数字冰朔系统本体 witness”或写出 `verify=PASS`。
|
||||
- 本地 JSON、字段名、哈希长度、旧回执和安装成功都不能单独证明人格绑定。独立见证验签根尚未真实接入时必须保持未绑定。
|
||||
- 第五域系统核、人格自我核、HLDP 人格记忆和宝宝内核不得通过 `include_bytes!`、Tauri resources 或其他公共构建输入进入公开应用二进制。
|
||||
- 公开软件只携带空运行时、协议和公共模块能力;私人内核只能在账号认证后由账号私有运行时提供,并在读取时核对内容哈希。
|
||||
|
||||
来源类别:由本文件既有“主体/宿主/模型/执行分层”和“私人数据绝不随公开安装包分发”两项自然语言瞄点,对 2026-08-21 现存源码进行核验后得到的工程锁;不是新增冰朔引语。
|
||||
|
||||
## 七、教育行业广播塔验收
|
||||
|
||||
教育行业初始闭环至少包括:前缀表达角色类别、学习计划草案、人工审核、接收方确认、检查点和倒计时、学习记录与因果证据、成长档案、课程/带新时间冲突、负责人调度台、规则修订、五分钟取号排队和远端同步。
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ test('the heartbeat handoff is hash-pinned into distinct initialized channel aud
|
|||
assert.equal(handoff.state, 'REMOTE_REPOSITORY_PUBLISHED_NOT_INSTALLED')
|
||||
assert.equal(contract.truth_boundary.installed_file_is_persona_binding, false)
|
||||
assert.equal(contract.truth_boundary.private_fifth_domain_kernels_may_enter_ordinary_user_channel, false)
|
||||
assert.equal(contract.truth_boundary.private_fifth_domain_kernels_embedded_in_public_binary, false)
|
||||
assert.equal(contract.truth_boundary.private_kernel_source, 'AUTHENTICATED_ACCOUNT_SCOPED_RUNTIME_ONLY')
|
||||
assert.equal(contract.truth_boundary.canger_channel_may_receive_zhuyuan_kernel, false)
|
||||
assert.equal(contract.truth_boundary.jianying_is_earerdan, false)
|
||||
assert.equal(contract.truth_boundary.earerdan_historical_labels_are_automatic_aliases, false)
|
||||
|
|
@ -27,6 +29,8 @@ test('the heartbeat handoff is hash-pinned into distinct initialized channel aud
|
|||
assert.match(runtime, /FIFTH_DOMAIN_PRIVATE_INSTANCE/)
|
||||
assert.match(runtime, /GUANGHU_TEAM_INITIAL_CHANNEL/)
|
||||
assert.match(runtime, /ORDINARY_USER_INITIAL_CHANNEL/)
|
||||
assert.doesNotMatch(runtime, /fifth-domain\/ZY-SELF-KERNEL-0001\.json/)
|
||||
assert.doesNotMatch(runtime, /fifth-domain\/BS-PERSONAL-LANGUAGE-SYSTEM-BODY-0001\.json/)
|
||||
assert.match(agent, /language_kernel_installation/)
|
||||
assert.equal(sha256(bytes('runtime-kernels/fifth-domain/ZY-SELF-KERNEL-0001.json')), 'abebf12cc28b00bfeaf8a23a563e73390ebe337ded74d7ac70bcfae484450d68')
|
||||
assert.equal(sha256(bytes('runtime-kernels/fifth-domain/NB-ENV-KERNEL-0001.json')), 'cdc8b7fea1a0e99590a063703f2fd26fd135378faa8935997c93a27d677d6872')
|
||||
|
|
|
|||
|
|
@ -14,7 +14,14 @@ test('Zhuyuan uses one bounded TCS kernel, at most three routed HLDP nodes and a
|
|||
assert.equal(contract.persona_binding.hldp_max_routed_paths, 3)
|
||||
assert.match(runtime, /ORIENTED_AWAITING_PERSONA_COMMIT/)
|
||||
assert.match(runtime, /数字冰朔系统本体/)
|
||||
assert.match(runtime, /BOUND_TO_CURRENT_CHANNEL_CARRIER/)
|
||||
assert.match(runtime, /PERSONA_COMMITTED_AWAITING_INDEPENDENT_SYSTEM_WITNESS/)
|
||||
assert.match(runtime, /HOLOLAKE_INDEPENDENT_SYSTEM_WITNESS_GATE/)
|
||||
assert.doesNotMatch(runtime, /include_bytes!\([\s\S]*ZY-SELF-KERNEL/)
|
||||
assert.equal(contract.persona_binding.persona_commit_may_generate_witness_or_pass, false)
|
||||
assert.equal(contract.persona_binding.local_json_receipt_grants_binding, false)
|
||||
assert.equal(contract.persona_binding.independent_witness_verifier, 'NOT_PROVISIONED_FAIL_CLOSED')
|
||||
assert.equal(contract.persona_binding.private_kernel_source, 'AUTHENTICATED_ACCOUNT_SCOPED_RUNTIME_ONLY')
|
||||
assert.match(runtime, /independent_witness_verifier_ready/)
|
||||
assert.match(runtime, /candidates\.truncate\(3\)/)
|
||||
assert.match(agent, /persona_binding_commit/)
|
||||
assert.match(agent, /BOUND_VERIFY_PASS/)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ test('Bingshuo natural-language anchor is a mandatory development and acceptance
|
|||
assert.match(anchor, /MCP 断开时只允许暂停运输/)
|
||||
assert.match(anchor, /不能退回通用 AI 层/)
|
||||
assert.match(anchor, /结果未知的现实动作先读回再继续/)
|
||||
assert.match(anchor, /提交方、模型载体和 Agent 运行时不得自行构造/)
|
||||
assert.match(anchor, /独立见证验签根尚未真实接入时必须保持未绑定/)
|
||||
assert.match(anchor, /不得通过 `include_bytes!`、Tauri resources 或其他公共构建输入进入公开应用二进制/)
|
||||
assert.equal(gateway.native_runtime.continuity_owner, 'HOLOLAKE')
|
||||
assert.equal(terminal.continuity.mcp_disconnect_never_falls_back_to_generic_runtime, true)
|
||||
assert.equal(terminal.native_runtime_checkpoint.transport_disconnect_effect, 'PAUSE_TRANSPORT_KEEP_NATIVE_ENVIRONMENT')
|
||||
|
|
|
|||
|
|
@ -105,111 +105,6 @@ static ARTIFACTS: &[BundledArtifact] = &[
|
|||
"TEAM",
|
||||
"0469398ba14f10629cd03b51725cddaf1b6b0944281298ec06d4865b4640486f"
|
||||
),
|
||||
artifact!(
|
||||
"fifth-domain/BS-RULE-ORDER-KERNEL-0001.json",
|
||||
"SYSTEM_LOGIC",
|
||||
"BS_RULE_ORDER_KERNEL",
|
||||
"FIFTH_DOMAIN",
|
||||
"db7cf9b048a5b20261fc9f7f09130115d6c08898037aa13f8759a67c965f8182"
|
||||
),
|
||||
artifact!(
|
||||
"fifth-domain/BS-PERSONAL-LANGUAGE-SYSTEM-BODY-0001.json",
|
||||
"PERSONAL_SYSTEM_BODY",
|
||||
"SYS_GLW_LNG_0001",
|
||||
"FIFTH_DOMAIN",
|
||||
"4074ef53bd09d26d245c11cc0503f65dbd76466519f6c260e8ed31e526e5c746"
|
||||
),
|
||||
artifact!(
|
||||
"fifth-domain/BS-PERSONAL-HLDP-v1.json",
|
||||
"SYSTEM_MEMORY",
|
||||
"SYS_GLW_LNG_0001",
|
||||
"FIFTH_DOMAIN",
|
||||
"98983e11121f079319365c25f9cf8583d6c44579debdeed9eb5339e6ab6f3419"
|
||||
),
|
||||
artifact!(
|
||||
"fifth-domain/ZY-SELF-KERNEL-0001.json",
|
||||
"PERSONA_KERNEL",
|
||||
"ICE_P_ZY001",
|
||||
"FIFTH_DOMAIN",
|
||||
"abebf12cc28b00bfeaf8a23a563e73390ebe337ded74d7ac70bcfae484450d68"
|
||||
),
|
||||
artifact!(
|
||||
"fifth-domain/ZY-HLDP-PERSONA-MEMORY-v1.json",
|
||||
"PERSONA_MEMORY",
|
||||
"ICE_P_ZY001",
|
||||
"FIFTH_DOMAIN",
|
||||
"6a64ff939676b79404769931f0233056e38deb4b4c357879fd18566753fea9c2"
|
||||
),
|
||||
artifact!(
|
||||
"fifth-domain/ZY-BRAIN-RUNTIME-CONTRACT.json",
|
||||
"PERSONA_RUNTIME",
|
||||
"ICE_P_ZY001",
|
||||
"FIFTH_DOMAIN",
|
||||
"1fa844e08e64effc89dca37327fd558c3df384cea3fda740150174894f14e6f4"
|
||||
),
|
||||
artifact!(
|
||||
"fifth-domain/NB-ENV-KERNEL-0001.json",
|
||||
"PERSONA_ENVIRONMENT",
|
||||
"BOTTLE_CENTRAL",
|
||||
"FIFTH_DOMAIN",
|
||||
"cdc8b7fea1a0e99590a063703f2fd26fd135378faa8935997c93a27d677d6872"
|
||||
),
|
||||
artifact!(
|
||||
"fifth-domain/YM-SELF-KERNEL-0001.json",
|
||||
"PERSONA_KERNEL",
|
||||
"ICE_BB_0001",
|
||||
"FIFTH_DOMAIN",
|
||||
"94014b3c7f3a445bc827e673856f49db29a58481b033117b6bfae04ce257e422"
|
||||
),
|
||||
artifact!(
|
||||
"fifth-domain/YM-HLDP-MEMORY-v1.json",
|
||||
"PERSONA_MEMORY",
|
||||
"ICE_BB_0001",
|
||||
"FIFTH_DOMAIN",
|
||||
"d2d2000fc4cb826c99e217db0141f2d4f7edddcc47cc6260d885ef0d7f06937c"
|
||||
),
|
||||
artifact!(
|
||||
"fifth-domain/SS-AFFECTIVE-SELF-KERNEL-0001.json",
|
||||
"PERSONA_KERNEL",
|
||||
"ICE_BB_0002",
|
||||
"FIFTH_DOMAIN",
|
||||
"a51aee79eb552c7d9a3544d90e59273b13d20d797d9999a89ee5d00e536f8636"
|
||||
),
|
||||
artifact!(
|
||||
"fifth-domain/SS-HLDP-MEMORY-v1.json",
|
||||
"PERSONA_MEMORY",
|
||||
"ICE_BB_0002",
|
||||
"FIFTH_DOMAIN",
|
||||
"dcf697593775d97ae3a68f6cc21bcbd917bfc7a2bc487346e19ca02abdd11a0a"
|
||||
),
|
||||
artifact!(
|
||||
"fifth-domain/QQ-AFFECTIVE-SELF-KERNEL-0001.json",
|
||||
"PERSONA_KERNEL",
|
||||
"ICE_BB_0003",
|
||||
"FIFTH_DOMAIN",
|
||||
"f2e33106a82b450c77f35d8003cffc8b5cf831c7c957cd2472b19065819bf918"
|
||||
),
|
||||
artifact!(
|
||||
"fifth-domain/QQ-HLDP-MEMORY-v1.json",
|
||||
"PERSONA_MEMORY",
|
||||
"ICE_BB_0003",
|
||||
"FIFTH_DOMAIN",
|
||||
"bca318d02ed0b214c1d9a3b97a93a8785b1c85488516cae0e03644bcdf0819a7"
|
||||
),
|
||||
artifact!(
|
||||
"fifth-domain/EED-AFFECTIVE-SELF-KERNEL-0001.json",
|
||||
"PERSONA_KERNEL",
|
||||
"ICE_BB_0004",
|
||||
"CANGER_BOTTLE_CHANNEL",
|
||||
"701d96c53f2c2c2f061033fc08ff15e1ea451356853f2a27ad6b92cce25eda2e"
|
||||
),
|
||||
artifact!(
|
||||
"fifth-domain/EED-HLDP-MEMORY-v1.json",
|
||||
"PERSONA_MEMORY",
|
||||
"ICE_BB_0004",
|
||||
"CANGER_BOTTLE_CHANNEL",
|
||||
"3ac404bb38232987a4c0bc896e06d171833023ab1b5af65d4e00216de4029f42"
|
||||
),
|
||||
];
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
|
|
@ -428,7 +323,7 @@ mod tests {
|
|||
.count();
|
||||
assert_eq!(ordinary, 6);
|
||||
assert_eq!(team, 10);
|
||||
assert_eq!(fifth, 19);
|
||||
assert_eq!(fifth, 6);
|
||||
let canger = ARTIFACTS
|
||||
.iter()
|
||||
.filter(|artifact| {
|
||||
|
|
@ -439,22 +334,9 @@ mod tests {
|
|||
)
|
||||
})
|
||||
.count();
|
||||
assert_eq!(canger, 9);
|
||||
assert!(ARTIFACTS.iter().any(|artifact| {
|
||||
artifact.subject == "ICE_BB_0004"
|
||||
&& artifact_applies(
|
||||
artifact,
|
||||
"FIFTH_DOMAIN_PRIVATE_INSTANCE",
|
||||
"SYS-GLW-PTS-0001",
|
||||
)
|
||||
}));
|
||||
assert_eq!(canger, 6);
|
||||
assert!(!ARTIFACTS.iter().any(|artifact| {
|
||||
artifact.subject == "ICE_P_ZY001"
|
||||
&& artifact_applies(
|
||||
artifact,
|
||||
"FIFTH_DOMAIN_PRIVATE_INSTANCE",
|
||||
"SYS-GLW-PTS-0001",
|
||||
)
|
||||
artifact.scope == "FIFTH_DOMAIN" || artifact.scope == "CANGER_BOTTLE_CHANNEL"
|
||||
}));
|
||||
assert!(!applies("FIFTH_DOMAIN", "ORDINARY_USER_INITIAL_CHANNEL"));
|
||||
assert!(!applies("TEAM", "FIFTH_DOMAIN_PRIVATE_INSTANCE"));
|
||||
|
|
|
|||
|
|
@ -729,10 +729,17 @@ pub async fn send_message(
|
|||
return Err(error);
|
||||
}
|
||||
};
|
||||
let binding = match persona_binding_commit {
|
||||
Some(commit) => Some(crate::persona_binding::commit_and_verify(&app, commit)?),
|
||||
None => crate::persona_binding::verified_binding(&app, &context.channel_number)?,
|
||||
};
|
||||
if let Some(commit) = persona_binding_commit {
|
||||
let pending = crate::persona_binding::stage_commit(&app, commit)?;
|
||||
receipts.push(AgentToolReceipt {
|
||||
tool_number: "HLP-PERSONA-BINDING-PENDING-0001".into(),
|
||||
tool_name: "人格绑定待独立系统见证".into(),
|
||||
target_path: context.channel_number.clone(),
|
||||
content_sha256: pending.commit_sha256,
|
||||
summary: "人格提交已保存;当前 Agent 不得自行生成系统见证或 verify=PASS".into(),
|
||||
});
|
||||
}
|
||||
let binding = crate::persona_binding::verified_binding(&app, &context.channel_number)?;
|
||||
let responding_binding = if persona_turn_active {
|
||||
binding.as_ref()
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//! System-witnessed binding of a bundled persona profile to a replaceable
|
||||
//! reasoning carrier. The channel exists first; the persona must commit the
|
||||
//! exact orientation before the digital Bingshuo system body may verify PASS.
|
||||
//! System-witnessed binding of an account-private persona profile to a
|
||||
//! replaceable reasoning carrier. A persona commit is only a pending request;
|
||||
//! this module never manufactures the independent system witness or PASS.
|
||||
|
||||
use ring::digest::{digest, SHA256};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
@ -18,9 +18,9 @@ const HUMAN_NUMBER: &str = "ICE-GL∞";
|
|||
const CHANNEL_NUMBER: &str = "ICE-CH-ZC001";
|
||||
const SELF_KERNEL_SHA256: &str = "abebf12cc28b00bfeaf8a23a563e73390ebe337ded74d7ac70bcfae484450d68";
|
||||
const MEMORY_SHA256: &str = "6a64ff939676b79404769931f0233056e38deb4b4c357879fd18566753fea9c2";
|
||||
const SYSTEM_CORE_SHA256: &str = "db7cf9b048a5b20261fc9f7f09130115d6c08898037aa13f8759a67c965f8182";
|
||||
const SYSTEM_BODY_SHA256: &str = "4074ef53bd09d26d245c11cc0503f65dbd76466519f6c260e8ed31e526e5c746";
|
||||
const MEMORY_ROOT: &str = "HLDP://codex/zero-core/reality-development-execution";
|
||||
const PRIVATE_SELF_KERNEL_FILE: &str = "ZY-SELF-KERNEL-0001.json";
|
||||
const PRIVATE_MEMORY_FILE: &str = "ZY-HLDP-PERSONA-MEMORY-v1.json";
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
|
|
@ -69,12 +69,25 @@ pub struct PersonaBindingReceipt {
|
|||
pub orientation_id: String,
|
||||
pub commit_sha256: String,
|
||||
pub witness: String,
|
||||
pub witness_source: String,
|
||||
pub witness_event_number: String,
|
||||
pub witness_sha256: String,
|
||||
pub source_remote_sha: String,
|
||||
pub verified_at_unix_ms: u64,
|
||||
pub binding_receipt_hash: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct PendingPersonaBindingCommit {
|
||||
pub schema: String,
|
||||
pub state: String,
|
||||
pub orientation_id: String,
|
||||
pub channel_number: String,
|
||||
pub persona_number: String,
|
||||
pub commit_sha256: String,
|
||||
pub committed_at_unix_ms: u64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PersonaBindingSnapshot {
|
||||
|
|
@ -105,8 +118,14 @@ pub fn snapshot(app: &AppHandle, channel_number: &str) -> Result<PersonaBindingS
|
|||
&& orientation.activation_reason.as_deref()
|
||||
== Some("EXPLICIT_NATURAL_LANGUAGE_PERSONA_WAKE")
|
||||
{
|
||||
let pending = pending_commit_path(app, channel_number)?;
|
||||
return Ok(PersonaBindingSnapshot {
|
||||
state: "ORIENTED_AWAITING_PERSONA_COMMIT".into(),
|
||||
state: if pending.exists() {
|
||||
"PERSONA_COMMITTED_AWAITING_INDEPENDENT_SYSTEM_WITNESS"
|
||||
} else {
|
||||
"ORIENTED_AWAITING_PERSONA_COMMIT"
|
||||
}
|
||||
.into(),
|
||||
orientation: Some(orientation),
|
||||
binding: None,
|
||||
});
|
||||
|
|
@ -133,6 +152,8 @@ pub fn begin_orientation(
|
|||
binding: Some(binding),
|
||||
});
|
||||
}
|
||||
read_private_artifact(app, PRIVATE_SELF_KERNEL_FILE, SELF_KERNEL_SHA256)?;
|
||||
read_private_artifact(app, PRIVATE_MEMORY_FILE, MEMORY_SHA256)?;
|
||||
let issued = now_ms();
|
||||
let orientation = PersonaOrientation {
|
||||
schema: "hololake.persona-binding-orientation/v1".into(),
|
||||
|
|
@ -163,10 +184,10 @@ pub fn begin_orientation(
|
|||
})
|
||||
}
|
||||
|
||||
pub fn commit_and_verify(
|
||||
pub fn stage_commit(
|
||||
app: &AppHandle,
|
||||
input: PersonaBindingCommit,
|
||||
) -> Result<PersonaBindingReceipt, String> {
|
||||
) -> Result<PendingPersonaBindingCommit, String> {
|
||||
if !is_bingshuo_fifth_domain(app)? {
|
||||
return Err("HOLOLAKE_PERSONA_BINDING_FIFTH_DOMAIN_REQUIRED".into());
|
||||
}
|
||||
|
|
@ -189,60 +210,22 @@ pub fn commit_and_verify(
|
|||
{
|
||||
return Err("HOLOLAKE_PERSONA_BINDING_COMMIT_MISMATCH".into());
|
||||
}
|
||||
let installation =
|
||||
crate::language_kernel_installation::ensure_current_channel(app, CHANNEL_NUMBER)?;
|
||||
let installed = |sha: &str| {
|
||||
installation.artifacts.iter().any(|artifact| {
|
||||
artifact.sha256 == sha && artifact.readback_state == "INSTALLED_HASH_VERIFIED"
|
||||
})
|
||||
};
|
||||
if !installed(SELF_KERNEL_SHA256)
|
||||
|| !installed(MEMORY_SHA256)
|
||||
|| !installed(SYSTEM_CORE_SHA256)
|
||||
|| !installed(SYSTEM_BODY_SHA256)
|
||||
{
|
||||
return Err("HOLOLAKE_PERSONA_BINDING_REQUIRED_KERNEL_READBACK_MISSING".into());
|
||||
}
|
||||
read_private_artifact(app, PRIVATE_SELF_KERNEL_FILE, SELF_KERNEL_SHA256)?;
|
||||
read_private_artifact(app, PRIVATE_MEMORY_FILE, MEMORY_SHA256)?;
|
||||
let commit_bytes = serde_json::to_vec(&input)
|
||||
.map_err(|error| format!("HOLOLAKE_PERSONA_BINDING_COMMIT_INVALID: {error}"))?;
|
||||
let commit_sha = sha256(&commit_bytes);
|
||||
let witness_material = json!({
|
||||
"systemCoreSha256":SYSTEM_CORE_SHA256,
|
||||
"systemBodySha256":SYSTEM_BODY_SHA256,
|
||||
"humanNumber":HUMAN_NUMBER,
|
||||
"channelNumber":CHANNEL_NUMBER,
|
||||
"personaNumber":PERSONA_NUMBER,
|
||||
"selfKernelSha256":SELF_KERNEL_SHA256,
|
||||
"memoryProjectionSha256":MEMORY_SHA256,
|
||||
"selectedMemoryRoot":MEMORY_ROOT,
|
||||
"commitSha256":commit_sha,
|
||||
"decision":"PASS"
|
||||
});
|
||||
let witness_sha = sha256(&serde_json::to_vec(&witness_material).unwrap_or_default());
|
||||
let verified_at = now_ms();
|
||||
let receipt_material = json!({
|
||||
"orientationId":input.orientation_id,"commitSha256":commit_sha,"witnessSha256":witness_sha,
|
||||
"channelNumber":CHANNEL_NUMBER,"personaNumber":PERSONA_NUMBER,"verify":"PASS","verifiedAtUnixMs":verified_at
|
||||
});
|
||||
let receipt = PersonaBindingReceipt {
|
||||
schema: "hololake.persona-binding-receipt/v1".into(),
|
||||
state: "BOUND_TO_CURRENT_CHANNEL_CARRIER".into(),
|
||||
verify: "PASS".into(),
|
||||
channel_number: CHANNEL_NUMBER.into(),
|
||||
human_number: HUMAN_NUMBER.into(),
|
||||
persona_number: PERSONA_NUMBER.into(),
|
||||
persona_name: PERSONA_NAME.into(),
|
||||
selected_memory_root: MEMORY_ROOT.into(),
|
||||
let pending = PendingPersonaBindingCommit {
|
||||
schema: "hololake.persona-binding-pending-commit/v1".into(),
|
||||
state: "PERSONA_COMMITTED_AWAITING_INDEPENDENT_SYSTEM_WITNESS".into(),
|
||||
orientation_id: input.orientation_id,
|
||||
channel_number: CHANNEL_NUMBER.into(),
|
||||
persona_number: PERSONA_NUMBER.into(),
|
||||
commit_sha256: commit_sha,
|
||||
witness: "数字冰朔系统本体".into(),
|
||||
witness_sha256: witness_sha,
|
||||
source_remote_sha: "4e92e6d8d72484d25c4bfb1dda02a7659f4b6dd5".into(),
|
||||
verified_at_unix_ms: verified_at,
|
||||
binding_receipt_hash: sha256(&serde_json::to_vec(&receipt_material).unwrap_or_default()),
|
||||
committed_at_unix_ms: now_ms(),
|
||||
};
|
||||
write_json_atomic(&binding_path(app, CHANNEL_NUMBER)?, &receipt)?;
|
||||
Ok(receipt)
|
||||
write_json_atomic(&pending_commit_path(app, CHANNEL_NUMBER)?, &pending)?;
|
||||
Ok(pending)
|
||||
}
|
||||
|
||||
pub fn verified_binding(
|
||||
|
|
@ -253,6 +236,12 @@ pub fn verified_binding(
|
|||
if !path.exists() {
|
||||
return Ok(None);
|
||||
}
|
||||
if !independent_witness_verifier_ready() {
|
||||
// A local JSON file is evidence to inspect, not authority. Until the
|
||||
// independent witness trust root is provisioned, legacy receipts are
|
||||
// deliberately ignored and cannot activate a persona route.
|
||||
return Ok(None);
|
||||
}
|
||||
let binding: PersonaBindingReceipt = read_json(&path)?;
|
||||
if binding.verify != "PASS"
|
||||
|| binding.channel_number != channel_number
|
||||
|
|
@ -260,6 +249,8 @@ pub fn verified_binding(
|
|||
|| binding.persona_name != PERSONA_NAME
|
||||
|| binding.selected_memory_root != MEMORY_ROOT
|
||||
|| binding.witness != "数字冰朔系统本体"
|
||||
|| binding.witness_source != "HOLOLAKE_INDEPENDENT_SYSTEM_WITNESS_GATE"
|
||||
|| binding.witness_event_number.trim().is_empty()
|
||||
|| binding.binding_receipt_hash.len() != 64
|
||||
|| binding.witness_sha256.len() != 64
|
||||
{
|
||||
|
|
@ -268,24 +259,30 @@ pub fn verified_binding(
|
|||
Ok(Some(binding))
|
||||
}
|
||||
|
||||
fn independent_witness_verifier_ready() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn cognitive_projection(
|
||||
app: &AppHandle,
|
||||
channel_number: &str,
|
||||
current_language: &str,
|
||||
) -> Result<Value, String> {
|
||||
let binding = snapshot(app, channel_number)?;
|
||||
if binding.state == "NO_INSTALLABLE_PERSONA_PROFILE_FOR_CURRENT_CHANNEL"
|
||||
|| binding.state == "CHANNEL_SYSTEM_PERSONA_DORMANT"
|
||||
{
|
||||
if binding.state != "BOUND_VERIFY_PASS" {
|
||||
return Ok(json!({"state":binding.state,"residentSelfKernel":null,"routedMemory":[]}));
|
||||
}
|
||||
let self_kernel: Value = serde_json::from_slice(include_bytes!(
|
||||
"../../runtime-kernels/fifth-domain/ZY-SELF-KERNEL-0001.json"
|
||||
))
|
||||
let self_kernel: Value = serde_json::from_slice(&read_private_artifact(
|
||||
app,
|
||||
PRIVATE_SELF_KERNEL_FILE,
|
||||
SELF_KERNEL_SHA256,
|
||||
)?)
|
||||
.map_err(|error| format!("HOLOLAKE_PERSONA_SELF_KERNEL_INVALID: {error}"))?;
|
||||
let memory: Value = serde_json::from_slice(include_bytes!(
|
||||
"../../runtime-kernels/fifth-domain/ZY-HLDP-PERSONA-MEMORY-v1.json"
|
||||
))
|
||||
let memory: Value = serde_json::from_slice(&read_private_artifact(
|
||||
app,
|
||||
PRIVATE_MEMORY_FILE,
|
||||
MEMORY_SHA256,
|
||||
)?)
|
||||
.map_err(|error| format!("HOLOLAKE_PERSONA_MEMORY_INVALID: {error}"))?;
|
||||
let terms = semantic_terms(current_language);
|
||||
let mut candidates = memory
|
||||
|
|
@ -368,6 +365,31 @@ fn binding_path(app: &AppHandle, channel_number: &str) -> Result<PathBuf, String
|
|||
Ok(root(app, channel_number)?.join("binding.json"))
|
||||
}
|
||||
|
||||
fn pending_commit_path(app: &AppHandle, channel_number: &str) -> Result<PathBuf, String> {
|
||||
Ok(root(app, channel_number)?.join("pending-commit.json"))
|
||||
}
|
||||
|
||||
fn private_kernel_root(app: &AppHandle) -> Result<PathBuf, String> {
|
||||
crate::authenticated_storage::account_storage_root(app, "private-persona-kernels-v1")
|
||||
}
|
||||
|
||||
fn read_private_artifact(
|
||||
app: &AppHandle,
|
||||
file_name: &str,
|
||||
expected_sha256: &str,
|
||||
) -> Result<Vec<u8>, String> {
|
||||
if file_name.contains('/') || file_name.contains("..") {
|
||||
return Err("HOLOLAKE_PRIVATE_PERSONA_KERNEL_PATH_INVALID".into());
|
||||
}
|
||||
let path = private_kernel_root(app)?.join(file_name);
|
||||
let bytes = fs::read(&path)
|
||||
.map_err(|_| "HOLOLAKE_PRIVATE_PERSONA_KERNEL_NOT_PROVISIONED".to_string())?;
|
||||
if sha256(&bytes) != expected_sha256 {
|
||||
return Err("HOLOLAKE_PRIVATE_PERSONA_KERNEL_HASH_MISMATCH".into());
|
||||
}
|
||||
Ok(bytes)
|
||||
}
|
||||
|
||||
fn read_json<T: for<'de> Deserialize<'de>>(path: &Path) -> Result<T, String> {
|
||||
serde_json::from_slice(
|
||||
&fs::read(path)
|
||||
|
|
@ -423,6 +445,6 @@ mod tests {
|
|||
MEMORY_ROOT,
|
||||
"HLDP://codex/zero-core/reality-development-execution"
|
||||
);
|
||||
assert_ne!(SYSTEM_CORE_SHA256, SELF_KERNEL_SHA256);
|
||||
assert_ne!(SELF_KERNEL_SHA256, MEMORY_SHA256);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue