Rebuild Idunn semantic launch authority
This commit is contained in:
parent
b924fe5b7d
commit
a5d4078c74
10 changed files with 776 additions and 181 deletions
|
|
@ -28,6 +28,7 @@ use epiphany_core::load_epiphany_cultmesh_daemon_restart_policy;
|
|||
use epiphany_core::load_epiphany_cultmesh_daemon_service_lifecycle_receipts;
|
||||
use epiphany_core::load_epiphany_cultmesh_managed_service_policies;
|
||||
use epiphany_core::load_epiphany_cultmesh_managed_service_policy;
|
||||
use epiphany_core::load_epiphany_cultmesh_managed_service_policy_with_digest;
|
||||
use epiphany_core::load_epiphany_cultmesh_status;
|
||||
use epiphany_core::load_epiphany_cultmesh_swarm_brake;
|
||||
use epiphany_core::observe_native_process as observe_process;
|
||||
|
|
@ -370,8 +371,33 @@ fn service_launch(args: Args) -> Result<()> {
|
|||
let started_at = Utc::now();
|
||||
let command_path = service_command_path(&args)?;
|
||||
let service_args = service_serve_args(&args);
|
||||
let reserved_launch = if args.service_id == SEMANTIC_PROJECTOR_SERVICE_ID {
|
||||
let (policy, digest) = load_epiphany_cultmesh_managed_service_policy_with_digest(
|
||||
&args.store,
|
||||
args.runtime_id.clone(),
|
||||
SEMANTIC_PROJECTOR_SERVICE_ID,
|
||||
)?
|
||||
.context("reserved semantic projector managed policy is absent")?;
|
||||
if command_path != PathBuf::from(&policy.command)
|
||||
|| service_args != policy.args
|
||||
|| args.cwd.as_ref().map(|path| path.display().to_string()) != policy.cwd
|
||||
{
|
||||
anyhow::bail!(
|
||||
"reserved semantic projector launch must use the exact current managed policy"
|
||||
);
|
||||
}
|
||||
if args.wait_child {
|
||||
anyhow::bail!("reserved semantic projector launch is an infinite managed child");
|
||||
}
|
||||
Some((policy.policy_id, digest, Uuid::new_v4().to_string()))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let mut command = Command::new(&command_path);
|
||||
command.args(&service_args);
|
||||
if let Some((_, _, receipt_id)) = &reserved_launch {
|
||||
command.env("EPIPHANY_STARTUP_LIFECYCLE_RECEIPT_ID", receipt_id);
|
||||
}
|
||||
if let Some(stdout_path) = &args.stdout_artifact {
|
||||
if let Some(parent) = stdout_path.parent() {
|
||||
fs::create_dir_all(parent)?;
|
||||
|
|
@ -400,7 +426,7 @@ fn service_launch(args: Args) -> Result<()> {
|
|||
.with_context(|| format!("failed to launch service {}", command_path.display()))?;
|
||||
let process_id = Some(child.id());
|
||||
let mut exit_code = None;
|
||||
let mut completed_at = None;
|
||||
let mut completed_at = reserved_launch.as_ref().map(|_| Utc::now());
|
||||
let mut status = "launched".to_string();
|
||||
if args.wait_child {
|
||||
let output = child
|
||||
|
|
@ -414,7 +440,7 @@ fn service_launch(args: Args) -> Result<()> {
|
|||
"failed".to_string()
|
||||
};
|
||||
}
|
||||
let receipt = service_lifecycle_receipt(
|
||||
let mut receipt = service_lifecycle_receipt(
|
||||
&args,
|
||||
"launch",
|
||||
&status,
|
||||
|
|
@ -428,11 +454,27 @@ fn service_launch(args: Args) -> Result<()> {
|
|||
.as_ref()
|
||||
.map(|path| path.display().to_string()),
|
||||
);
|
||||
let written = write_epiphany_cultmesh_daemon_service_lifecycle_receipt(
|
||||
if let Some((policy_id, policy_digest, receipt_id)) = reserved_launch {
|
||||
receipt.receipt_id = receipt_id.clone();
|
||||
receipt.managed_policy_id = policy_id;
|
||||
receipt.managed_policy_digest = policy_digest;
|
||||
receipt.provider_daemon_id = SEMANTIC_PROJECTOR_EXECUTOR_ID.to_string();
|
||||
receipt.startup_correlation_id = receipt_id;
|
||||
}
|
||||
let written = match write_epiphany_cultmesh_daemon_service_lifecycle_receipt(
|
||||
&args.store,
|
||||
args.runtime_id.clone(),
|
||||
receipt,
|
||||
)?;
|
||||
) {
|
||||
Ok(written) => written,
|
||||
Err(error) => {
|
||||
if args.service_id == SEMANTIC_PROJECTOR_SERVICE_ID {
|
||||
let _ = child.kill();
|
||||
let _ = child.wait();
|
||||
}
|
||||
return Err(error).context("failed to persist service launch receipt");
|
||||
}
|
||||
};
|
||||
println!(
|
||||
"{}",
|
||||
serde_json::to_string_pretty(&json!({
|
||||
|
|
@ -557,6 +599,14 @@ fn semantic_projector_service_policy(mut args: Args) -> Result<()> {
|
|||
.runtime_store
|
||||
.as_ref()
|
||||
.context("semantic-projector-service-policy requires --runtime-store")?;
|
||||
let qdrant_url = args
|
||||
.qdrant_url
|
||||
.as_deref()
|
||||
.context("semantic-projector-service-policy requires --qdrant-url")?;
|
||||
let ollama_base_url = args
|
||||
.ollama_base_url
|
||||
.as_deref()
|
||||
.context("semantic-projector-service-policy requires --ollama-base-url")?;
|
||||
if agent_store == runtime_store {
|
||||
anyhow::bail!("semantic projector Mind and Modeling stores must be distinct");
|
||||
}
|
||||
|
|
@ -572,6 +622,9 @@ fn semantic_projector_service_policy(mut args: Args) -> Result<()> {
|
|||
&args.store,
|
||||
&args.runtime_id,
|
||||
args.loop_interval_seconds,
|
||||
qdrant_url,
|
||||
ollama_base_url,
|
||||
&args.ollama_model,
|
||||
);
|
||||
if args.max_iterations != 0 {
|
||||
anyhow::bail!("semantic projector managed service must not have a finite iteration limit");
|
||||
|
|
@ -603,6 +656,9 @@ fn semantic_projector_service_args(
|
|||
local_verse_store: &Path,
|
||||
runtime_id: &str,
|
||||
interval_seconds: i64,
|
||||
qdrant_url: &str,
|
||||
ollama_base_url: &str,
|
||||
ollama_model: &str,
|
||||
) -> Vec<String> {
|
||||
vec![
|
||||
"serve".to_string(),
|
||||
|
|
@ -616,6 +672,12 @@ fn semantic_projector_service_args(
|
|||
runtime_id.to_string(),
|
||||
"--interval-seconds".to_string(),
|
||||
interval_seconds.to_string(),
|
||||
"--qdrant-url".to_string(),
|
||||
qdrant_url.to_string(),
|
||||
"--ollama-base-url".to_string(),
|
||||
ollama_base_url.to_string(),
|
||||
"--ollama-model".to_string(),
|
||||
ollama_model.to_string(),
|
||||
]
|
||||
}
|
||||
|
||||
|
|
@ -3483,6 +3545,10 @@ fn service_lifecycle_receipt(
|
|||
preflight_witness_id: String::new(),
|
||||
required_document_types: Vec::new(),
|
||||
schema_preflight_passed: false,
|
||||
managed_policy_id: String::new(),
|
||||
managed_policy_digest: String::new(),
|
||||
provider_daemon_id: String::new(),
|
||||
startup_correlation_id: String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3693,6 +3759,9 @@ mod semantic_projector_authority_tests {
|
|||
Path::new("local-verse.ccmp"),
|
||||
"local-runtime",
|
||||
60,
|
||||
"http://127.0.0.1:16333",
|
||||
"http://10.77.0.1:11435",
|
||||
"qwen3-embedding:0.6b",
|
||||
);
|
||||
assert_eq!(
|
||||
args,
|
||||
|
|
@ -3708,11 +3777,40 @@ mod semantic_projector_authority_tests {
|
|||
"local-runtime",
|
||||
"--interval-seconds",
|
||||
"60",
|
||||
"--qdrant-url",
|
||||
"http://127.0.0.1:16333",
|
||||
"--ollama-base-url",
|
||||
"http://10.77.0.1:11435",
|
||||
"--ollama-model",
|
||||
"qwen3-embedding:0.6b",
|
||||
]
|
||||
);
|
||||
assert_eq!(args.iter().filter(|arg| arg.as_str() == "serve").count(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reserved_projector_launch_seals_spawn_before_the_child_may_publish() {
|
||||
let source = include_str!("epiphany-daemon-supervisor.rs");
|
||||
let start = source.find("fn service_launch(args: Args)").unwrap();
|
||||
let tail = &source[start..];
|
||||
let end = tail.find("\nfn ").unwrap();
|
||||
let body = &tail[..end];
|
||||
let uuid = body.find("Uuid::new_v4()").unwrap();
|
||||
let env = body.find("EPIPHANY_STARTUP_LIFECYCLE_RECEIPT_ID").unwrap();
|
||||
let spawn = body.find(".spawn()").unwrap();
|
||||
let completion = body
|
||||
.find("reserved_launch.as_ref().map(|_| Utc::now())")
|
||||
.unwrap();
|
||||
let persist = body
|
||||
.find("write_epiphany_cultmesh_daemon_service_lifecycle_receipt")
|
||||
.unwrap();
|
||||
assert!(uuid < env && env < spawn && spawn < completion && completion < persist);
|
||||
assert!(body.contains("receipt.managed_policy_digest = policy_digest"));
|
||||
assert!(body.contains("receipt.startup_correlation_id = receipt_id"));
|
||||
assert!(body.contains("let _ = child.kill()"));
|
||||
assert!(body.contains("let _ = child.wait()"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reserved_projector_policy_has_no_generic_or_command_override_path() {
|
||||
let source = include_str!("epiphany-daemon-supervisor.rs");
|
||||
|
|
@ -3784,6 +3882,9 @@ struct Args {
|
|||
runtime_store: Option<PathBuf>,
|
||||
expected_claim_id: Option<String>,
|
||||
provider_heartbeat_id: Option<String>,
|
||||
qdrant_url: Option<String>,
|
||||
ollama_base_url: Option<String>,
|
||||
ollama_model: String,
|
||||
}
|
||||
|
||||
impl Args {
|
||||
|
|
@ -3831,6 +3932,9 @@ impl Args {
|
|||
let mut runtime_store = None;
|
||||
let mut expected_claim_id = None;
|
||||
let mut provider_heartbeat_id = None;
|
||||
let mut qdrant_url = None;
|
||||
let mut ollama_base_url = None;
|
||||
let mut ollama_model = "qwen3-embedding:0.6b".to_string();
|
||||
|
||||
while let Some(arg) = values.next() {
|
||||
match arg.as_str() {
|
||||
|
|
@ -3994,6 +4098,16 @@ impl Args {
|
|||
.context("missing --provider-heartbeat-id value")?,
|
||||
)
|
||||
}
|
||||
"--qdrant-url" => {
|
||||
qdrant_url = Some(values.next().context("missing --qdrant-url value")?)
|
||||
}
|
||||
"--ollama-base-url" => {
|
||||
ollama_base_url =
|
||||
Some(values.next().context("missing --ollama-base-url value")?)
|
||||
}
|
||||
"--ollama-model" => {
|
||||
ollama_model = values.next().context("missing --ollama-model value")?
|
||||
}
|
||||
other => anyhow::bail!("unknown argument {other:?}"),
|
||||
}
|
||||
}
|
||||
|
|
@ -4135,6 +4249,9 @@ impl Args {
|
|||
runtime_store,
|
||||
expected_claim_id,
|
||||
provider_heartbeat_id,
|
||||
qdrant_url,
|
||||
ollama_base_url,
|
||||
ollama_model,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ use epiphany_core::{
|
|||
EPIPHANY_CULTMESH_DAEMON_HEARTBEAT_EVENT_SCHEMA_VERSION,
|
||||
EpiphanyCultMeshDaemonHeartbeatEventEntry, MemorySemanticIndexConfig,
|
||||
MemorySemanticProjectionInput, MemorySemanticProjectorPulseStatus,
|
||||
SemanticProjectorServiceBody, publish_epiphany_cultmesh_semantic_projection_health,
|
||||
SemanticProjectorServiceBody, authenticate_epiphany_cultmesh_semantic_projector_launch,
|
||||
load_epiphany_cultmesh_daemon_service_lifecycle_receipt,
|
||||
publish_epiphany_cultmesh_semantic_projection_health,
|
||||
write_epiphany_cultmesh_daemon_heartbeat_event,
|
||||
};
|
||||
use serde_json::json;
|
||||
|
|
@ -11,17 +13,27 @@ use std::env;
|
|||
use std::path::PathBuf;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use std::time::Instant;
|
||||
use uuid::Uuid;
|
||||
|
||||
const DAEMON_ID: &str = "epiphany-memory-semantic-projector";
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let args = Args::parse()?;
|
||||
let projector = SemanticProjectorServiceBody::new(
|
||||
&args.agent_store,
|
||||
&args.runtime_store,
|
||||
MemorySemanticIndexConfig::from_env(),
|
||||
)?;
|
||||
if args.requires_managed_launch {
|
||||
if args.startup_lifecycle_receipt_id.trim().is_empty() {
|
||||
return Err(anyhow!(
|
||||
"managed projector requires its startup launch receipt id"
|
||||
));
|
||||
}
|
||||
authenticate_managed_launch(&args)?;
|
||||
}
|
||||
let mut semantic_config = MemorySemanticIndexConfig::from_env();
|
||||
semantic_config.qdrant_url = args.qdrant_url.clone();
|
||||
semantic_config.ollama_base_url = args.ollama_base_url.clone();
|
||||
semantic_config.ollama_model = args.ollama_model.clone();
|
||||
let projector =
|
||||
SemanticProjectorServiceBody::new(&args.agent_store, &args.runtime_store, semantic_config)?;
|
||||
let provider_incarnation = projector.provider_incarnation().to_string();
|
||||
let mut cursor = None;
|
||||
let mut sequence = 0_u64;
|
||||
|
|
@ -100,6 +112,32 @@ fn main() -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn authenticate_managed_launch(args: &Args) -> Result<()> {
|
||||
let deadline = Instant::now() + Duration::from_secs(5);
|
||||
loop {
|
||||
if load_epiphany_cultmesh_daemon_service_lifecycle_receipt(
|
||||
&args.local_verse_store,
|
||||
args.runtime_id.clone(),
|
||||
&args.startup_lifecycle_receipt_id,
|
||||
)?
|
||||
.is_some()
|
||||
{
|
||||
authenticate_epiphany_cultmesh_semantic_projector_launch(
|
||||
&args.local_verse_store,
|
||||
args.runtime_id.clone(),
|
||||
&args.startup_lifecycle_receipt_id,
|
||||
)?;
|
||||
return Ok(());
|
||||
}
|
||||
if Instant::now() >= deadline {
|
||||
return Err(anyhow!(
|
||||
"managed projector startup launch receipt was not persisted"
|
||||
));
|
||||
}
|
||||
thread::sleep(Duration::from_millis(20));
|
||||
}
|
||||
}
|
||||
|
||||
fn source_store<'a>(args: &'a Args, input: &MemorySemanticProjectionInput) -> Result<&'a PathBuf> {
|
||||
match input.obligation().partition.as_str() {
|
||||
"mind" => Ok(&args.agent_store),
|
||||
|
|
@ -128,6 +166,10 @@ struct Args {
|
|||
interval_seconds: u64,
|
||||
max_iterations: u64,
|
||||
startup_lifecycle_receipt_id: String,
|
||||
qdrant_url: String,
|
||||
ollama_base_url: String,
|
||||
ollama_model: String,
|
||||
requires_managed_launch: bool,
|
||||
}
|
||||
|
||||
impl Args {
|
||||
|
|
@ -147,6 +189,9 @@ impl Args {
|
|||
} else {
|
||||
0
|
||||
};
|
||||
let mut qdrant_url = None;
|
||||
let mut ollama_base_url = None;
|
||||
let mut ollama_model = "qwen3-embedding:0.6b".to_string();
|
||||
while let Some(flag) = values.next() {
|
||||
let mut value = || {
|
||||
values
|
||||
|
|
@ -160,6 +205,9 @@ impl Args {
|
|||
"--runtime-id" => runtime_id = value()?,
|
||||
"--interval-seconds" => interval_seconds = value()?.parse()?,
|
||||
"--max-iterations" => max_iterations = value()?.parse()?,
|
||||
"--qdrant-url" => qdrant_url = Some(value()?),
|
||||
"--ollama-base-url" => ollama_base_url = Some(value()?),
|
||||
"--ollama-model" => ollama_model = value()?,
|
||||
_ => return Err(anyhow!("unexpected argument {flag:?}")),
|
||||
}
|
||||
}
|
||||
|
|
@ -175,6 +223,10 @@ impl Args {
|
|||
max_iterations,
|
||||
startup_lifecycle_receipt_id: env::var("EPIPHANY_STARTUP_LIFECYCLE_RECEIPT_ID")
|
||||
.unwrap_or_default(),
|
||||
qdrant_url: qdrant_url.context("missing --qdrant-url")?,
|
||||
ollama_base_url: ollama_base_url.context("missing --ollama-base-url")?,
|
||||
ollama_model,
|
||||
requires_managed_launch: matches!(command.as_str(), "serve" | "daemon"),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2685,6 +2685,10 @@ fn run_cli() -> Result<()> {
|
|||
required_document_types: Vec::new(),
|
||||
schema_preflight_passed: false,
|
||||
schema_catalog_sha256: String::new(),
|
||||
managed_policy_id: String::new(),
|
||||
managed_policy_digest: String::new(),
|
||||
provider_daemon_id: String::new(),
|
||||
startup_correlation_id: String::new(),
|
||||
};
|
||||
let readiness_follow_up_row = receipt_directory_service_lifecycle_row(
|
||||
"cluster-service-lifecycle",
|
||||
|
|
@ -9946,6 +9950,10 @@ mod lifecycle_projection_tests {
|
|||
notes: Vec::new(),
|
||||
executable_sha256: String::new(),
|
||||
schema_catalog_sha256: String::new(),
|
||||
managed_policy_id: String::new(),
|
||||
managed_policy_digest: String::new(),
|
||||
provider_daemon_id: String::new(),
|
||||
startup_correlation_id: String::new(),
|
||||
preflight_witness_id: String::new(),
|
||||
required_document_types: Vec::new(),
|
||||
schema_preflight_passed: false,
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ pub const EPIPHANY_CULTMESH_DAEMON_SCHEDULER_RECEIPT_LATEST_KEY: &str =
|
|||
pub const EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_TYPE: &str =
|
||||
"epiphany.cultmesh.daemon_service_lifecycle_receipt";
|
||||
pub const EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_SCHEMA_VERSION: &str =
|
||||
"epiphany.cultmesh.daemon_service_lifecycle_receipt.v0";
|
||||
"epiphany.cultmesh.daemon_service_lifecycle_receipt.v1";
|
||||
pub const EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_LATEST_KEY: &str =
|
||||
"epiphany-local/daemon-service-lifecycle-receipt/latest";
|
||||
pub const EPIPHANY_CULTMESH_MANAGED_SERVICE_POLICY_TYPE: &str =
|
||||
|
|
@ -1460,6 +1460,14 @@ pub struct EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry {
|
|||
pub schema_preflight_passed: bool,
|
||||
#[cultcache(key = 22, default)]
|
||||
pub schema_catalog_sha256: String,
|
||||
#[cultcache(key = 23, default)]
|
||||
pub managed_policy_id: String,
|
||||
#[cultcache(key = 24, default)]
|
||||
pub managed_policy_digest: String,
|
||||
#[cultcache(key = 25, default)]
|
||||
pub provider_daemon_id: String,
|
||||
#[cultcache(key = 26, default)]
|
||||
pub startup_correlation_id: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
|
||||
|
|
@ -4080,22 +4088,159 @@ pub fn write_epiphany_cultmesh_daemon_service_lifecycle_receipt(
|
|||
receipt: EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry,
|
||||
) -> Result<EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry> {
|
||||
validate_daemon_service_lifecycle_receipt(&receipt)?;
|
||||
let mut node = open_epiphany_cultmesh_node(store_path, runtime_id)?;
|
||||
let store_path = store_path.as_ref();
|
||||
let node = open_epiphany_cultmesh_node(store_path, runtime_id)?;
|
||||
let receipt_key = epiphany_cultmesh_daemon_service_lifecycle_receipt_key(&receipt.receipt_id);
|
||||
let written = node.put(receipt_key.as_str(), &receipt)?;
|
||||
if let Some(existing) =
|
||||
node.get::<EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry>(&receipt_key)?
|
||||
{
|
||||
if existing == receipt {
|
||||
return Ok(existing);
|
||||
}
|
||||
return Err(anyhow!(
|
||||
"daemon service lifecycle receipt identity collision for {:?}",
|
||||
receipt.receipt_id
|
||||
));
|
||||
}
|
||||
let (receipt_envelope, written) = node.cache().prepare_entry(receipt_key, &receipt)?;
|
||||
let mut expected = Vec::new();
|
||||
let mut replacements = vec![receipt_envelope];
|
||||
if written.service_id == EPIPHANY_SEMANTIC_PROJECTOR_SERVICE_ID && written.action == "launch" {
|
||||
let policy_key = epiphany_cultmesh_managed_service_policy_key(&written.service_id);
|
||||
let policy_envelope = node
|
||||
.cache()
|
||||
.get_envelope::<EpiphanyCultMeshManagedServicePolicyEntry>(&policy_key)?
|
||||
.ok_or_else(|| anyhow!("reserved semantic projector managed policy is absent"))?;
|
||||
let mut digest = Sha256::new();
|
||||
digest.update(policy_envelope.r#type.as_bytes());
|
||||
digest.update([0]);
|
||||
digest.update(policy_envelope.key.as_bytes());
|
||||
digest.update([0]);
|
||||
digest.update(&policy_envelope.payload);
|
||||
if written.managed_policy_digest != format!("sha256-{:x}", digest.finalize()) {
|
||||
return Err(anyhow!(
|
||||
"reserved semantic projector launch receipt has stale managed policy digest"
|
||||
));
|
||||
}
|
||||
expected.push(policy_envelope.clone());
|
||||
replacements.push(policy_envelope);
|
||||
}
|
||||
let current_latest = node.get::<EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry>(
|
||||
EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_LATEST_KEY,
|
||||
)?;
|
||||
if current_latest.as_ref().is_none_or(|current| {
|
||||
daemon_service_lifecycle_event_key(&written) >= daemon_service_lifecycle_event_key(current)
|
||||
}) {
|
||||
node.put(
|
||||
EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_LATEST_KEY,
|
||||
&written,
|
||||
)?;
|
||||
if let Some(envelope) = node
|
||||
.cache()
|
||||
.get_envelope::<EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry>(
|
||||
EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_LATEST_KEY,
|
||||
)?
|
||||
{
|
||||
expected.push(envelope);
|
||||
}
|
||||
replacements.push(
|
||||
node.cache()
|
||||
.prepare_entry(
|
||||
EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_LATEST_KEY,
|
||||
&written,
|
||||
)?
|
||||
.0,
|
||||
);
|
||||
}
|
||||
node.flush()?;
|
||||
Ok(written)
|
||||
let service_latest_key =
|
||||
epiphany_cultmesh_daemon_service_lifecycle_receipt_latest_key(&written.service_id);
|
||||
let current_service_latest =
|
||||
node.get::<EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry>(&service_latest_key)?;
|
||||
if current_service_latest.as_ref().is_none_or(|current| {
|
||||
daemon_service_lifecycle_event_key(&written) >= daemon_service_lifecycle_event_key(current)
|
||||
}) {
|
||||
if let Some(envelope) = node
|
||||
.cache()
|
||||
.get_envelope::<EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry>(
|
||||
&service_latest_key,
|
||||
)?
|
||||
{
|
||||
expected.push(envelope);
|
||||
}
|
||||
replacements.push(node.cache().prepare_entry(&service_latest_key, &written)?.0);
|
||||
}
|
||||
let backing = SingleFileMessagePackBackingStore::new(store_path);
|
||||
if backing.compare_and_swap_batch(&expected, replacements)? {
|
||||
return Ok(written);
|
||||
}
|
||||
let reloaded = open_epiphany_cultmesh_node(store_path, "lifecycle-cas-readback")?;
|
||||
match reloaded.get::<EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry>(
|
||||
&epiphany_cultmesh_daemon_service_lifecycle_receipt_key(&written.receipt_id),
|
||||
)? {
|
||||
Some(existing) if existing == written => Ok(existing),
|
||||
Some(_) => Err(anyhow!(
|
||||
"daemon service lifecycle receipt identity collision for {:?}",
|
||||
written.receipt_id
|
||||
)),
|
||||
None => Err(anyhow!(
|
||||
"daemon service lifecycle receipt CAS lost concurrent latest-state race"
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_epiphany_cultmesh_daemon_service_lifecycle_receipt(
|
||||
store_path: impl AsRef<Path>,
|
||||
runtime_id: impl Into<String>,
|
||||
receipt_id: &str,
|
||||
) -> Result<Option<EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry>> {
|
||||
let node = open_epiphany_cultmesh_node(store_path, runtime_id)?;
|
||||
node.get(&epiphany_cultmesh_daemon_service_lifecycle_receipt_key(
|
||||
receipt_id,
|
||||
))
|
||||
}
|
||||
|
||||
pub fn load_epiphany_cultmesh_managed_service_policy_with_digest(
|
||||
store_path: impl AsRef<Path>,
|
||||
runtime_id: impl Into<String>,
|
||||
service_id: &str,
|
||||
) -> Result<Option<(EpiphanyCultMeshManagedServicePolicyEntry, String)>> {
|
||||
let node = open_epiphany_cultmesh_node(store_path, runtime_id)?;
|
||||
let key = epiphany_cultmesh_managed_service_policy_key(service_id);
|
||||
let Some(policy) = node.get::<EpiphanyCultMeshManagedServicePolicyEntry>(&key)? else {
|
||||
return Ok(None);
|
||||
};
|
||||
let digest =
|
||||
cultmesh_envelope_digest::<EpiphanyCultMeshManagedServicePolicyEntry>(&node, &key)?;
|
||||
Ok(Some((policy, digest)))
|
||||
}
|
||||
|
||||
pub fn authenticate_epiphany_cultmesh_semantic_projector_launch(
|
||||
store_path: impl AsRef<Path>,
|
||||
runtime_id: impl Into<String>,
|
||||
receipt_id: &str,
|
||||
) -> Result<EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry> {
|
||||
let runtime_id = runtime_id.into();
|
||||
let receipt = load_epiphany_cultmesh_daemon_service_lifecycle_receipt(
|
||||
store_path.as_ref(),
|
||||
runtime_id.clone(),
|
||||
receipt_id,
|
||||
)?
|
||||
.ok_or_else(|| anyhow!("semantic projector startup launch receipt is absent"))?;
|
||||
validate_semantic_projector_launch_receipt(&receipt)?;
|
||||
let (policy, digest) = load_epiphany_cultmesh_managed_service_policy_with_digest(
|
||||
store_path,
|
||||
runtime_id,
|
||||
EPIPHANY_SEMANTIC_PROJECTOR_SERVICE_ID,
|
||||
)?
|
||||
.ok_or_else(|| anyhow!("semantic projector managed policy is absent"))?;
|
||||
validate_semantic_projector_managed_service_policy(&policy)?;
|
||||
if receipt.managed_policy_id != policy.policy_id
|
||||
|| receipt.managed_policy_digest != digest
|
||||
|| receipt.command != policy.command
|
||||
|| receipt.args != policy.args
|
||||
|| receipt.cwd != policy.cwd
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"semantic projector startup launch receipt disagrees with current managed policy"
|
||||
));
|
||||
}
|
||||
Ok(receipt)
|
||||
}
|
||||
|
||||
pub fn load_latest_epiphany_cultmesh_daemon_service_lifecycle_receipt(
|
||||
|
|
@ -4114,7 +4259,10 @@ pub fn load_epiphany_cultmesh_daemon_service_lifecycle_receipts(
|
|||
Ok(node
|
||||
.get_all_with_keys::<EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry>()?
|
||||
.into_iter()
|
||||
.filter(|(key, _)| key != EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_LATEST_KEY)
|
||||
.filter(|(key, _)| {
|
||||
key != EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_LATEST_KEY
|
||||
&& !key.starts_with("epiphany-local/daemon-service-lifecycle-receipt/latest/")
|
||||
})
|
||||
.map(|(_, receipt)| receipt)
|
||||
.collect())
|
||||
}
|
||||
|
|
@ -4577,7 +4725,7 @@ fn validate_semantic_projector_managed_service_policy(
|
|||
if policy.policy_id != "managed-service-policy-epiphany-memory-semantic-projector-service"
|
||||
|| policy.owner_daemon_id != "epiphany-daemon-supervisor"
|
||||
|| policy.restart_mode != "always"
|
||||
|| policy.args.len() != 11
|
||||
|| policy.args.len() != 17
|
||||
|| policy.args[0] != "serve"
|
||||
|| policy.args[1] != "--agent-store"
|
||||
|| policy.args[2].trim().is_empty()
|
||||
|
|
@ -4593,6 +4741,12 @@ fn validate_semantic_projector_managed_service_policy(
|
|||
.ok()
|
||||
.filter(|value| *value > 0)
|
||||
.is_none()
|
||||
|| policy.args[11] != "--qdrant-url"
|
||||
|| policy.args[12].trim().is_empty()
|
||||
|| policy.args[13] != "--ollama-base-url"
|
||||
|| policy.args[14].trim().is_empty()
|
||||
|| policy.args[15] != "--ollama-model"
|
||||
|| policy.args[16].trim().is_empty()
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"reserved semantic projector policy must bind one packaged process to both canonical stores"
|
||||
|
|
@ -4701,6 +4855,32 @@ fn validate_daemon_service_lifecycle_receipt(
|
|||
"typed daemon service lifecycle receipt requires passing schema preflight, executable fingerprint, and preflight witness"
|
||||
));
|
||||
}
|
||||
if receipt.service_id == EPIPHANY_SEMANTIC_PROJECTOR_SERVICE_ID && receipt.action == "launch" {
|
||||
validate_semantic_projector_launch_receipt(receipt)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn validate_semantic_projector_launch_receipt(
|
||||
receipt: &EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry,
|
||||
) -> Result<()> {
|
||||
if receipt.schema_version != EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_SCHEMA_VERSION
|
||||
|| receipt.service_id != EPIPHANY_SEMANTIC_PROJECTOR_SERVICE_ID
|
||||
|| receipt.action != "launch"
|
||||
|| receipt.status != "launched"
|
||||
|| receipt.process_id.is_none()
|
||||
|| receipt.exit_code.is_some()
|
||||
|| receipt.completed_at_utc.is_none()
|
||||
|| receipt.managed_policy_id.trim().is_empty()
|
||||
|| !receipt.managed_policy_digest.starts_with("sha256-")
|
||||
|| receipt.provider_daemon_id != "epiphany-memory-semantic-projector"
|
||||
|| receipt.startup_correlation_id != receipt.receipt_id
|
||||
|| Uuid::parse_str(&receipt.receipt_id).is_err()
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"reserved semantic projector launch receipt must bind completed spawn to exact managed policy and provider identity"
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -6673,6 +6853,10 @@ fn epiphany_cultmesh_daemon_service_lifecycle_receipt_key(receipt_id: &str) -> S
|
|||
format!("epiphany-local/daemon-service-lifecycle-receipt/{receipt_id}")
|
||||
}
|
||||
|
||||
fn epiphany_cultmesh_daemon_service_lifecycle_receipt_latest_key(service_id: &str) -> String {
|
||||
format!("epiphany-local/daemon-service-lifecycle-receipt/latest/{service_id}")
|
||||
}
|
||||
|
||||
fn epiphany_cultmesh_managed_service_policy_key(service_id: &str) -> String {
|
||||
format!("epiphany-local/managed-service-policy/{service_id}")
|
||||
}
|
||||
|
|
@ -7219,7 +7403,7 @@ pub fn idunn_recover_memory_semantic_projection_from_cultmesh(
|
|||
input: &crate::MemorySemanticProjectionInput,
|
||||
expected_claim_id: &str,
|
||||
replacement_executor_id: &str,
|
||||
lifecycle_receipt_id: &str,
|
||||
launch_lifecycle_receipt_id: &str,
|
||||
provider_heartbeat_id: &str,
|
||||
recovered_at: &str,
|
||||
) -> Result<(
|
||||
|
|
@ -7231,33 +7415,20 @@ pub fn idunn_recover_memory_semantic_projection_from_cultmesh(
|
|||
let canonical_store = canonical_store.as_ref();
|
||||
crate::observe_memory_semantic_projection(canonical_store, input)?;
|
||||
|
||||
let receipt = authenticate_epiphany_cultmesh_semantic_projector_launch(
|
||||
verse_store,
|
||||
runtime_id.clone(),
|
||||
launch_lifecycle_receipt_id,
|
||||
)?;
|
||||
let (policy, policy_digest) = load_epiphany_cultmesh_managed_service_policy_with_digest(
|
||||
verse_store,
|
||||
runtime_id.clone(),
|
||||
EPIPHANY_SEMANTIC_PROJECTOR_SERVICE_ID,
|
||||
)?
|
||||
.ok_or_else(|| anyhow!("Idunn recovery managed service policy is absent"))?;
|
||||
let node = open_epiphany_cultmesh_node(verse_store, runtime_id)?;
|
||||
let receipt_key = epiphany_cultmesh_daemon_poke_receipt_key(lifecycle_receipt_id);
|
||||
let receipt = node
|
||||
.get::<EpiphanyCultMeshDaemonPokeReceiptEntry>(&receipt_key)?
|
||||
.ok_or_else(|| anyhow!("Idunn recovery lifecycle receipt is absent"))?;
|
||||
validate_daemon_poke_receipt(&receipt)?;
|
||||
if receipt.receipt_id != lifecycle_receipt_id
|
||||
|| receipt.target_daemon_id != "epiphany-memory-semantic-projector"
|
||||
|| receipt.status != "restart-succeeded"
|
||||
|| receipt.resulting_status != "awaiting-provider-heartbeat"
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"Idunn recovery requires the exact successful awaiting-heartbeat receipt"
|
||||
));
|
||||
}
|
||||
|
||||
let intent_key = epiphany_cultmesh_daemon_poke_intent_key(&receipt.intent_id);
|
||||
let intent = node
|
||||
.get::<EpiphanyCultMeshDaemonPokeIntentEntry>(&intent_key)?
|
||||
.ok_or_else(|| anyhow!("Idunn recovery lifecycle intent is absent"))?;
|
||||
validate_daemon_poke_intent(&intent)?;
|
||||
if intent.intent_id != receipt.intent_id
|
||||
|| intent.target_daemon_id != receipt.target_daemon_id
|
||||
|| intent.target_cluster_id != receipt.target_cluster_id
|
||||
{
|
||||
return Err(anyhow!("Idunn recovery lifecycle chain disagrees"));
|
||||
}
|
||||
let receipt_key =
|
||||
epiphany_cultmesh_daemon_service_lifecycle_receipt_key(launch_lifecycle_receipt_id);
|
||||
|
||||
let heartbeat_key = epiphany_cultmesh_daemon_heartbeat_event_key(provider_heartbeat_id);
|
||||
let heartbeat = node
|
||||
|
|
@ -7265,14 +7436,18 @@ pub fn idunn_recover_memory_semantic_projection_from_cultmesh(
|
|||
.ok_or_else(|| anyhow!("Idunn recovery provider heartbeat is absent"))?;
|
||||
validate_daemon_heartbeat_event(&heartbeat)?;
|
||||
if heartbeat.heartbeat_id != provider_heartbeat_id
|
||||
|| heartbeat.daemon_id != receipt.target_daemon_id
|
||||
|| heartbeat.cluster_id != receipt.target_cluster_id
|
||||
|| heartbeat.daemon_id != receipt.provider_daemon_id
|
||||
|| heartbeat.cluster_id != "local"
|
||||
|| heartbeat.status != "ready"
|
||||
|| heartbeat.startup_lifecycle_receipt_id != receipt.receipt_id
|
||||
{
|
||||
return Err(anyhow!("Idunn recovery provider heartbeat disagrees"));
|
||||
}
|
||||
let receipt_completed = DateTime::parse_from_rfc3339(&receipt.completed_at_utc)?;
|
||||
let receipt_completed_at = receipt
|
||||
.completed_at_utc
|
||||
.as_deref()
|
||||
.ok_or_else(|| anyhow!("Idunn recovery launch receipt is not completed"))?;
|
||||
let receipt_completed = DateTime::parse_from_rfc3339(receipt_completed_at)?;
|
||||
let heartbeat_at = DateTime::parse_from_rfc3339(&heartbeat.heartbeat_at)?;
|
||||
if heartbeat_at <= receipt_completed {
|
||||
return Err(anyhow!(
|
||||
|
|
@ -7280,10 +7455,9 @@ pub fn idunn_recover_memory_semantic_projection_from_cultmesh(
|
|||
));
|
||||
}
|
||||
|
||||
let intent_digest =
|
||||
cultmesh_envelope_digest::<EpiphanyCultMeshDaemonPokeIntentEntry>(&node, &intent_key)?;
|
||||
let receipt_digest =
|
||||
cultmesh_envelope_digest::<EpiphanyCultMeshDaemonPokeReceiptEntry>(&node, &receipt_key)?;
|
||||
let receipt_digest = cultmesh_envelope_digest::<
|
||||
EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry,
|
||||
>(&node, &receipt_key)?;
|
||||
let heartbeat_digest = cultmesh_envelope_digest::<EpiphanyCultMeshDaemonHeartbeatEventEntry>(
|
||||
&node,
|
||||
&heartbeat_key,
|
||||
|
|
@ -7294,11 +7468,11 @@ pub fn idunn_recover_memory_semantic_projection_from_cultmesh(
|
|||
input,
|
||||
expected_claim_id,
|
||||
&format!("idunn-{}", Uuid::new_v4()),
|
||||
&intent.intent_id,
|
||||
&intent_digest,
|
||||
&policy.policy_id,
|
||||
&policy_digest,
|
||||
&receipt.receipt_id,
|
||||
&receipt_digest,
|
||||
&receipt.completed_at_utc,
|
||||
receipt_completed_at,
|
||||
&heartbeat.heartbeat_id,
|
||||
&heartbeat_digest,
|
||||
&heartbeat.provider_incarnation,
|
||||
|
|
@ -7890,6 +8064,12 @@ mod tests {
|
|||
"local",
|
||||
"--interval-seconds",
|
||||
"60",
|
||||
"--qdrant-url",
|
||||
"http://127.0.0.1:16333",
|
||||
"--ollama-base-url",
|
||||
"http://10.77.0.1:11435",
|
||||
"--ollama-model",
|
||||
"qwen3-embedding:0.6b",
|
||||
]
|
||||
.into_iter()
|
||||
.map(str::to_string)
|
||||
|
|
@ -7915,8 +8095,77 @@ mod tests {
|
|||
.is_err()
|
||||
);
|
||||
assert!(
|
||||
write_epiphany_cultmesh_semantic_projector_service_policy(&store, "local", exact)
|
||||
.is_ok()
|
||||
write_epiphany_cultmesh_semantic_projector_service_policy(
|
||||
&store,
|
||||
"local",
|
||||
exact.clone(),
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
let (_, policy_digest) = load_epiphany_cultmesh_managed_service_policy_with_digest(
|
||||
&store,
|
||||
"local",
|
||||
EPIPHANY_SEMANTIC_PROJECTOR_SERVICE_ID,
|
||||
)?
|
||||
.context("missing exact policy")?;
|
||||
let receipt = EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry {
|
||||
schema_version: EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_SCHEMA_VERSION
|
||||
.into(),
|
||||
receipt_id: "9f63fa72-a2e1-4ca5-9c1a-9292b7798891".into(),
|
||||
service_id: EPIPHANY_SEMANTIC_PROJECTOR_SERVICE_ID.into(),
|
||||
scheduler_id: "epiphany-daemon-supervisor".into(),
|
||||
runtime_id: "local".into(),
|
||||
daemon_selector: "epiphany-daemon-supervisor".into(),
|
||||
action: "launch".into(),
|
||||
status: "launched".into(),
|
||||
command: exact.command.clone(),
|
||||
args: exact.args.clone(),
|
||||
cwd: exact.cwd.clone(),
|
||||
process_id: Some(4242),
|
||||
exit_code: None,
|
||||
started_at_utc: "2026-07-15T12:00:00Z".into(),
|
||||
completed_at_utc: Some("2026-07-15T12:00:01Z".into()),
|
||||
operator_artifact_ref: "service://semantic-projector/launch".into(),
|
||||
private_state_exposed: false,
|
||||
notes: vec![],
|
||||
executable_sha256: String::new(),
|
||||
preflight_witness_id: String::new(),
|
||||
required_document_types: vec![],
|
||||
schema_preflight_passed: false,
|
||||
schema_catalog_sha256: String::new(),
|
||||
managed_policy_id: exact.policy_id.clone(),
|
||||
managed_policy_digest: policy_digest,
|
||||
provider_daemon_id: "epiphany-memory-semantic-projector".into(),
|
||||
startup_correlation_id: "9f63fa72-a2e1-4ca5-9c1a-9292b7798891".into(),
|
||||
};
|
||||
let written = write_epiphany_cultmesh_daemon_service_lifecycle_receipt(
|
||||
&store,
|
||||
"local",
|
||||
receipt.clone(),
|
||||
)?;
|
||||
assert_eq!(
|
||||
authenticate_epiphany_cultmesh_semantic_projector_launch(
|
||||
&store,
|
||||
"local",
|
||||
&receipt.receipt_id,
|
||||
)?,
|
||||
written
|
||||
);
|
||||
assert_eq!(
|
||||
write_epiphany_cultmesh_daemon_service_lifecycle_receipt(
|
||||
&store,
|
||||
"local",
|
||||
receipt.clone(),
|
||||
)?,
|
||||
receipt
|
||||
);
|
||||
let mut collision = receipt;
|
||||
collision.process_id = Some(4343);
|
||||
assert!(
|
||||
write_epiphany_cultmesh_daemon_service_lifecycle_receipt(&store, "local", collision,)
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.contains("identity collision")
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -8472,6 +8721,10 @@ mod tests {
|
|||
required_document_types: Vec::new(),
|
||||
schema_preflight_passed: false,
|
||||
schema_catalog_sha256: String::new(),
|
||||
managed_policy_id: String::new(),
|
||||
managed_policy_digest: String::new(),
|
||||
provider_daemon_id: String::new(),
|
||||
startup_correlation_id: String::new(),
|
||||
};
|
||||
let mut second = first.clone();
|
||||
second.receipt_id = "service-lifecycle-second".to_string();
|
||||
|
|
@ -8630,6 +8883,10 @@ mod tests {
|
|||
required_document_types: Vec::new(),
|
||||
schema_preflight_passed: false,
|
||||
schema_catalog_sha256: String::new(),
|
||||
managed_policy_id: String::new(),
|
||||
managed_policy_digest: String::new(),
|
||||
provider_daemon_id: String::new(),
|
||||
startup_correlation_id: String::new(),
|
||||
};
|
||||
assert!(
|
||||
write_epiphany_cultmesh_daemon_service_lifecycle_receipt(
|
||||
|
|
@ -8688,6 +8945,10 @@ mod tests {
|
|||
required_document_types: Vec::new(),
|
||||
schema_preflight_passed: false,
|
||||
schema_catalog_sha256: String::new(),
|
||||
managed_policy_id: String::new(),
|
||||
managed_policy_digest: String::new(),
|
||||
provider_daemon_id: String::new(),
|
||||
startup_correlation_id: String::new(),
|
||||
},
|
||||
]);
|
||||
let runbook_check = report
|
||||
|
|
@ -11193,7 +11454,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn semantic_recovery_requires_exact_correlated_restart_heartbeat_and_is_single_use()
|
||||
fn semantic_recovery_requires_current_policy_launch_heartbeat_chain_and_is_single_use()
|
||||
-> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let canonical = temp.path().join("canonical.msgpack");
|
||||
|
|
@ -11210,44 +11471,102 @@ mod tests {
|
|||
"2026-07-15T12:00:00Z",
|
||||
)?
|
||||
.claim;
|
||||
let status = EpiphanyCultMeshDaemonStatusEntry {
|
||||
schema_version: EPIPHANY_CULTMESH_DAEMON_STATUS_SCHEMA_VERSION.to_string(),
|
||||
daemon_id: "epiphany-memory-semantic-projector".to_string(),
|
||||
cluster_id: "local".to_string(),
|
||||
body_domain: "semantic-projection".to_string(),
|
||||
daemon_surface_id: "daemon.semantic-projector".to_string(),
|
||||
eve_surface_id: "eve.semantic-projector".to_string(),
|
||||
status: "stale".to_string(),
|
||||
last_heartbeat_utc: "2026-07-15T12:00:01Z".to_string(),
|
||||
supported_actions: vec!["pokeDaemon".to_string()],
|
||||
operator_action: "restart".to_string(),
|
||||
private_state_exposed: false,
|
||||
notes: Vec::new(),
|
||||
let binary = if cfg!(windows) {
|
||||
"C:\\epiphany-memory-semantic-projector.exe"
|
||||
} else {
|
||||
"/tmp/epiphany-memory-semantic-projector"
|
||||
};
|
||||
let mut intent = epiphany_cultmesh_daemon_poke_intent_from_status(
|
||||
"semantic-restart-intent-1",
|
||||
"idunn",
|
||||
&status,
|
||||
"fence exact abandoned semantic projector claim",
|
||||
);
|
||||
intent.requested_at_utc = "2026-07-15T12:01:00Z".to_string();
|
||||
write_epiphany_cultmesh_daemon_poke_intent(&verse, "runtime-test", intent.clone())?;
|
||||
let mut receipt = epiphany_cultmesh_daemon_poke_receipt_for_intent(
|
||||
"semantic-restart-receipt-1",
|
||||
&intent,
|
||||
"restart-succeeded",
|
||||
"awaiting-provider-heartbeat",
|
||||
"process://semantic-projector/exit/0",
|
||||
);
|
||||
receipt.attempted_at_utc = "2026-07-15T12:01:00Z".to_string();
|
||||
receipt.completed_at_utc = "2026-07-15T12:02:00Z".to_string();
|
||||
write_epiphany_cultmesh_daemon_poke_receipt(&verse, "runtime-test", receipt.clone())?;
|
||||
let policy = EpiphanyCultMeshManagedServicePolicyEntry {
|
||||
schema_version: EPIPHANY_CULTMESH_MANAGED_SERVICE_POLICY_SCHEMA_VERSION.to_string(),
|
||||
policy_id: "managed-service-policy-epiphany-memory-semantic-projector-service".into(),
|
||||
service_id: EPIPHANY_SEMANTIC_PROJECTOR_SERVICE_ID.into(),
|
||||
owner_daemon_id: "epiphany-daemon-supervisor".into(),
|
||||
command: binary.into(),
|
||||
args: vec![
|
||||
"serve",
|
||||
"--agent-store",
|
||||
"mind.ccmp",
|
||||
"--runtime-store",
|
||||
"modeling.ccmp",
|
||||
"--local-verse-store",
|
||||
"verse.ccmp",
|
||||
"--runtime-id",
|
||||
"runtime-test",
|
||||
"--interval-seconds",
|
||||
"60",
|
||||
"--qdrant-url",
|
||||
"http://127.0.0.1:16333",
|
||||
"--ollama-base-url",
|
||||
"http://10.77.0.1:11435",
|
||||
"--ollama-model",
|
||||
"qwen3-embedding:0.6b",
|
||||
]
|
||||
.into_iter()
|
||||
.map(str::to_string)
|
||||
.collect(),
|
||||
cwd: None,
|
||||
enabled: true,
|
||||
restart_mode: "always".into(),
|
||||
cooldown_seconds: 0,
|
||||
backoff_multiplier: 1,
|
||||
stdout_artifact: "projector.stdout.log".into(),
|
||||
stderr_artifact: "projector.stderr.log".into(),
|
||||
updated_at_utc: "2026-07-15T12:01:00Z".into(),
|
||||
private_state_exposed: false,
|
||||
notes: vec![],
|
||||
};
|
||||
write_epiphany_cultmesh_semantic_projector_service_policy(
|
||||
&verse,
|
||||
"runtime-test",
|
||||
policy.clone(),
|
||||
)?;
|
||||
let (_, policy_digest) = load_epiphany_cultmesh_managed_service_policy_with_digest(
|
||||
&verse,
|
||||
"runtime-test",
|
||||
EPIPHANY_SEMANTIC_PROJECTOR_SERVICE_ID,
|
||||
)?
|
||||
.context("semantic policy missing")?;
|
||||
let receipt = EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry {
|
||||
schema_version: EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_SCHEMA_VERSION
|
||||
.into(),
|
||||
receipt_id: "f32666a9-94ce-47c5-b2bd-7d18624dfe9b".into(),
|
||||
service_id: EPIPHANY_SEMANTIC_PROJECTOR_SERVICE_ID.into(),
|
||||
scheduler_id: "epiphany-daemon-supervisor".into(),
|
||||
runtime_id: "runtime-test".into(),
|
||||
daemon_selector: "epiphany-daemon-supervisor".into(),
|
||||
action: "launch".into(),
|
||||
status: "launched".into(),
|
||||
command: policy.command.clone(),
|
||||
args: policy.args.clone(),
|
||||
cwd: None,
|
||||
process_id: Some(4242),
|
||||
exit_code: None,
|
||||
started_at_utc: "2026-07-15T12:01:00Z".into(),
|
||||
completed_at_utc: Some("2026-07-15T12:02:00Z".into()),
|
||||
operator_artifact_ref: "service://semantic-projector/launch".into(),
|
||||
private_state_exposed: false,
|
||||
notes: vec![],
|
||||
executable_sha256: String::new(),
|
||||
preflight_witness_id: String::new(),
|
||||
required_document_types: vec![],
|
||||
schema_preflight_passed: false,
|
||||
schema_catalog_sha256: String::new(),
|
||||
managed_policy_id: policy.policy_id.clone(),
|
||||
managed_policy_digest: policy_digest,
|
||||
provider_daemon_id: "epiphany-memory-semantic-projector".into(),
|
||||
startup_correlation_id: "f32666a9-94ce-47c5-b2bd-7d18624dfe9b".into(),
|
||||
};
|
||||
write_epiphany_cultmesh_daemon_service_lifecycle_receipt(
|
||||
&verse,
|
||||
"runtime-test",
|
||||
receipt.clone(),
|
||||
)?;
|
||||
|
||||
let unrelated = EpiphanyCultMeshDaemonHeartbeatEventEntry {
|
||||
schema_version: EPIPHANY_CULTMESH_DAEMON_HEARTBEAT_EVENT_SCHEMA_VERSION.to_string(),
|
||||
heartbeat_id: "semantic-heartbeat-unrelated".to_string(),
|
||||
daemon_id: status.daemon_id.clone(),
|
||||
cluster_id: status.cluster_id.clone(),
|
||||
daemon_id: "epiphany-memory-semantic-projector".into(),
|
||||
cluster_id: "local".into(),
|
||||
provider_incarnation: "provider-new".to_string(),
|
||||
sequence: 1,
|
||||
status: "ready".to_string(),
|
||||
|
|
@ -11271,6 +11590,31 @@ mod tests {
|
|||
.is_err()
|
||||
);
|
||||
|
||||
let mut advanced_policy = policy.clone();
|
||||
advanced_policy.updated_at_utc = "2026-07-15T12:02:30Z".into();
|
||||
write_epiphany_cultmesh_semantic_projector_service_policy(
|
||||
&verse,
|
||||
"runtime-test",
|
||||
advanced_policy,
|
||||
)?;
|
||||
assert!(
|
||||
idunn_recover_memory_semantic_projection_from_cultmesh(
|
||||
&verse,
|
||||
"runtime-test",
|
||||
&canonical,
|
||||
&input,
|
||||
&claim.claim_id,
|
||||
"executor-new",
|
||||
&receipt.receipt_id,
|
||||
"semantic-heartbeat-unrelated",
|
||||
"2026-07-15T12:04:00Z",
|
||||
)
|
||||
.expect_err("an obsolete launch receipt cannot authorize a newer policy")
|
||||
.to_string()
|
||||
.contains("disagrees with current managed policy")
|
||||
);
|
||||
write_epiphany_cultmesh_semantic_projector_service_policy(&verse, "runtime-test", policy)?;
|
||||
|
||||
let correlated = EpiphanyCultMeshDaemonHeartbeatEventEntry {
|
||||
heartbeat_id: "semantic-heartbeat-correlated".to_string(),
|
||||
sequence: 2,
|
||||
|
|
@ -11283,8 +11627,8 @@ mod tests {
|
|||
)
|
||||
};
|
||||
let mut correlated = correlated;
|
||||
correlated.daemon_id = status.daemon_id;
|
||||
correlated.cluster_id = status.cluster_id;
|
||||
correlated.daemon_id = "epiphany-memory-semantic-projector".into();
|
||||
correlated.cluster_id = "local".into();
|
||||
write_epiphany_cultmesh_daemon_heartbeat_event(&verse, "runtime-test", correlated.clone())?;
|
||||
let (_, recovered) = idunn_recover_memory_semantic_projection_from_cultmesh(
|
||||
&verse,
|
||||
|
|
|
|||
|
|
@ -386,6 +386,7 @@ pub use cultmesh_integration::EpiphanyLocalVerseContractSummary;
|
|||
pub use cultmesh_integration::EpiphanyLocalVerseWorkLoopSummary;
|
||||
pub use cultmesh_integration::EpiphanyServiceExecutionAuditCheck;
|
||||
pub use cultmesh_integration::EpiphanyServiceExecutionAuditReport;
|
||||
pub use cultmesh_integration::authenticate_epiphany_cultmesh_semantic_projector_launch;
|
||||
pub use cultmesh_integration::default_epiphany_cultmesh_swarm_brake;
|
||||
pub use cultmesh_integration::epiphany_cluster_service_execution_audit_report;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_agent_state_soa_summary_from_entry;
|
||||
|
|
@ -445,6 +446,7 @@ pub use cultmesh_integration::load_epiphany_cultmesh_daemon_poke_intent;
|
|||
pub use cultmesh_integration::load_epiphany_cultmesh_daemon_poke_receipt;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_daemon_restart_policy;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_daemon_restart_policy_directory;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_daemon_service_lifecycle_receipt;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_daemon_service_lifecycle_receipts;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_daemon_tool_directory;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_eve_surface_directory;
|
||||
|
|
@ -452,6 +454,7 @@ pub use cultmesh_integration::load_epiphany_cultmesh_idunn_aftercare_audit_recei
|
|||
pub use cultmesh_integration::load_epiphany_cultmesh_idunn_deployment_receipt;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_managed_service_policies;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_managed_service_policy;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_managed_service_policy_with_digest;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_operator_run_intent;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_operator_run_receipt;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_operator_snapshot;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ pub const MEMORY_SEMANTIC_PROJECTION_CLAIM_SCHEMA_VERSION: &str =
|
|||
pub const MEMORY_SEMANTIC_PROJECTOR_EXECUTOR_GRANT_SCHEMA_VERSION: &str =
|
||||
"gamecult.epiphany.memory_semantic_projector_executor_grant.v1";
|
||||
pub const MEMORY_SEMANTIC_PROJECTOR_RECOVERY_AUTHORIZATION_SCHEMA_VERSION: &str =
|
||||
"gamecult.epiphany.memory_semantic_projector_recovery_authorization.v1";
|
||||
"gamecult.epiphany.memory_semantic_projector_recovery_authorization.v2";
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
|
|
@ -285,16 +285,16 @@ mod authority_tests {
|
|||
&projection_input,
|
||||
&acquisition.claim.claim_id,
|
||||
"idunn-incarnation-a",
|
||||
"poke-intent-1",
|
||||
"sha256-intent",
|
||||
"poke-receipt-1",
|
||||
"sha256-receipt",
|
||||
"managed-policy-1",
|
||||
"sha256-policy",
|
||||
"launch-receipt-1",
|
||||
"sha256-launch-receipt",
|
||||
"2026-07-15T04:02:00Z",
|
||||
"heartbeat-1",
|
||||
"sha256-heartbeat",
|
||||
"provider-new",
|
||||
"2026-07-15T04:03:00Z",
|
||||
"poke-receipt-1",
|
||||
"launch-receipt-1",
|
||||
)?;
|
||||
let (authorization, recovered) = idunn_recover_memory_semantic_projection(
|
||||
&store,
|
||||
|
|
@ -306,8 +306,11 @@ mod authority_tests {
|
|||
"2026-07-15T04:04:00Z",
|
||||
)?;
|
||||
assert_eq!(authorization.status, "consumed");
|
||||
assert_eq!(authorization.lifecycle_intent_id, "poke-intent-1");
|
||||
assert_eq!(authorization.lifecycle_receipt_id, "poke-receipt-1");
|
||||
assert_eq!(authorization.managed_service_policy_id, "managed-policy-1");
|
||||
assert_eq!(
|
||||
authorization.launch_lifecycle_receipt_id,
|
||||
"launch-receipt-1"
|
||||
);
|
||||
assert_eq!(authorization.provider_heartbeat_id, "heartbeat-1");
|
||||
assert_eq!(
|
||||
authorization.provider_incarnation,
|
||||
|
|
@ -329,16 +332,16 @@ mod authority_tests {
|
|||
&projection_input,
|
||||
&recovered.claim_id,
|
||||
"idunn-incarnation-a",
|
||||
"poke-intent-2",
|
||||
"sha256-intent-2",
|
||||
"poke-receipt-2",
|
||||
"sha256-receipt-2",
|
||||
"managed-policy-2",
|
||||
"sha256-policy-2",
|
||||
"launch-receipt-2",
|
||||
"sha256-launch-receipt-2",
|
||||
"2026-07-15T04:03:00Z",
|
||||
"heartbeat-2",
|
||||
"sha256-heartbeat-2",
|
||||
"provider-new",
|
||||
"2026-07-15T04:03:00Z",
|
||||
"poke-receipt-2",
|
||||
"launch-receipt-2",
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
|
|
@ -381,9 +384,9 @@ pub struct MemorySemanticProjectorRecoveryAuthorization {
|
|||
#[cultcache(key = 13)]
|
||||
pub issuer_incarnation: String,
|
||||
#[cultcache(key = 14)]
|
||||
pub lifecycle_intent_id: String,
|
||||
pub managed_service_policy_id: String,
|
||||
#[cultcache(key = 15)]
|
||||
pub lifecycle_intent_digest: String,
|
||||
pub managed_service_policy_digest: String,
|
||||
#[cultcache(key = 16)]
|
||||
pub status: String,
|
||||
#[cultcache(key = 17)]
|
||||
|
|
@ -397,11 +400,11 @@ pub struct MemorySemanticProjectorRecoveryAuthorization {
|
|||
#[cultcache(key = 21)]
|
||||
pub abandoned_executor_incarnation: String,
|
||||
#[cultcache(key = 22)]
|
||||
pub lifecycle_receipt_id: String,
|
||||
pub launch_lifecycle_receipt_id: String,
|
||||
#[cultcache(key = 23)]
|
||||
pub lifecycle_receipt_digest: String,
|
||||
pub launch_lifecycle_receipt_digest: String,
|
||||
#[cultcache(key = 24)]
|
||||
pub lifecycle_receipt_completed_at: String,
|
||||
pub launch_lifecycle_receipt_completed_at: String,
|
||||
#[cultcache(key = 25)]
|
||||
pub provider_heartbeat_id: String,
|
||||
#[cultcache(key = 26)]
|
||||
|
|
@ -413,7 +416,7 @@ pub struct MemorySemanticProjectorRecoveryAuthorization {
|
|||
#[cultcache(key = 29)]
|
||||
pub canonical_store_id: String,
|
||||
#[cultcache(key = 30)]
|
||||
pub lifecycle_correlation_id: String,
|
||||
pub startup_correlation_id: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DatabaseEntry)]
|
||||
|
|
@ -454,11 +457,11 @@ pub struct MemorySemanticProjectionClaim {
|
|||
#[derive(Clone, Debug)]
|
||||
pub struct IdunnSemanticRecoveryEvidence {
|
||||
issuer_incarnation: String,
|
||||
lifecycle_intent_id: String,
|
||||
lifecycle_intent_digest: String,
|
||||
lifecycle_receipt_id: String,
|
||||
lifecycle_receipt_digest: String,
|
||||
lifecycle_receipt_completed_at: String,
|
||||
managed_service_policy_id: String,
|
||||
managed_service_policy_digest: String,
|
||||
launch_lifecycle_receipt_id: String,
|
||||
launch_lifecycle_receipt_digest: String,
|
||||
launch_lifecycle_receipt_completed_at: String,
|
||||
provider_heartbeat_id: String,
|
||||
provider_heartbeat_digest: String,
|
||||
provider_incarnation: String,
|
||||
|
|
@ -471,7 +474,7 @@ pub struct IdunnSemanticRecoveryEvidence {
|
|||
claim_id: String,
|
||||
claim_epoch: u64,
|
||||
abandoned_executor_incarnation: String,
|
||||
lifecycle_correlation_id: String,
|
||||
startup_correlation_id: String,
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
|
|
@ -480,16 +483,16 @@ pub(crate) fn idunn_semantic_recovery_evidence_from_cultmesh(
|
|||
input: &MemorySemanticProjectionInput,
|
||||
expected_claim_id: &str,
|
||||
issuer_incarnation: &str,
|
||||
lifecycle_intent_id: &str,
|
||||
lifecycle_intent_digest: &str,
|
||||
lifecycle_receipt_id: &str,
|
||||
lifecycle_receipt_digest: &str,
|
||||
lifecycle_receipt_completed_at: &str,
|
||||
managed_service_policy_id: &str,
|
||||
managed_service_policy_digest: &str,
|
||||
launch_lifecycle_receipt_id: &str,
|
||||
launch_lifecycle_receipt_digest: &str,
|
||||
launch_lifecycle_receipt_completed_at: &str,
|
||||
provider_heartbeat_id: &str,
|
||||
provider_heartbeat_digest: &str,
|
||||
provider_incarnation: &str,
|
||||
provider_heartbeat_at: &str,
|
||||
lifecycle_correlation_id: &str,
|
||||
startup_correlation_id: &str,
|
||||
) -> Result<IdunnSemanticRecoveryEvidence> {
|
||||
validate_memory_semantic_projection_obligation(&input.obligation)?;
|
||||
let store_path = store_path.as_ref();
|
||||
|
|
@ -526,11 +529,11 @@ pub(crate) fn idunn_semantic_recovery_evidence_from_cultmesh(
|
|||
authenticate_claim_authority_from_envelopes(&envelopes, &claim)?;
|
||||
let evidence = IdunnSemanticRecoveryEvidence {
|
||||
issuer_incarnation: issuer_incarnation.to_string(),
|
||||
lifecycle_intent_id: lifecycle_intent_id.to_string(),
|
||||
lifecycle_intent_digest: lifecycle_intent_digest.to_string(),
|
||||
lifecycle_receipt_id: lifecycle_receipt_id.to_string(),
|
||||
lifecycle_receipt_digest: lifecycle_receipt_digest.to_string(),
|
||||
lifecycle_receipt_completed_at: lifecycle_receipt_completed_at.to_string(),
|
||||
managed_service_policy_id: managed_service_policy_id.to_string(),
|
||||
managed_service_policy_digest: managed_service_policy_digest.to_string(),
|
||||
launch_lifecycle_receipt_id: launch_lifecycle_receipt_id.to_string(),
|
||||
launch_lifecycle_receipt_digest: launch_lifecycle_receipt_digest.to_string(),
|
||||
launch_lifecycle_receipt_completed_at: launch_lifecycle_receipt_completed_at.to_string(),
|
||||
provider_heartbeat_id: provider_heartbeat_id.to_string(),
|
||||
provider_heartbeat_digest: provider_heartbeat_digest.to_string(),
|
||||
provider_incarnation: provider_incarnation.to_string(),
|
||||
|
|
@ -543,7 +546,7 @@ pub(crate) fn idunn_semantic_recovery_evidence_from_cultmesh(
|
|||
claim_id: claim.claim_id,
|
||||
claim_epoch: claim.epoch,
|
||||
abandoned_executor_incarnation: claim.executor_incarnation,
|
||||
lifecycle_correlation_id: lifecycle_correlation_id.to_string(),
|
||||
startup_correlation_id: startup_correlation_id.to_string(),
|
||||
};
|
||||
validate_idunn_semantic_recovery_evidence(&evidence)?;
|
||||
Ok(evidence)
|
||||
|
|
@ -1159,9 +1162,9 @@ pub(crate) fn idunn_recover_memory_semantic_projection(
|
|||
));
|
||||
}
|
||||
ensure_strictly_before(
|
||||
&evidence.lifecycle_receipt_completed_at,
|
||||
&evidence.launch_lifecycle_receipt_completed_at,
|
||||
&evidence.provider_heartbeat_at,
|
||||
"provider heartbeat must follow lifecycle receipt",
|
||||
"provider heartbeat must follow managed-service launch receipt",
|
||||
)?;
|
||||
ensure_not_before(
|
||||
recovered_at,
|
||||
|
|
@ -1231,8 +1234,8 @@ pub(crate) fn idunn_recover_memory_semantic_projection(
|
|||
format!(
|
||||
"{}|{}|{}|{}",
|
||||
evidence.canonical_store_id,
|
||||
evidence.lifecycle_intent_digest,
|
||||
evidence.lifecycle_receipt_digest,
|
||||
evidence.managed_service_policy_digest,
|
||||
evidence.launch_lifecycle_receipt_digest,
|
||||
evidence.provider_heartbeat_digest
|
||||
)
|
||||
.as_bytes()
|
||||
|
|
@ -1277,17 +1280,19 @@ pub(crate) fn idunn_recover_memory_semantic_projection(
|
|||
replacement_executor_incarnation: replacement_executor_incarnation.to_string(),
|
||||
issuer_id: "idunn".to_string(),
|
||||
issuer_incarnation: evidence.issuer_incarnation.clone(),
|
||||
lifecycle_intent_id: evidence.lifecycle_intent_id.clone(),
|
||||
lifecycle_intent_digest: evidence.lifecycle_intent_digest.clone(),
|
||||
lifecycle_receipt_id: evidence.lifecycle_receipt_id.clone(),
|
||||
lifecycle_receipt_digest: evidence.lifecycle_receipt_digest.clone(),
|
||||
lifecycle_receipt_completed_at: evidence.lifecycle_receipt_completed_at.clone(),
|
||||
managed_service_policy_id: evidence.managed_service_policy_id.clone(),
|
||||
managed_service_policy_digest: evidence.managed_service_policy_digest.clone(),
|
||||
launch_lifecycle_receipt_id: evidence.launch_lifecycle_receipt_id.clone(),
|
||||
launch_lifecycle_receipt_digest: evidence.launch_lifecycle_receipt_digest.clone(),
|
||||
launch_lifecycle_receipt_completed_at: evidence
|
||||
.launch_lifecycle_receipt_completed_at
|
||||
.clone(),
|
||||
provider_heartbeat_id: evidence.provider_heartbeat_id.clone(),
|
||||
provider_heartbeat_digest: evidence.provider_heartbeat_digest.clone(),
|
||||
provider_incarnation: evidence.provider_incarnation.clone(),
|
||||
provider_heartbeat_at: evidence.provider_heartbeat_at.clone(),
|
||||
canonical_store_id: evidence.canonical_store_id.clone(),
|
||||
lifecycle_correlation_id: evidence.lifecycle_correlation_id.clone(),
|
||||
startup_correlation_id: evidence.startup_correlation_id.clone(),
|
||||
status: "consumed".to_string(),
|
||||
issued_at: recovered_at.to_string(),
|
||||
consumed_at: Some(recovered_at.to_string()),
|
||||
|
|
@ -1606,22 +1611,22 @@ pub fn validate_memory_semantic_projector_recovery_authorization(
|
|||
|| !is_opaque_identity(&authorization.replacement_executor_incarnation)
|
||||
|| authorization.issuer_id != "idunn"
|
||||
|| !is_opaque_identity(&authorization.issuer_incarnation)
|
||||
|| !is_opaque_identity(&authorization.lifecycle_intent_id)
|
||||
|| !is_opaque_identity(&authorization.lifecycle_intent_digest)
|
||||
|| !is_opaque_identity(&authorization.lifecycle_receipt_id)
|
||||
|| !is_opaque_identity(&authorization.lifecycle_receipt_digest)
|
||||
|| !valid_rfc3339(&authorization.lifecycle_receipt_completed_at)
|
||||
|| !is_opaque_identity(&authorization.managed_service_policy_id)
|
||||
|| !is_opaque_identity(&authorization.managed_service_policy_digest)
|
||||
|| !is_opaque_identity(&authorization.launch_lifecycle_receipt_id)
|
||||
|| !is_opaque_identity(&authorization.launch_lifecycle_receipt_digest)
|
||||
|| !valid_rfc3339(&authorization.launch_lifecycle_receipt_completed_at)
|
||||
|| !is_opaque_identity(&authorization.provider_heartbeat_id)
|
||||
|| !is_opaque_identity(&authorization.provider_heartbeat_digest)
|
||||
|| !is_opaque_identity(&authorization.provider_incarnation)
|
||||
|| !valid_rfc3339(&authorization.provider_heartbeat_at)
|
||||
|| !is_opaque_identity(&authorization.canonical_store_id)
|
||||
|| !is_opaque_identity(&authorization.lifecycle_correlation_id)
|
||||
|| authorization.lifecycle_correlation_id != authorization.lifecycle_receipt_id
|
||||
|| !is_opaque_identity(&authorization.startup_correlation_id)
|
||||
|| authorization.startup_correlation_id != authorization.launch_lifecycle_receipt_id
|
||||
|| authorization.replacement_executor_incarnation != authorization.provider_incarnation
|
||||
|| authorization.provider_incarnation == authorization.abandoned_executor_incarnation
|
||||
|| !strictly_before(
|
||||
&authorization.lifecycle_receipt_completed_at,
|
||||
&authorization.launch_lifecycle_receipt_completed_at,
|
||||
&authorization.provider_heartbeat_at,
|
||||
)
|
||||
|| !not_before(
|
||||
|
|
@ -1954,12 +1959,21 @@ fn validate_idunn_semantic_recovery_evidence(
|
|||
) -> Result<()> {
|
||||
for (value, label) in [
|
||||
(&evidence.issuer_incarnation, "issuer incarnation"),
|
||||
(&evidence.lifecycle_intent_id, "lifecycle intent identity"),
|
||||
(&evidence.lifecycle_intent_digest, "lifecycle intent digest"),
|
||||
(&evidence.lifecycle_receipt_id, "lifecycle receipt identity"),
|
||||
(
|
||||
&evidence.lifecycle_receipt_digest,
|
||||
"lifecycle receipt digest",
|
||||
&evidence.managed_service_policy_id,
|
||||
"managed service policy identity",
|
||||
),
|
||||
(
|
||||
&evidence.managed_service_policy_digest,
|
||||
"managed service policy digest",
|
||||
),
|
||||
(
|
||||
&evidence.launch_lifecycle_receipt_id,
|
||||
"launch lifecycle receipt identity",
|
||||
),
|
||||
(
|
||||
&evidence.launch_lifecycle_receipt_digest,
|
||||
"launch lifecycle receipt digest",
|
||||
),
|
||||
(
|
||||
&evidence.provider_heartbeat_id,
|
||||
|
|
@ -1980,20 +1994,20 @@ fn validate_idunn_semantic_recovery_evidence(
|
|||
"abandoned executor incarnation",
|
||||
),
|
||||
(
|
||||
&evidence.lifecycle_correlation_id,
|
||||
"lifecycle correlation identity",
|
||||
&evidence.startup_correlation_id,
|
||||
"startup correlation identity",
|
||||
),
|
||||
] {
|
||||
validate_opaque_identity(value, label)?;
|
||||
}
|
||||
if !valid_rfc3339(&evidence.lifecycle_receipt_completed_at)
|
||||
if !valid_rfc3339(&evidence.launch_lifecycle_receipt_completed_at)
|
||||
|| !valid_rfc3339(&evidence.provider_heartbeat_at)
|
||||
|| !matches!(evidence.partition.as_str(), "mind" | "modeling")
|
||||
|| evidence.claim_epoch == 0
|
||||
|| evidence.provider_incarnation == evidence.abandoned_executor_incarnation
|
||||
|| evidence.lifecycle_correlation_id != evidence.lifecycle_receipt_id
|
||||
|| evidence.startup_correlation_id != evidence.launch_lifecycle_receipt_id
|
||||
|| !strictly_before(
|
||||
&evidence.lifecycle_receipt_completed_at,
|
||||
&evidence.launch_lifecycle_receipt_completed_at,
|
||||
&evidence.provider_heartbeat_at,
|
||||
)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1296,3 +1296,40 @@ then publish the reserved projector policy. Run one bounded live pulse, prove
|
|||
both derived health rows and provider heartbeat, kill the body once, and prove
|
||||
Idunn restart plus causally linked heartbeat/recovery/resumption. This is a
|
||||
preflight and survival proof, not permission to call deployment complete.
|
||||
|
||||
## Managed semantic launch authority rebuild (2026-07-15)
|
||||
|
||||
Deployment inspection found incompatible lifecycle stories. The packaged
|
||||
managed-service launcher spawned an infinite child and wrote a mutable v0
|
||||
event, while semantic recovery expected a completed daemon-poke receipt from a
|
||||
blocking restart command. That command could never truthfully witness this
|
||||
service.
|
||||
|
||||
The authority is now one causal chain. The reserved managed policy is desired
|
||||
state. Idunn preallocates a UUID, injects it into the child, spawns once, and
|
||||
atomically writes an immutable v1 lifecycle receipt binding child PID, spawn
|
||||
completion, exact policy id and envelope digest, fixed projector daemon, and
|
||||
startup correlation. Failed persistence kills and waits for the child. The
|
||||
child authenticates that receipt against the current policy before constructing
|
||||
the service body or publishing a pulse or heartbeat. A launch receipt proves
|
||||
spawn completion, never readiness.
|
||||
|
||||
Semantic recovery authorization is v2 and consumes only the current policy,
|
||||
its exact launch receipt, and a strictly later correlated provider heartbeat.
|
||||
Advancing policy invalidates an older launch receipt. Daemon poke remains an
|
||||
operator intervention surface for ordinary daemons but cannot authorize
|
||||
semantic recovery. Hostile tests cover unrelated heartbeat, policy advance,
|
||||
successful exact recovery, and single-use refusal. Full library proof is 371
|
||||
passed/1 ignored; supervisor tests are 7/7; all binaries compile.
|
||||
|
||||
Infrastructure truth also changed. The retired local `voidbot-qdrant` must stay
|
||||
stopped. Shared Yggdrasil Qdrant is authoritative and reaches this workstation
|
||||
through the ops tunnel at `127.0.0.1:16333`; Yggdrasil Ollama is reachable at
|
||||
`http://10.77.0.1:11435`. Both Epiphany collections are green 1024-dimensional
|
||||
cosine collections using `qwen3-embedding:0.6b`.
|
||||
|
||||
Next: publish the reserved policy and place both the managed-service reconciler
|
||||
and Qdrant tunnel under durable Idunn/OS survival ownership. Live proof must
|
||||
cover real child handshake, bounded pulse, heartbeat and health, forced
|
||||
restart/correlation, singleton refusal, and safe exact recovery/resumption
|
||||
where an abandoned claim can be created without forging canonical work.
|
||||
|
|
|
|||
|
|
@ -28,18 +28,20 @@ $env:CARGO_TARGET_DIR='C:\Users\Meta\.cargo-target-codex'
|
|||
cargo build --release --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-memory-semantic-projector --bin epiphany-daemon-supervisor
|
||||
```
|
||||
|
||||
## Required configuration
|
||||
## Transport configuration
|
||||
|
||||
Set these in the Idunn service environment before launch:
|
||||
The reserved typed service policy binds the non-secret transport coordinates:
|
||||
|
||||
```text
|
||||
EPIPHANY_QDRANT_URL=http://127.0.0.1:6333
|
||||
EPIPHANY_OLLAMA_URL=http://<yggdrasil-wireguard-address>:11435
|
||||
--qdrant-url http://127.0.0.1:16333
|
||||
--ollama-base-url http://10.77.0.1:11435
|
||||
--ollama-model qwen3-embedding:0.6b
|
||||
```
|
||||
|
||||
Use the embedding model and collection configuration already consumed by
|
||||
`MemorySemanticIndexConfig::from_env`. Keep credentials in the service
|
||||
environment or secret store; never place them in policy arguments or logs.
|
||||
Qdrant REST reaches Yggdrasil loopback through the ops-owned SSH tunnel; Ollama
|
||||
is admitted directly on WireGuard. API keys remain in the service environment
|
||||
or secret store and never enter policy arguments or logs. Collection names and
|
||||
timeouts retain their typed configuration defaults unless deliberately changed.
|
||||
|
||||
## Preflight
|
||||
|
||||
|
|
@ -54,10 +56,11 @@ environment or secret store; never place them in policy arguments or logs.
|
|||
5. Confirm the local Verse store is bootstrapped and Idunn's managed-service
|
||||
reconciler is running.
|
||||
|
||||
Current local observation on 2026-07-15: Docker reports `voidbot-qdrant` as
|
||||
`Exited (143)`. Its name indicates foreign service ownership, so this runbook
|
||||
does not restart or silently adopt it. Deployment remains blocked until an
|
||||
explicit Epiphany-owned or intentionally shared Qdrant endpoint is live.
|
||||
Current observation on 2026-07-15: the workstation's retired
|
||||
`voidbot-qdrant` container is intentionally stopped after the VoidBot cutover.
|
||||
The authoritative Yggdrasil Qdrant is physically shared and contains the
|
||||
Epiphany Mind and Modeling collections. The ops tunnel exposes its loopback
|
||||
REST/gRPC ports locally as `16333`/`16334`; do not restart the retired node.
|
||||
|
||||
## Publish the typed service policy
|
||||
|
||||
|
|
@ -67,7 +70,10 @@ $supervisor = '.\target\release\epiphany-daemon-supervisor.exe'
|
|||
--store .\.epiphany-run\cultmesh\local-verse.ccmp `
|
||||
--runtime-id epiphany-local `
|
||||
--agent-store .\state\agents.msgpack `
|
||||
--runtime-store <runtime-spine-store> `
|
||||
--runtime-store .\state\runtime-spine.msgpack `
|
||||
--qdrant-url http://127.0.0.1:16333 `
|
||||
--ollama-base-url http://10.77.0.1:11435 `
|
||||
--ollama-model qwen3-embedding:0.6b `
|
||||
--loop-interval-seconds 60
|
||||
```
|
||||
|
||||
|
|
@ -81,17 +87,31 @@ limits do not own this service shape. The generic managed-service writer
|
|||
refuses the reserved service id.
|
||||
|
||||
Idunn's existing `managed-service-serve` loop reconciles that policy and writes
|
||||
the startup lifecycle receipt identifier into the child environment. The
|
||||
projector publishes its first provider heartbeat only after it holds the OS
|
||||
singleton and validates both canonical inputs.
|
||||
the startup lifecycle receipt identifier into the child environment. For each
|
||||
launch it preallocates a fresh UUID, authenticates the exact current reserved
|
||||
policy envelope, spawns the one infinite child, then atomically seals an
|
||||
immutable v1 lifecycle receipt. That receipt binds `action=launch`,
|
||||
`status=launched`, the child PID, spawn completion time, policy id and envelope
|
||||
digest, fixed projector daemon id, and a startup correlation id equal to the
|
||||
receipt id. If sealing fails, Idunn kills and waits for the unowned child.
|
||||
|
||||
The projector resolves that exact receipt from the local Verse and rechecks its
|
||||
binding to the current reserved policy before constructing its service body or
|
||||
publishing a pulse or heartbeat. A launch receipt proves process creation; it
|
||||
does not claim semantic readiness. The first heartbeat comes later, after the
|
||||
projector holds the OS singleton and validates both canonical inputs.
|
||||
|
||||
## Recovery
|
||||
|
||||
Use `semantic-recover` only with the exact abandoned claim, successful Idunn
|
||||
restart receipt, and causally linked provider heartbeat. Recovery always assigns
|
||||
the fixed packaged projector executor identity. It rotates authority; it does
|
||||
not execute projection or mint readiness. The running projector resumes its own
|
||||
recovered claim on the next pulse.
|
||||
Use `semantic-recover` only with the exact abandoned claim, the immutable launch
|
||||
receipt for the current reserved managed policy, and its causally later provider
|
||||
heartbeat. The launch receipt must still authenticate against the current policy
|
||||
envelope; advancing policy invalidates an older launch witness. Ordinary daemon
|
||||
poke intents and receipts cannot authorize semantic recovery.
|
||||
|
||||
Recovery always assigns the fixed packaged projector executor identity. It
|
||||
rotates authority; it does not execute projection or mint readiness. The running
|
||||
projector resumes its own recovered claim on the next pulse.
|
||||
|
||||
## Proof after launch
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -714,4 +714,4 @@ current_status:
|
|||
- Service lifecycle receipt history is now event-only: `load_epiphany_cultmesh_daemon_service_lifecycle_receipts` filters out the `epiphany-local/daemon-service-lifecycle-receipt/latest` mirror, while `load_latest_epiphany_cultmesh_daemon_service_lifecycle_receipt` remains the latest-state reader. Focused unit test `service_lifecycle_receipt_history_excludes_latest_mirror` proves two per-receipt writes return exactly two history records and latest points at the second. Fresh smoke `verse-query-lifecycle-history-filter-smoke` and live overview/triage `local-20260618-145632-497-efac6f0d` / `local-20260618-145632-321-867947af` prove compact swarm sights still expose service lifecycle attention plus the present elevated runbook artifact without daemon pokes or service mutation. Do not use a broad unscoped cargo test filter for this check on Windows; it fans out across bin harnesses and hit a broken pipe during this pass.
|
||||
- `epiphany-verse-query seed-compact` is the compact seed receipt for wrappers and read-only rites. The older `seed` command still prints the full local Verse context for explicit debugging, but compact wrapper modes now avoid full `seed`/final `query` readback after the combined overview proof exposed Windows debug stack overflow from full-context serialization pressure.
|
||||
last_completed_repo_swarm_cut: Huginn live-fire has crossed the first real repo Body from Persona pressure to branch-local Hands commit and Soul/Mind closure, and now has repeatable closure and redacted-public-proof mouths. On `E:\Projects\Huginn` branch `epiphany/huginn/first-awakening`, `tools/epiphany_local_run.ps1 -Mode repo-persona-intake` accepted item `huginn-inspection-readback-livefire`, Weksa/Persona intake remained sealed, and `epiphany-work derive-plan` lowered it to model-authored safe family `repo.status_section` for `README.md` only. `tools/epiphany_local_run.ps1 -Mode repo-swarm-run` advanced four bounded pulses: run-from-plan, adopt-from-plan, execute-from-plan, and close-from-execute. Huginn commit `e9b07c38fceabbdc89ea35c2156326c80c0393a2` updated only `README.md`; closure receipt `.epiphany\work\work-close-huginn-inspection-readback-livefire.json` records status `closed`, Soul verdict `passed`, Mind state commit `repo-work-close-huginn-inspection-readback-livefire-mind-commit`, safe family `repo.status_section`, path scope `README.md`, Bifrost publication gate, and `privateStateExposed=false`. Verification also ran Huginn's TypeScript compiler through concrete Node path: `C:\Program Files\nodejs\node.exe E:\Projects\Huginn\node_modules\typescript\bin\tsc -p tsconfig.json` passed. Native verifier `epiphany-repo-livefire-closure-smoke --workspace E:\Projects\Huginn --item huginn-inspection-readback-livefire --expected-path README.md --expected-family repo.status_section --expected-gate awaiting-publication --expected-blocker bifrost-publication-missing` checks closure receipt, Mind map entry, overview gate/blocker, authority seals, and `git show` changed paths, returning `status=ok`, `soulVerdict=passed`, `publicationGate=Bifrost`, and `privateStateExposed=false`. Wrapper `tools/epiphany_local_run.ps1 -Mode repo-livefire-closure -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exposes the same read-only proof through the local operator mouth; artifact `local-20260621-190156-803-2f85ba15` printed commit, path, gate, blocker, Soul verdict, Mind commit receipt, and `privateStateExposed=False` without push, merge, publication, or target mutation. New wrapper `tools/epiphany_local_run.ps1 -Mode repo-work-public-proof -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exports the redacted proof bundle and repo-local Verse index without publishing; artifact `local-20260621-190645-345-4555b1dc` wrote `.epiphany\public\proof-bundles\repo-work-public-proof-huginn-inspection-readback-livefire.json`, proof id `repo-work-public-proof-huginn-inspection-readback-livefire`, SHA-256 `857545b199f3e37eb06c2e757e5cfc201958e46667bb1f8403fd333a22620f63`, nine artifact rows, zero publication rows, and `privateStateExposed=False`. swarm overview readback `local-20260621-190701-140-b9519ec6` sees the `REPO-WORK-PUBLIC-PROOF` row and action row from Huginn's repo-local Verse with the same SHA-256 while Bifrost publication remains missing. Launcher compact modes are now named compact operator-context modes instead of read-only modes, and `bifrost-public-proof` summaries print item, target public Verse, room, proof SHA-256, review receipts, and credit receipts so publication receipts are auditable without claiming upstream sync.
|
||||
next_action: Complete the live preflight and survival proof for the landed workstation semantic projector service body. One Idunn-managed `epiphany-memory-semantic-projector` process now owns execution for two explicit distinct same-swarm canonical stores: Mind and Modeling retain separate obligations, claims, Qdrant collections, and receipts. The body takes a host OS singleton for the canonical pair before minting a process-stable incarnation. Every fresh pulse reloads both sealed inputs, stores no open-work queue, permits at most one fair global action, never executes ready/foreign-running/succeeded/stale inputs, and resumes only an exact running claim owned by its current incarnation. Pending/failed work acquires exact Idunn authority before the crate-private executor; overlapping pulses are busy and cooldown follows completion. Exact recovery remains a separate supervisor action over authenticated lifecycle and provider-heartbeat evidence; it only rotates authority, after which the ordinary pulse resumes the recovered claim. The legacy CLI index/claim mouth and public raw execute surface are gone. Idunn's specialized writer exclusively owns the reserved fixed service policy and packaged sibling command; the generic managed-service writer cannot claim that service id or override its command, stores, restart mode, or unbounded serve shape. Provider health and heartbeat are derived sight only; the canonical grant-or-recovery/claim/attempt/receipt chain alone admits query. Deployment is not live: local `voidbot-qdrant` is stopped with exit code 143 and is foreign-owned, so Epiphany did not restart or adopt it; no projector policy or restart proof is claimed. Next establish explicit Qdrant ownership and a live workstation-reachable endpoint, verify collection compatibility and Yggdrasil Ollama reachability, then publish the reserved policy and prove bounded pulse, provider heartbeat, both health rows, forced Idunn restart, causal heartbeat, exact recovery/resumption, and singleton refusal. Do not call that deployment complete until those live proofs pass; do not move only the projector to Yggdrasil or start a second owner.
|
||||
next_action: Complete the live survival proof for the workstation semantic projector service body. The shared Yggdrasil Qdrant is authoritative and reachable through the ops-owned workstation tunnel at `127.0.0.1:16333`; Yggdrasil Ollama is reachable on WireGuard at `10.77.0.1:11435`, and both Epiphany collections are green, 1024-dimensional cosine collections owned by the configured Qwen embedding model. Idunn's reserved policy now binds those endpoints and is the sole desired-state owner. Managed launch preallocates a UUID, injects it before spawn, and atomically seals an immutable v1 PID-bound launch receipt against the exact current policy envelope; a child cannot construct its service body, pulse, or heartbeat until that receipt authenticates, and failed sealing kills and waits for the child. Semantic recovery v2 accepts only the current policy -> exact launch receipt -> causally later correlated provider heartbeat chain; daemon poke receipts cannot mint claim authority. One packaged process still owns fair bounded execution across distinct same-swarm Mind and Modeling stores, with canonical grants/claims/attempts/receipts as query authority and provider health as sight only. Library proof is green (371 passed, 1 ignored), supervisor authority proof is green (7 passed), and all binaries compile. Next publish the reserved policy, place the reconciler and Qdrant tunnel under durable Idunn/OS survival ownership, then prove a real child launch and handshake, bounded pulse, provider heartbeat, both health rows, forced restart with new correlated heartbeat, exact recovery/resumption where a safe abandoned claim can be created, and host singleton refusal. Do not call deployment complete until those live proofs pass.
|
||||
|
|
|
|||
Reference in a new issue