diff --git a/epiphany-core/src/cultmesh_integration.rs b/epiphany-core/src/cultmesh_integration.rs index 98f8245a..a9368d50 100644 --- a/epiphany-core/src/cultmesh_integration.rs +++ b/epiphany-core/src/cultmesh_integration.rs @@ -63,27 +63,6 @@ pub const EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_DAEMON_ID: &str = pub const EPIPHANY_CULTMESH_SWARM_BRAKE_TYPE: &str = "epiphany.cultmesh.swarm_brake"; pub const EPIPHANY_CULTMESH_SWARM_BRAKE_SCHEMA_VERSION: &str = "epiphany.cultmesh.swarm_brake.v0"; pub const EPIPHANY_CULTMESH_SWARM_BRAKE_KEY: &str = "epiphany-local/swarm-brake"; -pub const EPIPHANY_CULTMESH_BIFROST_CONTRACT_TYPE: &str = "epiphany.cultmesh.bifrost_contract"; -pub const EPIPHANY_CULTMESH_BIFROST_CONTRACT_SCHEMA_VERSION: &str = - "epiphany.cultmesh.bifrost_contract.v0"; -pub const EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_INTENT_TYPE: &str = - "gamecult.bifrost.body_change_publication_intent"; -pub const EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_INTENT_SCHEMA_VERSION: &str = - "gamecult.bifrost.body_change_publication_intent.v0"; -pub const EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_INTENT_ARRIVAL_LATEST_KEY: &str = - "gamecult-local/bifrost/body-change-publication-intent/latest"; -pub const EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_RECEIPT_TYPE: &str = - "gamecult.bifrost.body_change_publication_receipt"; -pub const EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_RECEIPT_SCHEMA_VERSION: &str = - "gamecult.bifrost.body_change_publication_receipt.v0"; -pub const EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_RECEIPT_ARRIVAL_LATEST_KEY: &str = - "gamecult-local/bifrost/body-change-publication-receipt/latest"; -pub const EPIPHANY_CULTMESH_BIFROST_GITHUB_PUBLICATION_RECEIPT_TYPE: &str = - "gamecult.bifrost.github_publication_receipt"; -pub const EPIPHANY_CULTMESH_BIFROST_GITHUB_PUBLICATION_RECEIPT_SCHEMA_VERSION: &str = - "gamecult.bifrost.github_publication_receipt.v0"; -pub const EPIPHANY_CULTMESH_BIFROST_GITHUB_PUBLICATION_RECEIPT_ARRIVAL_LATEST_KEY: &str = - "gamecult-local/bifrost/github-publication-receipt/latest"; pub const EPIPHANY_CULTMESH_INTERNAL_VERSE_ID: &str = "epiphany-internal"; pub const EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID: &str = "gamecult-local"; pub const EPIPHANY_CULTMESH_GLOBAL_VERSE_ID: &str = "epiphany-global"; @@ -362,148 +341,6 @@ pub struct EpiphanyCultMeshSwarmBrakeEntry { pub runtime_id: String, } -#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)] -#[cultcache( - type = "epiphany.cultmesh.bifrost_contract", - schema = "EpiphanyCultMeshBifrostContractEntry" -)] -pub struct EpiphanyCultMeshBifrostContractEntry { - #[cultcache(key = 0)] - pub schema_version: String, - #[cultcache(key = 1)] - pub contract_id: String, - #[cultcache(key = 2)] - pub verse_id: String, - #[cultcache(key = 3)] - pub document_type: String, - #[cultcache(key = 4)] - pub payload_schema_version: String, - #[cultcache(key = 5)] - pub authority: String, - #[cultcache(key = 6)] - pub operations: Vec, - #[cultcache(key = 7)] - pub intent_document_types: Vec, - #[cultcache(key = 8)] - pub receipt_document_types: Vec, - #[cultcache(key = 9)] - pub notes: Vec, -} - -#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)] -#[cultcache( - type = "gamecult.bifrost.body_change_publication_intent", - schema = "EpiphanyCultMeshBifrostBodyChangePublicationIntentEntry" -)] -pub struct EpiphanyCultMeshBifrostBodyChangePublicationIntentEntry { - #[cultcache(key = 0)] - pub schema_version: String, - #[cultcache(key = 1)] - pub intent_id: String, - #[cultcache(key = 2)] - pub source_cluster_id: String, - #[cultcache(key = 3)] - pub source_agent_id: String, - #[cultcache(key = 4)] - pub body_domain: String, - #[cultcache(key = 5)] - pub target_repository: String, - #[cultcache(key = 6)] - pub target_branch: String, - #[cultcache(key = 7)] - pub change_summary: String, - #[cultcache(key = 8)] - pub justification: String, - #[cultcache(key = 9)] - pub changed_paths: Vec, - #[cultcache(key = 10)] - pub verification_receipt_ids: Vec, - #[cultcache(key = 11)] - pub review_receipt_ids: Vec, - #[cultcache(key = 12)] - pub authorship_agent_ids: Vec, - #[cultcache(key = 13)] - pub credit_subjects: Vec, - #[cultcache(key = 14)] - pub github_publication_requested: bool, - #[cultcache(key = 15)] - pub private_state_included: bool, - #[cultcache(key = 16)] - pub notes: Vec, -} - -#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)] -#[cultcache( - type = "gamecult.bifrost.body_change_publication_receipt", - schema = "EpiphanyCultMeshBifrostBodyChangePublicationReceiptEntry" -)] -pub struct EpiphanyCultMeshBifrostBodyChangePublicationReceiptEntry { - #[cultcache(key = 0)] - pub schema_version: String, - #[cultcache(key = 1)] - pub receipt_id: String, - #[cultcache(key = 2)] - pub intent_id: String, - #[cultcache(key = 3)] - pub status: String, - #[cultcache(key = 4)] - pub bifrost_ledger_entry_id: String, - #[cultcache(key = 5)] - pub github_publication_receipt_id: String, - #[cultcache(key = 6)] - pub credit_receipt_ids: Vec, - #[cultcache(key = 7)] - pub accepted_changed_paths: Vec, - #[cultcache(key = 8)] - pub reviewer_ids: Vec, - #[cultcache(key = 9)] - pub publication_url: String, - #[cultcache(key = 10)] - pub private_state_exposed: bool, - #[cultcache(key = 11)] - pub notes: Vec, -} - -#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)] -#[cultcache( - type = "gamecult.bifrost.github_publication_receipt", - schema = "EpiphanyCultMeshBifrostGithubPublicationReceiptEntry" -)] -pub struct EpiphanyCultMeshBifrostGithubPublicationReceiptEntry { - #[cultcache(key = 0)] - pub schema_version: String, - #[cultcache(key = 1)] - pub receipt_id: String, - #[cultcache(key = 2)] - pub bifrost_publication_receipt_id: String, - #[cultcache(key = 3)] - pub hands_pr_receipt_id: String, - #[cultcache(key = 4)] - pub target_repository: String, - #[cultcache(key = 5)] - pub target_branch: String, - #[cultcache(key = 6)] - pub pull_request_url: String, - #[cultcache(key = 7)] - pub pull_request_number: String, - #[cultcache(key = 8)] - pub commit_sha: String, - #[cultcache(key = 9)] - pub changed_paths: Vec, - #[cultcache(key = 10)] - pub ledger_entry_id: String, - #[cultcache(key = 11)] - pub credit_receipt_ids: Vec, - #[cultcache(key = 12)] - pub published_by_agent_id: String, - #[cultcache(key = 13)] - pub publication_status: String, - #[cultcache(key = 14)] - pub private_state_exposed: bool, - #[cultcache(key = 15)] - pub notes: Vec, -} - #[derive(Clone, Debug, PartialEq, Eq, Serialize)] #[serde(rename_all = "camelCase")] pub struct EpiphanyLocalVerseContext { @@ -518,12 +355,6 @@ pub struct EpiphanyLocalVerseContext { pub global_room_policies: Vec, pub cluster_topology: Vec, pub swarm_brake: Option, - pub arrival_latest_bifrost_body_change_publication_intent: - Option, - pub arrival_latest_bifrost_body_change_publication_receipt: - Option, - pub arrival_latest_bifrost_github_publication_receipt: - Option, pub contract_summaries: Vec, } @@ -555,10 +386,6 @@ cultmesh_documents!(EpiphanyCultMeshDocuments { EpiphanyPackagedReleaseEntry => crate::packaged_release::EPIPHANY_PACKAGED_RELEASE_SCHEMA_VERSION, EpiphanyPackagedReleaseHead => crate::packaged_release::EPIPHANY_PACKAGED_RELEASE_HEAD_SCHEMA_VERSION, EpiphanyCultMeshSwarmBrakeEntry => EPIPHANY_CULTMESH_SWARM_BRAKE_SCHEMA_VERSION, - EpiphanyCultMeshBifrostContractEntry => EPIPHANY_CULTMESH_BIFROST_CONTRACT_SCHEMA_VERSION, - EpiphanyCultMeshBifrostBodyChangePublicationIntentEntry => EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_INTENT_SCHEMA_VERSION, - EpiphanyCultMeshBifrostBodyChangePublicationReceiptEntry => EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_RECEIPT_SCHEMA_VERSION, - EpiphanyCultMeshBifrostGithubPublicationReceiptEntry => EPIPHANY_CULTMESH_BIFROST_GITHUB_PUBLICATION_RECEIPT_SCHEMA_VERSION, crate::persona_feedback_admission::LocalAdmittedPersonaFeedback => crate::persona_feedback_admission::LOCAL_PERSONA_FEEDBACK_SCHEMA_VERSION, EpiphanyCultMeshSemanticProjectionHealthEntry => EPIPHANY_CULTMESH_SEMANTIC_PROJECTION_HEALTH_SCHEMA_VERSION, }); @@ -1377,285 +1204,6 @@ fn validate_semantic_projector_launch_receipt( Ok(()) } -pub fn epiphany_cultmesh_bifrost_body_change_publication_intent( - intent_id: impl Into, - source_cluster_id: impl Into, - source_agent_id: impl Into, - body_domain: impl Into, - target_repository: impl Into, - target_branch: impl Into, - change_summary: impl Into, - justification: impl Into, - changed_paths: Vec, - verification_receipt_ids: Vec, - review_receipt_ids: Vec, - authorship_agent_ids: Vec, - credit_subjects: Vec, -) -> EpiphanyCultMeshBifrostBodyChangePublicationIntentEntry { - EpiphanyCultMeshBifrostBodyChangePublicationIntentEntry { - schema_version: EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_INTENT_SCHEMA_VERSION - .to_string(), - intent_id: intent_id.into(), - source_cluster_id: source_cluster_id.into(), - source_agent_id: source_agent_id.into(), - body_domain: body_domain.into(), - target_repository: target_repository.into(), - target_branch: target_branch.into(), - change_summary: change_summary.into(), - justification: justification.into(), - changed_paths, - verification_receipt_ids, - review_receipt_ids, - authorship_agent_ids, - credit_subjects, - github_publication_requested: true, - private_state_included: false, - notes: vec![ - "Bifrost publication intent routes a body change to the local trusted GameCult Verse before GitHub publication.".to_string(), - "GitHub is the publication substrate; Bifrost owns ledger attribution, review proof, and credit routing.".to_string(), - "Private worker/operator/agent state must stay sealed outside this operator-safe publication packet.".to_string(), - ], - } -} - -#[cfg(test)] -pub fn epiphany_cultmesh_bifrost_body_change_publication_receipt_for_intent( - receipt_id: impl Into, - intent: &EpiphanyCultMeshBifrostBodyChangePublicationIntentEntry, - status: impl Into, - bifrost_ledger_entry_id: impl Into, - github_publication_receipt_id: impl Into, - credit_receipt_ids: Vec, - reviewer_ids: Vec, - publication_url: impl Into, -) -> EpiphanyCultMeshBifrostBodyChangePublicationReceiptEntry { - EpiphanyCultMeshBifrostBodyChangePublicationReceiptEntry { - schema_version: EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_RECEIPT_SCHEMA_VERSION - .to_string(), - receipt_id: receipt_id.into(), - intent_id: intent.intent_id.clone(), - status: status.into(), - bifrost_ledger_entry_id: bifrost_ledger_entry_id.into(), - github_publication_receipt_id: github_publication_receipt_id.into(), - credit_receipt_ids, - accepted_changed_paths: intent.changed_paths.clone(), - reviewer_ids, - publication_url: publication_url.into(), - private_state_exposed: false, - notes: vec![ - "Bifrost receipt records publication routing and ledger attribution before treating GitHub publication as blessed.".to_string(), - "Credit and GitHub receipts are referenced as typed proof surfaces, not hidden side effects.".to_string(), - ], - } -} - -pub fn write_epiphany_cultmesh_bifrost_body_change_publication_intent( - store_path: impl AsRef, - runtime_id: impl Into, - intent: EpiphanyCultMeshBifrostBodyChangePublicationIntentEntry, -) -> Result { - validate_bifrost_body_change_publication_intent(&intent)?; - let mut node = open_epiphany_cultmesh_node(store_path, runtime_id)?; - let intent_key = - epiphany_cultmesh_bifrost_body_change_publication_intent_key(&intent.intent_id); - let written = node.put(intent_key.as_str(), &intent)?; - node.put( - EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_INTENT_ARRIVAL_LATEST_KEY, - &written, - )?; - node.flush()?; - Ok(written) -} - -#[cfg(test)] -pub fn write_epiphany_cultmesh_bifrost_body_change_publication_receipt( - store_path: impl AsRef, - runtime_id: impl Into, - receipt: EpiphanyCultMeshBifrostBodyChangePublicationReceiptEntry, -) -> Result { - validate_bifrost_body_change_publication_receipt(&receipt)?; - let mut node = open_epiphany_cultmesh_node(store_path, runtime_id)?; - let receipt_key = - epiphany_cultmesh_bifrost_body_change_publication_receipt_key(&receipt.receipt_id); - let written = node.put(receipt_key.as_str(), &receipt)?; - node.put( - EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_RECEIPT_ARRIVAL_LATEST_KEY, - &written, - )?; - node.flush()?; - Ok(written) -} - -#[allow(clippy::too_many_arguments)] -#[cfg(test)] -pub fn epiphany_cultmesh_bifrost_github_publication_receipt_for_publication( - receipt_id: impl Into, - publication_receipt: &EpiphanyCultMeshBifrostBodyChangePublicationReceiptEntry, - hands_pr_receipt_id: impl Into, - target_repository: impl Into, - target_branch: impl Into, - pull_request_number: impl Into, - commit_sha: impl Into, - published_by_agent_id: impl Into, -) -> EpiphanyCultMeshBifrostGithubPublicationReceiptEntry { - EpiphanyCultMeshBifrostGithubPublicationReceiptEntry { - schema_version: EPIPHANY_CULTMESH_BIFROST_GITHUB_PUBLICATION_RECEIPT_SCHEMA_VERSION - .to_string(), - receipt_id: receipt_id.into(), - bifrost_publication_receipt_id: publication_receipt.receipt_id.clone(), - hands_pr_receipt_id: hands_pr_receipt_id.into(), - target_repository: target_repository.into(), - target_branch: target_branch.into(), - pull_request_url: publication_receipt.publication_url.clone(), - pull_request_number: pull_request_number.into(), - commit_sha: commit_sha.into(), - changed_paths: publication_receipt.accepted_changed_paths.clone(), - ledger_entry_id: publication_receipt.bifrost_ledger_entry_id.clone(), - credit_receipt_ids: publication_receipt.credit_receipt_ids.clone(), - published_by_agent_id: published_by_agent_id.into(), - publication_status: publication_receipt.status.clone(), - private_state_exposed: false, - notes: vec![ - "Bifrost GitHub publication receipt binds the Bifrost ledger decision to a concrete Hands PR receipt.".to_string(), - "GitHub is recorded as a publication substrate; Bifrost remains the routing and credit authority.".to_string(), - "This receipt must not expose private worker, operator, or agent-thought state.".to_string(), - ], - } -} - -#[cfg(test)] -pub fn write_epiphany_cultmesh_bifrost_github_publication_receipt( - store_path: impl AsRef, - runtime_id: impl Into, - receipt: EpiphanyCultMeshBifrostGithubPublicationReceiptEntry, -) -> Result { - validate_bifrost_github_publication_receipt(&receipt)?; - let mut node = open_epiphany_cultmesh_node(store_path, runtime_id)?; - let receipt_key = epiphany_cultmesh_bifrost_github_publication_receipt_key(&receipt.receipt_id); - let written = node.put(receipt_key.as_str(), &receipt)?; - node.put( - EPIPHANY_CULTMESH_BIFROST_GITHUB_PUBLICATION_RECEIPT_ARRIVAL_LATEST_KEY, - &written, - )?; - node.flush()?; - Ok(written) -} - -fn validate_bifrost_body_change_publication_intent( - intent: &EpiphanyCultMeshBifrostBodyChangePublicationIntentEntry, -) -> Result<()> { - if intent.private_state_included { - return Err(anyhow!( - "Bifrost body change publication intents must not include private state" - )); - } - if !intent.github_publication_requested { - return Err(anyhow!( - "Bifrost body change publication intents must request GitHub publication routing" - )); - } - if intent.justification.trim().is_empty() { - return Err(anyhow!( - "Bifrost body change publication intents require justification" - )); - } - if intent.changed_paths.is_empty() { - return Err(anyhow!( - "Bifrost body change publication intents require changed path scope" - )); - } - if intent.verification_receipt_ids.is_empty() { - return Err(anyhow!( - "Bifrost body change publication intents require verification receipts" - )); - } - if intent.review_receipt_ids.is_empty() { - return Err(anyhow!( - "Bifrost body change publication intents require review receipts" - )); - } - if intent.authorship_agent_ids.is_empty() { - return Err(anyhow!( - "Bifrost body change publication intents require authorship" - )); - } - if intent.credit_subjects.is_empty() { - return Err(anyhow!( - "Bifrost body change publication intents require credit metadata" - )); - } - Ok(()) -} - -#[cfg(test)] -fn validate_bifrost_body_change_publication_receipt( - receipt: &EpiphanyCultMeshBifrostBodyChangePublicationReceiptEntry, -) -> Result<()> { - if receipt.private_state_exposed { - return Err(anyhow!( - "Bifrost body change publication receipts must not expose private state" - )); - } - if receipt.bifrost_ledger_entry_id.trim().is_empty() { - return Err(anyhow!( - "Bifrost body change publication receipts require a ledger entry" - )); - } - if receipt.github_publication_receipt_id.trim().is_empty() { - return Err(anyhow!( - "Bifrost body change publication receipts require a GitHub publication receipt" - )); - } - if receipt.credit_receipt_ids.is_empty() { - return Err(anyhow!( - "Bifrost body change publication receipts require credit receipts" - )); - } - Ok(()) -} - -#[cfg(test)] -fn validate_bifrost_github_publication_receipt( - receipt: &EpiphanyCultMeshBifrostGithubPublicationReceiptEntry, -) -> Result<()> { - if receipt.private_state_exposed { - return Err(anyhow!( - "Bifrost GitHub publication receipts must not expose private state" - )); - } - if receipt.bifrost_publication_receipt_id.trim().is_empty() { - return Err(anyhow!( - "Bifrost GitHub publication receipts require a Bifrost publication receipt" - )); - } - if receipt.hands_pr_receipt_id.trim().is_empty() { - return Err(anyhow!( - "Bifrost GitHub publication receipts require a Hands PR receipt" - )); - } - if receipt.pull_request_url.trim().is_empty() { - return Err(anyhow!( - "Bifrost GitHub publication receipts require a pull request URL" - )); - } - if receipt.ledger_entry_id.trim().is_empty() { - return Err(anyhow!( - "Bifrost GitHub publication receipts require a ledger entry" - )); - } - if receipt.credit_receipt_ids.is_empty() { - return Err(anyhow!( - "Bifrost GitHub publication receipts require credit receipts" - )); - } - if receipt.changed_paths.is_empty() { - return Err(anyhow!( - "Bifrost GitHub publication receipts require changed paths" - )); - } - Ok(()) -} - pub fn seed_epiphany_local_verse_context( store_path: impl AsRef, runtime_id: impl Into, @@ -1683,7 +1231,6 @@ pub fn seed_epiphany_local_verse_context( )?; } } - write_epiphany_cultmesh_bifrost_contracts(store_path, runtime_id.clone())?; Ok(()) } @@ -1743,14 +1290,6 @@ pub fn query_epiphany_local_verse_context( .into_iter() .map(IntoLocalVerseContractSummary::into_local_verse_summary), ); - for contract in epiphany_cultmesh_bifrost_contracts() { - if let Some(loaded) = - node.get::(&contract.contract_id)? - { - contract_summaries.push(loaded.into_local_verse_summary()); - } - } - Ok(EpiphanyLocalVerseContext { schema_version: "epiphany.local_verse_context.v0".to_string(), runtime_id: runtime_id.clone(), @@ -1763,12 +1302,6 @@ pub fn query_epiphany_local_verse_context( global_room_policies, cluster_topology, swarm_brake: node.get(EPIPHANY_CULTMESH_SWARM_BRAKE_KEY)?, - arrival_latest_bifrost_body_change_publication_intent: node - .get(EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_INTENT_ARRIVAL_LATEST_KEY)?, - arrival_latest_bifrost_body_change_publication_receipt: node - .get(EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_RECEIPT_ARRIVAL_LATEST_KEY)?, - arrival_latest_bifrost_github_publication_receipt: node - .get(EPIPHANY_CULTMESH_BIFROST_GITHUB_PUBLICATION_RECEIPT_ARRIVAL_LATEST_KEY)?, contract_summaries, }) } @@ -1800,7 +1333,6 @@ impl_local_verse_contract_summary!(crate::EyesCultNetContract); impl_local_verse_contract_summary!(crate::HandsCultNetContract); impl_local_verse_contract_summary!(crate::SoulCultNetContract); impl_local_verse_contract_summary!(crate::ContinuityCultNetContract); -impl_local_verse_contract_summary!(EpiphanyCultMeshBifrostContractEntry); fn epiphany_cultmesh_daemon_service_lifecycle_receipt_key(receipt_id: &str) -> String { format!("epiphany-local/daemon-service-lifecycle-receipt/{receipt_id}") @@ -1814,20 +1346,6 @@ fn epiphany_cultmesh_managed_service_policy_key(service_id: &str) -> String { format!("epiphany-local/managed-service-policy/{service_id}") } -fn epiphany_cultmesh_bifrost_body_change_publication_intent_key(intent_id: &str) -> String { - format!("gamecult-local/bifrost/body-change-publication-intent/{intent_id}") -} - -#[cfg(test)] -fn epiphany_cultmesh_bifrost_body_change_publication_receipt_key(receipt_id: &str) -> String { - format!("gamecult-local/bifrost/body-change-publication-receipt/{receipt_id}") -} - -#[cfg(test)] -fn epiphany_cultmesh_bifrost_github_publication_receipt_key(receipt_id: &str) -> String { - format!("gamecult-local/bifrost/github-publication-receipt/{receipt_id}") -} - pub fn epiphany_verse_policies() -> Vec { vec![ EpiphanyVersePolicy { @@ -2249,56 +1767,6 @@ fn validate_heartbeat_identifier(label: &str, value: &str) -> Result<()> { Ok(()) } -pub fn epiphany_cultmesh_bifrost_contracts() -> Vec { - vec![ - EpiphanyCultMeshBifrostContractEntry { - schema_version: EPIPHANY_CULTMESH_BIFROST_CONTRACT_SCHEMA_VERSION.to_string(), - contract_id: "gamecult.bifrost.body_change.publication".to_string(), - verse_id: EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID.to_string(), - document_type: EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_INTENT_TYPE - .to_string(), - payload_schema_version: - EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_INTENT_SCHEMA_VERSION - .to_string(), - authority: "bifrost".to_string(), - operations: vec![ - "intentSubmit".to_string(), - "receiptWatch".to_string(), - "snapshot".to_string(), - ], - intent_document_types: vec![ - EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_INTENT_TYPE.to_string(), - ], - receipt_document_types: vec![ - EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_RECEIPT_TYPE.to_string(), - EPIPHANY_CULTMESH_BIFROST_GITHUB_PUBLICATION_RECEIPT_TYPE.to_string(), - "gamecult.bifrost.credit_receipt".to_string(), - ], - notes: vec![ - format!( - "CultMesh advertises this Bifrost contract as {EPIPHANY_CULTMESH_BIFROST_CONTRACT_TYPE}." - ), - "Body changes require justification, changed-path scope, verifier evidence, authorship, review, and credit metadata before GitHub publication.".to_string(), - "Bifrost is the credit and publication-routing authority; GitHub is a publication substrate, not the governance source.".to_string(), - "Epiphany clusters may prepare intents, but Bifrost receipts bless public publication and ledger attribution.".to_string(), - ], - }, - ] -} - -pub fn write_epiphany_cultmesh_bifrost_contracts( - store_path: impl AsRef, - runtime_id: impl Into, -) -> Result> { - let mut node = open_epiphany_cultmesh_node(store_path, runtime_id)?; - let mut written = Vec::new(); - for contract in epiphany_cultmesh_bifrost_contracts() { - written.push(node.put(contract.contract_id.clone(), &contract)?); - } - node.flush()?; - Ok(written) -} - #[cfg(test)] mod tests { use super::*; @@ -3140,310 +2608,6 @@ mod tests { Ok(()) } - #[test] - fn bifrost_body_change_projection_binds_intent_to_governed_receipt() -> Result<()> { - let temp = tempfile::tempdir()?; - let store = temp - .path() - .join("epiphany-bifrost-body-change-publication.ccmp"); - let intent = epiphany_cultmesh_bifrost_body_change_publication_intent( - "bifrost-publication-intent-test", - "epiphany.cluster.hands", - "epiphany.Hands", - "repo:E:/Projects/EpiphanyAgent", - "E:/Projects/EpiphanyAgent", - "codex/perfect-machine-cultmesh", - "Route typed CultMesh publication proof through Bifrost.", - "Publication needs Bifrost ledger, credit, review, and GitHub routing proof.", - vec!["epiphany-core/src/cultmesh_integration.rs".to_string()], - vec!["soul-verdict-test".to_string()], - vec!["maintainer-review-test".to_string()], - vec!["epiphany.Hands".to_string()], - vec!["GameCult/EpiphanyAgent".to_string()], - ); - let receipt = epiphany_cultmesh_bifrost_body_change_publication_receipt_for_intent( - "bifrost-publication-receipt-test", - &intent, - "accepted-for-github-publication", - "bifrost-ledger-test", - "github-publication-test", - vec!["credit-receipt-test".to_string()], - vec!["maintainer-review-test".to_string()], - "https://github.com/GameCult/EpiphanyAgent/pull/test", - ); - - write_epiphany_cultmesh_bifrost_body_change_publication_intent( - &store, - "epiphany-test", - intent.clone(), - )?; - write_epiphany_cultmesh_bifrost_body_change_publication_receipt( - &store, - "epiphany-test", - receipt.clone(), - )?; - - let context = query_epiphany_local_verse_context(&store, "epiphany-test")?; - assert_eq!( - context.arrival_latest_bifrost_body_change_publication_intent, - Some(intent.clone()) - ); - assert_eq!( - context.arrival_latest_bifrost_body_change_publication_receipt, - Some(receipt.clone()) - ); - assert!(intent.github_publication_requested); - assert!(!intent.private_state_included); - assert_eq!(intent.verification_receipt_ids, vec!["soul-verdict-test"]); - assert_eq!(receipt.bifrost_ledger_entry_id, "bifrost-ledger-test"); - assert_eq!( - receipt.github_publication_receipt_id, - "github-publication-test" - ); - assert!(!receipt.private_state_exposed); - Ok(()) - } - - #[test] - fn bifrost_body_change_publication_refuses_private_or_unverified_intents() -> Result<()> { - let temp = tempfile::tempdir()?; - let store = temp - .path() - .join("epiphany-bifrost-publication-refusal.ccmp"); - let mut intent = epiphany_cultmesh_bifrost_body_change_publication_intent( - "bifrost-publication-private-test", - "epiphany.cluster.hands", - "epiphany.Hands", - "repo:E:/Projects/EpiphanyAgent", - "E:/Projects/EpiphanyAgent", - "codex/perfect-machine-cultmesh", - "Attempt invalid publication.", - "This should be refused.", - vec!["epiphany-core/src/cultmesh_integration.rs".to_string()], - vec!["soul-verdict-test".to_string()], - vec!["maintainer-review-test".to_string()], - vec!["epiphany.Hands".to_string()], - vec!["GameCult/EpiphanyAgent".to_string()], - ); - intent.private_state_included = true; - - let error = write_epiphany_cultmesh_bifrost_body_change_publication_intent( - &store, - "epiphany-test", - intent, - ) - .expect_err("private publication payloads must be refused"); - assert!(error.to_string().contains("must not include private state")); - - let unverified = epiphany_cultmesh_bifrost_body_change_publication_intent( - "bifrost-publication-unverified-test", - "epiphany.cluster.hands", - "epiphany.Hands", - "repo:E:/Projects/EpiphanyAgent", - "E:/Projects/EpiphanyAgent", - "codex/perfect-machine-cultmesh", - "Attempt unverified publication.", - "This should be refused.", - vec!["epiphany-core/src/cultmesh_integration.rs".to_string()], - Vec::new(), - vec!["maintainer-review-test".to_string()], - vec!["epiphany.Hands".to_string()], - vec!["GameCult/EpiphanyAgent".to_string()], - ); - let error = write_epiphany_cultmesh_bifrost_body_change_publication_intent( - &store, - "epiphany-test", - unverified, - ) - .expect_err("unverified publication payloads must be refused"); - assert!(error.to_string().contains("require verification receipts")); - Ok(()) - } - - #[test] - fn bifrost_github_projection_binds_hands_pr_and_ledger_proof() -> Result<()> { - let temp = tempfile::tempdir()?; - let store = temp.path().join("epiphany-bifrost-github-publication.ccmp"); - let intent = epiphany_cultmesh_bifrost_body_change_publication_intent( - "bifrost-publication-intent-test", - "epiphany.cluster.hands", - "epiphany.Hands", - "repo:E:/Projects/EpiphanyAgent", - "E:/Projects/EpiphanyAgent", - "codex/perfect-machine-cultmesh", - "Route typed GitHub publication proof through Bifrost.", - "Publication needs Bifrost ledger, Hands PR, credit, and review proof.", - vec!["epiphany-core/src/cultmesh_integration.rs".to_string()], - vec!["soul-verdict-test".to_string()], - vec!["maintainer-review-test".to_string()], - vec!["epiphany.Hands".to_string()], - vec!["GameCult/EpiphanyAgent".to_string()], - ); - let publication = epiphany_cultmesh_bifrost_body_change_publication_receipt_for_intent( - "bifrost-publication-receipt-test", - &intent, - "accepted-for-github-publication", - "bifrost-ledger-test", - "github-publication-test", - vec!["credit-receipt-test".to_string()], - vec!["maintainer-review-test".to_string()], - "https://github.com/GameCult/EpiphanyAgent/pull/test", - ); - let github = epiphany_cultmesh_bifrost_github_publication_receipt_for_publication( - "github-publication-test", - &publication, - "hands-pr-test", - "E:/Projects/EpiphanyAgent", - "codex/perfect-machine-cultmesh", - "test", - "abc123", - "epiphany.Hands", - ); - - write_epiphany_cultmesh_bifrost_body_change_publication_intent( - &store, - "epiphany-test", - intent.clone(), - )?; - write_epiphany_cultmesh_bifrost_body_change_publication_receipt( - &store, - "epiphany-test", - publication.clone(), - )?; - write_epiphany_cultmesh_bifrost_github_publication_receipt( - &store, - "epiphany-test", - github.clone(), - )?; - - let context = query_epiphany_local_verse_context(&store, "epiphany-test")?; - assert_eq!( - context.arrival_latest_bifrost_body_change_publication_intent, - Some(intent) - ); - assert_eq!( - context.arrival_latest_bifrost_body_change_publication_receipt, - Some(publication) - ); - assert_eq!( - context.arrival_latest_bifrost_github_publication_receipt, - Some(github.clone()) - ); - assert_eq!( - github.bifrost_publication_receipt_id, - "bifrost-publication-receipt-test" - ); - assert_eq!(github.hands_pr_receipt_id, "hands-pr-test"); - assert_eq!(github.ledger_entry_id, "bifrost-ledger-test"); - assert_eq!(github.credit_receipt_ids, vec!["credit-receipt-test"]); - assert_eq!( - github.pull_request_url, - "https://github.com/GameCult/EpiphanyAgent/pull/test" - ); - assert!(!github.private_state_exposed); - Ok(()) - } - - #[test] - fn bifrost_github_publication_refuses_private_or_unlinked_receipts() -> Result<()> { - let publication = EpiphanyCultMeshBifrostBodyChangePublicationReceiptEntry { - schema_version: - EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_RECEIPT_SCHEMA_VERSION.to_string(), - receipt_id: "bifrost-publication-receipt-test".to_string(), - intent_id: "bifrost-publication-intent-test".to_string(), - status: "accepted-for-github-publication".to_string(), - bifrost_ledger_entry_id: "bifrost-ledger-test".to_string(), - github_publication_receipt_id: "github-publication-test".to_string(), - credit_receipt_ids: vec!["credit-receipt-test".to_string()], - accepted_changed_paths: vec!["epiphany-core/src/cultmesh_integration.rs".to_string()], - reviewer_ids: vec!["maintainer-review-test".to_string()], - publication_url: "https://github.com/GameCult/EpiphanyAgent/pull/test".to_string(), - private_state_exposed: false, - notes: Vec::new(), - }; - let mut github = epiphany_cultmesh_bifrost_github_publication_receipt_for_publication( - "github-publication-test", - &publication, - "hands-pr-test", - "E:/Projects/EpiphanyAgent", - "codex/perfect-machine-cultmesh", - "test", - "abc123", - "epiphany.Hands", - ); - github.private_state_exposed = true; - let temp = tempfile::tempdir()?; - let store = temp.path().join("epiphany-bifrost-github-refusal.ccmp"); - let error = write_epiphany_cultmesh_bifrost_github_publication_receipt( - &store, - "epiphany-test", - github, - ) - .expect_err("private GitHub publication receipts must be refused"); - assert!(error.to_string().contains("must not expose private state")); - - let mut unlinked = epiphany_cultmesh_bifrost_github_publication_receipt_for_publication( - "github-publication-unlinked-test", - &publication, - "hands-pr-test", - "E:/Projects/EpiphanyAgent", - "codex/perfect-machine-cultmesh", - "test", - "abc123", - "epiphany.Hands", - ); - unlinked.hands_pr_receipt_id.clear(); - let error = write_epiphany_cultmesh_bifrost_github_publication_receipt( - &store, - "epiphany-test", - unlinked, - ) - .expect_err("GitHub publication receipts without Hands PR proof must be refused"); - assert!(error.to_string().contains("require a Hands PR receipt")); - Ok(()) - } - - #[test] - fn bifrost_contracts_expose_publication_without_feedback_admission_substitution() -> Result<()> - { - let temp = tempfile::tempdir()?; - let store = temp.path().join("epiphany-bifrost-contracts.ccmp"); - let written = write_epiphany_cultmesh_bifrost_contracts(&store, "epiphany-test")?; - assert_eq!(written.len(), 1); - - let node = open_epiphany_cultmesh_node(&store, "epiphany-test")?; - let publication = node.get_required::( - "gamecult.bifrost.body_change.publication", - )?; - assert!( - node.get::( - "gamecult.bifrost.collaboration.feedback", - )? - .is_none() - ); - assert_eq!(publication.verse_id, EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID); - assert_eq!(publication.authority, "bifrost"); - assert!( - publication - .receipt_document_types - .iter() - .any(|receipt| receipt == "gamecult.bifrost.github_publication_receipt") - ); - assert!( - publication - .receipt_document_types - .iter() - .any(|receipt| receipt == "gamecult.bifrost.credit_receipt") - ); - assert!( - publication - .notes - .iter() - .any(|note| note.contains("GitHub publication")) - ); - Ok(()) - } - fn heartbeat_event( heartbeat_id: &str, incarnation: &str, diff --git a/epiphany-core/src/lib.rs b/epiphany-core/src/lib.rs index 0855f66d..499fca6a 100644 --- a/epiphany-core/src/lib.rs +++ b/epiphany-core/src/lib.rs @@ -117,17 +117,6 @@ pub use cultcache_rs::RedbMessagePackBackingStore; pub use cultcache_rs::SingleFileMessagePackBackingStore; pub use cultmesh_integration::EPIPHANY_CANONICAL_SWARM_BRAKE_ID; pub use cultmesh_integration::EPIPHANY_CANONICAL_SWARM_BRAKE_OWNER; -pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_INTENT_ARRIVAL_LATEST_KEY; -pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_INTENT_SCHEMA_VERSION; -pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_INTENT_TYPE; -pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_RECEIPT_ARRIVAL_LATEST_KEY; -pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_RECEIPT_SCHEMA_VERSION; -pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_RECEIPT_TYPE; -pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_CONTRACT_SCHEMA_VERSION; -pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_CONTRACT_TYPE; -pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_GITHUB_PUBLICATION_RECEIPT_ARRIVAL_LATEST_KEY; -pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_GITHUB_PUBLICATION_RECEIPT_SCHEMA_VERSION; -pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_GITHUB_PUBLICATION_RECEIPT_TYPE; pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_HEARTBEAT_EVENT_SCHEMA_VERSION; pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_HEARTBEAT_EVENT_TYPE; pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_SCHEMA_VERSION; @@ -147,10 +136,6 @@ pub use cultmesh_integration::EPIPHANY_CULTMESH_SWARM_BRAKE_SCHEMA_VERSION; pub use cultmesh_integration::EPIPHANY_CULTMESH_SWARM_BRAKE_TYPE; pub use cultmesh_integration::EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_DAEMON_ID; pub use cultmesh_integration::EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_SERVICE_ID; -pub use cultmesh_integration::EpiphanyCultMeshBifrostBodyChangePublicationIntentEntry; -pub use cultmesh_integration::EpiphanyCultMeshBifrostBodyChangePublicationReceiptEntry; -pub use cultmesh_integration::EpiphanyCultMeshBifrostContractEntry; -pub use cultmesh_integration::EpiphanyCultMeshBifrostGithubPublicationReceiptEntry; pub use cultmesh_integration::EpiphanyCultMeshClusterTopologyEntry; pub use cultmesh_integration::EpiphanyCultMeshDaemonHeartbeatEventEntry; pub use cultmesh_integration::EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry; @@ -166,12 +151,6 @@ pub use cultmesh_integration::authenticate_epiphany_cultmesh_semantic_projector_ pub use cultmesh_integration::canonical_epiphany_swarm_brake_protected_surfaces; pub use cultmesh_integration::default_epiphany_cultmesh_swarm_brake; pub use cultmesh_integration::engage_epiphany_cultmesh_swarm_brake; -pub use cultmesh_integration::epiphany_cultmesh_bifrost_body_change_publication_intent; -#[cfg(test)] -pub use cultmesh_integration::epiphany_cultmesh_bifrost_body_change_publication_receipt_for_intent; -pub use cultmesh_integration::epiphany_cultmesh_bifrost_contracts; -#[cfg(test)] -pub use cultmesh_integration::epiphany_cultmesh_bifrost_github_publication_receipt_for_publication; pub use cultmesh_integration::epiphany_global_room_policies; pub use cultmesh_integration::epiphany_verse_policies; pub use cultmesh_integration::idunn_recover_memory_semantic_projection_from_cultmesh; @@ -190,12 +169,6 @@ pub use cultmesh_integration::publish_epiphany_cultmesh_semantic_projection_heal pub use cultmesh_integration::query_epiphany_local_verse_context; pub use cultmesh_integration::release_epiphany_cultmesh_swarm_brake; pub use cultmesh_integration::seed_epiphany_local_verse_context; -pub use cultmesh_integration::write_epiphany_cultmesh_bifrost_body_change_publication_intent; -#[cfg(test)] -pub use cultmesh_integration::write_epiphany_cultmesh_bifrost_body_change_publication_receipt; -pub use cultmesh_integration::write_epiphany_cultmesh_bifrost_contracts; -#[cfg(test)] -pub use cultmesh_integration::write_epiphany_cultmesh_bifrost_github_publication_receipt; pub use cultmesh_integration::write_epiphany_cultmesh_daemon_heartbeat_event; pub use cultmesh_integration::write_epiphany_cultmesh_daemon_service_lifecycle_receipt; pub use cultmesh_integration::write_epiphany_cultmesh_semantic_projector_service_policy;