Add native operator snapshots
This commit is contained in:
parent
f476f17223
commit
3abd6803a4
14 changed files with 672 additions and 39 deletions
|
|
@ -4,14 +4,17 @@ use epiphany_core::EPIPHANY_CULTMESH_INTERNAL_VERSE_ID;
|
|||
use epiphany_core::EPIPHANY_CULTMESH_STATUS_SCHEMA_VERSION;
|
||||
use epiphany_core::EpiphanyCultMeshStatusEntry;
|
||||
use epiphany_core::default_epiphany_cultmesh_operator_status;
|
||||
use epiphany_core::epiphany_cultmesh_operator_snapshot_from_status_json;
|
||||
use epiphany_core::load_epiphany_cultmesh_operator_status;
|
||||
use epiphany_core::load_epiphany_cultmesh_status;
|
||||
use epiphany_core::load_latest_epiphany_cultmesh_operator_snapshot;
|
||||
use epiphany_core::write_epiphany_cultmesh_body_contracts;
|
||||
use epiphany_core::write_epiphany_cultmesh_eyes_contracts;
|
||||
use epiphany_core::write_epiphany_cultmesh_global_room_policies;
|
||||
use epiphany_core::write_epiphany_cultmesh_hands_contracts;
|
||||
use epiphany_core::write_epiphany_cultmesh_life_contracts;
|
||||
use epiphany_core::write_epiphany_cultmesh_mind_contracts;
|
||||
use epiphany_core::write_epiphany_cultmesh_operator_snapshot;
|
||||
use epiphany_core::write_epiphany_cultmesh_operator_status;
|
||||
use epiphany_core::write_epiphany_cultmesh_soul_contracts;
|
||||
use epiphany_core::write_epiphany_cultmesh_status;
|
||||
|
|
@ -47,6 +50,42 @@ fn main() -> Result<()> {
|
|||
"2026-05-27T00:00:00Z",
|
||||
);
|
||||
write_epiphany_cultmesh_operator_status(&store, operator_status.clone())?;
|
||||
let operator_snapshot = epiphany_cultmesh_operator_snapshot_from_status_json(
|
||||
"epiphany-cultmesh-smoke",
|
||||
"cultmesh-smoke-status",
|
||||
"2026-05-27T00:00:00Z",
|
||||
"status",
|
||||
".epiphany-smoke/cultmesh/status.json",
|
||||
&serde_json::json!({
|
||||
"threadId": "thread-smoke",
|
||||
"scene": {
|
||||
"scene": {
|
||||
"stateStatus": "missing",
|
||||
"availableActions": ["crrc", "roles"]
|
||||
}
|
||||
},
|
||||
"pressure": {
|
||||
"pressure": {
|
||||
"level": "low"
|
||||
}
|
||||
},
|
||||
"reorient": {
|
||||
"decision": {
|
||||
"action": "regather",
|
||||
"nextAction": "Regather source context."
|
||||
}
|
||||
},
|
||||
"crrc": {
|
||||
"recommendation": {
|
||||
"action": "regatherManually"
|
||||
}
|
||||
},
|
||||
"coordinator": {
|
||||
"action": "wait"
|
||||
}
|
||||
}),
|
||||
)?;
|
||||
write_epiphany_cultmesh_operator_snapshot(&store, operator_snapshot.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");
|
||||
|
|
@ -56,6 +95,11 @@ fn main() -> Result<()> {
|
|||
if loaded_operator_status != Some(operator_status) {
|
||||
anyhow::bail!("CultMesh smoke failed to round-trip Epiphany operator status document");
|
||||
}
|
||||
let loaded_operator_snapshot =
|
||||
load_latest_epiphany_cultmesh_operator_snapshot(&store, "epiphany-cultmesh-smoke")?;
|
||||
if loaded_operator_snapshot != Some(operator_snapshot) {
|
||||
anyhow::bail!("CultMesh smoke failed to round-trip Epiphany operator snapshot document");
|
||||
}
|
||||
|
||||
println!(
|
||||
"epiphany cultmesh smoke ok: {}",
|
||||
|
|
|
|||
164
epiphany-core/src/bin/epiphany-operator-snapshot.rs
Normal file
164
epiphany-core/src/bin/epiphany-operator-snapshot.rs
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use chrono::Utc;
|
||||
use epiphany_core::epiphany_cultmesh_operator_snapshot_from_status_json;
|
||||
use epiphany_core::load_latest_epiphany_cultmesh_operator_snapshot;
|
||||
use epiphany_core::write_epiphany_cultmesh_operator_snapshot;
|
||||
use serde_json::Value;
|
||||
use serde_json::json;
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let args = Args::parse()?;
|
||||
match args.command.as_str() {
|
||||
"from-status" => {
|
||||
let input = args.input.context("from-status requires --input")?;
|
||||
let source = fs::read_to_string(&input)
|
||||
.with_context(|| format!("failed to read {}", input.display()))?;
|
||||
let status_json: Value = serde_json::from_str(&source)
|
||||
.with_context(|| format!("failed to parse {}", input.display()))?;
|
||||
let snapshot = epiphany_cultmesh_operator_snapshot_from_status_json(
|
||||
args.runtime_id.clone(),
|
||||
args.snapshot_id.clone(),
|
||||
Utc::now().to_rfc3339(),
|
||||
args.source_mode.clone(),
|
||||
input.to_string_lossy(),
|
||||
&status_json,
|
||||
)?;
|
||||
let written = write_epiphany_cultmesh_operator_snapshot(&args.store, snapshot)?;
|
||||
print_json(json!({
|
||||
"status": "written",
|
||||
"store": args.store,
|
||||
"snapshot": written,
|
||||
}))?;
|
||||
}
|
||||
"latest" => {
|
||||
let latest =
|
||||
load_latest_epiphany_cultmesh_operator_snapshot(&args.store, &args.runtime_id)?;
|
||||
print_json(json!({
|
||||
"status": if latest.is_some() { "ready" } else { "missing" },
|
||||
"store": args.store,
|
||||
"snapshot": latest,
|
||||
}))?;
|
||||
}
|
||||
"smoke" => {
|
||||
let status_json = json!({
|
||||
"threadId": "thread-smoke",
|
||||
"scene": {
|
||||
"scene": {
|
||||
"stateStatus": "missing",
|
||||
"availableActions": ["crrc", "roles"]
|
||||
}
|
||||
},
|
||||
"pressure": {
|
||||
"pressure": {
|
||||
"level": "low"
|
||||
}
|
||||
},
|
||||
"reorient": {
|
||||
"decision": {
|
||||
"action": "regather",
|
||||
"nextAction": "Regather source context."
|
||||
}
|
||||
},
|
||||
"crrc": {
|
||||
"recommendation": {
|
||||
"action": "regatherManually"
|
||||
}
|
||||
},
|
||||
"coordinator": {
|
||||
"action": "wait"
|
||||
},
|
||||
"rawResult": {
|
||||
"sealed": true
|
||||
}
|
||||
});
|
||||
let snapshot = epiphany_cultmesh_operator_snapshot_from_status_json(
|
||||
args.runtime_id.clone(),
|
||||
args.snapshot_id.clone(),
|
||||
"2026-05-27T00:00:00Z",
|
||||
"status",
|
||||
".epiphany-smoke/operator-status.json",
|
||||
&status_json,
|
||||
)?;
|
||||
write_epiphany_cultmesh_operator_snapshot(&args.store, snapshot.clone())?;
|
||||
let latest =
|
||||
load_latest_epiphany_cultmesh_operator_snapshot(&args.store, &args.runtime_id)?;
|
||||
if latest != Some(snapshot) {
|
||||
anyhow::bail!("operator snapshot did not round-trip through CultMesh");
|
||||
}
|
||||
print_json(json!({
|
||||
"status": "ok",
|
||||
"store": args.store,
|
||||
"runtimeId": args.runtime_id,
|
||||
"snapshotId": args.snapshot_id,
|
||||
}))?;
|
||||
}
|
||||
other => anyhow::bail!("unknown command {other:?}; use from-status, latest, or smoke"),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
struct Args {
|
||||
command: String,
|
||||
store: PathBuf,
|
||||
runtime_id: String,
|
||||
snapshot_id: String,
|
||||
source_mode: String,
|
||||
input: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl Args {
|
||||
fn parse() -> Result<Self> {
|
||||
let mut values = env::args().skip(1);
|
||||
let command = values.next().unwrap_or_else(|| "latest".to_string());
|
||||
let mut store = PathBuf::from(".epiphany-run/cultmesh/operator-snapshots.ccmp");
|
||||
let mut runtime_id = "epiphany-local".to_string();
|
||||
let mut snapshot_id = format!("snapshot-{}", Utc::now().timestamp());
|
||||
let mut source_mode = "status".to_string();
|
||||
let mut input = None;
|
||||
|
||||
while let Some(arg) = values.next() {
|
||||
match arg.as_str() {
|
||||
"--store" => {
|
||||
store = PathBuf::from(values.next().context("missing --store value")?);
|
||||
}
|
||||
"--runtime-id" => {
|
||||
runtime_id = values.next().context("missing --runtime-id value")?;
|
||||
}
|
||||
"--snapshot-id" => {
|
||||
snapshot_id = values.next().context("missing --snapshot-id value")?;
|
||||
}
|
||||
"--source-mode" => {
|
||||
source_mode = values.next().context("missing --source-mode value")?;
|
||||
}
|
||||
"--input" => {
|
||||
input = Some(PathBuf::from(
|
||||
values.next().context("missing --input value")?,
|
||||
));
|
||||
}
|
||||
_ => anyhow::bail!("unknown argument {arg:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(parent) = store.parent() {
|
||||
fs::create_dir_all(parent)?;
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
command,
|
||||
store,
|
||||
runtime_id,
|
||||
snapshot_id,
|
||||
source_mode,
|
||||
input,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn print_json(value: Value) -> Result<()> {
|
||||
println!("{}", serde_json::to_string_pretty(&value)?);
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -5,11 +5,13 @@ use crate::default_life_cultnet_contracts;
|
|||
use crate::default_mind_cultnet_contracts;
|
||||
use crate::default_soul_cultnet_contracts;
|
||||
use anyhow::Result;
|
||||
use anyhow::anyhow;
|
||||
use cultcache_rs::DatabaseEntry;
|
||||
use cultmesh_rs::CultMesh;
|
||||
use cultmesh_rs::CultMeshNode;
|
||||
use cultmesh_rs::CultMeshNodeOptions;
|
||||
use cultmesh_rs::cultmesh_documents;
|
||||
use serde_json::Value;
|
||||
use std::path::Path;
|
||||
|
||||
pub const EPIPHANY_CULTMESH_STATUS_TYPE: &str = "epiphany.cultmesh.status";
|
||||
|
|
@ -19,6 +21,11 @@ pub const EPIPHANY_CULTMESH_OPERATOR_STATUS_TYPE: &str = "epiphany.cultmesh.oper
|
|||
pub const EPIPHANY_CULTMESH_OPERATOR_STATUS_SCHEMA_VERSION: &str =
|
||||
"epiphany.cultmesh.operator_status.v0";
|
||||
pub const EPIPHANY_CULTMESH_OPERATOR_STATUS_KEY: &str = "epiphany-local/operator-status";
|
||||
pub const EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_TYPE: &str = "epiphany.cultmesh.operator_snapshot";
|
||||
pub const EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_SCHEMA_VERSION: &str =
|
||||
"epiphany.cultmesh.operator_snapshot.v0";
|
||||
pub const EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_LATEST_KEY: &str =
|
||||
"epiphany-local/operator-snapshot/latest";
|
||||
pub const EPIPHANY_CULTMESH_VERSE_POLICY_TYPE: &str = "epiphany.cultmesh.verse_policy";
|
||||
pub const EPIPHANY_CULTMESH_VERSE_POLICY_SCHEMA_VERSION: &str = "epiphany.cultmesh.verse_policy.v0";
|
||||
pub const EPIPHANY_CULTMESH_GLOBAL_ROOM_POLICY_TYPE: &str = "epiphany.cultmesh.global_room_policy";
|
||||
|
|
@ -101,6 +108,50 @@ pub struct EpiphanyCultMeshOperatorStatusEntry {
|
|||
pub quarantined_surfaces: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.cultmesh.operator_snapshot",
|
||||
schema = "EpiphanyCultMeshOperatorSnapshotEntry"
|
||||
)]
|
||||
pub struct EpiphanyCultMeshOperatorSnapshotEntry {
|
||||
#[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 snapshot_id: String,
|
||||
#[cultcache(key = 4)]
|
||||
pub generated_at_utc: String,
|
||||
#[cultcache(key = 5)]
|
||||
pub source_mode: String,
|
||||
#[cultcache(key = 6)]
|
||||
pub source_path: String,
|
||||
#[cultcache(key = 7)]
|
||||
pub thread_id: String,
|
||||
#[cultcache(key = 8)]
|
||||
pub status: String,
|
||||
#[cultcache(key = 9)]
|
||||
pub state_status: String,
|
||||
#[cultcache(key = 10)]
|
||||
pub coordinator_action: String,
|
||||
#[cultcache(key = 11)]
|
||||
pub crrc_action: String,
|
||||
#[cultcache(key = 12)]
|
||||
pub pressure_level: String,
|
||||
#[cultcache(key = 13)]
|
||||
pub reorient_action: String,
|
||||
#[cultcache(key = 14)]
|
||||
pub next_action: String,
|
||||
#[cultcache(key = 15)]
|
||||
pub artifact_refs: Vec<String>,
|
||||
#[cultcache(key = 16)]
|
||||
pub available_actions: Vec<String>,
|
||||
#[cultcache(key = 17)]
|
||||
pub notes: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.cultmesh.verse_policy",
|
||||
|
|
@ -324,6 +375,7 @@ pub struct EpiphanyCultMeshLifeContractEntry {
|
|||
cultmesh_documents!(EpiphanyCultMeshDocuments {
|
||||
EpiphanyCultMeshStatusEntry => EPIPHANY_CULTMESH_STATUS_SCHEMA_VERSION,
|
||||
EpiphanyCultMeshOperatorStatusEntry => EPIPHANY_CULTMESH_OPERATOR_STATUS_SCHEMA_VERSION,
|
||||
EpiphanyCultMeshOperatorSnapshotEntry => EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_SCHEMA_VERSION,
|
||||
EpiphanyCultMeshVersePolicyEntry => EPIPHANY_CULTMESH_VERSE_POLICY_SCHEMA_VERSION,
|
||||
EpiphanyCultMeshGlobalRoomPolicyEntry => EPIPHANY_CULTMESH_GLOBAL_ROOM_POLICY_SCHEMA_VERSION,
|
||||
EpiphanyCultMeshMindContractEntry => EPIPHANY_CULTMESH_MIND_CONTRACT_SCHEMA_VERSION,
|
||||
|
|
@ -420,6 +472,113 @@ pub fn load_epiphany_cultmesh_operator_status(
|
|||
node.get(EPIPHANY_CULTMESH_OPERATOR_STATUS_KEY)
|
||||
}
|
||||
|
||||
pub fn epiphany_cultmesh_operator_snapshot_from_status_json(
|
||||
runtime_id: impl Into<String>,
|
||||
snapshot_id: impl Into<String>,
|
||||
generated_at_utc: impl Into<String>,
|
||||
source_mode: impl Into<String>,
|
||||
source_path: impl Into<String>,
|
||||
status_json: &Value,
|
||||
) -> Result<EpiphanyCultMeshOperatorSnapshotEntry> {
|
||||
let source_path = source_path.into();
|
||||
let state_status = pointer_text(status_json, "/scene/scene/stateStatus", "unknown");
|
||||
let crrc_action = pointer_text(status_json, "/crrc/recommendation/action", "unknown");
|
||||
let reorient_action = pointer_text(status_json, "/reorient/decision/action", "unknown");
|
||||
let operator_status = if state_status == "missing" || crrc_action == "regatherManually" {
|
||||
"needs-regather"
|
||||
} else {
|
||||
"ready"
|
||||
};
|
||||
let mut artifact_refs = Vec::new();
|
||||
if !source_path.trim().is_empty() {
|
||||
artifact_refs.push(source_path.clone());
|
||||
}
|
||||
|
||||
Ok(EpiphanyCultMeshOperatorSnapshotEntry {
|
||||
schema_version: EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_SCHEMA_VERSION.to_string(),
|
||||
runtime_id: runtime_id.into(),
|
||||
verse_id: EPIPHANY_CULTMESH_INTERNAL_VERSE_ID.to_string(),
|
||||
snapshot_id: snapshot_id.into(),
|
||||
generated_at_utc: generated_at_utc.into(),
|
||||
source_mode: source_mode.into(),
|
||||
source_path,
|
||||
thread_id: pointer_text(status_json, "/threadId", "missing"),
|
||||
status: operator_status.to_string(),
|
||||
state_status,
|
||||
coordinator_action: pointer_text(status_json, "/coordinator/action", "none"),
|
||||
crrc_action,
|
||||
pressure_level: pointer_text(status_json, "/pressure/pressure/level", "unknown"),
|
||||
reorient_action,
|
||||
next_action: pointer_text(status_json, "/reorient/decision/nextAction", "none"),
|
||||
artifact_refs,
|
||||
available_actions: pointer_string_array(status_json, "/scene/scene/availableActions")?,
|
||||
notes: vec![
|
||||
"Snapshot is derived from the operator-safe MVP status artifact; raw JSON remains an edge artifact, not internal state.".to_string(),
|
||||
"Codex app-server remains compatibility transport for this source until the status surface is native end to end.".to_string(),
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
pub fn write_epiphany_cultmesh_operator_snapshot(
|
||||
store_path: impl AsRef<Path>,
|
||||
snapshot: EpiphanyCultMeshOperatorSnapshotEntry,
|
||||
) -> Result<EpiphanyCultMeshOperatorSnapshotEntry> {
|
||||
let mut node = open_epiphany_cultmesh_node(&store_path, snapshot.runtime_id.clone())?;
|
||||
let snapshot_key = epiphany_cultmesh_operator_snapshot_key(&snapshot.snapshot_id);
|
||||
let written = node.put(snapshot_key.as_str(), &snapshot)?;
|
||||
node.put(EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_LATEST_KEY, &written)?;
|
||||
node.flush()?;
|
||||
Ok(written)
|
||||
}
|
||||
|
||||
pub fn load_epiphany_cultmesh_operator_snapshot(
|
||||
store_path: impl AsRef<Path>,
|
||||
runtime_id: impl Into<String>,
|
||||
snapshot_id: impl AsRef<str>,
|
||||
) -> Result<Option<EpiphanyCultMeshOperatorSnapshotEntry>> {
|
||||
let node = open_epiphany_cultmesh_node(store_path, runtime_id)?;
|
||||
let snapshot_key = epiphany_cultmesh_operator_snapshot_key(snapshot_id.as_ref());
|
||||
node.get(snapshot_key.as_str())
|
||||
}
|
||||
|
||||
pub fn load_latest_epiphany_cultmesh_operator_snapshot(
|
||||
store_path: impl AsRef<Path>,
|
||||
runtime_id: impl Into<String>,
|
||||
) -> Result<Option<EpiphanyCultMeshOperatorSnapshotEntry>> {
|
||||
let node = open_epiphany_cultmesh_node(store_path, runtime_id)?;
|
||||
node.get(EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_LATEST_KEY)
|
||||
}
|
||||
|
||||
fn epiphany_cultmesh_operator_snapshot_key(snapshot_id: &str) -> String {
|
||||
format!("epiphany-local/operator-snapshot/{snapshot_id}")
|
||||
}
|
||||
|
||||
fn pointer_text(value: &Value, pointer: &str, fallback: &str) -> String {
|
||||
value
|
||||
.pointer(pointer)
|
||||
.and_then(Value::as_str)
|
||||
.filter(|text| !text.trim().is_empty())
|
||||
.unwrap_or(fallback)
|
||||
.to_string()
|
||||
}
|
||||
|
||||
fn pointer_string_array(value: &Value, pointer: &str) -> Result<Vec<String>> {
|
||||
let Some(items) = value.pointer(pointer) else {
|
||||
return Ok(Vec::new());
|
||||
};
|
||||
let items = items
|
||||
.as_array()
|
||||
.ok_or_else(|| anyhow!("{pointer} must be an array when present"))?;
|
||||
items
|
||||
.iter()
|
||||
.map(|item| {
|
||||
item.as_str()
|
||||
.map(ToString::to_string)
|
||||
.ok_or_else(|| anyhow!("{pointer} must contain only strings"))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn epiphany_cultmesh_verse_policies() -> Vec<EpiphanyCultMeshVersePolicyEntry> {
|
||||
vec![
|
||||
EpiphanyCultMeshVersePolicyEntry {
|
||||
|
|
@ -766,6 +925,73 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn operator_snapshot_distills_status_json_into_typed_cultmesh_document() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let store = temp.path().join("epiphany-operator-snapshot.ccmp");
|
||||
let status_json = serde_json::json!({
|
||||
"threadId": "thread-test",
|
||||
"scene": {
|
||||
"scene": {
|
||||
"stateStatus": "missing",
|
||||
"availableActions": ["crrc", "roles"]
|
||||
}
|
||||
},
|
||||
"pressure": {
|
||||
"pressure": {
|
||||
"level": "low"
|
||||
}
|
||||
},
|
||||
"reorient": {
|
||||
"decision": {
|
||||
"action": "regather",
|
||||
"nextAction": "Regather source context."
|
||||
}
|
||||
},
|
||||
"crrc": {
|
||||
"recommendation": {
|
||||
"action": "regatherManually"
|
||||
}
|
||||
},
|
||||
"coordinator": {
|
||||
"action": "wait"
|
||||
},
|
||||
"rawResult": {
|
||||
"sealed": true
|
||||
}
|
||||
});
|
||||
let snapshot = epiphany_cultmesh_operator_snapshot_from_status_json(
|
||||
"epiphany-test",
|
||||
"snapshot-test",
|
||||
"2026-05-27T00:00:00Z",
|
||||
"status",
|
||||
".epiphany-run/status.json",
|
||||
&status_json,
|
||||
)?;
|
||||
|
||||
assert_eq!(snapshot.status, "needs-regather");
|
||||
assert_eq!(snapshot.thread_id, "thread-test");
|
||||
assert_eq!(snapshot.available_actions, vec!["crrc", "roles"]);
|
||||
assert_eq!(snapshot.artifact_refs, vec![".epiphany-run/status.json"]);
|
||||
|
||||
write_epiphany_cultmesh_operator_snapshot(&store, snapshot.clone())?;
|
||||
assert_eq!(
|
||||
load_epiphany_cultmesh_operator_snapshot(&store, "epiphany-test", "snapshot-test")?,
|
||||
Some(snapshot.clone())
|
||||
);
|
||||
assert_eq!(
|
||||
load_latest_epiphany_cultmesh_operator_snapshot(&store, "epiphany-test")?,
|
||||
Some(snapshot)
|
||||
);
|
||||
let node = open_epiphany_cultmesh_node(&store, "epiphany-test")?;
|
||||
assert!(
|
||||
node.documents()
|
||||
.binding(EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_TYPE)
|
||||
.is_some()
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn builtin_verse_policies_keep_public_and_private_boundaries_apart() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
|
|
|
|||
|
|
@ -97,6 +97,9 @@ pub use cultmesh_integration::EPIPHANY_CULTMESH_LOCAL_AREA_TIER;
|
|||
pub use cultmesh_integration::EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_MIND_CONTRACT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_MIND_CONTRACT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_OPERATOR_STATUS_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_OPERATOR_STATUS_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_OPERATOR_STATUS_TYPE;
|
||||
|
|
@ -114,6 +117,7 @@ pub use cultmesh_integration::EpiphanyCultMeshGlobalRoomPolicyEntry;
|
|||
pub use cultmesh_integration::EpiphanyCultMeshHandsContractEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshLifeContractEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshMindContractEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshOperatorSnapshotEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshOperatorStatusEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshSoulContractEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshStatusEntry;
|
||||
|
|
@ -125,10 +129,13 @@ pub use cultmesh_integration::epiphany_cultmesh_global_room_policies;
|
|||
pub use cultmesh_integration::epiphany_cultmesh_hands_contracts;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_life_contracts;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_mind_contracts;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_operator_snapshot_from_status_json;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_soul_contracts;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_verse_policies;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_operator_snapshot;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_operator_status;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_status;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_operator_snapshot;
|
||||
pub use cultmesh_integration::open_epiphany_cultmesh_node;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_body_contracts;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_eyes_contracts;
|
||||
|
|
@ -136,6 +143,7 @@ pub use cultmesh_integration::write_epiphany_cultmesh_global_room_policies;
|
|||
pub use cultmesh_integration::write_epiphany_cultmesh_hands_contracts;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_life_contracts;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_mind_contracts;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_operator_snapshot;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_operator_status;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_soul_contracts;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_status;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ use crate::body_gateway::BODY_REPO_MUTATION_RECEIPT_SCHEMA_VERSION;
|
|||
use crate::body_gateway::BODY_REPO_MUTATION_RECEIPT_TYPE;
|
||||
use crate::body_gateway::BODY_REPO_SNAPSHOT_RECEIPT_SCHEMA_VERSION;
|
||||
use crate::body_gateway::BODY_REPO_SNAPSHOT_RECEIPT_TYPE;
|
||||
use crate::cultmesh_integration::EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_SCHEMA_VERSION;
|
||||
use crate::cultmesh_integration::EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_TYPE;
|
||||
use crate::cultmesh_integration::EPIPHANY_CULTMESH_OPERATOR_STATUS_SCHEMA_VERSION;
|
||||
use crate::cultmesh_integration::EPIPHANY_CULTMESH_OPERATOR_STATUS_TYPE;
|
||||
use crate::eyes_gateway::EYES_EVIDENCE_PACKET_SCHEMA_VERSION;
|
||||
|
|
@ -2148,6 +2150,21 @@ fn epiphany_mutation_contracts() -> Vec<CultNetDocumentMutationContract> {
|
|||
"This surface names the Codex bridge role, Epiphany authority role, prompt-authority boundary, and quarantined optional bridges.",
|
||||
],
|
||||
),
|
||||
mutation_contract(
|
||||
EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_TYPE,
|
||||
EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_SCHEMA_VERSION,
|
||||
vec![
|
||||
CultNetDocumentOperation::Snapshot,
|
||||
CultNetDocumentOperation::DocumentPut,
|
||||
],
|
||||
CultNetMutationAuthority::LocalUser,
|
||||
vec![],
|
||||
vec![],
|
||||
vec![
|
||||
"Operator snapshots are bounded typed receipts derived from operator-safe status/run artifacts.",
|
||||
"Raw Codex app-server JSON remains an edge artifact; this CultMesh document is the native Epiphany status receipt.",
|
||||
],
|
||||
),
|
||||
read_only_surface_contract(
|
||||
SURFACE_SCENE_TYPE,
|
||||
SCENE_SURFACE_SCHEMA_VERSION,
|
||||
|
|
@ -2911,6 +2928,21 @@ mod tests {
|
|||
.any(|note| note.contains("Codex app-server status is bridge"))
|
||||
})
|
||||
);
|
||||
let operator_snapshot_contract = contracts
|
||||
.iter()
|
||||
.find(|contract| {
|
||||
contract.document_type == EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_TYPE
|
||||
})
|
||||
.expect("operator snapshot should advertise a local typed receipt document");
|
||||
assert_eq!(
|
||||
operator_snapshot_contract.authority,
|
||||
CultNetMutationAuthority::LocalUser
|
||||
);
|
||||
assert!(
|
||||
operator_snapshot_contract
|
||||
.operations
|
||||
.contains(&CultNetDocumentOperation::DocumentPut)
|
||||
);
|
||||
assert!(
|
||||
contracts
|
||||
.iter()
|
||||
|
|
@ -3048,6 +3080,11 @@ mod tests {
|
|||
&& schema.schema_version.as_deref()
|
||||
== Some(EPIPHANY_CULTMESH_OPERATOR_STATUS_SCHEMA_VERSION)
|
||||
}));
|
||||
assert!(schemas.iter().any(|schema| {
|
||||
schema.document_type.as_deref() == Some(EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_TYPE)
|
||||
&& schema.schema_version.as_deref()
|
||||
== Some(EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_SCHEMA_VERSION)
|
||||
}));
|
||||
assert!(
|
||||
!schemas.iter().any(|schema| {
|
||||
schema.document_type.as_deref() == Some("epiphany.surface.rider_bridge")
|
||||
|
|
|
|||
Reference in a new issue