Rebuild Idunn semantic projector authority
This commit is contained in:
parent
05f11df79a
commit
fd7ff60adc
11 changed files with 2223 additions and 581 deletions
|
|
@ -1,17 +1,20 @@
|
|||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use chrono::Utc;
|
||||
use epiphany_core::EPIPHANY_CULTMESH_DAEMON_HEARTBEAT_EVENT_SCHEMA_VERSION;
|
||||
use epiphany_core::EPIPHANY_CULTMESH_DAEMON_STATUS_SCHEMA_VERSION;
|
||||
use epiphany_core::EpiphanyCultMeshDaemonHeartbeatEventEntry;
|
||||
use epiphany_core::EpiphanyCultMeshDaemonStatusEntry;
|
||||
use epiphany_core::load_epiphany_cultmesh_cluster_topology;
|
||||
use epiphany_core::load_epiphany_cultmesh_daemon_liveness;
|
||||
use epiphany_core::publish_epiphany_cultmesh_provider_state;
|
||||
use epiphany_core::write_epiphany_cultmesh_daemon_heartbeat_event;
|
||||
use epiphany_core::write_epiphany_cultmesh_daemon_status;
|
||||
use serde_json::json;
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use uuid::Uuid;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let args = Args::parse()?;
|
||||
|
|
@ -39,7 +42,10 @@ fn serve(args: Args) -> Result<()> {
|
|||
print_output(&args, "serveComplete", written)
|
||||
}
|
||||
|
||||
fn write_heartbeat(args: &Args, iteration: u64) -> Result<EpiphanyCultMeshDaemonStatusEntry> {
|
||||
fn write_heartbeat(
|
||||
args: &Args,
|
||||
iteration: u64,
|
||||
) -> Result<EpiphanyCultMeshDaemonHeartbeatEventEntry> {
|
||||
let topology = load_epiphany_cultmesh_cluster_topology(&args.store, args.runtime_id.clone())?;
|
||||
let cluster = topology
|
||||
.into_iter()
|
||||
|
|
@ -55,52 +61,76 @@ fn write_heartbeat(args: &Args, iteration: u64) -> Result<EpiphanyCultMeshDaemon
|
|||
args.runtime_id.clone(),
|
||||
&args.daemon_id,
|
||||
)?;
|
||||
let current = load_epiphany_cultmesh_daemon_liveness(&args.store, args.runtime_id.clone())?
|
||||
.into_iter()
|
||||
.map(|(_, status)| status)
|
||||
.find(|status| status.daemon_id == args.daemon_id)
|
||||
.unwrap_or_else(|| EpiphanyCultMeshDaemonStatusEntry {
|
||||
let heartbeat_at = Utc::now().to_rfc3339();
|
||||
let heartbeat = new_heartbeat_event(
|
||||
args,
|
||||
&cluster.daemon_id,
|
||||
&cluster.cluster_id,
|
||||
iteration,
|
||||
heartbeat_at,
|
||||
);
|
||||
let written = write_epiphany_cultmesh_daemon_heartbeat_event(
|
||||
&args.store,
|
||||
args.runtime_id.clone(),
|
||||
heartbeat,
|
||||
)?;
|
||||
|
||||
// Compatibility sight for readers not yet migrated to heartbeat events. It is
|
||||
// derived after the provider-owned event and cannot mint heartbeat authority.
|
||||
write_epiphany_cultmesh_daemon_status(
|
||||
&args.store,
|
||||
args.runtime_id.clone(),
|
||||
EpiphanyCultMeshDaemonStatusEntry {
|
||||
schema_version: EPIPHANY_CULTMESH_DAEMON_STATUS_SCHEMA_VERSION.to_string(),
|
||||
daemon_id: cluster.daemon_id,
|
||||
cluster_id: cluster.cluster_id,
|
||||
body_domain: cluster.body_domain,
|
||||
daemon_surface_id: cluster.daemon_surface_id,
|
||||
eve_surface_id: cluster.eve_surface_id,
|
||||
status: "unknown".to_string(),
|
||||
last_heartbeat_utc: "unknown".to_string(),
|
||||
status: written.status.clone(),
|
||||
last_heartbeat_utc: written.heartbeat_at.clone(),
|
||||
supported_actions: vec![
|
||||
"inspectStatus".to_string(),
|
||||
"pokeDaemon".to_string(),
|
||||
"watchHeartbeat".to_string(),
|
||||
],
|
||||
operator_action: "pokeDaemon".to_string(),
|
||||
operator_action: "none".to_string(),
|
||||
private_state_exposed: false,
|
||||
notes: vec![
|
||||
"Initial status constructed by the owning cluster daemon from persisted topology."
|
||||
"Display-only compatibility projection derived from the provider heartbeat event."
|
||||
.to_string(),
|
||||
format!("Source heartbeat id: {}", written.heartbeat_id),
|
||||
],
|
||||
});
|
||||
let mut next = current.clone();
|
||||
next.status = "ready".to_string();
|
||||
next.last_heartbeat_utc = Utc::now().to_rfc3339();
|
||||
next.operator_action = if next.status == "ready" {
|
||||
"none".to_string()
|
||||
} else {
|
||||
"pokeDaemon".to_string()
|
||||
};
|
||||
next.private_state_exposed = false;
|
||||
next.notes = vec![
|
||||
"Heartbeat published by epiphany-cluster-daemon; local Verse status is liveness projection, not private daemon memory.".to_string(),
|
||||
format!("Daemon body domain: {}", current.body_domain),
|
||||
format!("Heartbeat iteration: {iteration}"),
|
||||
];
|
||||
write_epiphany_cultmesh_daemon_status(&args.store, args.runtime_id.clone(), next)
|
||||
},
|
||||
)?;
|
||||
Ok(written)
|
||||
}
|
||||
|
||||
fn new_heartbeat_event(
|
||||
args: &Args,
|
||||
daemon_id: &str,
|
||||
cluster_id: &str,
|
||||
iteration: u64,
|
||||
heartbeat_at: String,
|
||||
) -> EpiphanyCultMeshDaemonHeartbeatEventEntry {
|
||||
EpiphanyCultMeshDaemonHeartbeatEventEntry {
|
||||
schema_version: EPIPHANY_CULTMESH_DAEMON_HEARTBEAT_EVENT_SCHEMA_VERSION.to_string(),
|
||||
heartbeat_id: Uuid::new_v4().to_string(),
|
||||
daemon_id: daemon_id.to_string(),
|
||||
cluster_id: cluster_id.to_string(),
|
||||
provider_incarnation: args.provider_incarnation.clone(),
|
||||
sequence: iteration.saturating_add(1),
|
||||
status: "ready".to_string(),
|
||||
heartbeat_at,
|
||||
private_state_exposed: false,
|
||||
startup_lifecycle_receipt_id: args.startup_lifecycle_receipt_id.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
fn print_output(
|
||||
args: &Args,
|
||||
status: &str,
|
||||
written: Vec<EpiphanyCultMeshDaemonStatusEntry>,
|
||||
written: Vec<EpiphanyCultMeshDaemonHeartbeatEventEntry>,
|
||||
) -> Result<()> {
|
||||
let latest = written
|
||||
.last()
|
||||
|
|
@ -115,7 +145,10 @@ fn print_output(
|
|||
"daemonId": latest.daemon_id,
|
||||
"clusterId": latest.cluster_id,
|
||||
"daemonStatus": latest.status,
|
||||
"lastHeartbeatUtc": latest.last_heartbeat_utc,
|
||||
"heartbeatId": latest.heartbeat_id,
|
||||
"providerIncarnation": latest.provider_incarnation,
|
||||
"sequence": latest.sequence,
|
||||
"lastHeartbeatUtc": latest.heartbeat_at,
|
||||
"heartbeatCount": written.len(),
|
||||
"intervalSeconds": args.interval_seconds,
|
||||
"maxIterations": args.max_iterations,
|
||||
|
|
@ -132,6 +165,8 @@ struct Args {
|
|||
daemon_id: String,
|
||||
interval_seconds: u64,
|
||||
max_iterations: u64,
|
||||
provider_incarnation: String,
|
||||
startup_lifecycle_receipt_id: String,
|
||||
}
|
||||
|
||||
impl Args {
|
||||
|
|
@ -143,6 +178,9 @@ impl Args {
|
|||
let mut daemon_id = None;
|
||||
let mut interval_seconds = 60_u64;
|
||||
let mut max_iterations = 1_u64;
|
||||
let mut provider_incarnation = None;
|
||||
let mut startup_lifecycle_receipt_id =
|
||||
env::var("EPIPHANY_STARTUP_LIFECYCLE_RECEIPT_ID").unwrap_or_default();
|
||||
|
||||
while let Some(arg) = values.next() {
|
||||
match arg.as_str() {
|
||||
|
|
@ -165,6 +203,18 @@ impl Args {
|
|||
.context("missing --max-iterations value")?
|
||||
.parse()?;
|
||||
}
|
||||
"--provider-incarnation" => {
|
||||
provider_incarnation = Some(
|
||||
values
|
||||
.next()
|
||||
.context("missing --provider-incarnation value")?,
|
||||
)
|
||||
}
|
||||
"--startup-lifecycle-receipt-id" => {
|
||||
startup_lifecycle_receipt_id = values
|
||||
.next()
|
||||
.context("missing --startup-lifecycle-receipt-id value")?
|
||||
}
|
||||
other => anyhow::bail!("unknown argument {other:?}"),
|
||||
}
|
||||
}
|
||||
|
|
@ -177,6 +227,47 @@ impl Args {
|
|||
daemon_id,
|
||||
interval_seconds,
|
||||
max_iterations,
|
||||
provider_incarnation: provider_incarnation
|
||||
.unwrap_or_else(|| Uuid::new_v4().to_string()),
|
||||
startup_lifecycle_receipt_id,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn process_heartbeat_events_keep_one_incarnation_and_increment_sequence() {
|
||||
let args = Args {
|
||||
command: "serve".to_string(),
|
||||
store: PathBuf::from("unused.ccmp"),
|
||||
runtime_id: "runtime-test".to_string(),
|
||||
daemon_id: "daemon-test".to_string(),
|
||||
interval_seconds: 1,
|
||||
max_iterations: 2,
|
||||
provider_incarnation: "incarnation-test".to_string(),
|
||||
startup_lifecycle_receipt_id: "receipt-test".to_string(),
|
||||
};
|
||||
let first = new_heartbeat_event(
|
||||
&args,
|
||||
"daemon-test",
|
||||
"cluster-test",
|
||||
0,
|
||||
"2026-07-15T12:00:00Z".to_string(),
|
||||
);
|
||||
let second = new_heartbeat_event(
|
||||
&args,
|
||||
"daemon-test",
|
||||
"cluster-test",
|
||||
1,
|
||||
"2026-07-15T12:00:01Z".to_string(),
|
||||
);
|
||||
assert_eq!(first.provider_incarnation, second.provider_incarnation);
|
||||
assert_eq!(first.sequence, 1);
|
||||
assert_eq!(second.sequence, 2);
|
||||
assert_ne!(first.heartbeat_id, second.heartbeat_id);
|
||||
assert_eq!(first.startup_lifecycle_receipt_id, "receipt-test");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,10 +16,14 @@ use epiphany_core::EpiphanyCultMeshSwarmBrakeEntry;
|
|||
use epiphany_core::EpiphanyLocalVerseContext;
|
||||
use epiphany_core::EpiphanyProcessObservation as ProcessObservation;
|
||||
use epiphany_core::EpiphanyServiceExecutionAuditReport;
|
||||
use epiphany_core::MemorySemanticProjectionInput;
|
||||
use epiphany_core::agent_memory_semantic_projection_input;
|
||||
use epiphany_core::epiphany_cluster_service_execution_audit_report;
|
||||
use epiphany_core::epiphany_cultmesh_daemon_poke_intent_from_status;
|
||||
use epiphany_core::epiphany_cultmesh_daemon_poke_receipt_for_intent;
|
||||
use epiphany_core::epiphany_service_execution_audit_report;
|
||||
use epiphany_core::idunn_acquire_memory_semantic_projection_for_local_supervisor;
|
||||
use epiphany_core::idunn_recover_memory_semantic_projection_from_cultmesh;
|
||||
use epiphany_core::load_epiphany_cultmesh_cluster_topology;
|
||||
use epiphany_core::load_epiphany_cultmesh_daemon_restart_policy;
|
||||
use epiphany_core::load_epiphany_cultmesh_daemon_service_lifecycle_receipts;
|
||||
|
|
@ -29,6 +33,7 @@ use epiphany_core::load_epiphany_cultmesh_status;
|
|||
use epiphany_core::load_epiphany_cultmesh_swarm_brake;
|
||||
use epiphany_core::observe_native_process as observe_process;
|
||||
use epiphany_core::query_epiphany_local_verse_context;
|
||||
use epiphany_core::runtime_modeling_semantic_projection_input;
|
||||
use epiphany_core::seed_epiphany_local_verse_context;
|
||||
use epiphany_core::write_epiphany_cultmesh_daemon_poke_intent;
|
||||
use epiphany_core::write_epiphany_cultmesh_daemon_poke_receipt;
|
||||
|
|
@ -130,12 +135,82 @@ fn main() -> Result<()> {
|
|||
"windows-service-start" | "service-start" => windows_service_control(args, "start"),
|
||||
"windows-service-stop" | "service-stop" => windows_service_control(args, "stop"),
|
||||
"policy" | "write-policy" => write_policy(args),
|
||||
"semantic-acquire" => semantic_acquire(args),
|
||||
"semantic-recover" => semantic_recover(args),
|
||||
other => anyhow::bail!(
|
||||
"unknown command {other:?}; use reconcile, tick, serve, service-plan, service-launch, service-runbook, repo-work-service-audit, cluster-service-runbook, cluster-service-install-plan, cluster-service-audit, cluster-service-start, cluster-service-stop, cluster-service-execution-readiness, cluster-service-execution-runbook, cluster-service-execution-audit, windows-service-install, windows-service-execution-readiness, windows-service-execution-runbook, windows-service-execution-audit, service-execution-audit-smoke, windows-service-reconcile, windows-service-status, windows-service-start, windows-service-stop, or policy"
|
||||
"unknown command {other:?}; use reconcile, tick, serve, service-plan, service-launch, service-runbook, repo-work-service-audit, cluster-service-runbook, cluster-service-install-plan, cluster-service-audit, cluster-service-start, cluster-service-stop, cluster-service-execution-readiness, cluster-service-execution-runbook, cluster-service-execution-audit, windows-service-install, windows-service-execution-readiness, windows-service-execution-runbook, windows-service-execution-audit, service-execution-audit-smoke, windows-service-reconcile, windows-service-status, windows-service-start, windows-service-stop, policy, semantic-acquire, or semantic-recover"
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
fn semantic_projection_input(args: &Args) -> Result<(MemorySemanticProjectionInput, &Path)> {
|
||||
match (&args.agent_store, &args.runtime_store) {
|
||||
(Some(path), None) => Ok((agent_memory_semantic_projection_input(path)?, path)),
|
||||
(None, Some(path)) => Ok((runtime_modeling_semantic_projection_input(path)?, path)),
|
||||
_ => anyhow::bail!(
|
||||
"semantic projector commands require exactly one of --agent-store or --runtime-store"
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
fn required<'a>(value: &'a Option<String>, flag: &str) -> Result<&'a str> {
|
||||
value.as_deref().with_context(|| format!("missing {flag}"))
|
||||
}
|
||||
|
||||
fn semantic_acquire(args: Args) -> Result<()> {
|
||||
let (input, store) = semantic_projection_input(&args)?;
|
||||
let purpose = required(&args.semantic_purpose, "--purpose")?;
|
||||
if !matches!(purpose, "execute" | "repair") {
|
||||
anyhow::bail!("--purpose must be execute or repair");
|
||||
}
|
||||
let acquisition = idunn_acquire_memory_semantic_projection_for_local_supervisor(
|
||||
store,
|
||||
&input,
|
||||
required(&args.executor_id, "--executor-id")?,
|
||||
purpose,
|
||||
&Utc::now().to_rfc3339(),
|
||||
)?;
|
||||
println!(
|
||||
"{}",
|
||||
serde_json::to_string_pretty(&json!({
|
||||
"grantId": acquisition.grant.grant_id,
|
||||
"claimId": acquisition.claim.claim_id,
|
||||
"epoch": acquisition.claim.epoch,
|
||||
"executorId": acquisition.claim.executor_id,
|
||||
"purpose": purpose,
|
||||
"privateStateExposed": false
|
||||
}))?
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn semantic_recover(args: Args) -> Result<()> {
|
||||
let (input, store) = semantic_projection_input(&args)?;
|
||||
let (authorization, claim) = idunn_recover_memory_semantic_projection_from_cultmesh(
|
||||
&args.store,
|
||||
args.runtime_id.clone(),
|
||||
store,
|
||||
&input,
|
||||
required(&args.expected_claim_id, "--expected-claim-id")?,
|
||||
required(&args.executor_id, "--executor-id")?,
|
||||
required(&args.receipt_id, "--receipt-id")?,
|
||||
required(&args.provider_heartbeat_id, "--provider-heartbeat-id")?,
|
||||
&Utc::now().to_rfc3339(),
|
||||
)?;
|
||||
println!(
|
||||
"{}",
|
||||
serde_json::to_string_pretty(&json!({
|
||||
"authorizationId": authorization.authorization_id,
|
||||
"claimId": claim.claim_id,
|
||||
"epoch": claim.epoch,
|
||||
"executorId": claim.executor_id,
|
||||
"executorIncarnation": claim.executor_incarnation,
|
||||
"privateStateExposed": false
|
||||
}))?
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn require_supervisor_bootstrap(args: &Args) -> Result<()> {
|
||||
load_epiphany_cultmesh_status(&args.store, args.runtime_id.clone())?
|
||||
.with_context(|| {
|
||||
|
|
@ -2667,7 +2742,7 @@ fn reconcile_daemon_status(
|
|||
)?;
|
||||
|
||||
let attempted_at = Utc::now();
|
||||
let restart_output = run_restart_command(policy)?;
|
||||
let restart_output = run_restart_command(policy, &receipt_id)?;
|
||||
let completed_at = Utc::now();
|
||||
let resulting_status = restart_lifecycle_observation(&restart_output).to_string();
|
||||
let receipt_status = if restart_output.success {
|
||||
|
|
@ -3344,9 +3419,16 @@ fn service_lifecycle_receipt(
|
|||
}
|
||||
}
|
||||
|
||||
fn run_restart_command(policy: &EpiphanyCultMeshDaemonRestartPolicyEntry) -> Result<RestartOutput> {
|
||||
fn run_restart_command(
|
||||
policy: &EpiphanyCultMeshDaemonRestartPolicyEntry,
|
||||
lifecycle_receipt_id: &str,
|
||||
) -> Result<RestartOutput> {
|
||||
let mut command = Command::new(&policy.restart_command);
|
||||
command.args(&policy.restart_args);
|
||||
command.env(
|
||||
"EPIPHANY_STARTUP_LIFECYCLE_RECEIPT_ID",
|
||||
lifecycle_receipt_id,
|
||||
);
|
||||
if let Some(cwd) = &policy.cwd {
|
||||
command.current_dir(cwd);
|
||||
}
|
||||
|
|
@ -3499,6 +3581,38 @@ mod provider_status_ownership_tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod semantic_projector_authority_tests {
|
||||
#[test]
|
||||
fn supervisor_owns_idunn_incarnations_and_exact_evidence_selection() {
|
||||
let source = include_str!("epiphany-daemon-supervisor.rs");
|
||||
let issuer_flag = ["--issuer", "-incarnation"].concat();
|
||||
let executor_flag = ["--executor", "-incarnation"].concat();
|
||||
assert!(!source.contains(&issuer_flag));
|
||||
assert!(!source.contains(&executor_flag));
|
||||
let evidence_id_flag = ["--lifecycle", "-evidence-id"].concat();
|
||||
let evidence_hash_flag = ["--lifecycle", "-evidence-hash"].concat();
|
||||
assert!(!source.contains(&evidence_id_flag));
|
||||
assert!(!source.contains(&evidence_hash_flag));
|
||||
assert!(source.contains("--receipt-id"));
|
||||
assert!(source.contains("--provider-heartbeat-id"));
|
||||
assert!(source.contains("idunn_acquire_memory_semantic_projection_for_local_supervisor"));
|
||||
assert!(source.contains("idunn_recover_memory_semantic_projection_from_cultmesh"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recovery_command_only_rotates_claim_authority() {
|
||||
let source = include_str!("epiphany-daemon-supervisor.rs");
|
||||
let start = source.find("fn semantic_recover(args: Args)").unwrap();
|
||||
let tail = &source[start..];
|
||||
let end = tail.find("\nfn ").unwrap_or(tail.len());
|
||||
let body = &tail[..end];
|
||||
assert!(body.contains("idunn_recover_memory_semantic_projection_from_cultmesh"));
|
||||
assert!(!body.contains("execute_memory_semantic_projection"));
|
||||
assert!(!body.contains("MemorySemanticIndexConfig"));
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Args {
|
||||
command: String,
|
||||
|
|
@ -3538,6 +3652,12 @@ struct Args {
|
|||
artifact_ref: Option<String>,
|
||||
stdout_artifact: Option<PathBuf>,
|
||||
stderr_artifact: Option<PathBuf>,
|
||||
agent_store: Option<PathBuf>,
|
||||
runtime_store: Option<PathBuf>,
|
||||
executor_id: Option<String>,
|
||||
semantic_purpose: Option<String>,
|
||||
expected_claim_id: Option<String>,
|
||||
provider_heartbeat_id: Option<String>,
|
||||
}
|
||||
|
||||
impl Args {
|
||||
|
|
@ -3581,6 +3701,12 @@ impl Args {
|
|||
let mut artifact_ref = None;
|
||||
let mut stdout_artifact = None;
|
||||
let mut stderr_artifact = None;
|
||||
let mut agent_store = None;
|
||||
let mut runtime_store = None;
|
||||
let mut executor_id = None;
|
||||
let mut semantic_purpose = None;
|
||||
let mut expected_claim_id = None;
|
||||
let mut provider_heartbeat_id = None;
|
||||
|
||||
while let Some(arg) = values.next() {
|
||||
match arg.as_str() {
|
||||
|
|
@ -3723,6 +3849,33 @@ impl Args {
|
|||
values.next().context("missing --stderr-artifact value")?,
|
||||
));
|
||||
}
|
||||
"--agent-store" => {
|
||||
agent_store = Some(PathBuf::from(
|
||||
values.next().context("missing --agent-store value")?,
|
||||
))
|
||||
}
|
||||
"--runtime-store" => {
|
||||
runtime_store = Some(PathBuf::from(
|
||||
values.next().context("missing --runtime-store value")?,
|
||||
))
|
||||
}
|
||||
"--executor-id" => {
|
||||
executor_id = Some(values.next().context("missing --executor-id value")?)
|
||||
}
|
||||
"--purpose" => {
|
||||
semantic_purpose = Some(values.next().context("missing --purpose value")?)
|
||||
}
|
||||
"--expected-claim-id" => {
|
||||
expected_claim_id =
|
||||
Some(values.next().context("missing --expected-claim-id value")?)
|
||||
}
|
||||
"--provider-heartbeat-id" => {
|
||||
provider_heartbeat_id = Some(
|
||||
values
|
||||
.next()
|
||||
.context("missing --provider-heartbeat-id value")?,
|
||||
)
|
||||
}
|
||||
other => anyhow::bail!("unknown argument {other:?}"),
|
||||
}
|
||||
}
|
||||
|
|
@ -3804,6 +3957,8 @@ impl Args {
|
|||
| "service-start"
|
||||
| "windows-service-stop"
|
||||
| "service-stop"
|
||||
| "semantic-acquire"
|
||||
| "semantic-recover"
|
||||
) =>
|
||||
{
|
||||
"*".to_string()
|
||||
|
|
@ -3858,6 +4013,12 @@ impl Args {
|
|||
artifact_ref,
|
||||
stdout_artifact,
|
||||
stderr_artifact,
|
||||
agent_store,
|
||||
runtime_store,
|
||||
executor_id,
|
||||
semantic_purpose,
|
||||
expected_claim_id,
|
||||
provider_heartbeat_id,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@ fn main() -> Result<()> {
|
|||
match command.as_str() {
|
||||
"index" => {
|
||||
let (input, source_store) = options.load_projection_input()?;
|
||||
let executor_id = options
|
||||
.executor_id
|
||||
let claim_id = options
|
||||
.claim_id
|
||||
.as_deref()
|
||||
.ok_or_else(|| usage_error("index requires --executor-id <id>"))?;
|
||||
.ok_or_else(|| usage_error("index requires --claim-id <id>"))?;
|
||||
let receipt =
|
||||
execute_memory_semantic_projection(source_store, &input, executor_id, &config)?;
|
||||
execute_memory_semantic_projection(source_store, &input, claim_id, &config)?;
|
||||
print_receipt(&receipt, source_store)?;
|
||||
}
|
||||
"health" => {
|
||||
|
|
@ -82,7 +82,7 @@ struct Options {
|
|||
graph_store: Option<PathBuf>,
|
||||
runtime_store: Option<PathBuf>,
|
||||
agent_store: Option<PathBuf>,
|
||||
executor_id: Option<String>,
|
||||
claim_id: Option<String>,
|
||||
local_verse_store: Option<PathBuf>,
|
||||
runtime_id: String,
|
||||
provider_incarnation: Option<String>,
|
||||
|
|
@ -100,7 +100,7 @@ impl Options {
|
|||
graph_store: None,
|
||||
runtime_store: None,
|
||||
agent_store: None,
|
||||
executor_id: None,
|
||||
claim_id: None,
|
||||
local_verse_store: None,
|
||||
runtime_id: "epiphany-memory-semantic".to_string(),
|
||||
provider_incarnation: None,
|
||||
|
|
@ -121,7 +121,7 @@ impl Options {
|
|||
"--graph-store" => options.graph_store = Some(PathBuf::from(value()?)),
|
||||
"--runtime-store" => options.runtime_store = Some(PathBuf::from(value()?)),
|
||||
"--agent-store" => options.agent_store = Some(PathBuf::from(value()?)),
|
||||
"--executor-id" => options.executor_id = Some(value()?),
|
||||
"--claim-id" => options.claim_id = Some(value()?),
|
||||
"--local-verse-store" => options.local_verse_store = Some(PathBuf::from(value()?)),
|
||||
"--runtime-id" => options.runtime_id = value()?,
|
||||
"--provider-incarnation" => options.provider_incarnation = Some(value()?),
|
||||
|
|
@ -235,7 +235,7 @@ fn parse_profile(value: &str) -> Result<epiphany_core::EpiphanyMemoryProfile> {
|
|||
|
||||
fn usage_error(message: &str) -> anyhow::Error {
|
||||
anyhow!(
|
||||
"{message}\nusage: epiphany-memory-semantic <index|context|health> (--runtime-store <path>|--agent-store <path>|--graph-store <path>) [--swarm-id <id>] --partition <mind|modeling> [--executor-id <id>] [--local-verse-store <path> --runtime-id <id> --provider-incarnation <id>] [--text <query>] [--query-id <id>] [--budget <n>] [--profile <profile>]"
|
||||
"{message}\nusage: epiphany-memory-semantic <index|context|health> (--runtime-store <path>|--agent-store <path>|--graph-store <path>) [--swarm-id <id>] --partition <mind|modeling> [--claim-id <id>] [--local-verse-store <path> --runtime-id <id> --provider-incarnation <id>] [--text <query>] [--query-id <id>] [--budget <n>] [--profile <profile>]"
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,10 @@ use cultmesh_rs::CultMeshNodeOptions;
|
|||
use cultmesh_rs::cultmesh_documents;
|
||||
use serde::Serialize;
|
||||
use serde_json::Value;
|
||||
use sha2::Digest;
|
||||
use sha2::Sha256;
|
||||
use std::path::Path;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub const EPIPHANY_CULTMESH_STATUS_TYPE: &str = "epiphany.cultmesh.status";
|
||||
pub const EPIPHANY_CULTMESH_STATUS_SCHEMA_VERSION: &str = "epiphany.cultmesh.status.v0";
|
||||
|
|
@ -124,6 +127,10 @@ pub const EPIPHANY_CULTMESH_EVE_SURFACE_STATE_SCHEMA_VERSION: &str =
|
|||
pub const EPIPHANY_CULTMESH_DAEMON_STATUS_TYPE: &str = "epiphany.cultmesh.daemon_status";
|
||||
pub const EPIPHANY_CULTMESH_DAEMON_STATUS_SCHEMA_VERSION: &str =
|
||||
"epiphany.cultmesh.daemon_status.v0";
|
||||
pub const EPIPHANY_CULTMESH_DAEMON_HEARTBEAT_EVENT_TYPE: &str =
|
||||
"epiphany.cultmesh.daemon_heartbeat_event";
|
||||
pub const EPIPHANY_CULTMESH_DAEMON_HEARTBEAT_EVENT_SCHEMA_VERSION: &str =
|
||||
"epiphany.cultmesh.daemon_heartbeat_event.v1";
|
||||
pub const EPIPHANY_CULTMESH_DAEMON_POKE_INTENT_TYPE: &str = "epiphany.cultmesh.daemon_poke_intent";
|
||||
pub const EPIPHANY_CULTMESH_DAEMON_POKE_INTENT_SCHEMA_VERSION: &str =
|
||||
"epiphany.cultmesh.daemon_poke_intent.v1";
|
||||
|
|
@ -1218,6 +1225,34 @@ pub struct EpiphanyCultMeshDaemonStatusEntry {
|
|||
pub notes: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.cultmesh.daemon_heartbeat_event",
|
||||
schema = "EpiphanyCultMeshDaemonHeartbeatEventEntry"
|
||||
)]
|
||||
pub struct EpiphanyCultMeshDaemonHeartbeatEventEntry {
|
||||
#[cultcache(key = 0)]
|
||||
pub schema_version: String,
|
||||
#[cultcache(key = 1)]
|
||||
pub heartbeat_id: String,
|
||||
#[cultcache(key = 2)]
|
||||
pub daemon_id: String,
|
||||
#[cultcache(key = 3)]
|
||||
pub cluster_id: String,
|
||||
#[cultcache(key = 4)]
|
||||
pub provider_incarnation: String,
|
||||
#[cultcache(key = 5)]
|
||||
pub sequence: u64,
|
||||
#[cultcache(key = 6)]
|
||||
pub status: String,
|
||||
#[cultcache(key = 7)]
|
||||
pub heartbeat_at: String,
|
||||
#[cultcache(key = 8)]
|
||||
pub private_state_exposed: bool,
|
||||
#[cultcache(key = 9, default)]
|
||||
pub startup_lifecycle_receipt_id: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.cultmesh.daemon_poke_intent",
|
||||
|
|
@ -2584,6 +2619,7 @@ cultmesh_documents!(EpiphanyCultMeshDocuments {
|
|||
EpiphanyCultMeshEveConnectionReceiptEntry => EPIPHANY_CULTMESH_EVE_CONNECTION_RECEIPT_SCHEMA_VERSION,
|
||||
EpiphanyCultMeshEveSurfaceStateEntry => EPIPHANY_CULTMESH_EVE_SURFACE_STATE_SCHEMA_VERSION,
|
||||
EpiphanyCultMeshDaemonStatusEntry => EPIPHANY_CULTMESH_DAEMON_STATUS_SCHEMA_VERSION,
|
||||
EpiphanyCultMeshDaemonHeartbeatEventEntry => EPIPHANY_CULTMESH_DAEMON_HEARTBEAT_EVENT_SCHEMA_VERSION,
|
||||
EpiphanyCultMeshDaemonPokeIntentEntry => EPIPHANY_CULTMESH_DAEMON_POKE_INTENT_SCHEMA_VERSION,
|
||||
EpiphanyCultMeshDaemonPokeReceiptEntry => EPIPHANY_CULTMESH_DAEMON_POKE_RECEIPT_SCHEMA_VERSION,
|
||||
EpiphanyCultMeshDaemonRestartPolicyEntry => EPIPHANY_CULTMESH_DAEMON_RESTART_POLICY_SCHEMA_VERSION,
|
||||
|
|
@ -3950,6 +3986,18 @@ pub fn load_latest_epiphany_cultmesh_daemon_poke_intent(
|
|||
node.get(EPIPHANY_CULTMESH_DAEMON_POKE_INTENT_LATEST_KEY)
|
||||
}
|
||||
|
||||
pub fn load_epiphany_cultmesh_daemon_poke_intent(
|
||||
store_path: impl AsRef<Path>,
|
||||
runtime_id: impl Into<String>,
|
||||
intent_id: &str,
|
||||
) -> Result<Option<EpiphanyCultMeshDaemonPokeIntentEntry>> {
|
||||
if intent_id.trim().is_empty() {
|
||||
return Err(anyhow!("daemon poke intent identity is required"));
|
||||
}
|
||||
let node = open_epiphany_cultmesh_node(store_path, runtime_id)?;
|
||||
node.get(&epiphany_cultmesh_daemon_poke_intent_key(intent_id))
|
||||
}
|
||||
|
||||
pub fn load_latest_epiphany_cultmesh_daemon_poke_receipt(
|
||||
store_path: impl AsRef<Path>,
|
||||
runtime_id: impl Into<String>,
|
||||
|
|
@ -3958,6 +4006,18 @@ pub fn load_latest_epiphany_cultmesh_daemon_poke_receipt(
|
|||
node.get(EPIPHANY_CULTMESH_DAEMON_POKE_RECEIPT_LATEST_KEY)
|
||||
}
|
||||
|
||||
pub fn load_epiphany_cultmesh_daemon_poke_receipt(
|
||||
store_path: impl AsRef<Path>,
|
||||
runtime_id: impl Into<String>,
|
||||
receipt_id: &str,
|
||||
) -> Result<Option<EpiphanyCultMeshDaemonPokeReceiptEntry>> {
|
||||
if receipt_id.trim().is_empty() {
|
||||
return Err(anyhow!("daemon poke receipt identity is required"));
|
||||
}
|
||||
let node = open_epiphany_cultmesh_node(store_path, runtime_id)?;
|
||||
node.get(&epiphany_cultmesh_daemon_poke_receipt_key(receipt_id))
|
||||
}
|
||||
|
||||
pub fn write_epiphany_cultmesh_daemon_restart_policy(
|
||||
store_path: impl AsRef<Path>,
|
||||
runtime_id: impl Into<String>,
|
||||
|
|
@ -7000,6 +7060,288 @@ pub fn write_epiphany_cultmesh_daemon_status(
|
|||
Ok(written)
|
||||
}
|
||||
|
||||
fn epiphany_cultmesh_daemon_heartbeat_event_key(heartbeat_id: &str) -> String {
|
||||
format!("epiphany-local/daemon-heartbeat/event/{heartbeat_id}")
|
||||
}
|
||||
|
||||
fn epiphany_cultmesh_daemon_heartbeat_latest_key(daemon_id: &str) -> String {
|
||||
format!("epiphany-local/daemon-heartbeat/{daemon_id}/latest")
|
||||
}
|
||||
|
||||
pub fn write_epiphany_cultmesh_daemon_heartbeat_event(
|
||||
store_path: impl AsRef<Path>,
|
||||
runtime_id: impl Into<String>,
|
||||
event: EpiphanyCultMeshDaemonHeartbeatEventEntry,
|
||||
) -> Result<EpiphanyCultMeshDaemonHeartbeatEventEntry> {
|
||||
validate_daemon_heartbeat_event(&event)?;
|
||||
let store_path = store_path.as_ref();
|
||||
let runtime_id = runtime_id.into();
|
||||
let event_key = epiphany_cultmesh_daemon_heartbeat_event_key(&event.heartbeat_id);
|
||||
let latest_key = epiphany_cultmesh_daemon_heartbeat_latest_key(&event.daemon_id);
|
||||
let backing = SingleFileMessagePackBackingStore::new(store_path);
|
||||
|
||||
for _ in 0..8 {
|
||||
let node = open_epiphany_cultmesh_node(store_path, runtime_id.clone())?;
|
||||
if let Some(existing) = node.get::<EpiphanyCultMeshDaemonHeartbeatEventEntry>(&event_key)? {
|
||||
return if existing == event {
|
||||
Ok(existing)
|
||||
} else {
|
||||
Err(anyhow!(
|
||||
"immutable daemon heartbeat identity collision for {:?}",
|
||||
event.heartbeat_id
|
||||
))
|
||||
};
|
||||
}
|
||||
let latest = node.get::<EpiphanyCultMeshDaemonHeartbeatEventEntry>(&latest_key)?;
|
||||
let advances_latest = match latest.as_ref() {
|
||||
Some(current) => daemon_heartbeat_advances(current, &event)?,
|
||||
None => true,
|
||||
};
|
||||
let event_envelope = node.cache().prepare_entry(&event_key, &event)?.0;
|
||||
let mut replacements = vec![event_envelope];
|
||||
let mut expected = Vec::new();
|
||||
if advances_latest {
|
||||
if let Some(envelope) = node
|
||||
.cache()
|
||||
.get_envelope::<EpiphanyCultMeshDaemonHeartbeatEventEntry>(&latest_key)?
|
||||
{
|
||||
expected.push(envelope);
|
||||
}
|
||||
replacements.push(node.cache().prepare_entry(&latest_key, &event)?.0);
|
||||
}
|
||||
if backing.compare_and_swap_batch(&expected, replacements)? {
|
||||
return Ok(event);
|
||||
}
|
||||
}
|
||||
Err(anyhow!(
|
||||
"daemon heartbeat latest advanced during publication"
|
||||
))
|
||||
}
|
||||
|
||||
pub fn load_epiphany_cultmesh_daemon_heartbeat_event(
|
||||
store_path: impl AsRef<Path>,
|
||||
runtime_id: impl Into<String>,
|
||||
heartbeat_id: &str,
|
||||
) -> Result<Option<EpiphanyCultMeshDaemonHeartbeatEventEntry>> {
|
||||
validate_heartbeat_identifier("heartbeat", heartbeat_id)?;
|
||||
open_epiphany_cultmesh_node(store_path, runtime_id)?
|
||||
.get(&epiphany_cultmesh_daemon_heartbeat_event_key(heartbeat_id))
|
||||
}
|
||||
|
||||
pub fn load_latest_epiphany_cultmesh_daemon_heartbeat(
|
||||
store_path: impl AsRef<Path>,
|
||||
runtime_id: impl Into<String>,
|
||||
daemon_id: &str,
|
||||
) -> Result<Option<EpiphanyCultMeshDaemonHeartbeatEventEntry>> {
|
||||
validate_heartbeat_identifier("daemon", daemon_id)?;
|
||||
open_epiphany_cultmesh_node(store_path, runtime_id)?
|
||||
.get(&epiphany_cultmesh_daemon_heartbeat_latest_key(daemon_id))
|
||||
}
|
||||
|
||||
pub fn idunn_acquire_memory_semantic_projection_for_local_supervisor(
|
||||
canonical_store: impl AsRef<Path>,
|
||||
input: &crate::MemorySemanticProjectionInput,
|
||||
executor_id: &str,
|
||||
purpose: &str,
|
||||
acquired_at: &str,
|
||||
) -> Result<crate::MemorySemanticProjectorAcquisition> {
|
||||
crate::memory_graph::semantic_projector::idunn_acquire_memory_semantic_projection(
|
||||
canonical_store,
|
||||
input,
|
||||
executor_id,
|
||||
&format!("executor-{}", Uuid::new_v4()),
|
||||
purpose,
|
||||
&format!("idunn-{}", Uuid::new_v4()),
|
||||
acquired_at,
|
||||
)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn idunn_recover_memory_semantic_projection_from_cultmesh(
|
||||
verse_store: impl AsRef<Path>,
|
||||
runtime_id: impl Into<String>,
|
||||
canonical_store: impl AsRef<Path>,
|
||||
input: &crate::MemorySemanticProjectionInput,
|
||||
expected_claim_id: &str,
|
||||
replacement_executor_id: &str,
|
||||
lifecycle_receipt_id: &str,
|
||||
provider_heartbeat_id: &str,
|
||||
recovered_at: &str,
|
||||
) -> Result<(
|
||||
crate::MemorySemanticProjectorRecoveryAuthorization,
|
||||
crate::MemorySemanticProjectionClaim,
|
||||
)> {
|
||||
let verse_store = verse_store.as_ref();
|
||||
let runtime_id = runtime_id.into();
|
||||
let canonical_store = canonical_store.as_ref();
|
||||
crate::observe_memory_semantic_projection(canonical_store, input)?;
|
||||
|
||||
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 heartbeat_key = epiphany_cultmesh_daemon_heartbeat_event_key(provider_heartbeat_id);
|
||||
let heartbeat = node
|
||||
.get::<EpiphanyCultMeshDaemonHeartbeatEventEntry>(&heartbeat_key)?
|
||||
.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.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 heartbeat_at = DateTime::parse_from_rfc3339(&heartbeat.heartbeat_at)?;
|
||||
if heartbeat_at <= receipt_completed {
|
||||
return Err(anyhow!(
|
||||
"Idunn recovery heartbeat must follow lifecycle completion"
|
||||
));
|
||||
}
|
||||
|
||||
let intent_digest =
|
||||
cultmesh_envelope_digest::<EpiphanyCultMeshDaemonPokeIntentEntry>(&node, &intent_key)?;
|
||||
let receipt_digest =
|
||||
cultmesh_envelope_digest::<EpiphanyCultMeshDaemonPokeReceiptEntry>(&node, &receipt_key)?;
|
||||
let heartbeat_digest = cultmesh_envelope_digest::<EpiphanyCultMeshDaemonHeartbeatEventEntry>(
|
||||
&node,
|
||||
&heartbeat_key,
|
||||
)?;
|
||||
let evidence =
|
||||
crate::memory_graph::semantic_projector::idunn_semantic_recovery_evidence_from_cultmesh(
|
||||
canonical_store,
|
||||
input,
|
||||
expected_claim_id,
|
||||
&format!("idunn-{}", Uuid::new_v4()),
|
||||
&intent.intent_id,
|
||||
&intent_digest,
|
||||
&receipt.receipt_id,
|
||||
&receipt_digest,
|
||||
&receipt.completed_at_utc,
|
||||
&heartbeat.heartbeat_id,
|
||||
&heartbeat_digest,
|
||||
&heartbeat.provider_incarnation,
|
||||
&heartbeat.heartbeat_at,
|
||||
&heartbeat.startup_lifecycle_receipt_id,
|
||||
)?;
|
||||
crate::memory_graph::semantic_projector::idunn_recover_memory_semantic_projection(
|
||||
canonical_store,
|
||||
input,
|
||||
expected_claim_id,
|
||||
replacement_executor_id,
|
||||
&heartbeat.provider_incarnation,
|
||||
&evidence,
|
||||
recovered_at,
|
||||
)
|
||||
}
|
||||
|
||||
fn cultmesh_envelope_digest<T: DatabaseEntry>(node: &CultMeshNode, key: &str) -> Result<String> {
|
||||
let envelope = node
|
||||
.cache()
|
||||
.get_envelope::<T>(key)?
|
||||
.ok_or_else(|| anyhow!("authenticated CultMesh evidence envelope disappeared"))?;
|
||||
let mut digest = Sha256::new();
|
||||
digest.update(envelope.r#type.as_bytes());
|
||||
digest.update([0]);
|
||||
digest.update(envelope.key.as_bytes());
|
||||
digest.update([0]);
|
||||
digest.update(&envelope.payload);
|
||||
Ok(format!("sha256-{:x}", digest.finalize()))
|
||||
}
|
||||
|
||||
fn daemon_heartbeat_advances(
|
||||
current: &EpiphanyCultMeshDaemonHeartbeatEventEntry,
|
||||
candidate: &EpiphanyCultMeshDaemonHeartbeatEventEntry,
|
||||
) -> Result<bool> {
|
||||
validate_daemon_heartbeat_event(current)?;
|
||||
let current_time = DateTime::parse_from_rfc3339(¤t.heartbeat_at)?;
|
||||
let candidate_time = DateTime::parse_from_rfc3339(&candidate.heartbeat_at)?;
|
||||
if current.provider_incarnation == candidate.provider_incarnation {
|
||||
if candidate.sequence > current.sequence && candidate_time < current_time {
|
||||
return Err(anyhow!(
|
||||
"daemon heartbeat time regressed within provider incarnation"
|
||||
));
|
||||
}
|
||||
if candidate.sequence <= current.sequence {
|
||||
return Ok(false);
|
||||
}
|
||||
}
|
||||
Ok(
|
||||
(candidate_time, candidate.sequence, &candidate.heartbeat_id)
|
||||
> (current_time, current.sequence, ¤t.heartbeat_id),
|
||||
)
|
||||
}
|
||||
|
||||
fn validate_daemon_heartbeat_event(
|
||||
event: &EpiphanyCultMeshDaemonHeartbeatEventEntry,
|
||||
) -> Result<()> {
|
||||
if event.schema_version != EPIPHANY_CULTMESH_DAEMON_HEARTBEAT_EVENT_SCHEMA_VERSION {
|
||||
return Err(anyhow!("unsupported daemon heartbeat schema"));
|
||||
}
|
||||
validate_heartbeat_identifier("heartbeat", &event.heartbeat_id)?;
|
||||
validate_heartbeat_identifier("daemon", &event.daemon_id)?;
|
||||
validate_heartbeat_identifier("cluster", &event.cluster_id)?;
|
||||
validate_heartbeat_identifier("provider incarnation", &event.provider_incarnation)?;
|
||||
if !event.startup_lifecycle_receipt_id.is_empty() {
|
||||
validate_heartbeat_identifier(
|
||||
"startup lifecycle receipt",
|
||||
&event.startup_lifecycle_receipt_id,
|
||||
)?;
|
||||
}
|
||||
if event.sequence == 0 {
|
||||
return Err(anyhow!("daemon heartbeat sequence must be positive"));
|
||||
}
|
||||
if !matches!(event.status.as_str(), "ready" | "degraded" | "stopping") {
|
||||
return Err(anyhow!("invalid daemon heartbeat status"));
|
||||
}
|
||||
DateTime::parse_from_rfc3339(&event.heartbeat_at)
|
||||
.context("daemon heartbeat requires RFC3339 heartbeat_at")?;
|
||||
if event.private_state_exposed {
|
||||
return Err(anyhow!("daemon heartbeat must not expose private state"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn validate_heartbeat_identifier(label: &str, value: &str) -> Result<()> {
|
||||
if value.is_empty()
|
||||
|| value.len() > 128
|
||||
|| !value
|
||||
.bytes()
|
||||
.all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'-' | b'_' | b'.'))
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"daemon heartbeat requires a bounded opaque {label} id"
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn validate_daemon_status(status: &EpiphanyCultMeshDaemonStatusEntry) -> Result<()> {
|
||||
if status.private_state_exposed {
|
||||
return Err(anyhow!("daemon statuses must not expose private state"));
|
||||
|
|
@ -7752,12 +8094,14 @@ mod tests {
|
|||
)?;
|
||||
assert_eq!(pending.status, "pending");
|
||||
|
||||
let claim = crate::memory_graph::semantic_projector::claim_memory_semantic_projection(
|
||||
let claim = idunn_acquire_memory_semantic_projection_for_local_supervisor(
|
||||
&canonical,
|
||||
input.obligation(),
|
||||
&input,
|
||||
"executor-a",
|
||||
"execute",
|
||||
"2026-07-15T12:01:00Z",
|
||||
)?;
|
||||
)?
|
||||
.claim;
|
||||
let raw_receipt = crate::MemorySemanticIndexReceipt {
|
||||
schema_version: crate::MEMORY_SEMANTIC_INDEX_RECEIPT_SCHEMA_VERSION.to_string(),
|
||||
receipt_id: "receipt-four-state".to_string(),
|
||||
|
|
@ -7800,18 +8144,14 @@ mod tests {
|
|||
assert_eq!(ready.status, "ready");
|
||||
assert!(ready.query_eligible_display_only);
|
||||
|
||||
let terminal_claim = crate::MemorySemanticProjectionClaim {
|
||||
status: "succeeded".to_string(),
|
||||
completed_at: Some("2026-07-15T12:02:01Z".to_string()),
|
||||
..claim.clone()
|
||||
};
|
||||
let repair = crate::memory_graph::semantic_projector::reopen_succeeded_projection_claim(
|
||||
let repair = idunn_acquire_memory_semantic_projection_for_local_supervisor(
|
||||
&canonical,
|
||||
&terminal_claim,
|
||||
input.obligation(),
|
||||
&input,
|
||||
"executor-b",
|
||||
"repair",
|
||||
"2026-07-15T12:03:00Z",
|
||||
)?;
|
||||
)?
|
||||
.claim;
|
||||
crate::memory_graph::semantic_projector::fail_memory_semantic_projection_claim(
|
||||
&canonical,
|
||||
&repair.claim_id,
|
||||
|
|
@ -10659,6 +10999,201 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn heartbeat_event(
|
||||
heartbeat_id: &str,
|
||||
incarnation: &str,
|
||||
sequence: u64,
|
||||
heartbeat_at: &str,
|
||||
) -> EpiphanyCultMeshDaemonHeartbeatEventEntry {
|
||||
EpiphanyCultMeshDaemonHeartbeatEventEntry {
|
||||
schema_version: EPIPHANY_CULTMESH_DAEMON_HEARTBEAT_EVENT_SCHEMA_VERSION.to_string(),
|
||||
heartbeat_id: heartbeat_id.to_string(),
|
||||
daemon_id: "daemon-test".to_string(),
|
||||
cluster_id: "cluster-test".to_string(),
|
||||
provider_incarnation: incarnation.to_string(),
|
||||
sequence,
|
||||
status: "ready".to_string(),
|
||||
heartbeat_at: heartbeat_at.to_string(),
|
||||
private_state_exposed: false,
|
||||
startup_lifecycle_receipt_id: String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn daemon_heartbeat_events_are_immutable_and_advance_latest_monotonically() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let store = temp.path().join("daemon-heartbeats.ccmp");
|
||||
let first = heartbeat_event("heartbeat-1", "incarnation-a", 1, "2026-07-15T12:00:00Z");
|
||||
write_epiphany_cultmesh_daemon_heartbeat_event(&store, "runtime-test", first.clone())?;
|
||||
assert_eq!(
|
||||
load_epiphany_cultmesh_daemon_heartbeat_event(&store, "runtime-test", "heartbeat-1")?,
|
||||
Some(first.clone())
|
||||
);
|
||||
|
||||
let delayed = heartbeat_event(
|
||||
"heartbeat-delayed",
|
||||
"incarnation-a",
|
||||
1,
|
||||
"2026-07-15T11:59:59Z",
|
||||
);
|
||||
write_epiphany_cultmesh_daemon_heartbeat_event(&store, "runtime-test", delayed)?;
|
||||
assert_eq!(
|
||||
load_latest_epiphany_cultmesh_daemon_heartbeat(&store, "runtime-test", "daemon-test")?,
|
||||
Some(first.clone())
|
||||
);
|
||||
|
||||
let restarted = heartbeat_event("heartbeat-2", "incarnation-b", 1, "2026-07-15T12:00:01Z");
|
||||
write_epiphany_cultmesh_daemon_heartbeat_event(&store, "runtime-test", restarted.clone())?;
|
||||
assert_eq!(
|
||||
load_latest_epiphany_cultmesh_daemon_heartbeat(&store, "runtime-test", "daemon-test")?,
|
||||
Some(restarted)
|
||||
);
|
||||
|
||||
let mut collision = first.clone();
|
||||
collision.status = "degraded".to_string();
|
||||
assert!(
|
||||
write_epiphany_cultmesh_daemon_heartbeat_event(&store, "runtime-test", collision)
|
||||
.expect_err("heartbeat identity is immutable")
|
||||
.to_string()
|
||||
.contains("identity collision")
|
||||
);
|
||||
let mut private = heartbeat_event(
|
||||
"heartbeat-private",
|
||||
"incarnation-b",
|
||||
2,
|
||||
"2026-07-15T12:00:02Z",
|
||||
);
|
||||
private.private_state_exposed = true;
|
||||
assert!(
|
||||
write_epiphany_cultmesh_daemon_heartbeat_event(&store, "runtime-test", private)
|
||||
.expect_err("private heartbeat must be refused")
|
||||
.to_string()
|
||||
.contains("must not expose private state")
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn semantic_recovery_requires_exact_correlated_restart_heartbeat_and_is_single_use()
|
||||
-> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let canonical = temp.path().join("canonical.msgpack");
|
||||
let verse = temp.path().join("verse.ccmp");
|
||||
let input = semantic_health_input(&canonical, "swarm-recovery", "mind", 1)?;
|
||||
let claim = idunn_acquire_memory_semantic_projection_for_local_supervisor(
|
||||
&canonical,
|
||||
&input,
|
||||
"executor-old",
|
||||
"execute",
|
||||
"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 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 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(),
|
||||
provider_incarnation: "provider-new".to_string(),
|
||||
sequence: 1,
|
||||
status: "ready".to_string(),
|
||||
heartbeat_at: "2026-07-15T12:03:00Z".to_string(),
|
||||
private_state_exposed: false,
|
||||
startup_lifecycle_receipt_id: String::new(),
|
||||
};
|
||||
write_epiphany_cultmesh_daemon_heartbeat_event(&verse, "runtime-test", unrelated)?;
|
||||
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",
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
|
||||
let correlated = EpiphanyCultMeshDaemonHeartbeatEventEntry {
|
||||
heartbeat_id: "semantic-heartbeat-correlated".to_string(),
|
||||
sequence: 2,
|
||||
startup_lifecycle_receipt_id: receipt.receipt_id.clone(),
|
||||
..heartbeat_event(
|
||||
"semantic-heartbeat-template",
|
||||
"provider-new",
|
||||
2,
|
||||
"2026-07-15T12:03:00Z",
|
||||
)
|
||||
};
|
||||
let mut correlated = correlated;
|
||||
correlated.daemon_id = status.daemon_id;
|
||||
correlated.cluster_id = status.cluster_id;
|
||||
write_epiphany_cultmesh_daemon_heartbeat_event(&verse, "runtime-test", correlated.clone())?;
|
||||
let (_, recovered) = idunn_recover_memory_semantic_projection_from_cultmesh(
|
||||
&verse,
|
||||
"runtime-test",
|
||||
&canonical,
|
||||
&input,
|
||||
&claim.claim_id,
|
||||
"executor-new",
|
||||
&receipt.receipt_id,
|
||||
&correlated.heartbeat_id,
|
||||
"2026-07-15T12:04:00Z",
|
||||
)?;
|
||||
assert_eq!(recovered.epoch, claim.epoch + 1);
|
||||
assert_eq!(recovered.executor_incarnation, "provider-new");
|
||||
assert!(
|
||||
idunn_recover_memory_semantic_projection_from_cultmesh(
|
||||
&verse,
|
||||
"runtime-test",
|
||||
&canonical,
|
||||
&input,
|
||||
&recovered.claim_id,
|
||||
"executor-third",
|
||||
&receipt.receipt_id,
|
||||
&correlated.heartbeat_id,
|
||||
"2026-07-15T12:05:00Z",
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bifrost_mirrors_name_arrival_order_without_rewriting_storage_keys() {
|
||||
let source = include_str!("cultmesh_integration.rs");
|
||||
|
|
|
|||
|
|
@ -224,6 +224,8 @@ pub use cultmesh_integration::EPIPHANY_CULTMESH_CONTINUITY_CONTRACT_TYPE;
|
|||
pub use cultmesh_integration::EPIPHANY_CULTMESH_COORDINATOR_RUN_RECEIPT_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_COORDINATOR_RUN_RECEIPT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_COORDINATOR_RUN_RECEIPT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_HEARTBEAT_EVENT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_HEARTBEAT_EVENT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_POKE_INTENT_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_POKE_INTENT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_POKE_INTENT_TYPE;
|
||||
|
|
@ -337,6 +339,7 @@ pub use cultmesh_integration::EpiphanyCultMeshBifrostPublicProofPublicationRecei
|
|||
pub use cultmesh_integration::EpiphanyCultMeshClusterTopologyEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshContinuityContractEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshCoordinatorRunReceiptEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshDaemonHeartbeatEventEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshDaemonPokeIntentEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshDaemonPokeReceiptEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshDaemonRestartPolicyEntry;
|
||||
|
|
@ -426,6 +429,8 @@ pub use cultmesh_integration::epiphany_cultmesh_substrate_gate_contracts;
|
|||
pub use cultmesh_integration::epiphany_cultmesh_verse_policies;
|
||||
pub use cultmesh_integration::epiphany_local_verse_work_loop_summary;
|
||||
pub use cultmesh_integration::epiphany_service_execution_audit_report;
|
||||
pub use cultmesh_integration::idunn_acquire_memory_semantic_projection_for_local_supervisor;
|
||||
pub use cultmesh_integration::idunn_recover_memory_semantic_projection_from_cultmesh;
|
||||
pub use cultmesh_integration::load_arrival_latest_epiphany_cultmesh_bifrost_artifact_acceptance_receipt;
|
||||
pub use cultmesh_integration::load_arrival_latest_epiphany_cultmesh_bifrost_body_change_publication_intent;
|
||||
pub use cultmesh_integration::load_arrival_latest_epiphany_cultmesh_bifrost_body_change_publication_receipt;
|
||||
|
|
@ -434,7 +439,10 @@ pub use cultmesh_integration::load_arrival_latest_epiphany_cultmesh_bifrost_gith
|
|||
pub use cultmesh_integration::load_arrival_latest_epiphany_cultmesh_bifrost_metrics_receipt;
|
||||
pub use cultmesh_integration::load_arrival_latest_epiphany_cultmesh_bifrost_public_proof_publication_receipt;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_cluster_topology;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_daemon_heartbeat_event;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_daemon_liveness;
|
||||
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_receipts;
|
||||
|
|
@ -456,6 +464,7 @@ pub use cultmesh_integration::load_epiphany_cultmesh_status;
|
|||
pub use cultmesh_integration::load_epiphany_cultmesh_swarm_brake;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_agent_state_soa_summary;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_coordinator_run_receipt;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_daemon_heartbeat;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_daemon_poke_intent;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_daemon_poke_receipt;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_daemon_scheduler_receipt;
|
||||
|
|
@ -500,6 +509,7 @@ pub use cultmesh_integration::write_epiphany_cultmesh_bifrost_metrics_receipt;
|
|||
pub use cultmesh_integration::write_epiphany_cultmesh_bifrost_public_proof_publication_receipt;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_continuity_contracts;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_coordinator_run_receipt;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_daemon_heartbeat_event;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_daemon_poke_intent;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_daemon_poke_receipt;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_daemon_restart_policy;
|
||||
|
|
@ -639,6 +649,8 @@ pub use memory_graph::MEMORY_SEMANTIC_INDEX_RECEIPT_SCHEMA_VERSION;
|
|||
pub use memory_graph::MEMORY_SEMANTIC_PROJECTION_ATTEMPT_SCHEMA_VERSION;
|
||||
pub use memory_graph::MEMORY_SEMANTIC_PROJECTION_CLAIM_SCHEMA_VERSION;
|
||||
pub use memory_graph::MEMORY_SEMANTIC_PROJECTION_OBLIGATION_SCHEMA_VERSION;
|
||||
pub use memory_graph::MEMORY_SEMANTIC_PROJECTOR_EXECUTOR_GRANT_SCHEMA_VERSION;
|
||||
pub use memory_graph::MEMORY_SEMANTIC_PROJECTOR_RECOVERY_AUTHORIZATION_SCHEMA_VERSION;
|
||||
pub use memory_graph::MemorySemanticIndexConfig;
|
||||
pub use memory_graph::MemorySemanticIndexReceipt;
|
||||
pub use memory_graph::MemorySemanticProjectionAttempt;
|
||||
|
|
@ -650,6 +662,9 @@ pub use memory_graph::MemorySemanticProjectionObligation;
|
|||
pub use memory_graph::MemorySemanticProjectionObservation;
|
||||
pub use memory_graph::MemorySemanticProjectionReadiness;
|
||||
pub use memory_graph::MemorySemanticProjectionSourceHead;
|
||||
pub use memory_graph::MemorySemanticProjectorAcquisition;
|
||||
pub use memory_graph::MemorySemanticProjectorExecutorGrant;
|
||||
pub use memory_graph::MemorySemanticProjectorRecoveryAuthorization;
|
||||
pub use memory_graph::RepoFrontierAdoptedPlan;
|
||||
pub use memory_graph::RepoFrontierItem;
|
||||
pub use memory_graph::RepoFrontierStatus;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ pub const MEMORY_SEMANTIC_INDEX_RECEIPT_SCHEMA_VERSION: &str =
|
|||
pub const MEMORY_SEMANTIC_PROJECTION_OBLIGATION_SCHEMA_VERSION: &str =
|
||||
"gamecult.epiphany.memory_semantic_projection_obligation.v0";
|
||||
pub const MEMORY_SEMANTIC_PROJECTION_ATTEMPT_SCHEMA_VERSION: &str =
|
||||
"gamecult.epiphany.memory_semantic_projection_attempt.v0";
|
||||
"gamecult.epiphany.memory_semantic_projection_attempt.v1";
|
||||
const MODELING_COLLECTION_DEFAULT: &str = "epiphany_modeling_v1";
|
||||
const MIND_COLLECTION_DEFAULT: &str = "epiphany_mind_v1";
|
||||
const QUERY_LIMIT_MAX: usize = 64;
|
||||
|
|
@ -159,6 +159,16 @@ pub struct MemorySemanticProjectionAttempt {
|
|||
pub status: String,
|
||||
#[cultcache(key = 6)]
|
||||
pub error: Option<String>,
|
||||
#[cultcache(key = 7)]
|
||||
pub claim_id: String,
|
||||
#[cultcache(key = 8)]
|
||||
pub claim_epoch: u64,
|
||||
#[cultcache(key = 9)]
|
||||
pub executor_id: String,
|
||||
#[cultcache(key = 10)]
|
||||
pub executor_incarnation: String,
|
||||
#[cultcache(key = 11)]
|
||||
pub authority_id: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
|
|
@ -356,6 +366,11 @@ pub fn validate_memory_semantic_projection_attempt(
|
|||
}
|
||||
if attempt.attempt_id.trim().is_empty()
|
||||
|| attempt.obligation_id.trim().is_empty()
|
||||
|| attempt.claim_id.trim().is_empty()
|
||||
|| attempt.claim_epoch == 0
|
||||
|| attempt.executor_id.trim().is_empty()
|
||||
|| attempt.executor_incarnation.trim().is_empty()
|
||||
|| attempt.authority_id.trim().is_empty()
|
||||
|| attempt.started_at.trim().is_empty()
|
||||
|| chrono::DateTime::parse_from_rfc3339(&attempt.started_at).is_err()
|
||||
|| attempt
|
||||
|
|
@ -367,6 +382,14 @@ pub fn validate_memory_semantic_projection_attempt(
|
|||
"semantic projection attempt is missing identity or time"
|
||||
));
|
||||
}
|
||||
if attempt.completed_at.as_deref().is_some_and(|completed_at| {
|
||||
chrono::DateTime::parse_from_rfc3339(completed_at).ok()
|
||||
< chrono::DateTime::parse_from_rfc3339(&attempt.started_at).ok()
|
||||
}) {
|
||||
return Err(anyhow!(
|
||||
"semantic projection attempt completes before it starts"
|
||||
));
|
||||
}
|
||||
match attempt.status.as_str() {
|
||||
"running" if attempt.completed_at.is_none() && attempt.error.is_none() => Ok(()),
|
||||
"failed" if attempt.completed_at.is_some() && attempt.error.is_some() => Ok(()),
|
||||
|
|
@ -1347,6 +1370,11 @@ mod tests {
|
|||
completed_at: Some("2026-07-15T10:00:31Z".to_string()),
|
||||
status: "failed".to_string(),
|
||||
error: Some("qdrant unavailable".to_string()),
|
||||
claim_id: "claim-7".to_string(),
|
||||
claim_epoch: 1,
|
||||
executor_id: "executor-a".to_string(),
|
||||
executor_incarnation: "executor-a-incarnation".to_string(),
|
||||
authority_id: "authority-a".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -590,5 +590,59 @@ retaining pulse `completed`, iteration `1`, and lifecycle receipt
|
|||
No command args or routine payloads are projected. Next merge these rows into
|
||||
the main provider-owned Eve composition rather than keeping a specialist query only.
|
||||
|
||||
## Semantic Projector Executor Authority
|
||||
|
||||
Canonical Mind and Modeling admission own projection demand. Their transaction
|
||||
writes the exact semantic-projection obligation beside the canonical source
|
||||
head; neither Idunn nor the projector may invent that demand. Idunn owns the
|
||||
decision to assign an executor or fence an abandoned executor. The projector
|
||||
owns only the claim-bound Qdrant mutation, post-write observation, attempt
|
||||
terminalization, and exact success receipt.
|
||||
|
||||
The execution chain is now:
|
||||
|
||||
`canonical obligation -> Idunn acquisition CAS -> consumed executor grant + running claim/attempt -> epoch-isolated Qdrant synchronization -> canonical authority reauthentication -> terminal claim/attempt + exact receipt CAS`.
|
||||
|
||||
Acquisition binds scope, obligation, executor identity and incarnation,
|
||||
purpose, Idunn incarnation, predecessor claim, and resulting claim epoch in one
|
||||
consumed typed grant. `execute` cannot reopen an exact succeeded claim;
|
||||
`repair` requires that exact predecessor. The execution CLI accepts a claim id,
|
||||
not an executor label, and authenticates the consumed authority behind the
|
||||
claim before touching Qdrant. Acquisition reauthenticates the complete sealed
|
||||
canonical input and carries its authority envelopes through the same CAS, so a
|
||||
persisted historical obligation cannot reopen an advanced source head.
|
||||
|
||||
Running-claim recovery reloads the exact Idunn poke intent/receipt and a
|
||||
provider-authored immutable heartbeat event from CultMesh. It requires an
|
||||
`awaiting-provider-heartbeat` lifecycle result followed by a newer ready
|
||||
heartbeat for the replacement provider incarnation, hashes those source
|
||||
envelopes, requires the heartbeat to name the exact restart receipt as its
|
||||
startup cause, and consumes a typed recovery authorization in the same CAS that
|
||||
fails the abandoned attempt and advances the claim epoch. The old executor can
|
||||
thereafter write only its physically isolated abandoned Qdrant namespace and
|
||||
cannot terminalize the active CultCache claim.
|
||||
|
||||
Projection health, elapsed time, process status, command exit, Qdrant counts,
|
||||
CultMesh mirrors, Eve, and swarm overview remain derived sight. They cannot
|
||||
create an obligation, grant, claim, attempt, success receipt, recovery, or
|
||||
query admission. Initial execution, retry, repair, and recovered execution all
|
||||
use the same claim-authenticating execution primitive; only acquisition and
|
||||
recovery differ in how Idunn establishes the claim authority.
|
||||
|
||||
Verification covers concurrent acquisition with one winner and no issued
|
||||
litter, predecessor/epoch ordering, purpose separation, claim-authority
|
||||
authentication, evidence field substitution, lifecycle/heartbeat causal
|
||||
ordering, recovery single use, and the inability of the recovery command to
|
||||
execute projection work itself.
|
||||
|
||||
Remaining limits are physical deployment, not permission for another adapter.
|
||||
There is no open-obligation daemon pulse or packaged single projector owner
|
||||
yet. The low-level mint and recovery primitives are crate-private. Their public
|
||||
local-supervisor ports generate incarnations internally, but remain trusted
|
||||
in-process ports rather than an OS-authenticated Idunn service boundary.
|
||||
Deployment must keep those ports inside one configured Idunn body until a
|
||||
durable authenticated service identity owns them. Canonical store and Qdrant
|
||||
placement must be chosen as one topology; dual projectors are forbidden.
|
||||
|
||||
This map must change when ownership changes. Historical scars belong in git,
|
||||
evidence, or an explicitly archived note—not in the machine's proprioception.
|
||||
evidence, or an explicitly archived note—not in the machine's Modeling state.
|
||||
|
|
|
|||
|
|
@ -1202,6 +1202,50 @@ mirror independently, and `epiphany-verse-query semantic-health` reads a named,
|
|||
compact report without touching canonical state. A stale sealed input is
|
||||
refused rather than published as if it described the current canonical head.
|
||||
|
||||
Next: give Idunn typed executor grants, single-use fenced recovery authority,
|
||||
open-obligation discovery, and one packaged projector owner. CultMesh, Idunn,
|
||||
Eve, and Gjallar remain unable to mint semantic readiness.
|
||||
## Idunn semantic executor authority cut (2026-07-15)
|
||||
|
||||
Executor labels no longer open semantic mutation authority. Idunn acquisition
|
||||
now atomically writes a consumed typed executor grant, a scope claim, and its
|
||||
running attempt against the exact persisted obligation and predecessor claim.
|
||||
The grant binds executor incarnation, purpose, Idunn incarnation, predecessor
|
||||
status/id/epoch, and resulting claim id/epoch. `execute` cannot repair a
|
||||
succeeded claim; `repair` requires that exact succeeded predecessor. The
|
||||
projector CLI now requires the acquired claim id and authenticates its consumed
|
||||
grant before Qdrant work or terminalization. Acquisition reauthenticates the
|
||||
whole sealed canonical input and carries its authority envelopes through the
|
||||
same CAS, so an old persisted obligation cannot mint against an advanced head.
|
||||
|
||||
Fenced recovery now consumes typed evidence rather than free-form reason text.
|
||||
The CultMesh bridge authenticates the exact immutable Idunn poke intent and
|
||||
successful `awaiting-provider-heartbeat` receipt, plus a provider-authored ready
|
||||
heartbeat event that causally follows receipt completion and names the
|
||||
replacement provider incarnation. The heartbeat must also name that exact
|
||||
restart receipt as its startup cause. Their envelope digests enter a consumed
|
||||
recovery authorization. One CAS fails the abandoned attempt, advances the
|
||||
epoch, creates the replacement claim/attempt, and records that authorization.
|
||||
Recovery rotates authority only; it cannot execute projection or mint success.
|
||||
Provider heartbeat events are immutable and their latest pointer advances
|
||||
monotonically per daemon/incarnation.
|
||||
|
||||
Authority map: canonical Mind/Modeling admission owns obligations; Idunn owns
|
||||
executor assignment and explicit recovery decision; the projector owns claim-
|
||||
bound mutation and terminal evidence; the query gate alone authenticates
|
||||
readiness. Health, liveness, timers, command exits, Qdrant state, CultMesh,
|
||||
Eve, and swarm overview remain derived sight and forbidden writers. Initial
|
||||
execution, retry, repair, and recovered execution share the same claim-
|
||||
authenticating projector primitive.
|
||||
|
||||
Remaining limits: open-obligation discovery is not yet attached to the Idunn
|
||||
daemon, no single projector owner is packaged, canonical-store/Qdrant placement
|
||||
between local and Yggdrasil remains undecided, and local Qdrant remains
|
||||
overexposed. The low-level mint and recovery primitives are crate-private.
|
||||
Their public local-supervisor ports generate incarnations internally, but are
|
||||
still a trusted in-process boundary rather than authenticated OS IPC. Keep them
|
||||
inside one configured Idunn body until durable service identity owns them. Do
|
||||
not expose those ports to untrusted Verse peers. Do not deploy two projectors.
|
||||
|
||||
Next: add a bounded Idunn pulse that discovers authenticated open Mind and
|
||||
Modeling obligations without creating demand, runs the same acquire/execute
|
||||
primitive, republishes sight independently, and reports provider readiness only
|
||||
after its own heartbeat. Then select and package exactly one deployment
|
||||
topology.
|
||||
|
|
|
|||
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 semantic projection physiology on the landed atomic admission, physically epoch-isolated projector, exact query gate, provider-status ownership cut, and non-authoritative CultMesh health sight. Mind and Modeling emit canonical obligations; live `gamecult.epiphany.main` projections are isolated in Qdrant by obligation, claim, and epoch; readiness authenticates the complete succeeded claim/attempt/receipt chain. CultMesh health publication reauthenticates the sealed canonical input and success chain, publishes bounded pending/failed/ready sight with provider incarnation through chronological CAS, refuses stale sealed inputs, and carries no readiness capability, private error, path, command, or payload prose. Idunn records stale observation, restart attempts, policy, and backoff without writing provider heartbeat/status; command success remains `awaiting-provider-heartbeat` until a causally newer provider heartbeat proves recovery. Next add typed Idunn executor grants and single-use recovery authorization, and add open-obligation discovery without letting a timer create demand. Package exactly one projector owner after resolving local-versus-Yggdrasil canonical-store placement; Yggdrasil currently has GPU Ollama/Odin/Idunn but no Qdrant or Epiphany target, while local Qdrant is healthy but overexposed on all interfaces. Timers, collection metadata, point counts, runtime ids, paths, CLI labels, Idunn liveness, CultMesh mirrors, Eve/Gjallar, and payload prose own no readiness.
|
||||
next_action: Complete semantic projection physiology on the landed atomic admission, physically epoch-isolated projector, exact query gate, provider-status ownership cut, non-authoritative CultMesh health sight, and typed Idunn executor/recovery authority. Mind and Modeling alone emit canonical obligations. Idunn acquisition reauthenticates the sealed current source and CAS-writes its authority envelopes with a consumed grant plus claim/attempt bound to exact scope, obligation, executor incarnation, purpose, predecessor, and epoch; historical obligations cannot reopen advanced heads, and execute cannot become repair. Execution accepts the authenticated claim id rather than treating an executor label as capability. Recovery authenticates the exact Idunn poke intent/awaiting-heartbeat receipt and a newer provider-authored ready heartbeat that names that receipt as its startup cause, then one CAS consumes their store/input/claim-bound authorization, fails the abandoned attempt, and advances the claim epoch; recovery cannot execute or mint readiness. The projector alone owns claim-bound Qdrant mutation and terminal evidence, while the opaque query gate authenticates the complete succeeded grant-or-recovery/claim/attempt/receipt chain. Next add bounded open-obligation discovery for both Mind and Modeling without letting a timer create demand, then package exactly one projector owner after resolving local-versus-Yggdrasil canonical-store and Qdrant placement. Low-level mint/recovery are crate-private; public local-supervisor ports generate incarnations internally but remain a trusted in-process boundary, not authenticated OS IPC. Keep them inside one configured Idunn body until durable service identity owns them. Yggdrasil has GPU Ollama/Odin/Idunn but no Qdrant or Epiphany target; local Qdrant is healthy but overexposed on all interfaces. Timers, collection metadata, point counts, paths, CLI labels, Idunn liveness, CultMesh mirrors, Eve/swarm overview, and payload prose own no obligation, recovery, completion, or readiness.
|
||||
|
|
|
|||
Reference in a new issue