Surface Heimdall bridge gate at Persona mouths
This commit is contained in:
parent
e5c9cff631
commit
a02c44710a
8 changed files with 124 additions and 19 deletions
|
|
@ -311,7 +311,7 @@ fn run_post(
|
|||
config,
|
||||
artifact_dir,
|
||||
"blocked",
|
||||
"missing Heimdall-backed capability/account reference for public Persona crossing",
|
||||
"missing Heimdall-backed Discord capability/account reference for public Persona crossing; register the Bifrost identity, link it to Heimdall, and provide a heimdall:discord:* reference",
|
||||
Some(&audit),
|
||||
)?;
|
||||
return Ok(serde_json::json!({
|
||||
|
|
@ -322,6 +322,23 @@ fn run_post(
|
|||
"speechAudit": audit,
|
||||
}));
|
||||
};
|
||||
if !is_heimdall_surface_reference(&heimdall_capability_ref, "discord") {
|
||||
let path = write_draft(
|
||||
content,
|
||||
config,
|
||||
artifact_dir,
|
||||
"blocked",
|
||||
"Heimdall reference must be shaped for Discord public Persona crossings: heimdall:discord:*",
|
||||
Some(&audit),
|
||||
)?;
|
||||
return Ok(serde_json::json!({
|
||||
"ok": false,
|
||||
"posted": false,
|
||||
"blocked": "wrong-heimdall-capability-surface",
|
||||
"draftPath": path,
|
||||
"speechAudit": audit,
|
||||
}));
|
||||
}
|
||||
let persona = resolve_persona(config, persona_name, persona_avatar_url)?;
|
||||
let posted = post_bifrost_discord_message(
|
||||
&bridge_cli_path,
|
||||
|
|
@ -705,9 +722,19 @@ console.log(JSON.stringify({
|
|||
let mut missing_capability_config = bridge_config.clone();
|
||||
missing_capability_config.heimdall_capability_ref_env =
|
||||
Some("HEIMDALL_CAPABILITY_REF_MISSING_FOR_SMOKE".to_string());
|
||||
let mut wrong_surface_config = bridge_config.clone();
|
||||
wrong_surface_config.heimdall_capability_ref_env =
|
||||
Some("HEIMDALL_CAPABILITY_REF_WRONG_SURFACE_FOR_SMOKE".to_string());
|
||||
unsafe {
|
||||
env::remove_var("EPIPHANY_PERSONA_AQUARIUM_CHANNEL_ID_TEST");
|
||||
env::set_var("HEIMDALL_CAPABILITY_REF_TEST", "heimdall-capability-smoke");
|
||||
env::set_var(
|
||||
"HEIMDALL_CAPABILITY_REF_TEST",
|
||||
"heimdall:discord:capability:smoke-persona",
|
||||
);
|
||||
env::set_var(
|
||||
"HEIMDALL_CAPABILITY_REF_WRONG_SURFACE_FOR_SMOKE",
|
||||
"heimdall:reddit:capability:smoke-persona",
|
||||
);
|
||||
env::remove_var("HEIMDALL_CAPABILITY_REF_MISSING_FOR_SMOKE");
|
||||
env::set_var("EPIPHANY_RUN_ID", "epiphany-run-smoke");
|
||||
}
|
||||
|
|
@ -765,6 +792,17 @@ console.log(JSON.stringify({
|
|||
None,
|
||||
None,
|
||||
)?;
|
||||
let wrong_surface_capability = run_post(
|
||||
"Wrong surface credential must stop before Discord transport.",
|
||||
&wrong_surface_config,
|
||||
&temp_dir,
|
||||
&cultmesh_store,
|
||||
runtime_id,
|
||||
Some("123".to_string()),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
)?;
|
||||
let bridged = run_post(
|
||||
"Persona crosses to Discord only through Bifrost.",
|
||||
&bridge_config,
|
||||
|
|
@ -836,11 +874,13 @@ console.log(JSON.stringify({
|
|||
&& missing_bridge["blocked"] == "missing-bifrost-bridge"
|
||||
&& missing_capability["ok"] == false
|
||||
&& missing_capability["blocked"] == "missing-heimdall-capability-ref"
|
||||
&& wrong_surface_capability["ok"] == false
|
||||
&& wrong_surface_capability["blocked"] == "wrong-heimdall-capability-surface"
|
||||
&& bridged["ok"] == true
|
||||
&& bridged["transport"] == "bifrost.discord-post"
|
||||
&& bridged["bifrostBridgeReceipt"]["provenance"]["bifrostIdentity"] == "epiphany.Persona"
|
||||
&& bridged["bifrostBridgeReceipt"]["provenance"]["heimdallCapabilityRef"]
|
||||
== "heimdall-capability-smoke"
|
||||
== "heimdall:discord:capability:smoke-persona"
|
||||
&& wrong["ok"] == false
|
||||
&& wrong["blocked"] == "wrong-channel"
|
||||
&& repeated["ok"] == false
|
||||
|
|
@ -862,6 +902,7 @@ console.log(JSON.stringify({
|
|||
"blocked": blocked,
|
||||
"missingBridge": missing_bridge,
|
||||
"missingCapability": missing_capability,
|
||||
"wrongSurfaceCapability": wrong_surface_capability,
|
||||
"bridged": bridged,
|
||||
"wrongChannel": wrong,
|
||||
"repeatedSpeech": repeated,
|
||||
|
|
@ -1185,6 +1226,11 @@ fn required_heimdall_capability_ref(config: &PersonaConfig) -> Option<String> {
|
|||
})
|
||||
}
|
||||
|
||||
fn is_heimdall_surface_reference(reference: &str, surface: &str) -> bool {
|
||||
let reference = reference.trim().to_ascii_lowercase();
|
||||
reference.starts_with("heimdall:") && reference.contains(&format!(":{surface}:"))
|
||||
}
|
||||
|
||||
fn env_value(name: &String) -> Option<String> {
|
||||
env::var(name)
|
||||
.ok()
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ fn run_post(
|
|||
config,
|
||||
artifact_dir,
|
||||
"blocked",
|
||||
"missing Heimdall-backed capability/account reference for public Persona crossing",
|
||||
"missing Heimdall-backed Reddit capability/account reference for public Persona crossing; register the Bifrost identity, link it to Heimdall, and provide a heimdall:reddit:* reference",
|
||||
Some(&audit),
|
||||
None,
|
||||
)?;
|
||||
|
|
@ -305,6 +305,25 @@ fn run_post(
|
|||
"speechAudit": audit,
|
||||
}));
|
||||
};
|
||||
if !is_heimdall_surface_reference(&heimdall_capability_ref, "reddit") {
|
||||
let path = write_post_artifact(
|
||||
title,
|
||||
content,
|
||||
config,
|
||||
artifact_dir,
|
||||
"blocked",
|
||||
"Heimdall reference must be shaped for Reddit public Persona crossings: heimdall:reddit:*",
|
||||
Some(&audit),
|
||||
None,
|
||||
)?;
|
||||
return Ok(serde_json::json!({
|
||||
"ok": false,
|
||||
"posted": false,
|
||||
"blocked": "wrong-heimdall-capability-surface",
|
||||
"draftPath": path,
|
||||
"speechAudit": audit,
|
||||
}));
|
||||
}
|
||||
let receipt = post_bifrost_reddit_thread(
|
||||
&bridge_cli_path,
|
||||
config,
|
||||
|
|
@ -588,8 +607,21 @@ console.log(JSON.stringify({
|
|||
heimdall_capability_ref_env: Some("HEIMDALL_CAPABILITY_REF_MISSING_FOR_SMOKE".to_string()),
|
||||
..config.clone()
|
||||
};
|
||||
let wrong_surface_config = PersonaRedditConfig {
|
||||
heimdall_capability_ref_env: Some(
|
||||
"HEIMDALL_CAPABILITY_REF_WRONG_SURFACE_FOR_SMOKE".to_string(),
|
||||
),
|
||||
..config.clone()
|
||||
};
|
||||
unsafe {
|
||||
env::set_var("HEIMDALL_CAPABILITY_REF_TEST", "heimdall-reddit-smoke");
|
||||
env::set_var(
|
||||
"HEIMDALL_CAPABILITY_REF_TEST",
|
||||
"heimdall:reddit:capability:smoke-persona",
|
||||
);
|
||||
env::set_var(
|
||||
"HEIMDALL_CAPABILITY_REF_WRONG_SURFACE_FOR_SMOKE",
|
||||
"heimdall:discord:capability:smoke-persona",
|
||||
);
|
||||
env::remove_var("HEIMDALL_CAPABILITY_REF_MISSING_FOR_SMOKE");
|
||||
env::set_var("EPIPHANY_RUN_ID", "epiphany-run-reddit-smoke");
|
||||
}
|
||||
|
|
@ -627,6 +659,18 @@ console.log(JSON.stringify({
|
|||
None,
|
||||
None,
|
||||
)?;
|
||||
let wrong_surface_capability = run_post(
|
||||
"Epiphany wrong Heimdall capability",
|
||||
"Persona should not reach Reddit with Discord Heimdall-backed capability proof.",
|
||||
&wrong_surface_config,
|
||||
&temp_dir,
|
||||
&cultmesh_store,
|
||||
runtime_id,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
)?;
|
||||
let bridged = run_post(
|
||||
"Epiphany crosses through Bifrost",
|
||||
"Persona posts to Reddit only through the Bifrost bridge.",
|
||||
|
|
@ -688,11 +732,13 @@ console.log(JSON.stringify({
|
|||
&& missing_bridge["blocked"] == "missing-bifrost-bridge"
|
||||
&& missing_capability["ok"] == false
|
||||
&& missing_capability["blocked"] == "missing-heimdall-capability-ref"
|
||||
&& wrong_surface_capability["ok"] == false
|
||||
&& wrong_surface_capability["blocked"] == "wrong-heimdall-capability-surface"
|
||||
&& bridged["ok"] == true
|
||||
&& bridged["transport"] == "bifrost.reddit-post"
|
||||
&& bridged["bifrostBridgeReceipt"]["provenance"]["bifrostIdentity"] == "epiphany.Persona"
|
||||
&& bridged["bifrostBridgeReceipt"]["provenance"]["heimdallCapabilityRef"]
|
||||
== "heimdall-reddit-smoke"
|
||||
== "heimdall:reddit:capability:smoke-persona"
|
||||
&& repeated["ok"] == false
|
||||
&& repeated["blocked"] == "speech-audit"
|
||||
&& repeated["speechAudit"]["reasons"]
|
||||
|
|
@ -705,6 +751,7 @@ console.log(JSON.stringify({
|
|||
"draft": draft,
|
||||
"missingBridge": missing_bridge,
|
||||
"missingCapability": missing_capability,
|
||||
"wrongSurfaceCapability": wrong_surface_capability,
|
||||
"bridged": bridged,
|
||||
"repeatedSpeech": repeated,
|
||||
"latestCultMeshSpeechAudit": latest_cultmesh_audit,
|
||||
|
|
@ -937,6 +984,11 @@ fn required_heimdall_capability_ref(config: &PersonaRedditConfig) -> Option<Stri
|
|||
})
|
||||
}
|
||||
|
||||
fn is_heimdall_surface_reference(reference: &str, surface: &str) -> bool {
|
||||
let reference = reference.trim().to_ascii_lowercase();
|
||||
reference.starts_with("heimdall:") && reference.contains(&format!(":{surface}:"))
|
||||
}
|
||||
|
||||
fn bifrost_node_executable() -> String {
|
||||
env::var("EPIPHANY_BIFROST_NODE")
|
||||
.ok()
|
||||
|
|
|
|||
Reference in a new issue