Add Bifrost public proof publication receipts

This commit is contained in:
Meta Vens 2026-06-20 13:17:17 +01:00
commit 228c9ad6c7
7 changed files with 607 additions and 10 deletions

View file

@ -3,6 +3,7 @@ use anyhow::Result;
use chrono::Utc;
use epiphany_core::EPIPHANY_CULTMESH_DAEMON_RESTART_POLICY_SCHEMA_VERSION;
use epiphany_core::EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_SCHEMA_VERSION;
use epiphany_core::EPIPHANY_CULTMESH_GLOBAL_VERSE_ID;
use epiphany_core::EPIPHANY_CULTMESH_INTERNAL_VERSE_ID;
use epiphany_core::EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_SCHEMA_VERSION;
use epiphany_core::EpiphanyAgentStateSoaEntry;
@ -11,6 +12,7 @@ use epiphany_core::EpiphanyCultMeshBifrostBodyChangePublicationIntentEntry;
use epiphany_core::EpiphanyCultMeshBifrostBodyChangePublicationReceiptEntry;
use epiphany_core::EpiphanyCultMeshBifrostCollaborationFeedbackEntry;
use epiphany_core::EpiphanyCultMeshBifrostGithubPublicationReceiptEntry;
use epiphany_core::EpiphanyCultMeshBifrostPublicProofPublicationReceiptEntry;
use epiphany_core::EpiphanyCultMeshClusterTopologyEntry;
use epiphany_core::EpiphanyCultMeshDaemonPokeReceiptEntry;
use epiphany_core::EpiphanyCultMeshDaemonRestartPolicyEntry;
@ -33,6 +35,7 @@ use epiphany_core::epiphany_cultmesh_bifrost_body_change_publication_intent;
use epiphany_core::epiphany_cultmesh_bifrost_body_change_publication_receipt_for_intent;
use epiphany_core::epiphany_cultmesh_bifrost_collaboration_feedback;
use epiphany_core::epiphany_cultmesh_bifrost_github_publication_receipt_for_publication;
use epiphany_core::epiphany_cultmesh_bifrost_public_proof_publication_receipt_for_proof;
use epiphany_core::epiphany_cultmesh_daemon_poke_intent_from_status;
use epiphany_core::epiphany_cultmesh_daemon_poke_receipt_for_intent;
use epiphany_core::epiphany_cultmesh_daemon_tool_invocation_intent_from_capability;
@ -56,6 +59,7 @@ use epiphany_core::load_latest_epiphany_cultmesh_bifrost_body_change_publication
use epiphany_core::load_latest_epiphany_cultmesh_bifrost_body_change_publication_receipt;
use epiphany_core::load_latest_epiphany_cultmesh_bifrost_collaboration_feedback;
use epiphany_core::load_latest_epiphany_cultmesh_bifrost_github_publication_receipt;
use epiphany_core::load_latest_epiphany_cultmesh_bifrost_public_proof_publication_receipt;
use epiphany_core::load_latest_epiphany_cultmesh_daemon_service_lifecycle_receipt;
use epiphany_core::load_latest_epiphany_cultmesh_daemon_tool_invocation_intent;
use epiphany_core::load_latest_epiphany_cultmesh_daemon_tool_invocation_receipt;
@ -72,6 +76,7 @@ use epiphany_core::write_epiphany_cultmesh_bifrost_body_change_publication_inten
use epiphany_core::write_epiphany_cultmesh_bifrost_body_change_publication_receipt;
use epiphany_core::write_epiphany_cultmesh_bifrost_collaboration_feedback;
use epiphany_core::write_epiphany_cultmesh_bifrost_github_publication_receipt;
use epiphany_core::write_epiphany_cultmesh_bifrost_public_proof_publication_receipt;
use epiphany_core::write_epiphany_cultmesh_daemon_poke_intent;
use epiphany_core::write_epiphany_cultmesh_daemon_poke_receipt;
use epiphany_core::write_epiphany_cultmesh_daemon_restart_policy;
@ -1071,6 +1076,114 @@ fn run_cli() -> Result<()> {
}))?
);
}
"bifrost-public-proof" | "publish-public-proof" | "public-proof-publication" => {
seed_epiphany_local_verse_context(
&args.store,
args.runtime_id.clone(),
Utc::now().to_rfc3339(),
)?;
let (latest_public_proof, public_proofs) = load_repo_work_public_proofs(&args)?;
let selected_public_proof = if let Some(public_proof_id) = args.public_proof_id.as_ref()
{
public_proofs
.iter()
.find(|proof| proof.public_proof_id == *public_proof_id)
.cloned()
.with_context(|| {
format!("bifrost-public-proof could not find --public-proof-id {public_proof_id}")
})?
} else {
latest_public_proof
.context("bifrost-public-proof requires a repo work public proof in local Verse or --public-proof-id")?
};
let ledger_entry_id = args
.ledger_entry_id
.clone()
.context("bifrost-public-proof requires --ledger-entry-id")?;
let review_receipts = required_list(
&args.review_receipts,
"bifrost-public-proof requires --review-receipt",
)?;
let credit_receipts = required_list(
&args.credit_receipt_ids,
"bifrost-public-proof requires --credit-receipt",
)?;
let public_room_id = args
.public_room_id
.clone()
.unwrap_or_else(|| "epiphany-global/repo-work/public-proofs".to_string());
let publication_url = args.publication_url.clone().unwrap_or_else(|| {
format!(
"cultmesh://{public_room_id}/{}",
selected_public_proof.public_proof_id
)
});
let receipt_id = args.receipt_id.clone().unwrap_or_else(|| {
format!(
"bifrost-public-proof-publication-{}",
selected_public_proof.public_proof_id
)
});
let receipt_status = args
.receipt_status
.clone()
.unwrap_or_else(|| "published-to-public-verse".to_string());
let receipt = epiphany_cultmesh_bifrost_public_proof_publication_receipt_for_proof(
receipt_id,
&selected_public_proof,
receipt_status,
EPIPHANY_CULTMESH_GLOBAL_VERSE_ID,
public_room_id,
ledger_entry_id,
credit_receipts,
review_receipts,
publication_url,
);
let written = write_epiphany_cultmesh_bifrost_public_proof_publication_receipt(
&args.store,
args.runtime_id.clone(),
receipt,
)?;
let latest = load_latest_epiphany_cultmesh_bifrost_public_proof_publication_receipt(
&args.store,
args.runtime_id.clone(),
)?;
if latest.as_ref().map(|receipt| receipt.receipt_id.as_str())
!= Some(written.receipt_id.as_str())
{
anyhow::bail!(
"local Verse query lost Bifrost public proof publication receipt after write"
);
}
println!(
"{}",
serde_json::to_string_pretty(&json!({
"schemaVersion": "epiphany.local_verse_bifrost_public_proof_publication.v0",
"status": "ok",
"store": args.store,
"runtimeId": args.runtime_id,
"receiptId": written.receipt_id,
"publicProofId": written.public_proof_id,
"publicProofRef": written.public_proof_ref,
"publicProofSha256": written.public_proof_sha256,
"item": written.item,
"sourceWorkspace": written.source_workspace,
"sourceBranch": written.source_branch,
"targetPublicVerseId": written.target_public_verse_id,
"publicRoomId": written.public_room_id,
"publicationUrl": written.publication_url,
"ledgerEntryId": written.bifrost_ledger_entry_id,
"creditReceiptIds": written.credit_receipt_ids,
"reviewReceiptIds": written.reviewer_ids,
"commands": {
"swarmOverview": WRAPPER_OVERVIEW_COMMAND,
"bifrostLedger": WRAPPER_BIFROST_LEDGER_COMMAND,
"bifrostPublicProof": "epiphany-verse-query bifrost-public-proof --public-proof-id <id> --ledger-entry-id <id> --review-receipt <id> --credit-receipt <id>"
},
"privateStateExposed": written.private_state_exposed,
}))?
);
}
"bifrost-ledger" | "publication-ledger" => {
seed_epiphany_local_verse_context(
&args.store,
@ -1087,10 +1200,12 @@ fn run_cli() -> Result<()> {
"runtimeId": args.runtime_id,
"rowCount": report.rows.len(),
"publicationChainCount": report.publication_chain_count,
"publicProofPublicationCount": report.public_proof_publication_count,
"collaborationChainCount": report.collaboration_chain_count,
"latestBifrostPublicationIntent": report.latest_publication_intent_id,
"latestBifrostPublicationReceipt": report.latest_publication_receipt_id,
"latestBifrostGithubReceipt": report.latest_github_receipt_id,
"latestBifrostPublicProofPublicationReceipt": report.latest_public_proof_publication_receipt_id,
"latestBifrostCollaborationFeedback": report.latest_feedback_id,
"latestImaginationConsensusReceipt": report.latest_consensus_receipt_id,
"tuiRows": report.tui_rows,
@ -3555,7 +3670,7 @@ fn run_cli() -> Result<()> {
);
}
other => anyhow::bail!(
"unknown command {other:?}; use seed, query, tools, tool-directory, invoke-tool, restart-policy-directory, swarm-brake, swarm-status, cluster-topology, eve-surfaces, daemon-status, agent-state, agent-state-report, poke-daemon, poke-down-daemons, bifrost-publication, bifrost-ledger, collaboration-feedback, connect-eve, or smoke"
"unknown command {other:?}; use seed, query, tools, tool-directory, invoke-tool, restart-policy-directory, swarm-brake, swarm-status, cluster-topology, eve-surfaces, daemon-status, agent-state, agent-state-report, poke-daemon, poke-down-daemons, bifrost-publication, bifrost-public-proof, bifrost-ledger, collaboration-feedback, connect-eve, or smoke"
),
}
Ok(())
@ -4330,10 +4445,12 @@ struct BifrostLedgerReport {
rows: Vec<BifrostLedgerRow>,
tui_rows: Vec<String>,
publication_chain_count: usize,
public_proof_publication_count: usize,
collaboration_chain_count: usize,
latest_publication_intent_id: Option<String>,
latest_publication_receipt_id: Option<String>,
latest_github_receipt_id: Option<String>,
latest_public_proof_publication_receipt_id: Option<String>,
latest_feedback_id: Option<String>,
latest_consensus_receipt_id: Option<String>,
private_state_exposed: bool,
@ -5901,6 +6018,62 @@ fn receipt_directory_report(
.unwrap_or(false),
},
);
push_receipt_directory_row(
&mut rows,
&mut tui_rows,
ReceiptDirectoryRow {
family: "bifrost-public-proof-publication".to_string(),
owner: "Bifrost".to_string(),
document_kind: "gamecult.bifrost.public_proof_publication_receipt.v0".to_string(),
latest_id: context
.latest_bifrost_public_proof_publication_receipt
.as_ref()
.map(|receipt| receipt.receipt_id.clone())
.unwrap_or_else(|| "missing".to_string()),
status: context
.latest_bifrost_public_proof_publication_receipt
.as_ref()
.map(|receipt| receipt.status.clone())
.unwrap_or_else(|| "missing".to_string()),
route: context
.latest_bifrost_public_proof_publication_receipt
.as_ref()
.map(|receipt| receipt.publication_url.clone())
.unwrap_or_else(|| "none".to_string()),
service_id: "none".to_string(),
service_route: "none".to_string(),
follow_up_command: WRAPPER_BIFROST_LEDGER_COMMAND.to_string(),
artifact_ref: context
.latest_bifrost_public_proof_publication_receipt
.as_ref()
.map(|receipt| receipt.public_proof_ref.clone())
.unwrap_or_else(|| "none".to_string()),
artifact_status: context
.latest_bifrost_public_proof_publication_receipt
.as_ref()
.map(|receipt| {
if receipt.public_proof_ref == "none" {
"none".to_string()
} else {
"external-ref".to_string()
}
})
.unwrap_or_else(|| "none".to_string()),
artifact_sha256: context
.latest_bifrost_public_proof_publication_receipt
.as_ref()
.map(|receipt| receipt.public_proof_sha256.clone())
.unwrap_or_else(|| "none".to_string()),
present: context
.latest_bifrost_public_proof_publication_receipt
.is_some(),
private_state_exposed: context
.latest_bifrost_public_proof_publication_receipt
.as_ref()
.map(|receipt| receipt.private_state_exposed)
.unwrap_or(false),
},
);
push_receipt_directory_row(
&mut rows,
&mut tui_rows,
@ -6600,6 +6773,11 @@ fn load_bifrost_ledger_report(args: &Args) -> Result<BifrostLedgerReport> {
&args.store,
args.runtime_id.clone(),
)?;
let latest_public_proof_publication =
load_latest_epiphany_cultmesh_bifrost_public_proof_publication_receipt(
&args.store,
args.runtime_id.clone(),
)?;
let latest_feedback = load_latest_epiphany_cultmesh_bifrost_collaboration_feedback(
&args.store,
args.runtime_id.clone(),
@ -6612,6 +6790,7 @@ fn load_bifrost_ledger_report(args: &Args) -> Result<BifrostLedgerReport> {
latest_intent.as_ref(),
latest_publication.as_ref(),
latest_github.as_ref(),
latest_public_proof_publication.as_ref(),
latest_feedback.as_ref(),
latest_consensus.as_ref(),
))
@ -6621,6 +6800,9 @@ fn bifrost_ledger_report(
latest_intent: Option<&EpiphanyCultMeshBifrostBodyChangePublicationIntentEntry>,
latest_publication: Option<&EpiphanyCultMeshBifrostBodyChangePublicationReceiptEntry>,
latest_github: Option<&EpiphanyCultMeshBifrostGithubPublicationReceiptEntry>,
latest_public_proof_publication: Option<
&EpiphanyCultMeshBifrostPublicProofPublicationReceiptEntry,
>,
latest_feedback: Option<&EpiphanyCultMeshBifrostCollaborationFeedbackEntry>,
latest_consensus: Option<&EpiphanyCultMeshImaginationConsensusReceiptEntry>,
) -> BifrostLedgerReport {
@ -6683,6 +6865,23 @@ fn bifrost_ledger_report(
},
);
}
if let Some(receipt) = latest_public_proof_publication {
push_bifrost_ledger_row(
&mut rows,
&mut tui_rows,
BifrostLedgerRow {
document_kind: "public-proof-publication-receipt".to_string(),
owner: "Bifrost".to_string(),
id: receipt.receipt_id.clone(),
status: receipt.status.clone(),
route: receipt.bifrost_ledger_entry_id.clone(),
summary: receipt.public_proof_sha256.clone(),
public_ref: receipt.publication_url.clone(),
private_state_included: false,
private_state_exposed: receipt.private_state_exposed,
},
);
}
if let Some(feedback) = latest_feedback {
push_bifrost_ledger_row(
&mut rows,
@ -6721,6 +6920,7 @@ fn bifrost_ledger_report(
let publication_chain_count = usize::from(latest_intent.is_some())
+ usize::from(latest_publication.is_some())
+ usize::from(latest_github.is_some());
let public_proof_publication_count = usize::from(latest_public_proof_publication.is_some());
let collaboration_chain_count =
usize::from(latest_feedback.is_some()) + usize::from(latest_consensus.is_some());
let private_state_exposed = rows.iter().any(|row| row.private_state_exposed);
@ -6738,10 +6938,13 @@ fn bifrost_ledger_report(
rows,
tui_rows,
publication_chain_count,
public_proof_publication_count,
collaboration_chain_count,
latest_publication_intent_id: latest_intent.map(|intent| intent.intent_id.clone()),
latest_publication_receipt_id: latest_publication.map(|receipt| receipt.receipt_id.clone()),
latest_github_receipt_id: latest_github.map(|receipt| receipt.receipt_id.clone()),
latest_public_proof_publication_receipt_id: latest_public_proof_publication
.map(|receipt| receipt.receipt_id.clone()),
latest_feedback_id: latest_feedback.map(|feedback| feedback.feedback_id.clone()),
latest_consensus_receipt_id: latest_consensus.map(|receipt| receipt.receipt_id.clone()),
private_state_exposed,
@ -7881,6 +8084,7 @@ struct Args {
ledger_entry_id: Option<String>,
hands_pr_receipt_id: Option<String>,
publication_url: Option<String>,
public_proof_id: Option<String>,
pull_request_number: Option<String>,
commit_sha: Option<String>,
source_cluster_id: Option<String>,
@ -7944,6 +8148,7 @@ impl Args {
let mut ledger_entry_id = None;
let mut hands_pr_receipt_id = None;
let mut publication_url = None;
let mut public_proof_id = None;
let mut pull_request_number = None;
let mut commit_sha = None;
let mut source_cluster_id = None;
@ -8123,6 +8328,10 @@ impl Args {
publication_url =
Some(values.next().context("missing --publication-url value")?);
}
"--public-proof-id" => {
public_proof_id =
Some(values.next().context("missing --public-proof-id value")?);
}
"--pull-request-number" => {
pull_request_number = Some(
values
@ -8269,6 +8478,7 @@ impl Args {
ledger_entry_id,
hands_pr_receipt_id,
publication_url,
public_proof_id,
pull_request_number,
commit_sha,
source_cluster_id,

View file

@ -204,6 +204,12 @@ pub const EPIPHANY_CULTMESH_BIFROST_GITHUB_PUBLICATION_RECEIPT_SCHEMA_VERSION: &
"gamecult.bifrost.github_publication_receipt.v0";
pub const EPIPHANY_CULTMESH_BIFROST_GITHUB_PUBLICATION_RECEIPT_LATEST_KEY: &str =
"gamecult-local/bifrost/github-publication-receipt/latest";
pub const EPIPHANY_CULTMESH_BIFROST_PUBLIC_PROOF_PUBLICATION_RECEIPT_TYPE: &str =
"gamecult.bifrost.public_proof_publication_receipt";
pub const EPIPHANY_CULTMESH_BIFROST_PUBLIC_PROOF_PUBLICATION_RECEIPT_SCHEMA_VERSION: &str =
"gamecult.bifrost.public_proof_publication_receipt.v0";
pub const EPIPHANY_CULTMESH_BIFROST_PUBLIC_PROOF_PUBLICATION_RECEIPT_LATEST_KEY: &str =
"gamecult-local/bifrost/public-proof-publication-receipt/latest";
pub const EPIPHANY_CULTMESH_BIFROST_COLLABORATION_FEEDBACK_TYPE: &str =
"gamecult.bifrost.collaboration_feedback";
pub const EPIPHANY_CULTMESH_BIFROST_COLLABORATION_FEEDBACK_SCHEMA_VERSION: &str =
@ -1926,6 +1932,48 @@ pub struct EpiphanyCultMeshBifrostGithubPublicationReceiptEntry {
pub notes: Vec<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "gamecult.bifrost.public_proof_publication_receipt",
schema = "EpiphanyCultMeshBifrostPublicProofPublicationReceiptEntry"
)]
pub struct EpiphanyCultMeshBifrostPublicProofPublicationReceiptEntry {
#[cultcache(key = 0)]
pub schema_version: String,
#[cultcache(key = 1)]
pub receipt_id: String,
#[cultcache(key = 2)]
pub public_proof_id: String,
#[cultcache(key = 3)]
pub public_proof_ref: String,
#[cultcache(key = 4)]
pub public_proof_sha256: String,
#[cultcache(key = 5)]
pub item: String,
#[cultcache(key = 6)]
pub source_workspace: String,
#[cultcache(key = 7)]
pub source_branch: String,
#[cultcache(key = 8)]
pub target_public_verse_id: String,
#[cultcache(key = 9)]
pub public_room_id: String,
#[cultcache(key = 10)]
pub status: String,
#[cultcache(key = 11)]
pub bifrost_ledger_entry_id: String,
#[cultcache(key = 12)]
pub credit_receipt_ids: Vec<String>,
#[cultcache(key = 13)]
pub reviewer_ids: Vec<String>,
#[cultcache(key = 14)]
pub publication_url: String,
#[cultcache(key = 15)]
pub private_state_exposed: bool,
#[cultcache(key = 16)]
pub notes: Vec<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "gamecult.bifrost.collaboration_feedback",
@ -2027,6 +2075,8 @@ pub struct EpiphanyLocalVerseContext {
Option<EpiphanyCultMeshBifrostBodyChangePublicationReceiptEntry>,
pub latest_bifrost_github_publication_receipt:
Option<EpiphanyCultMeshBifrostGithubPublicationReceiptEntry>,
pub latest_bifrost_public_proof_publication_receipt:
Option<EpiphanyCultMeshBifrostPublicProofPublicationReceiptEntry>,
pub latest_bifrost_collaboration_feedback:
Option<EpiphanyCultMeshBifrostCollaborationFeedbackEntry>,
pub latest_imagination_consensus_receipt:
@ -2121,6 +2171,7 @@ cultmesh_documents!(EpiphanyCultMeshDocuments {
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,
EpiphanyCultMeshBifrostPublicProofPublicationReceiptEntry => EPIPHANY_CULTMESH_BIFROST_PUBLIC_PROOF_PUBLICATION_RECEIPT_SCHEMA_VERSION,
EpiphanyCultMeshBifrostCollaborationFeedbackEntry => EPIPHANY_CULTMESH_BIFROST_COLLABORATION_FEEDBACK_SCHEMA_VERSION,
EpiphanyCultMeshImaginationConsensusReceiptEntry => EPIPHANY_CULTMESH_IMAGINATION_CONSENSUS_RECEIPT_SCHEMA_VERSION,
});
@ -3756,6 +3807,70 @@ pub fn load_latest_epiphany_cultmesh_bifrost_github_publication_receipt(
node.get(EPIPHANY_CULTMESH_BIFROST_GITHUB_PUBLICATION_RECEIPT_LATEST_KEY)
}
#[allow(clippy::too_many_arguments)]
pub fn epiphany_cultmesh_bifrost_public_proof_publication_receipt_for_proof(
receipt_id: impl Into<String>,
proof: &EpiphanyCultMeshRepoWorkPublicProofEntry,
status: impl Into<String>,
target_public_verse_id: impl Into<String>,
public_room_id: impl Into<String>,
bifrost_ledger_entry_id: impl Into<String>,
credit_receipt_ids: Vec<String>,
reviewer_ids: Vec<String>,
publication_url: impl Into<String>,
) -> EpiphanyCultMeshBifrostPublicProofPublicationReceiptEntry {
EpiphanyCultMeshBifrostPublicProofPublicationReceiptEntry {
schema_version:
EPIPHANY_CULTMESH_BIFROST_PUBLIC_PROOF_PUBLICATION_RECEIPT_SCHEMA_VERSION.to_string(),
receipt_id: receipt_id.into(),
public_proof_id: proof.public_proof_id.clone(),
public_proof_ref: proof.public_proof_ref.clone(),
public_proof_sha256: proof.public_proof_sha256.clone(),
item: proof.item.clone(),
source_workspace: proof.workspace.clone(),
source_branch: proof.branch.clone(),
target_public_verse_id: target_public_verse_id.into(),
public_room_id: public_room_id.into(),
status: status.into(),
bifrost_ledger_entry_id: bifrost_ledger_entry_id.into(),
credit_receipt_ids,
reviewer_ids,
publication_url: publication_url.into(),
private_state_exposed: false,
notes: vec![
"Bifrost public-proof publication receipt binds a redacted repo-work proof bundle to a public Verse room.".to_string(),
"The receipt carries only proof refs, hashes, ledger, review, and credit ids; private worker/operator/agent state remains sealed.".to_string(),
"Gjallar may read this closure, but Bifrost owns public publication authority.".to_string(),
],
}
}
pub fn write_epiphany_cultmesh_bifrost_public_proof_publication_receipt(
store_path: impl AsRef<Path>,
runtime_id: impl Into<String>,
receipt: EpiphanyCultMeshBifrostPublicProofPublicationReceiptEntry,
) -> Result<EpiphanyCultMeshBifrostPublicProofPublicationReceiptEntry> {
validate_bifrost_public_proof_publication_receipt(&receipt)?;
let mut node = open_epiphany_cultmesh_node(store_path, runtime_id)?;
let receipt_key =
epiphany_cultmesh_bifrost_public_proof_publication_receipt_key(&receipt.receipt_id);
let written = node.put(receipt_key.as_str(), &receipt)?;
node.put(
EPIPHANY_CULTMESH_BIFROST_PUBLIC_PROOF_PUBLICATION_RECEIPT_LATEST_KEY,
&written,
)?;
node.flush()?;
Ok(written)
}
pub fn load_latest_epiphany_cultmesh_bifrost_public_proof_publication_receipt(
store_path: impl AsRef<Path>,
runtime_id: impl Into<String>,
) -> Result<Option<EpiphanyCultMeshBifrostPublicProofPublicationReceiptEntry>> {
let node = open_epiphany_cultmesh_node(store_path, runtime_id)?;
node.get(EPIPHANY_CULTMESH_BIFROST_PUBLIC_PROOF_PUBLICATION_RECEIPT_LATEST_KEY)
}
pub fn epiphany_cultmesh_bifrost_collaboration_feedback(
feedback_id: impl Into<String>,
source_persona_id: impl Into<String>,
@ -3979,6 +4094,58 @@ fn validate_bifrost_github_publication_receipt(
Ok(())
}
fn validate_bifrost_public_proof_publication_receipt(
receipt: &EpiphanyCultMeshBifrostPublicProofPublicationReceiptEntry,
) -> Result<()> {
if receipt.schema_version
!= EPIPHANY_CULTMESH_BIFROST_PUBLIC_PROOF_PUBLICATION_RECEIPT_SCHEMA_VERSION
{
return Err(anyhow!(
"Bifrost public proof publication receipts require schema version {}",
EPIPHANY_CULTMESH_BIFROST_PUBLIC_PROOF_PUBLICATION_RECEIPT_SCHEMA_VERSION
));
}
if receipt.private_state_exposed {
return Err(anyhow!(
"Bifrost public proof publication receipts must not expose private state"
));
}
if receipt.public_proof_id.trim().is_empty()
|| receipt.public_proof_ref.trim().is_empty()
|| receipt.public_proof_sha256.trim().is_empty()
{
return Err(anyhow!(
"Bifrost public proof publication receipts require proof id, ref, and SHA-256"
));
}
if receipt.target_public_verse_id != EPIPHANY_CULTMESH_GLOBAL_VERSE_ID {
return Err(anyhow!(
"Bifrost public proof publication receipts must target the global public Verse"
));
}
if receipt.public_room_id.trim().is_empty() || receipt.publication_url.trim().is_empty() {
return Err(anyhow!(
"Bifrost public proof publication receipts require a public room and publication URL"
));
}
if receipt.bifrost_ledger_entry_id.trim().is_empty() {
return Err(anyhow!(
"Bifrost public proof publication receipts require a ledger entry"
));
}
if receipt.credit_receipt_ids.is_empty() {
return Err(anyhow!(
"Bifrost public proof publication receipts require credit receipts"
));
}
if receipt.reviewer_ids.is_empty() {
return Err(anyhow!(
"Bifrost public proof publication receipts require reviewer receipts"
));
}
Ok(())
}
fn validate_bifrost_collaboration_feedback(
feedback: &EpiphanyCultMeshBifrostCollaborationFeedbackEntry,
) -> Result<()> {
@ -4557,6 +4724,8 @@ pub fn query_epiphany_local_verse_context(
.get(EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_RECEIPT_LATEST_KEY)?,
latest_bifrost_github_publication_receipt: node
.get(EPIPHANY_CULTMESH_BIFROST_GITHUB_PUBLICATION_RECEIPT_LATEST_KEY)?,
latest_bifrost_public_proof_publication_receipt: node
.get(EPIPHANY_CULTMESH_BIFROST_PUBLIC_PROOF_PUBLICATION_RECEIPT_LATEST_KEY)?,
latest_bifrost_collaboration_feedback: node
.get(EPIPHANY_CULTMESH_BIFROST_COLLABORATION_FEEDBACK_LATEST_KEY)?,
latest_imagination_consensus_receipt: node
@ -4920,6 +5089,10 @@ fn epiphany_cultmesh_bifrost_github_publication_receipt_key(receipt_id: &str) ->
format!("gamecult-local/bifrost/github-publication-receipt/{receipt_id}")
}
fn epiphany_cultmesh_bifrost_public_proof_publication_receipt_key(receipt_id: &str) -> String {
format!("gamecult-local/bifrost/public-proof-publication-receipt/{receipt_id}")
}
fn epiphany_cultmesh_bifrost_collaboration_feedback_key(feedback_id: &str) -> String {
format!("gamecult-local/bifrost/collaboration-feedback/{feedback_id}")
}
@ -5730,6 +5903,36 @@ pub fn epiphany_cultmesh_bifrost_contracts() -> Vec<EpiphanyCultMeshBifrostContr
"Public Persona discussion is thought weather until reviewed local adoption and Bifrost/GameCult receipts bind it to implementation.".to_string(),
],
},
EpiphanyCultMeshBifrostContractEntry {
schema_version: EPIPHANY_CULTMESH_BIFROST_CONTRACT_SCHEMA_VERSION.to_string(),
contract_id: "gamecult.bifrost.public_proof.publication".to_string(),
verse_id: EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID.to_string(),
document_type:
EPIPHANY_CULTMESH_BIFROST_PUBLIC_PROOF_PUBLICATION_RECEIPT_TYPE.to_string(),
payload_schema_version:
EPIPHANY_CULTMESH_BIFROST_PUBLIC_PROOF_PUBLICATION_RECEIPT_SCHEMA_VERSION
.to_string(),
authority: "bifrost".to_string(),
operations: vec![
"publishRedactedProof".to_string(),
"receiptWatch".to_string(),
"snapshot".to_string(),
],
intent_document_types: vec![
EPIPHANY_CULTMESH_REPO_WORK_PUBLIC_PROOF_TYPE.to_string(),
],
receipt_document_types: vec![
EPIPHANY_CULTMESH_BIFROST_PUBLIC_PROOF_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}."
),
"Repo-work public proof bundles are redacted evidence packets, not body changes; Bifrost publishes them into public Verse rooms after review and credit receipts exist.".to_string(),
"Gjallar reads the published proof closure, but Bifrost owns public publication authority and ledger attribution.".to_string(),
],
},
]
}
@ -7458,6 +7661,144 @@ mod tests {
Ok(())
}
#[test]
fn bifrost_public_proof_publication_receipt_round_trips() -> Result<()> {
let temp = tempfile::tempdir()?;
let store = temp
.path()
.join("epiphany-bifrost-public-proof-publication.ccmp");
let proof = EpiphanyCultMeshRepoWorkPublicProofEntry {
schema_version: EPIPHANY_CULTMESH_REPO_WORK_PUBLIC_PROOF_SCHEMA_VERSION.to_string(),
runtime_id: "epiphany-test".to_string(),
verse_id: EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID.to_string(),
public_proof_id: "repo-work-public-proof-test".to_string(),
generated_at: "2026-06-20T12:00:00Z".to_string(),
workspace: "E:/Projects/EpiphanyAgent".to_string(),
item: "test-item".to_string(),
branch: "codex/test-item".to_string(),
current_gate: "awaiting-publication".to_string(),
blocker: "bifrost-publication-missing".to_string(),
next_safe_move: "publish-redacted-proof".to_string(),
changed_paths: vec!["notes/test.md".to_string()],
commit_sha: "abc123".to_string(),
soul_verdict: "passed".to_string(),
upstream_main_synced: true,
artifact_row_count: 3,
publication_row_count: 5,
public_proof_ref: "public-proof.json".to_string(),
public_proof_sha256: "0123456789abcdef".to_string(),
tui_rows: vec!["proof row".to_string()],
private_state_exposed: false,
notes: vec!["redacted proof".to_string()],
};
let receipt = epiphany_cultmesh_bifrost_public_proof_publication_receipt_for_proof(
"bifrost-public-proof-publication-test",
&proof,
"published-to-public-verse",
EPIPHANY_CULTMESH_GLOBAL_VERSE_ID,
"epiphany-global/repo-work/public-proofs",
"bifrost-ledger-public-proof-test",
vec!["credit-receipt-test".to_string()],
vec!["maintainer-review-test".to_string()],
"cultmesh://epiphany-global/repo-work/public-proofs/repo-work-public-proof-test",
);
write_epiphany_cultmesh_bifrost_public_proof_publication_receipt(
&store,
"epiphany-test",
receipt.clone(),
)?;
assert_eq!(
load_latest_epiphany_cultmesh_bifrost_public_proof_publication_receipt(
&store,
"epiphany-test"
)?,
Some(receipt.clone())
);
assert_eq!(receipt.public_proof_id, proof.public_proof_id);
assert_eq!(receipt.public_proof_sha256, proof.public_proof_sha256);
assert_eq!(
receipt.target_public_verse_id,
EPIPHANY_CULTMESH_GLOBAL_VERSE_ID
);
assert_eq!(receipt.credit_receipt_ids, vec!["credit-receipt-test"]);
assert_eq!(receipt.reviewer_ids, vec!["maintainer-review-test"]);
assert!(!receipt.private_state_exposed);
Ok(())
}
#[test]
fn bifrost_public_proof_publication_refuses_private_or_wrong_verse() -> Result<()> {
let temp = tempfile::tempdir()?;
let store = temp
.path()
.join("epiphany-bifrost-public-proof-publication-refusal.ccmp");
let proof = EpiphanyCultMeshRepoWorkPublicProofEntry {
schema_version: EPIPHANY_CULTMESH_REPO_WORK_PUBLIC_PROOF_SCHEMA_VERSION.to_string(),
runtime_id: "epiphany-test".to_string(),
verse_id: EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID.to_string(),
public_proof_id: "repo-work-public-proof-test".to_string(),
generated_at: "2026-06-20T12:00:00Z".to_string(),
workspace: "E:/Projects/EpiphanyAgent".to_string(),
item: "test-item".to_string(),
branch: "codex/test-item".to_string(),
current_gate: "awaiting-publication".to_string(),
blocker: "bifrost-publication-missing".to_string(),
next_safe_move: "publish-redacted-proof".to_string(),
changed_paths: vec!["notes/test.md".to_string()],
commit_sha: "abc123".to_string(),
soul_verdict: "passed".to_string(),
upstream_main_synced: true,
artifact_row_count: 3,
publication_row_count: 5,
public_proof_ref: "public-proof.json".to_string(),
public_proof_sha256: "0123456789abcdef".to_string(),
tui_rows: vec!["proof row".to_string()],
private_state_exposed: false,
notes: vec!["redacted proof".to_string()],
};
let mut receipt = epiphany_cultmesh_bifrost_public_proof_publication_receipt_for_proof(
"bifrost-public-proof-publication-private-test",
&proof,
"published-to-public-verse",
EPIPHANY_CULTMESH_GLOBAL_VERSE_ID,
"epiphany-global/repo-work/public-proofs",
"bifrost-ledger-public-proof-test",
vec!["credit-receipt-test".to_string()],
vec!["maintainer-review-test".to_string()],
"cultmesh://epiphany-global/repo-work/public-proofs/repo-work-public-proof-test",
);
receipt.private_state_exposed = true;
let error = write_epiphany_cultmesh_bifrost_public_proof_publication_receipt(
&store,
"epiphany-test",
receipt,
)
.expect_err("private proof publication receipts must be refused");
assert!(error.to_string().contains("must not expose private state"));
let wrong_verse = epiphany_cultmesh_bifrost_public_proof_publication_receipt_for_proof(
"bifrost-public-proof-publication-wrong-verse-test",
&proof,
"published-to-public-verse",
EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID,
"gamecult-local/repo-work/public-proofs",
"bifrost-ledger-public-proof-test",
vec!["credit-receipt-test".to_string()],
vec!["maintainer-review-test".to_string()],
"cultmesh://gamecult-local/repo-work/public-proofs/repo-work-public-proof-test",
);
let error = write_epiphany_cultmesh_bifrost_public_proof_publication_receipt(
&store,
"epiphany-test",
wrong_verse,
)
.expect_err("non-public Verse proof publication receipts must be refused");
assert!(error.to_string().contains("global public Verse"));
Ok(())
}
#[test]
fn collaboration_feedback_routes_to_imagination_consensus() -> Result<()> {
let temp = tempfile::tempdir()?;
@ -7796,7 +8137,7 @@ mod tests {
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(), 2);
assert_eq!(written.len(), 3);
let node = open_epiphany_cultmesh_node(&store, "epiphany-test")?;
let publication = node.get_required::<EpiphanyCultMeshBifrostContractEntry>(
@ -7805,6 +8146,9 @@ mod tests {
let feedback = node.get_required::<EpiphanyCultMeshBifrostContractEntry>(
"gamecult.bifrost.collaboration.feedback",
)?;
let public_proof = node.get_required::<EpiphanyCultMeshBifrostContractEntry>(
"gamecult.bifrost.public_proof.publication",
)?;
assert_eq!(publication.verse_id, EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID);
assert_eq!(publication.authority, "bifrost");
@ -7833,6 +8177,24 @@ mod tests {
.iter()
.any(|note| note.contains("thought weather"))
);
assert_eq!(public_proof.authority, "bifrost");
assert_eq!(
public_proof.document_type,
EPIPHANY_CULTMESH_BIFROST_PUBLIC_PROOF_PUBLICATION_RECEIPT_TYPE
);
assert!(
public_proof
.intent_document_types
.iter()
.any(|intent| intent == EPIPHANY_CULTMESH_REPO_WORK_PUBLIC_PROOF_TYPE)
);
assert!(
public_proof
.receipt_document_types
.iter()
.any(|receipt| receipt
== EPIPHANY_CULTMESH_BIFROST_PUBLIC_PROOF_PUBLICATION_RECEIPT_TYPE)
);
Ok(())
}
}

View file

@ -233,6 +233,7 @@ pub use cultmesh_integration::EpiphanyCultMeshBifrostBodyChangePublicationReceip
pub use cultmesh_integration::EpiphanyCultMeshBifrostCollaborationFeedbackEntry;
pub use cultmesh_integration::EpiphanyCultMeshBifrostContractEntry;
pub use cultmesh_integration::EpiphanyCultMeshBifrostGithubPublicationReceiptEntry;
pub use cultmesh_integration::EpiphanyCultMeshBifrostPublicProofPublicationReceiptEntry;
pub use cultmesh_integration::EpiphanyCultMeshClusterTopologyEntry;
pub use cultmesh_integration::EpiphanyCultMeshContinuityContractEntry;
pub use cultmesh_integration::EpiphanyCultMeshCoordinatorRunReceiptEntry;
@ -284,6 +285,7 @@ pub use cultmesh_integration::epiphany_cultmesh_bifrost_body_change_publication_
pub use cultmesh_integration::epiphany_cultmesh_bifrost_collaboration_feedback;
pub use cultmesh_integration::epiphany_cultmesh_bifrost_contracts;
pub use cultmesh_integration::epiphany_cultmesh_bifrost_github_publication_receipt_for_publication;
pub use cultmesh_integration::epiphany_cultmesh_bifrost_public_proof_publication_receipt_for_proof;
pub use cultmesh_integration::epiphany_cultmesh_continuity_contracts;
pub use cultmesh_integration::epiphany_cultmesh_coordinator_run_receipt_from_summary_json;
pub use cultmesh_integration::epiphany_cultmesh_daemon_poke_intent_from_status;
@ -327,6 +329,7 @@ pub use cultmesh_integration::load_latest_epiphany_cultmesh_bifrost_body_change_
pub use cultmesh_integration::load_latest_epiphany_cultmesh_bifrost_body_change_publication_receipt;
pub use cultmesh_integration::load_latest_epiphany_cultmesh_bifrost_collaboration_feedback;
pub use cultmesh_integration::load_latest_epiphany_cultmesh_bifrost_github_publication_receipt;
pub use cultmesh_integration::load_latest_epiphany_cultmesh_bifrost_public_proof_publication_receipt;
pub use cultmesh_integration::load_latest_epiphany_cultmesh_coordinator_run_receipt;
pub use cultmesh_integration::load_latest_epiphany_cultmesh_daemon_poke_intent;
pub use cultmesh_integration::load_latest_epiphany_cultmesh_daemon_poke_receipt;
@ -355,6 +358,7 @@ pub use cultmesh_integration::write_epiphany_cultmesh_bifrost_body_change_public
pub use cultmesh_integration::write_epiphany_cultmesh_bifrost_collaboration_feedback;
pub use cultmesh_integration::write_epiphany_cultmesh_bifrost_contracts;
pub use cultmesh_integration::write_epiphany_cultmesh_bifrost_github_publication_receipt;
pub use cultmesh_integration::write_epiphany_cultmesh_bifrost_public_proof_publication_receipt;
pub use cultmesh_integration::write_epiphany_cultmesh_continuity_contracts;
pub use cultmesh_integration::write_epiphany_cultmesh_coordinator_run_receipt;
pub use cultmesh_integration::write_epiphany_cultmesh_daemon_poke_intent;