Integrate local CultMesh status surface

This commit is contained in:
Meta Vens 2026-05-24 11:51:44 +01:00
commit 603ee8cd84
9 changed files with 148 additions and 5 deletions

View file

@ -0,0 +1,34 @@
use anyhow::Result;
use epiphany_core::EPIPHANY_CULTMESH_LOCAL_VERSE_ID;
use epiphany_core::EPIPHANY_CULTMESH_STATUS_SCHEMA_VERSION;
use epiphany_core::EpiphanyCultMeshStatusEntry;
use epiphany_core::load_epiphany_cultmesh_status;
use epiphany_core::write_epiphany_cultmesh_status;
use std::path::PathBuf;
fn main() -> Result<()> {
let mut store = PathBuf::from(".epiphany-smoke");
store.push("cultmesh");
std::fs::create_dir_all(&store)?;
store.push("epiphany-local.ccmp");
let status = EpiphanyCultMeshStatusEntry {
schema_version: EPIPHANY_CULTMESH_STATUS_SCHEMA_VERSION.to_string(),
runtime_id: "epiphany-cultmesh-smoke".to_string(),
verse_id: EPIPHANY_CULTMESH_LOCAL_VERSE_ID.to_string(),
app_id: "epiphany".to_string(),
note: "Epiphany wrote this through CultMesh, not direct CultNet plumbing.".to_string(),
};
write_epiphany_cultmesh_status(&store, status.clone())?;
let loaded = load_epiphany_cultmesh_status(&store, "epiphany-cultmesh-smoke")?;
if loaded != Some(status) {
anyhow::bail!("CultMesh smoke failed to round-trip Epiphany status document");
}
println!(
"epiphany cultmesh smoke ok: {}",
store.canonicalize()?.display()
);
Ok(())
}

View file

@ -0,0 +1,92 @@
use anyhow::Result;
use cultcache_rs::DatabaseEntry;
use cultmesh_rs::CultMesh;
use cultmesh_rs::CultMeshNode;
use cultmesh_rs::CultMeshNodeOptions;
use cultmesh_rs::cultmesh_documents;
use std::path::Path;
pub const EPIPHANY_CULTMESH_STATUS_TYPE: &str = "epiphany.cultmesh.status";
pub const EPIPHANY_CULTMESH_STATUS_SCHEMA_VERSION: &str = "epiphany.cultmesh.status.v0";
pub const EPIPHANY_CULTMESH_STATUS_KEY: &str = "epiphany-local/status";
pub const EPIPHANY_CULTMESH_LOCAL_VERSE_ID: &str = "epiphany-local";
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "epiphany.cultmesh.status",
schema = "EpiphanyCultMeshStatusEntry"
)]
pub struct EpiphanyCultMeshStatusEntry {
#[cultcache(key = 0)]
pub schema_version: String,
#[cultcache(key = 1)]
pub runtime_id: String,
#[cultcache(key = 2)]
pub verse_id: String,
#[cultcache(key = 3)]
pub app_id: String,
#[cultcache(key = 4)]
pub note: String,
}
cultmesh_documents!(EpiphanyCultMeshDocuments {
EpiphanyCultMeshStatusEntry => EPIPHANY_CULTMESH_STATUS_SCHEMA_VERSION,
});
pub fn open_epiphany_cultmesh_node(
store_path: impl AsRef<Path>,
runtime_id: impl Into<String>,
) -> Result<CultMeshNode> {
CultMesh::create_node(
store_path,
EpiphanyCultMeshDocuments,
CultMeshNodeOptions {
runtime_id: runtime_id.into(),
..CultMeshNodeOptions::default()
},
)
}
pub fn write_epiphany_cultmesh_status(
store_path: impl AsRef<Path>,
status: EpiphanyCultMeshStatusEntry,
) -> Result<EpiphanyCultMeshStatusEntry> {
let mut node = open_epiphany_cultmesh_node(&store_path, status.runtime_id.clone())?;
let written = node.put(EPIPHANY_CULTMESH_STATUS_KEY, &status)?;
node.flush()?;
Ok(written)
}
pub fn load_epiphany_cultmesh_status(
store_path: impl AsRef<Path>,
runtime_id: impl Into<String>,
) -> Result<Option<EpiphanyCultMeshStatusEntry>> {
let node = open_epiphany_cultmesh_node(store_path, runtime_id)?;
node.get(EPIPHANY_CULTMESH_STATUS_KEY)
}
#[cfg(test)]
mod tests {
use super::*;
use pretty_assertions::assert_eq;
#[test]
fn epiphany_status_round_trips_through_cultmesh() -> Result<()> {
let temp = tempfile::tempdir()?;
let store = temp.path().join("epiphany-local.ccmp");
let status = EpiphanyCultMeshStatusEntry {
schema_version: EPIPHANY_CULTMESH_STATUS_SCHEMA_VERSION.to_string(),
runtime_id: "epiphany-test".to_string(),
verse_id: EPIPHANY_CULTMESH_LOCAL_VERSE_ID.to_string(),
app_id: "epiphany".to_string(),
note: "CultMesh is the local abstraction over CultCache and CultNet.".to_string(),
};
write_epiphany_cultmesh_status(&store, status.clone())?;
assert_eq!(
load_epiphany_cultmesh_status(&store, "epiphany-test")?,
Some(status)
);
Ok(())
}
}

View file

@ -1,5 +1,6 @@
mod agent_memory;
mod agent_utterance_state;
mod cultmesh_integration;
mod distillation;
mod heartbeat_state;
mod memory_graph;
@ -56,6 +57,15 @@ pub use cultcache_rs::CultCacheEnvelope;
pub use cultcache_rs::DatabaseEntry;
pub use cultcache_rs::PushAllOptions;
pub use cultcache_rs::SingleFileMessagePackBackingStore;
pub use cultmesh_integration::EPIPHANY_CULTMESH_LOCAL_VERSE_ID;
pub use cultmesh_integration::EPIPHANY_CULTMESH_STATUS_KEY;
pub use cultmesh_integration::EPIPHANY_CULTMESH_STATUS_SCHEMA_VERSION;
pub use cultmesh_integration::EPIPHANY_CULTMESH_STATUS_TYPE;
pub use cultmesh_integration::EpiphanyCultMeshDocuments;
pub use cultmesh_integration::EpiphanyCultMeshStatusEntry;
pub use cultmesh_integration::load_epiphany_cultmesh_status;
pub use cultmesh_integration::open_epiphany_cultmesh_node;
pub use cultmesh_integration::write_epiphany_cultmesh_status;
pub use distillation::EpiphanyDistillInput;
pub use distillation::EpiphanyDistillProposal;
pub use distillation::distill_observation;