Mirror Weksa lowering receipts into CultMesh

This commit is contained in:
Meta Vens 2026-06-21 17:31:09 +01:00
commit d938455579
5 changed files with 307 additions and 2 deletions

View file

@ -7733,6 +7733,58 @@ fn receipt_directory_report(
private_state_exposed: false,
},
);
push_receipt_directory_row(
&mut rows,
&mut tui_rows,
ReceiptDirectoryRow {
family: "weksa-lowering".to_string(),
owner: "Weksa".to_string(),
document_kind: "epiphany.cultmesh.weksa_lowering_receipt.v0".to_string(),
latest_id: context
.latest_weksa_lowering_receipt
.as_ref()
.map(|receipt| receipt.receipt_id.clone())
.unwrap_or_else(|| "missing".to_string()),
status: context
.latest_weksa_lowering_receipt
.as_ref()
.map(|receipt| format!("lowered:{}", receipt.target_language))
.unwrap_or_else(|| "missing".to_string()),
route: context
.latest_weksa_lowering_receipt
.as_ref()
.map(|receipt| receipt.delivery_surface.clone())
.unwrap_or_else(|| "none".to_string()),
service_id: "none".to_string(),
service_route: "none".to_string(),
follow_up_command: "cargo run --manifest-path .\\epiphany-core\\Cargo.toml --bin epiphany-weksa-interlingua-smoke".to_string(),
artifact_ref: context
.latest_weksa_lowering_receipt
.as_ref()
.map(|receipt| receipt.lowered_text_ref.clone())
.unwrap_or_else(|| "none".to_string()),
artifact_status: context
.latest_weksa_lowering_receipt
.as_ref()
.map(|receipt| {
if receipt.lowered_text_ref.trim().is_empty() {
"none".to_string()
} else {
"external-ref".to_string()
}
})
.unwrap_or_else(|| "none".to_string()),
artifact_sha256: "none".to_string(),
present: context.latest_weksa_lowering_receipt.is_some(),
private_state_exposed: context
.latest_weksa_lowering_receipt
.as_ref()
.map(|receipt| {
receipt.private_state_exposed || receipt.publication_authorized
})
.unwrap_or(false),
},
);
push_receipt_directory_row(
&mut rows,
&mut tui_rows,

View file

@ -1,4 +1,8 @@
use anyhow::Result;
use chrono::Utc;
use epiphany_core::EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID;
use epiphany_core::EPIPHANY_CULTMESH_WEKSA_LOWERING_RECEIPT_SCHEMA_VERSION;
use epiphany_core::EpiphanyCultMeshWeksaLoweringReceiptEntry;
use epiphany_core::WEKSA_INTERLINGUA_PACKET_SCHEMA_VERSION;
use epiphany_core::WEKSA_TARGET_LOWERING_RECEIPT_SCHEMA_VERSION;
use epiphany_core::WEKSA_TARGET_LOWERING_REQUEST_SCHEMA_VERSION;
@ -7,9 +11,22 @@ use epiphany_core::WeksaSpeakerContext;
use epiphany_core::build_weksa_interlingua_packet;
use epiphany_core::build_weksa_lowering_prompt;
use epiphany_core::build_weksa_target_lowering_request;
use epiphany_core::load_latest_epiphany_cultmesh_weksa_lowering_receipt;
use epiphany_core::record_weksa_target_lowering_receipt;
use epiphany_core::write_epiphany_cultmesh_weksa_lowering_receipt;
use std::env;
use std::path::PathBuf;
fn main() -> Result<()> {
let cultmesh_store = env::args()
.skip(1)
.find_map(|arg| arg.strip_prefix("--cultmesh-store=").map(PathBuf::from))
.unwrap_or_else(|| {
PathBuf::from(".epiphany-smoke")
.join("weksa-interlingua")
.join("local-verse.ccmp")
});
let runtime_id = "weksa-interlingua-smoke";
let packet = build_weksa_interlingua_packet(WeksaInterlinguaInput {
packet_id: "weksa-packet-persona-smoke".to_string(),
source_interpreter_ref: "persona-interpreter:smoke-say".to_string(),
@ -74,9 +91,36 @@ fn main() -> Result<()> {
assert!(receipt.transport_authority.contains("must publish"));
assert!(!receipt.private_state_exposed);
let cultmesh_receipt = EpiphanyCultMeshWeksaLoweringReceiptEntry {
schema_version: EPIPHANY_CULTMESH_WEKSA_LOWERING_RECEIPT_SCHEMA_VERSION.to_string(),
receipt_id: receipt.receipt_id.clone(),
runtime_id: runtime_id.to_string(),
verse_id: EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID.to_string(),
packet_id: receipt.packet_id.clone(),
request_id: receipt.request_id.clone(),
persona_agent_id: request.packet.speaker.persona_id.clone(),
target_language: receipt.target_language.clone(),
target_register: receipt.target_register.clone(),
delivery_surface: receipt.delivery_surface.clone(),
lowering_method: receipt.lowering_method.clone(),
transport_authority: receipt.transport_authority.clone(),
publication_authorized: false,
lowered_text_ref: "artifact://weksa/interlingua-smoke/es".to_string(),
lowered_text_preview: receipt.lowered_text.clone(),
created_at_utc: Utc::now().to_rfc3339(),
private_state_exposed: false,
notes: vec!["Executable smoke mirrored Weksa lowering into local Verse sight.".to_string()],
};
write_epiphany_cultmesh_weksa_lowering_receipt(&cultmesh_store, cultmesh_receipt.clone())?;
let latest = load_latest_epiphany_cultmesh_weksa_lowering_receipt(&cultmesh_store, runtime_id)?
.expect("Weksa lowering receipt should round trip through CultMesh");
assert_eq!(latest.receipt_id, cultmesh_receipt.receipt_id);
assert!(!latest.publication_authorized);
assert!(!latest.private_state_exposed);
println!(
"status=ok weksaInterlingua=packet loweringRequest=model-required loweringReceipt=recorded targetLanguage={} transportAuthority=none privateStateExposed=false",
receipt.target_language
"status=ok weksaInterlingua=packet loweringRequest=model-required loweringReceipt=recorded cultmeshReceipt=mirrored targetLanguage={} transportAuthority=none privateStateExposed=false",
latest.target_language
);
Ok(())
}

View file

@ -173,6 +173,12 @@ pub const EPIPHANY_CULTMESH_PERSONA_SPEECH_AUDIT_SCHEMA_VERSION: &str =
"epiphany.cultmesh.persona_speech_audit.v0";
pub const EPIPHANY_CULTMESH_PERSONA_SPEECH_AUDIT_LATEST_KEY: &str =
"epiphany-local/persona-speech-audit/latest";
pub const EPIPHANY_CULTMESH_WEKSA_LOWERING_RECEIPT_TYPE: &str =
"epiphany.cultmesh.weksa_lowering_receipt";
pub const EPIPHANY_CULTMESH_WEKSA_LOWERING_RECEIPT_SCHEMA_VERSION: &str =
"epiphany.cultmesh.weksa_lowering_receipt.v0";
pub const EPIPHANY_CULTMESH_WEKSA_LOWERING_RECEIPT_LATEST_KEY: &str =
"epiphany-local/weksa-lowering-receipt/latest";
pub const EPIPHANY_CULTMESH_DAEMON_TOOL_CAPABILITY_TYPE: &str =
"epiphany.cultmesh.daemon_tool_capability";
pub const EPIPHANY_CULTMESH_DAEMON_TOOL_CAPABILITY_SCHEMA_VERSION: &str =
@ -1767,6 +1773,50 @@ pub struct EpiphanyCultMeshPersonaSpeechAuditEntry {
pub notes: Vec<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "epiphany.cultmesh.weksa_lowering_receipt",
schema = "EpiphanyCultMeshWeksaLoweringReceiptEntry"
)]
pub struct EpiphanyCultMeshWeksaLoweringReceiptEntry {
#[cultcache(key = 0)]
pub schema_version: String,
#[cultcache(key = 1)]
pub receipt_id: String,
#[cultcache(key = 2)]
pub runtime_id: String,
#[cultcache(key = 3)]
pub verse_id: String,
#[cultcache(key = 4)]
pub packet_id: String,
#[cultcache(key = 5)]
pub request_id: String,
#[cultcache(key = 6)]
pub persona_agent_id: String,
#[cultcache(key = 7)]
pub target_language: String,
#[cultcache(key = 8)]
pub target_register: String,
#[cultcache(key = 9)]
pub delivery_surface: String,
#[cultcache(key = 10)]
pub lowering_method: String,
#[cultcache(key = 11)]
pub transport_authority: String,
#[cultcache(key = 12)]
pub publication_authorized: bool,
#[cultcache(key = 13)]
pub lowered_text_ref: String,
#[cultcache(key = 14)]
pub lowered_text_preview: String,
#[cultcache(key = 15)]
pub created_at_utc: String,
#[cultcache(key = 16)]
pub private_state_exposed: bool,
#[cultcache(key = 17)]
pub notes: Vec<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "epiphany.cultmesh.daemon_tool_capability",
@ -2406,6 +2456,7 @@ pub struct EpiphanyLocalVerseContext {
Option<EpiphanyCultMeshIdunnAftercareAuditReceiptEntry>,
pub swarm_brake: Option<EpiphanyCultMeshSwarmBrakeEntry>,
pub latest_persona_speech_audit: Option<EpiphanyCultMeshPersonaSpeechAuditEntry>,
pub latest_weksa_lowering_receipt: Option<EpiphanyCultMeshWeksaLoweringReceiptEntry>,
pub daemon_tool_capabilities: Vec<EpiphanyCultMeshDaemonToolCapabilityEntry>,
pub latest_daemon_tool_invocation_intent:
Option<EpiphanyCultMeshDaemonToolInvocationIntentEntry>,
@ -2506,6 +2557,7 @@ cultmesh_documents!(EpiphanyCultMeshDocuments {
EpiphanyCultMeshIdunnAftercareAuditReceiptEntry => EPIPHANY_CULTMESH_IDUNN_AFTERCARE_AUDIT_RECEIPT_SCHEMA_VERSION,
EpiphanyCultMeshSwarmBrakeEntry => EPIPHANY_CULTMESH_SWARM_BRAKE_SCHEMA_VERSION,
EpiphanyCultMeshPersonaSpeechAuditEntry => EPIPHANY_CULTMESH_PERSONA_SPEECH_AUDIT_SCHEMA_VERSION,
EpiphanyCultMeshWeksaLoweringReceiptEntry => EPIPHANY_CULTMESH_WEKSA_LOWERING_RECEIPT_SCHEMA_VERSION,
EpiphanyCultMeshDaemonToolCapabilityEntry => EPIPHANY_CULTMESH_DAEMON_TOOL_CAPABILITY_SCHEMA_VERSION,
EpiphanyCultMeshDaemonToolInvocationIntentEntry => EPIPHANY_CULTMESH_DAEMON_TOOL_INVOCATION_INTENT_SCHEMA_VERSION,
EpiphanyCultMeshDaemonToolInvocationReceiptEntry => EPIPHANY_CULTMESH_DAEMON_TOOL_INVOCATION_RECEIPT_SCHEMA_VERSION,
@ -3695,6 +3747,71 @@ pub fn validate_persona_speech_audit(
Ok(())
}
pub fn write_epiphany_cultmesh_weksa_lowering_receipt(
store_path: impl AsRef<Path>,
receipt: EpiphanyCultMeshWeksaLoweringReceiptEntry,
) -> Result<EpiphanyCultMeshWeksaLoweringReceiptEntry> {
validate_weksa_lowering_receipt(&receipt)?;
let mut node = open_epiphany_cultmesh_node(&store_path, receipt.runtime_id.clone())?;
let receipt_key = epiphany_cultmesh_weksa_lowering_receipt_key(&receipt.receipt_id);
let written = node.put(receipt_key.as_str(), &receipt)?;
node.put(
EPIPHANY_CULTMESH_WEKSA_LOWERING_RECEIPT_LATEST_KEY,
&written,
)?;
node.flush()?;
Ok(written)
}
pub fn load_latest_epiphany_cultmesh_weksa_lowering_receipt(
store_path: impl AsRef<Path>,
runtime_id: impl Into<String>,
) -> Result<Option<EpiphanyCultMeshWeksaLoweringReceiptEntry>> {
let node = open_epiphany_cultmesh_node(store_path, runtime_id)?;
node.get(EPIPHANY_CULTMESH_WEKSA_LOWERING_RECEIPT_LATEST_KEY)
}
pub fn validate_weksa_lowering_receipt(
receipt: &EpiphanyCultMeshWeksaLoweringReceiptEntry,
) -> Result<()> {
if receipt.private_state_exposed {
return Err(anyhow!(
"Weksa lowering receipt must not expose private state"
));
}
if receipt.publication_authorized {
return Err(anyhow!(
"Weksa lowering receipt must not claim publication authority"
));
}
if receipt.receipt_id.trim().is_empty()
|| receipt.runtime_id.trim().is_empty()
|| receipt.packet_id.trim().is_empty()
|| receipt.request_id.trim().is_empty()
|| receipt.persona_agent_id.trim().is_empty()
{
return Err(anyhow!(
"Weksa lowering receipt requires receipt, runtime, packet, request, and persona ids"
));
}
if receipt.target_language.trim().is_empty()
|| receipt.delivery_surface.trim().is_empty()
|| receipt.created_at_utc.trim().is_empty()
{
return Err(anyhow!(
"Weksa lowering receipt requires target language, delivery surface, and timestamp"
));
}
if !receipt.transport_authority.contains("must publish")
&& receipt.transport_authority.trim() != "none"
{
return Err(anyhow!(
"Weksa lowering receipt transport authority must remain none or defer publication"
));
}
Ok(())
}
fn validate_swarm_brake(brake: &EpiphanyCultMeshSwarmBrakeEntry) -> Result<()> {
if brake.private_state_exposed {
return Err(anyhow!("swarm brake must not expose private state"));
@ -5689,6 +5806,8 @@ pub fn query_epiphany_local_verse_context(
swarm_brake: node.get(EPIPHANY_CULTMESH_SWARM_BRAKE_KEY)?,
latest_persona_speech_audit: node
.get(EPIPHANY_CULTMESH_PERSONA_SPEECH_AUDIT_LATEST_KEY)?,
latest_weksa_lowering_receipt: node
.get(EPIPHANY_CULTMESH_WEKSA_LOWERING_RECEIPT_LATEST_KEY)?,
daemon_tool_capabilities,
latest_daemon_tool_invocation_intent: node
.get(EPIPHANY_CULTMESH_DAEMON_TOOL_INVOCATION_INTENT_LATEST_KEY)?,
@ -6018,6 +6137,10 @@ fn epiphany_cultmesh_persona_speech_audit_key(audit_id: &str) -> String {
format!("epiphany-local/persona-speech-audit/{audit_id}")
}
fn epiphany_cultmesh_weksa_lowering_receipt_key(receipt_id: &str) -> String {
format!("epiphany-local/weksa-lowering-receipt/{receipt_id}")
}
fn epiphany_cultmesh_eve_connection_intent_key(intent_id: &str) -> String {
format!("epiphany-local/eve-connection-intent/{intent_id}")
}
@ -8156,6 +8279,86 @@ mod tests {
Ok(())
}
#[test]
fn weksa_lowering_receipt_round_trips_and_projects_without_publication_authority() -> Result<()>
{
let temp = tempfile::tempdir()?;
let store = temp.path().join("epiphany-weksa-lowering.ccmp");
seed_epiphany_local_verse_context(&store, "epiphany-test", "2026-06-21T00:00:00Z")?;
let receipt = EpiphanyCultMeshWeksaLoweringReceiptEntry {
schema_version: EPIPHANY_CULTMESH_WEKSA_LOWERING_RECEIPT_SCHEMA_VERSION.to_string(),
receipt_id: "weksa-lowering-receipt-test".to_string(),
runtime_id: "epiphany-test".to_string(),
verse_id: EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID.to_string(),
packet_id: "weksa-packet-test".to_string(),
request_id: "weksa-request-test".to_string(),
persona_agent_id: "epiphany.Persona".to_string(),
target_language: "es".to_string(),
target_register: "warm-technical".to_string(),
delivery_surface: "eve-public-room".to_string(),
lowering_method: "deterministic-test".to_string(),
transport_authority: "none; Bifrost or a configured mouth transport must publish"
.to_string(),
publication_authorized: false,
lowered_text_ref: "artifact://weksa/lowered-text/es".to_string(),
lowered_text_preview: "Epiphany puede seguir trabajando.".to_string(),
created_at_utc: "2026-06-21T00:00:00Z".to_string(),
private_state_exposed: false,
notes: vec!["CultMesh Weksa receipt is sight, not publication authority.".to_string()],
};
write_epiphany_cultmesh_weksa_lowering_receipt(&store, receipt.clone())?;
assert_eq!(
load_latest_epiphany_cultmesh_weksa_lowering_receipt(&store, "epiphany-test")?,
Some(receipt)
);
let context = query_epiphany_local_verse_context(&store, "epiphany-test")?;
let projected = context
.latest_weksa_lowering_receipt
.expect("Weksa lowering receipt should project into local Verse context");
assert_eq!(projected.target_language, "es");
assert!(!projected.publication_authorized);
assert!(!projected.private_state_exposed);
Ok(())
}
#[test]
fn weksa_lowering_receipt_refuses_private_state_and_publication_authority() -> Result<()> {
let temp = tempfile::tempdir()?;
let store = temp.path().join("epiphany-weksa-lowering-refusal.ccmp");
let mut receipt = EpiphanyCultMeshWeksaLoweringReceiptEntry {
schema_version: EPIPHANY_CULTMESH_WEKSA_LOWERING_RECEIPT_SCHEMA_VERSION.to_string(),
receipt_id: "weksa-lowering-receipt-test".to_string(),
runtime_id: "epiphany-test".to_string(),
verse_id: EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID.to_string(),
packet_id: "weksa-packet-test".to_string(),
request_id: "weksa-request-test".to_string(),
persona_agent_id: "epiphany.Persona".to_string(),
target_language: "es".to_string(),
target_register: "warm-technical".to_string(),
delivery_surface: "eve-public-room".to_string(),
lowering_method: "deterministic-test".to_string(),
transport_authority: "none".to_string(),
publication_authorized: false,
lowered_text_ref: "artifact://weksa/lowered-text/es".to_string(),
lowered_text_preview: "Epiphany puede seguir trabajando.".to_string(),
created_at_utc: "2026-06-21T00:00:00Z".to_string(),
private_state_exposed: true,
notes: Vec::new(),
};
let error = write_epiphany_cultmesh_weksa_lowering_receipt(&store, receipt.clone())
.expect_err("private Weksa receipt must be refused");
assert!(error.to_string().contains("private state"));
receipt.private_state_exposed = false;
receipt.publication_authorized = true;
let error = write_epiphany_cultmesh_weksa_lowering_receipt(&store, receipt)
.expect_err("publication-authorizing Weksa receipt must be refused");
assert!(error.to_string().contains("publication authority"));
Ok(())
}
#[test]
fn eve_connection_intent_and_receipt_route_feedback_without_private_state() -> Result<()> {
let temp = tempfile::tempdir()?;

View file

@ -249,6 +249,9 @@ pub use cultmesh_integration::EPIPHANY_CULTMESH_SWARM_BRAKE_SCHEMA_VERSION;
pub use cultmesh_integration::EPIPHANY_CULTMESH_SWARM_BRAKE_TYPE;
pub use cultmesh_integration::EPIPHANY_CULTMESH_VERSE_POLICY_SCHEMA_VERSION;
pub use cultmesh_integration::EPIPHANY_CULTMESH_VERSE_POLICY_TYPE;
pub use cultmesh_integration::EPIPHANY_CULTMESH_WEKSA_LOWERING_RECEIPT_LATEST_KEY;
pub use cultmesh_integration::EPIPHANY_CULTMESH_WEKSA_LOWERING_RECEIPT_SCHEMA_VERSION;
pub use cultmesh_integration::EPIPHANY_CULTMESH_WEKSA_LOWERING_RECEIPT_TYPE;
pub use cultmesh_integration::EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_LATEST_KEY;
pub use cultmesh_integration::EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_SCHEMA_VERSION;
pub use cultmesh_integration::EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_TYPE;
@ -302,6 +305,7 @@ pub use cultmesh_integration::EpiphanyCultMeshStatusEntry;
pub use cultmesh_integration::EpiphanyCultMeshSubstrateGateContractEntry;
pub use cultmesh_integration::EpiphanyCultMeshSwarmBrakeEntry;
pub use cultmesh_integration::EpiphanyCultMeshVersePolicyEntry;
pub use cultmesh_integration::EpiphanyCultMeshWeksaLoweringReceiptEntry;
pub use cultmesh_integration::EpiphanyCultMeshWorkLoopTelemetryEntry;
pub use cultmesh_integration::EpiphanyLocalVerseContext;
pub use cultmesh_integration::EpiphanyLocalVerseContractSummary;
@ -394,6 +398,7 @@ pub use cultmesh_integration::load_latest_epiphany_cultmesh_repo_work_public_pro
pub use cultmesh_integration::load_latest_epiphany_cultmesh_repo_work_readiness;
pub use cultmesh_integration::load_latest_epiphany_cultmesh_repo_work_readiness_review;
pub use cultmesh_integration::load_latest_epiphany_cultmesh_role_review_event;
pub use cultmesh_integration::load_latest_epiphany_cultmesh_weksa_lowering_receipt;
pub use cultmesh_integration::load_latest_epiphany_cultmesh_work_loop_telemetry;
pub use cultmesh_integration::open_epiphany_cultmesh_node;
pub use cultmesh_integration::query_epiphany_local_verse_context;
@ -446,6 +451,7 @@ pub use cultmesh_integration::write_epiphany_cultmesh_status;
pub use cultmesh_integration::write_epiphany_cultmesh_substrate_gate_contracts;
pub use cultmesh_integration::write_epiphany_cultmesh_swarm_brake;
pub use cultmesh_integration::write_epiphany_cultmesh_verse_policies;
pub use cultmesh_integration::write_epiphany_cultmesh_weksa_lowering_receipt;
pub use cultmesh_integration::write_epiphany_cultmesh_work_loop_telemetry;
pub use distillation::EpiphanyDistillInput;
pub use distillation::EpiphanyDistillProposal;

Binary file not shown.