diff --git a/.gitmodules b/.gitmodules index 6b0fc3b4..156588d7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "vendor/cultcache-rs"] path = vendor/cultcache-rs url = https://github.com/GameCult/cultcache-rs.git +[submodule "vendor/cultnet-rs"] + path = vendor/cultnet-rs + url = https://github.com/GameCult/cultnet-rs.git diff --git a/epiphany-core/Cargo.toml b/epiphany-core/Cargo.toml index f90265f4..7dc289f0 100644 --- a/epiphany-core/Cargo.toml +++ b/epiphany-core/Cargo.toml @@ -16,6 +16,7 @@ chrono = "0.4.44" codex-file-search = { path = "../vendor/codex/codex-rs/file-search" } codex-protocol = { path = "../vendor/codex/codex-rs/protocol" } cultcache-rs = { path = "../vendor/cultcache-rs" } +cultnet-rs = { path = "../vendor/cultnet-rs" } ignore = "0.4.23" reqwest = { version = "0.12", features = ["blocking", "json"] } serde = { version = "1", features = ["derive"] } diff --git a/epiphany-core/tests/cultnet_backend.rs b/epiphany-core/tests/cultnet_backend.rs new file mode 100644 index 00000000..3482a32d --- /dev/null +++ b/epiphany-core/tests/cultnet_backend.rs @@ -0,0 +1,50 @@ +use anyhow::Result; +use cultcache_rs::CultCache; +use cultcache_rs::SingleFileMessagePackBackingStore; +use cultnet_rs::CultNetDocumentBinding; +use cultnet_rs::CultNetDocumentRegistry; +use epiphany_core::EpiphanyAgentMemoryEntry; +use epiphany_core::agent_memory_status; + +#[test] +fn epiphany_agent_memory_can_move_over_cultnet_documents() -> Result<()> { + let temp = tempfile::tempdir()?; + let source_store = temp.path().join("source-agents.msgpack"); + let target_store = temp.path().join("target-agents.msgpack"); + std::fs::copy("../state/agents.msgpack", &source_store)?; + + let mut source_cache = CultCache::new(); + source_cache.register_entry_type::()?; + source_cache.add_generic_backing_store(SingleFileMessagePackBackingStore::new(&source_store)); + source_cache.pull_all_backing_stores()?; + + let mut registry = CultNetDocumentRegistry::new(); + registry.register( + CultNetDocumentBinding::for_entry::(Some( + "ghostlight.agent_state.v0".to_string(), + )), + ); + let snapshot = registry.create_snapshot_response( + &source_cache, + "epiphany-agent-memory-snapshot", + None, + None, + )?; + + let mut target_cache = CultCache::new(); + target_cache.register_entry_type::()?; + target_cache.add_generic_backing_store(SingleFileMessagePackBackingStore::new(&target_store)); + target_cache.pull_all_backing_stores()?; + let applied = registry + .apply_snapshot_response::(&mut target_cache, &snapshot)?; + assert_eq!(applied.len(), 8); + assert!( + target_cache + .get::("coordinator")? + .is_some() + ); + + let status = agent_memory_status(&target_store)?; + assert_eq!(status["ok"], true); + Ok(()) +} diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 816d953e..b97f0c40 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/vendor/cultnet-rs b/vendor/cultnet-rs new file mode 160000 index 00000000..38e796fb --- /dev/null +++ b/vendor/cultnet-rs @@ -0,0 +1 @@ +Subproject commit 38e796fb04ac3374f57d0b2d30017f1f56f04fce