Restore provider ownership of daemon liveness
This commit is contained in:
parent
5bd1b2bd15
commit
3b036bed53
9 changed files with 574 additions and 101 deletions
|
|
@ -35,7 +35,6 @@ use epiphany_core::write_epiphany_cultmesh_daemon_poke_receipt;
|
|||
use epiphany_core::write_epiphany_cultmesh_daemon_restart_policy;
|
||||
use epiphany_core::write_epiphany_cultmesh_daemon_scheduler_receipt;
|
||||
use epiphany_core::write_epiphany_cultmesh_daemon_service_lifecycle_receipt;
|
||||
use epiphany_core::write_epiphany_cultmesh_daemon_status;
|
||||
use epiphany_core::write_epiphany_cultmesh_managed_service_policy;
|
||||
use serde_json::Value;
|
||||
use serde_json::json;
|
||||
|
|
@ -46,6 +45,7 @@ use std::fs;
|
|||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
use std::process::Stdio;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[cfg(windows)]
|
||||
use std::os::windows::process::CommandExt;
|
||||
|
|
@ -197,6 +197,7 @@ fn reconcile(args: Args) -> Result<()> {
|
|||
&mut policy,
|
||||
args.force,
|
||||
false,
|
||||
false,
|
||||
)?;
|
||||
println!("{}", serde_json::to_string_pretty(&output)?);
|
||||
Ok(())
|
||||
|
|
@ -2327,7 +2328,7 @@ fn run_tick(args: &Args, iteration: u64, next_wake_utc: Option<String>) -> Resul
|
|||
|
||||
require_supervisor_bootstrap(&args)?;
|
||||
|
||||
let mut context = query_epiphany_local_verse_context(&args.store, args.runtime_id.clone())?;
|
||||
let context = query_epiphany_local_verse_context(&args.store, args.runtime_id.clone())?;
|
||||
assert_swarm_brake_allows_scheduler_tick(&context)?;
|
||||
|
||||
let now = Utc::now();
|
||||
|
|
@ -2383,22 +2384,11 @@ fn run_tick(args: &Args, iteration: u64, next_wake_utc: Option<String>) -> Resul
|
|||
continue;
|
||||
}
|
||||
|
||||
let mut scheduled_status = status;
|
||||
let scheduled_status = status;
|
||||
let heartbeat_stale = daemon_heartbeat_is_stale(&scheduled_status, &policy, now)?;
|
||||
let mut forced = args.force;
|
||||
if daemon_heartbeat_is_stale(&scheduled_status, &policy, now)? {
|
||||
scheduled_status.status = "degraded".to_string();
|
||||
scheduled_status.operator_action = "pokeDaemon".to_string();
|
||||
scheduled_status.notes.push(format!(
|
||||
"Supervisor scheduler marked heartbeat stale after {} seconds.",
|
||||
policy.heartbeat_stale_seconds
|
||||
));
|
||||
scheduled_status = write_epiphany_cultmesh_daemon_status(
|
||||
&args.store,
|
||||
args.runtime_id.clone(),
|
||||
scheduled_status,
|
||||
)?;
|
||||
if heartbeat_stale {
|
||||
forced = true;
|
||||
context = query_epiphany_local_verse_context(&args.store, args.runtime_id.clone())?;
|
||||
}
|
||||
|
||||
match reconcile_daemon_status(
|
||||
|
|
@ -2408,6 +2398,7 @@ fn run_tick(args: &Args, iteration: u64, next_wake_utc: Option<String>) -> Resul
|
|||
&mut policy,
|
||||
forced,
|
||||
true,
|
||||
heartbeat_stale,
|
||||
) {
|
||||
Ok(output) => outcomes.push(output),
|
||||
Err(error) => outcomes.push(json!({
|
||||
|
|
@ -2421,7 +2412,7 @@ fn run_tick(args: &Args, iteration: u64, next_wake_utc: Option<String>) -> Resul
|
|||
}
|
||||
|
||||
let outcome_count = outcomes.len() as u32;
|
||||
let restarted_count = count_outcomes(&outcomes, "restarted");
|
||||
let restarted_count = count_outcomes(&outcomes, "awaiting-provider-heartbeat");
|
||||
let refused_count = count_outcomes(&outcomes, "refused");
|
||||
let skipped_count = count_outcomes(&outcomes, "skipped");
|
||||
let tick_completed = Utc::now();
|
||||
|
|
@ -2595,13 +2586,21 @@ fn reconcile_daemon_status(
|
|||
policy: &mut EpiphanyCultMeshDaemonRestartPolicyEntry,
|
||||
force: bool,
|
||||
scheduled: bool,
|
||||
observed_heartbeat_stale: bool,
|
||||
) -> Result<Value> {
|
||||
assert_swarm_brake_allows_daemon_poke(context, daemon_status)?;
|
||||
let now = Utc::now();
|
||||
let needs_restart = force || daemon_status.status != "ready";
|
||||
if !needs_restart {
|
||||
let provider_proved_recovery =
|
||||
provider_heartbeat_follows_last_attempt(daemon_status, policy)?;
|
||||
policy.last_reconcile_utc = Some(now.to_rfc3339());
|
||||
policy.last_result_status = daemon_status.status.clone();
|
||||
if provider_proved_recovery {
|
||||
policy.failure_count = 0;
|
||||
policy.last_result_status = "provider-heartbeat-recovered".to_string();
|
||||
} else {
|
||||
policy.last_result_status = "awaiting-provider-heartbeat".to_string();
|
||||
}
|
||||
let written_policy = write_epiphany_cultmesh_daemon_restart_policy(
|
||||
&args.store,
|
||||
args.runtime_id.clone(),
|
||||
|
|
@ -2614,6 +2613,7 @@ fn reconcile_daemon_status(
|
|||
"runtimeId": args.runtime_id,
|
||||
"daemonId": daemon_status.daemon_id,
|
||||
"daemonStatus": daemon_status.status,
|
||||
"providerHeartbeatProvedRecovery": provider_proved_recovery,
|
||||
"policyId": written_policy.policy_id,
|
||||
"scheduled": scheduled,
|
||||
"lastReconcileUtc": written_policy.last_reconcile_utc,
|
||||
|
|
@ -2622,7 +2622,7 @@ fn reconcile_daemon_status(
|
|||
}
|
||||
assert_policy_allows_attempt(policy, now)?;
|
||||
|
||||
let reason = args.reason.clone().unwrap_or_else(|| {
|
||||
let mut reason = args.reason.clone().unwrap_or_else(|| {
|
||||
if scheduled {
|
||||
format!(
|
||||
"Scheduled supervisor reconciliation requested for {} after status {}.",
|
||||
|
|
@ -2635,19 +2635,25 @@ fn reconcile_daemon_status(
|
|||
)
|
||||
}
|
||||
});
|
||||
if observed_heartbeat_stale {
|
||||
reason.push_str(&format!(
|
||||
" Idunn observed a provider heartbeat older than the configured {} second threshold; provider status remains {} pending an authentic heartbeat.",
|
||||
policy.heartbeat_stale_seconds, daemon_status.status
|
||||
));
|
||||
}
|
||||
let suffix = if scheduled { "scheduled" } else { "intent" };
|
||||
let intent_id = args.intent_id.clone().unwrap_or_else(|| {
|
||||
format!(
|
||||
"daemon-supervisor-{}-{}",
|
||||
"daemon-supervisor-{}-{}-{}",
|
||||
suffix,
|
||||
sanitize_id(&daemon_status.daemon_id)
|
||||
sanitize_id(&daemon_status.daemon_id),
|
||||
Uuid::new_v4().simple()
|
||||
)
|
||||
});
|
||||
let receipt_id = args.receipt_id.clone().unwrap_or_else(|| {
|
||||
intent_id
|
||||
.replace("intent", "receipt")
|
||||
.replace("scheduled", "receipt")
|
||||
});
|
||||
let receipt_id = args
|
||||
.receipt_id
|
||||
.clone()
|
||||
.unwrap_or_else(|| format!("{intent_id}-receipt"));
|
||||
let intent = epiphany_cultmesh_daemon_poke_intent_from_status(
|
||||
intent_id,
|
||||
args.requesting_agent_id.clone(),
|
||||
|
|
@ -2660,13 +2666,10 @@ fn reconcile_daemon_status(
|
|||
intent.clone(),
|
||||
)?;
|
||||
|
||||
let attempted_at = Utc::now();
|
||||
let restart_output = run_restart_command(policy)?;
|
||||
let resulting_status = if restart_output.success {
|
||||
"ready"
|
||||
} else {
|
||||
"down"
|
||||
}
|
||||
.to_string();
|
||||
let completed_at = Utc::now();
|
||||
let resulting_status = restart_lifecycle_observation(&restart_output).to_string();
|
||||
let receipt_status = if restart_output.success {
|
||||
"restart-succeeded"
|
||||
} else {
|
||||
|
|
@ -2679,38 +2682,27 @@ fn reconcile_daemon_status(
|
|||
restart_output.exit_code.unwrap_or(-1)
|
||||
)
|
||||
});
|
||||
let receipt = epiphany_cultmesh_daemon_poke_receipt_for_intent(
|
||||
let mut receipt = epiphany_cultmesh_daemon_poke_receipt_for_intent(
|
||||
receipt_id,
|
||||
&intent,
|
||||
receipt_status,
|
||||
resulting_status.clone(),
|
||||
artifact_ref,
|
||||
);
|
||||
receipt.attempted_at_utc = attempted_at.to_rfc3339();
|
||||
receipt.completed_at_utc = completed_at.to_rfc3339();
|
||||
let written_receipt =
|
||||
write_epiphany_cultmesh_daemon_poke_receipt(&args.store, args.runtime_id.clone(), receipt)?;
|
||||
|
||||
let mut next_status = daemon_status.clone();
|
||||
next_status.status = resulting_status;
|
||||
next_status.last_heartbeat_utc = Utc::now().to_rfc3339();
|
||||
next_status.operator_action = if restart_output.success {
|
||||
"none".to_string()
|
||||
} else {
|
||||
"pokeDaemon".to_string()
|
||||
};
|
||||
next_status.notes.push(format!(
|
||||
"Supervisor command exited {:?}; stdout {} bytes; stderr {} bytes.",
|
||||
restart_output.exit_code, restart_output.stdout_len, restart_output.stderr_len
|
||||
));
|
||||
let written_status =
|
||||
write_epiphany_cultmesh_daemon_status(&args.store, args.runtime_id.clone(), next_status)?;
|
||||
policy.last_attempt_utc = Some(now.to_rfc3339());
|
||||
// The durable recovery boundary is command completion, not launch. A
|
||||
// provider heartbeat emitted while the command was still running cannot
|
||||
// prove that this lifecycle attempt recovered the daemon.
|
||||
policy.last_attempt_utc = Some(completed_at.to_rfc3339());
|
||||
policy.last_reconcile_utc = Some(now.to_rfc3339());
|
||||
policy.last_result_status = written_status.status.clone();
|
||||
policy.failure_count = if restart_output.success {
|
||||
0
|
||||
} else {
|
||||
policy.failure_count.saturating_add(1)
|
||||
};
|
||||
policy.last_result_status = resulting_status.clone();
|
||||
// A command attempt is not a recovered daemon. Backoff remains under
|
||||
// pressure until a later provider heartbeat proves this attempt worked.
|
||||
policy.failure_count = unresolved_attempt_failure_count(policy.failure_count);
|
||||
let written_policy = write_epiphany_cultmesh_daemon_restart_policy(
|
||||
&args.store,
|
||||
args.runtime_id.clone(),
|
||||
|
|
@ -2718,13 +2710,15 @@ fn reconcile_daemon_status(
|
|||
)?;
|
||||
|
||||
Ok(json!({
|
||||
"status": if restart_output.success { "restarted" } else { "restartFailed" },
|
||||
"status": resulting_status,
|
||||
"store": args.store,
|
||||
"runtimeId": args.runtime_id,
|
||||
"daemonId": written_status.daemon_id,
|
||||
"daemonId": daemon_status.daemon_id,
|
||||
"previousStatus": written_intent.observed_status,
|
||||
"resultingStatus": written_status.status,
|
||||
"operatorAction": written_status.operator_action,
|
||||
"resultingStatus": written_receipt.resulting_status,
|
||||
"providerStatus": daemon_status.status,
|
||||
"providerOperatorAction": daemon_status.operator_action,
|
||||
"providerLastHeartbeatUtc": daemon_status.last_heartbeat_utc,
|
||||
"intentId": written_intent.intent_id,
|
||||
"receiptId": written_receipt.receipt_id,
|
||||
"exitCode": restart_output.exit_code,
|
||||
|
|
@ -2734,12 +2728,47 @@ fn reconcile_daemon_status(
|
|||
"cooldownSeconds": written_policy.cooldown_seconds,
|
||||
"failureCount": written_policy.failure_count,
|
||||
"scheduled": scheduled,
|
||||
"observedHeartbeatStale": observed_heartbeat_stale,
|
||||
"heartbeatStaleSeconds": policy.heartbeat_stale_seconds,
|
||||
"lastReconcileUtc": written_policy.last_reconcile_utc,
|
||||
"privateStateRequested": written_intent.private_state_requested,
|
||||
"privateStateExposed": written_receipt.private_state_exposed || written_status.private_state_exposed,
|
||||
"privateStateExposed": written_receipt.private_state_exposed || daemon_status.private_state_exposed,
|
||||
}))
|
||||
}
|
||||
|
||||
fn provider_heartbeat_follows_last_attempt(
|
||||
daemon_status: &EpiphanyCultMeshDaemonStatusEntry,
|
||||
policy: &EpiphanyCultMeshDaemonRestartPolicyEntry,
|
||||
) -> Result<bool> {
|
||||
let Some(last_attempt) = policy.last_attempt_utc.as_deref() else {
|
||||
return Ok(true);
|
||||
};
|
||||
let attempt = DateTime::parse_from_rfc3339(last_attempt)
|
||||
.with_context(|| format!("invalid last_attempt_utc in policy {}", policy.policy_id))?;
|
||||
let heartbeat =
|
||||
DateTime::parse_from_rfc3339(&daemon_status.last_heartbeat_utc).with_context(|| {
|
||||
format!(
|
||||
"invalid last_heartbeat_utc for daemon {}",
|
||||
daemon_status.daemon_id
|
||||
)
|
||||
})?;
|
||||
Ok(heartbeat > attempt)
|
||||
}
|
||||
|
||||
fn restart_lifecycle_observation(output: &RestartOutput) -> &'static str {
|
||||
if output.success {
|
||||
// Process creation/exit is Idunn evidence only. The provider must publish
|
||||
// a later authentic heartbeat before anybody may call it ready.
|
||||
"awaiting-provider-heartbeat"
|
||||
} else {
|
||||
"restart-failed"
|
||||
}
|
||||
}
|
||||
|
||||
fn unresolved_attempt_failure_count(current: u32) -> u32 {
|
||||
current.saturating_add(1)
|
||||
}
|
||||
|
||||
fn assert_policy_allows_attempt(
|
||||
policy: &EpiphanyCultMeshDaemonRestartPolicyEntry,
|
||||
now: DateTime<Utc>,
|
||||
|
|
@ -3436,6 +3465,40 @@ struct RestartOutput {
|
|||
stderr_len: usize,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod provider_status_ownership_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn successful_command_awaits_provider_heartbeat_instead_of_minting_readiness() {
|
||||
let exit_zero = RestartOutput {
|
||||
success: true,
|
||||
exit_code: Some(0),
|
||||
stdout_len: 0,
|
||||
stderr_len: 0,
|
||||
};
|
||||
|
||||
let observation = restart_lifecycle_observation(&exit_zero);
|
||||
|
||||
assert_eq!(observation, "awaiting-provider-heartbeat");
|
||||
assert_ne!(observation, "ready");
|
||||
assert_eq!(unresolved_attempt_failure_count(0), 1);
|
||||
assert_eq!(unresolved_attempt_failure_count(3), 4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn supervisor_source_has_no_provider_status_writer() {
|
||||
let source = include_str!("epiphany-daemon-supervisor.rs");
|
||||
|
||||
let provider_writer = ["write_epiphany_cultmesh_", "daemon_status"].concat();
|
||||
let heartbeat_assignment = ["next_status.", "last_heartbeat_utc"].concat();
|
||||
let action_assignment = ["next_status.", "operator_action"].concat();
|
||||
assert!(!source.contains(&provider_writer));
|
||||
assert!(!source.contains(&heartbeat_assignment));
|
||||
assert!(!source.contains(&action_assignment));
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Args {
|
||||
command: String,
|
||||
|
|
|
|||
|
|
@ -71,6 +71,33 @@ fn run_smoke(args: Args) -> Result<Value> {
|
|||
vec!["-c", "exit 0"]
|
||||
};
|
||||
|
||||
cargo_json(
|
||||
&manifest,
|
||||
"epiphany-verse-query",
|
||||
&[
|
||||
"seed",
|
||||
"--store",
|
||||
path_str(&local_verse)?,
|
||||
"--runtime-id",
|
||||
runtime_id,
|
||||
],
|
||||
&root,
|
||||
)?;
|
||||
cargo_json(
|
||||
&manifest,
|
||||
"epiphany-cluster-daemon",
|
||||
&[
|
||||
"heartbeat",
|
||||
"--store",
|
||||
path_str(&local_verse)?,
|
||||
"--runtime-id",
|
||||
runtime_id,
|
||||
"--daemon-id",
|
||||
daemon_id,
|
||||
],
|
||||
&root,
|
||||
)?;
|
||||
|
||||
let mut policy_args = vec![
|
||||
"policy",
|
||||
"--store",
|
||||
|
|
@ -90,7 +117,7 @@ fn run_smoke(args: Args) -> Result<Value> {
|
|||
"--reconcile-interval-seconds",
|
||||
"0",
|
||||
"--heartbeat-stale-seconds",
|
||||
"3600",
|
||||
"2",
|
||||
]
|
||||
.into_iter()
|
||||
.map(str::to_string)
|
||||
|
|
@ -105,6 +132,18 @@ fn run_smoke(args: Args) -> Result<Value> {
|
|||
&string_refs(&policy_args),
|
||||
&root,
|
||||
)?;
|
||||
let provider_before = cargo_json(
|
||||
&manifest,
|
||||
"epiphany-verse-query",
|
||||
&[
|
||||
"swarm-status",
|
||||
"--store",
|
||||
path_str(&local_verse)?,
|
||||
"--runtime-id",
|
||||
runtime_id,
|
||||
],
|
||||
&root,
|
||||
)?;
|
||||
|
||||
let serve_args = vec![
|
||||
"serve",
|
||||
|
|
@ -120,11 +159,11 @@ fn run_smoke(args: Args) -> Result<Value> {
|
|||
"0",
|
||||
"--max-iterations",
|
||||
"2",
|
||||
"--force",
|
||||
]
|
||||
.into_iter()
|
||||
.map(str::to_string)
|
||||
.collect::<Vec<_>>();
|
||||
std::thread::sleep(std::time::Duration::from_secs(3));
|
||||
let serve = cargo_json(
|
||||
&manifest,
|
||||
"epiphany-daemon-supervisor",
|
||||
|
|
@ -145,6 +184,8 @@ fn run_smoke(args: Args) -> Result<Value> {
|
|||
if outputs.len() != 2 {
|
||||
return Err(anyhow!("expected 2 serve outputs, got {}", outputs.len()));
|
||||
}
|
||||
let mut intent_ids = Vec::new();
|
||||
let mut receipt_ids = Vec::new();
|
||||
for (idx, output) in outputs.iter().enumerate() {
|
||||
require_eq(output, &["status"], "tickComplete")?;
|
||||
require_eq(output, &["schedulerId"], scheduler_id)?;
|
||||
|
|
@ -160,10 +201,91 @@ fn run_smoke(args: Args) -> Result<Value> {
|
|||
let outcome = outcomes
|
||||
.first()
|
||||
.ok_or_else(|| anyhow!("tick output missing first outcome"))?;
|
||||
require_eq(outcome, &["status"], "restarted")?;
|
||||
require_eq(outcome, &["status"], "awaiting-provider-heartbeat")?;
|
||||
require_eq(outcome, &["resultingStatus"], "awaiting-provider-heartbeat")?;
|
||||
require_bool(outcome, &["observedHeartbeatStale"], true)?;
|
||||
require_eq(outcome, &["daemonId"], daemon_id)?;
|
||||
require_bool(outcome, &["privateStateExposed"], false)?;
|
||||
intent_ids.push(
|
||||
outcome["intentId"]
|
||||
.as_str()
|
||||
.context("restart outcome missing intentId")?
|
||||
.to_string(),
|
||||
);
|
||||
receipt_ids.push(
|
||||
outcome["receiptId"]
|
||||
.as_str()
|
||||
.context("restart outcome missing receiptId")?
|
||||
.to_string(),
|
||||
);
|
||||
}
|
||||
if intent_ids[0] == intent_ids[1] || receipt_ids[0] == receipt_ids[1] {
|
||||
return Err(anyhow!(
|
||||
"two supervisor attempts reused immutable intent/receipt identity"
|
||||
));
|
||||
}
|
||||
|
||||
let provider_after = cargo_json(
|
||||
&manifest,
|
||||
"epiphany-verse-query",
|
||||
&[
|
||||
"swarm-status",
|
||||
"--store",
|
||||
path_str(&local_verse)?,
|
||||
"--runtime-id",
|
||||
runtime_id,
|
||||
],
|
||||
&root,
|
||||
)?;
|
||||
let provider_row = |report: &Value| -> Result<Value> {
|
||||
rows(report)
|
||||
.iter()
|
||||
.find(|row| row.get("daemonId").and_then(Value::as_str) == Some(daemon_id))
|
||||
.map(|row| (*row).clone())
|
||||
.ok_or_else(|| anyhow!("swarm status omitted provider daemon {daemon_id}"))
|
||||
};
|
||||
let before_row = provider_row(&provider_before)?;
|
||||
let after_row = provider_row(&provider_after)?;
|
||||
for field in ["status", "operatorAction", "lastHeartbeatUtc"] {
|
||||
if before_row[field] != after_row[field] {
|
||||
return Err(anyhow!(
|
||||
"supervisor changed provider-owned {field}: before={} after={}",
|
||||
before_row[field],
|
||||
after_row[field]
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
cargo_json(
|
||||
&manifest,
|
||||
"epiphany-cluster-daemon",
|
||||
&[
|
||||
"heartbeat",
|
||||
"--store",
|
||||
path_str(&local_verse)?,
|
||||
"--runtime-id",
|
||||
runtime_id,
|
||||
"--daemon-id",
|
||||
daemon_id,
|
||||
],
|
||||
&root,
|
||||
)?;
|
||||
let recovered = cargo_json(
|
||||
&manifest,
|
||||
"epiphany-daemon-supervisor",
|
||||
&[
|
||||
"reconcile",
|
||||
"--store",
|
||||
path_str(&local_verse)?,
|
||||
"--runtime-id",
|
||||
runtime_id,
|
||||
"--daemon-id",
|
||||
daemon_id,
|
||||
],
|
||||
&root,
|
||||
)?;
|
||||
require_eq(&recovered, &["status"], "noop")?;
|
||||
require_bool(&recovered, &["providerHeartbeatProvedRecovery"], true)?;
|
||||
|
||||
let receipt_directory = cargo_json(
|
||||
&manifest,
|
||||
|
|
@ -186,6 +308,30 @@ fn run_smoke(args: Args) -> Result<Value> {
|
|||
require_eq(&scheduler_row, &["status"], "tickComplete")?;
|
||||
require_eq(&scheduler_row, &["route"], daemon_id)?;
|
||||
require_bool(&scheduler_row, &["privateStateExposed"], false)?;
|
||||
let poke_row = rows(&receipt_directory)
|
||||
.iter()
|
||||
.find(|row| row.get("family").and_then(Value::as_str) == Some("daemon-poke"))
|
||||
.cloned()
|
||||
.ok_or_else(|| anyhow!("receipt directory did not expose daemon poke row"))?;
|
||||
require_eq(&poke_row, &["status"], "resolved")?;
|
||||
let policy_directory = cargo_json(
|
||||
&manifest,
|
||||
"epiphany-verse-query",
|
||||
&[
|
||||
"restart-policy-directory",
|
||||
"--store",
|
||||
path_str(&local_verse)?,
|
||||
"--runtime-id",
|
||||
runtime_id,
|
||||
],
|
||||
&root,
|
||||
)?;
|
||||
let recovered_policy = rows(&policy_directory)
|
||||
.iter()
|
||||
.find(|row| row.get("daemonId").and_then(Value::as_str) == Some(daemon_id))
|
||||
.copied()
|
||||
.ok_or_else(|| anyhow!("restart policy directory omitted {daemon_id}"))?;
|
||||
require_u64(recovered_policy, &["failureCount"], 0)?;
|
||||
|
||||
let summary = json!({
|
||||
"schemaVersion": "epiphany.daemon_survival_rehearsal_smoke.v0",
|
||||
|
|
@ -201,6 +347,13 @@ fn run_smoke(args: Args) -> Result<Value> {
|
|||
"serveIterations": serve["iterations"],
|
||||
"schedulerReceiptId": scheduler_row["latestId"],
|
||||
"schedulerReceiptStatus": scheduler_row["status"],
|
||||
"pokeReceiptStatus": poke_row["status"],
|
||||
"providerEnvelopeUnchanged": true,
|
||||
"providerHeartbeatRequiredForRecovery": true,
|
||||
"providerHeartbeatResolvedReceipt": true,
|
||||
"providerHeartbeatResetFailureCount": true,
|
||||
"distinctAttemptIntentIds": intent_ids,
|
||||
"distinctAttemptReceiptIds": receipt_ids,
|
||||
"restartCommand": restart_command,
|
||||
"restartArgs": restart_args,
|
||||
"boundedProofMode": true,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use chrono::DateTime;
|
||||
use chrono::Utc;
|
||||
use epiphany_core::EPIPHANY_CULTMESH_DAEMON_RESTART_POLICY_SCHEMA_VERSION;
|
||||
use epiphany_core::EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_SCHEMA_VERSION;
|
||||
|
|
@ -7329,16 +7330,35 @@ fn receipt_directory_daemon_poke_status(
|
|||
context: &EpiphanyLocalVerseContext,
|
||||
receipt: &EpiphanyCultMeshDaemonPokeReceiptEntry,
|
||||
) -> String {
|
||||
let Some(current_status) = context
|
||||
let Some(current) = context
|
||||
.daemon_statuses
|
||||
.iter()
|
||||
.find(|status| status.daemon_id == receipt.target_daemon_id)
|
||||
.map(|status| status.status.as_str())
|
||||
else {
|
||||
return receipt.resulting_status.clone();
|
||||
};
|
||||
let current_status = current.status.as_str();
|
||||
|
||||
if current_status == "ready" && receipt.resulting_status != "ready" {
|
||||
let causally_recovered = current_status == "ready"
|
||||
&& receipt.resulting_status == "awaiting-provider-heartbeat"
|
||||
&& context
|
||||
.latest_daemon_poke_intent
|
||||
.as_ref()
|
||||
.filter(|intent| intent.intent_id == receipt.intent_id)
|
||||
.map(|intent| {
|
||||
provider_heartbeat_causally_follows_attempt(
|
||||
¤t.last_heartbeat_utc,
|
||||
&intent.observed_last_heartbeat_utc,
|
||||
&receipt.completed_at_utc,
|
||||
)
|
||||
})
|
||||
.unwrap_or(false);
|
||||
|
||||
if causally_recovered {
|
||||
"resolved".to_string()
|
||||
} else if receipt.resulting_status == "awaiting-provider-heartbeat" {
|
||||
receipt.resulting_status.clone()
|
||||
} else if current_status == "ready" && receipt.resulting_status != "ready" {
|
||||
"resolved".to_string()
|
||||
} else if current_status != receipt.resulting_status {
|
||||
format!("current-{current_status}")
|
||||
|
|
@ -7347,6 +7367,23 @@ fn receipt_directory_daemon_poke_status(
|
|||
}
|
||||
}
|
||||
|
||||
fn provider_heartbeat_causally_follows_attempt(
|
||||
current_heartbeat_utc: &str,
|
||||
observed_heartbeat_utc: &str,
|
||||
attempt_completed_utc: &str,
|
||||
) -> bool {
|
||||
let Ok(current) = DateTime::parse_from_rfc3339(current_heartbeat_utc) else {
|
||||
return false;
|
||||
};
|
||||
let Ok(observed) = DateTime::parse_from_rfc3339(observed_heartbeat_utc) else {
|
||||
return false;
|
||||
};
|
||||
let Ok(completed) = DateTime::parse_from_rfc3339(attempt_completed_utc) else {
|
||||
return false;
|
||||
};
|
||||
current > observed && current > completed
|
||||
}
|
||||
|
||||
fn service_execution_audit_check_tui_row(check: &EpiphanyServiceExecutionAuditCheck) -> String {
|
||||
let service_id = check.service_id.as_deref().unwrap_or("unknown-service");
|
||||
let observed_status = check.observed_status.as_deref().unwrap_or("missing");
|
||||
|
|
@ -9387,6 +9424,24 @@ fn required_list(values: &Option<Vec<String>>, message: &str) -> Result<Vec<Stri
|
|||
mod lifecycle_projection_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn stale_ready_heartbeat_cannot_resolve_a_later_restart_attempt() {
|
||||
assert!(!provider_heartbeat_causally_follows_attempt(
|
||||
"2026-07-15T10:00:00Z",
|
||||
"2026-07-15T10:00:00Z",
|
||||
"2026-07-15T10:01:00Z",
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn newer_provider_heartbeat_resolves_a_completed_restart_attempt() {
|
||||
assert!(provider_heartbeat_causally_follows_attempt(
|
||||
"2026-07-15T10:02:00Z",
|
||||
"2026-07-15T10:00:00Z",
|
||||
"2026-07-15T10:01:00Z",
|
||||
));
|
||||
}
|
||||
|
||||
fn managed_service_row(
|
||||
service_id: &str,
|
||||
enabled: bool,
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@ use anyhow::Result;
|
|||
use anyhow::anyhow;
|
||||
use chrono::DateTime;
|
||||
use chrono::FixedOffset;
|
||||
use chrono::Utc;
|
||||
use cultcache_rs::CultSoaColumnValues;
|
||||
use cultcache_rs::DatabaseEntry;
|
||||
use cultcache_rs::SingleFileMessagePackBackingStore;
|
||||
use cultcache_rs::SoaDocument;
|
||||
use cultmesh_rs::CultMesh;
|
||||
use cultmesh_rs::CultMeshNode;
|
||||
|
|
@ -123,13 +125,13 @@ pub const EPIPHANY_CULTMESH_DAEMON_STATUS_SCHEMA_VERSION: &str =
|
|||
"epiphany.cultmesh.daemon_status.v0";
|
||||
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.v0";
|
||||
"epiphany.cultmesh.daemon_poke_intent.v1";
|
||||
pub const EPIPHANY_CULTMESH_DAEMON_POKE_INTENT_LATEST_KEY: &str =
|
||||
"epiphany-local/daemon-poke-intent/latest";
|
||||
pub const EPIPHANY_CULTMESH_DAEMON_POKE_RECEIPT_TYPE: &str =
|
||||
"epiphany.cultmesh.daemon_poke_receipt";
|
||||
pub const EPIPHANY_CULTMESH_DAEMON_POKE_RECEIPT_SCHEMA_VERSION: &str =
|
||||
"epiphany.cultmesh.daemon_poke_receipt.v0";
|
||||
"epiphany.cultmesh.daemon_poke_receipt.v1";
|
||||
pub const EPIPHANY_CULTMESH_DAEMON_POKE_RECEIPT_LATEST_KEY: &str =
|
||||
"epiphany-local/daemon-poke-receipt/latest";
|
||||
pub const EPIPHANY_CULTMESH_DAEMON_RESTART_POLICY_TYPE: &str =
|
||||
|
|
@ -1193,6 +1195,10 @@ pub struct EpiphanyCultMeshDaemonPokeIntentEntry {
|
|||
pub private_state_requested: bool,
|
||||
#[cultcache(key = 11)]
|
||||
pub notes: Vec<String>,
|
||||
#[cultcache(key = 12, default)]
|
||||
pub observed_last_heartbeat_utc: String,
|
||||
#[cultcache(key = 13, default)]
|
||||
pub requested_at_utc: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
|
||||
|
|
@ -1223,6 +1229,10 @@ pub struct EpiphanyCultMeshDaemonPokeReceiptEntry {
|
|||
pub private_state_exposed: bool,
|
||||
#[cultcache(key = 10)]
|
||||
pub notes: Vec<String>,
|
||||
#[cultcache(key = 11, default)]
|
||||
pub attempted_at_utc: String,
|
||||
#[cultcache(key = 12, default)]
|
||||
pub completed_at_utc: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
|
||||
|
|
@ -3530,6 +3540,7 @@ pub fn epiphany_cultmesh_daemon_poke_intent_from_status(
|
|||
status: &EpiphanyCultMeshDaemonStatusEntry,
|
||||
reason: impl Into<String>,
|
||||
) -> EpiphanyCultMeshDaemonPokeIntentEntry {
|
||||
let requested_at_utc = Utc::now().to_rfc3339();
|
||||
EpiphanyCultMeshDaemonPokeIntentEntry {
|
||||
schema_version: EPIPHANY_CULTMESH_DAEMON_POKE_INTENT_SCHEMA_VERSION.to_string(),
|
||||
intent_id: intent_id.into(),
|
||||
|
|
@ -3546,6 +3557,8 @@ pub fn epiphany_cultmesh_daemon_poke_intent_from_status(
|
|||
"Daemon poke intent is an operator-safe lifecycle action request, not a private Verse inspection.".to_string(),
|
||||
"The target daemon owns the resulting status; this intent only records the requested poke.".to_string(),
|
||||
],
|
||||
observed_last_heartbeat_utc: status.last_heartbeat_utc.clone(),
|
||||
requested_at_utc,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3556,6 +3569,7 @@ pub fn epiphany_cultmesh_daemon_poke_receipt_for_intent(
|
|||
resulting_status: impl Into<String>,
|
||||
operator_artifact_ref: impl Into<String>,
|
||||
) -> EpiphanyCultMeshDaemonPokeReceiptEntry {
|
||||
let completed_at_utc = Utc::now().to_rfc3339();
|
||||
EpiphanyCultMeshDaemonPokeReceiptEntry {
|
||||
schema_version: EPIPHANY_CULTMESH_DAEMON_POKE_RECEIPT_SCHEMA_VERSION.to_string(),
|
||||
receipt_id: receipt_id.into(),
|
||||
|
|
@ -3571,6 +3585,8 @@ pub fn epiphany_cultmesh_daemon_poke_receipt_for_intent(
|
|||
"Daemon poke receipt records lifecycle intervention proof without exposing private daemon state.".to_string(),
|
||||
"Follow-up daemon status documents remain the liveness authority.".to_string(),
|
||||
],
|
||||
attempted_at_utc: intent.requested_at_utc.clone(),
|
||||
completed_at_utc,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3580,12 +3596,17 @@ pub fn write_epiphany_cultmesh_daemon_poke_intent(
|
|||
intent: EpiphanyCultMeshDaemonPokeIntentEntry,
|
||||
) -> Result<EpiphanyCultMeshDaemonPokeIntentEntry> {
|
||||
validate_daemon_poke_intent(&intent)?;
|
||||
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 intent_key = epiphany_cultmesh_daemon_poke_intent_key(&intent.intent_id);
|
||||
let written = node.put(intent_key.as_str(), &intent)?;
|
||||
node.put(EPIPHANY_CULTMESH_DAEMON_POKE_INTENT_LATEST_KEY, &written)?;
|
||||
node.flush()?;
|
||||
Ok(written)
|
||||
put_immutable_cultmesh_entry_and_advance_latest(
|
||||
&node,
|
||||
store_path,
|
||||
&intent_key,
|
||||
EPIPHANY_CULTMESH_DAEMON_POKE_INTENT_LATEST_KEY,
|
||||
&intent,
|
||||
|entry| &entry.requested_at_utc,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn write_epiphany_cultmesh_daemon_poke_receipt(
|
||||
|
|
@ -3594,12 +3615,94 @@ pub fn write_epiphany_cultmesh_daemon_poke_receipt(
|
|||
receipt: EpiphanyCultMeshDaemonPokeReceiptEntry,
|
||||
) -> Result<EpiphanyCultMeshDaemonPokeReceiptEntry> {
|
||||
validate_daemon_poke_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_poke_receipt_key(&receipt.receipt_id);
|
||||
let written = node.put(receipt_key.as_str(), &receipt)?;
|
||||
node.put(EPIPHANY_CULTMESH_DAEMON_POKE_RECEIPT_LATEST_KEY, &written)?;
|
||||
node.flush()?;
|
||||
Ok(written)
|
||||
put_immutable_cultmesh_entry_and_advance_latest(
|
||||
&node,
|
||||
store_path,
|
||||
&receipt_key,
|
||||
EPIPHANY_CULTMESH_DAEMON_POKE_RECEIPT_LATEST_KEY,
|
||||
&receipt,
|
||||
|entry| &entry.completed_at_utc,
|
||||
)
|
||||
}
|
||||
|
||||
fn put_immutable_cultmesh_entry_and_advance_latest<T, F>(
|
||||
node: &CultMeshNode,
|
||||
store_path: &Path,
|
||||
identity_key: &str,
|
||||
latest_key: &str,
|
||||
value: &T,
|
||||
event_time: F,
|
||||
) -> Result<T>
|
||||
where
|
||||
T: DatabaseEntry + Clone + PartialEq,
|
||||
F: Fn(&T) -> &str,
|
||||
{
|
||||
let existing = node.get::<T>(identity_key)?;
|
||||
if existing.as_ref().is_some_and(|current| current != value) {
|
||||
return Err(anyhow!(
|
||||
"immutable CultMesh identity collision for type {:?} key {:?}",
|
||||
T::TYPE,
|
||||
identity_key
|
||||
));
|
||||
}
|
||||
let candidate_time = DateTime::parse_from_rfc3339(event_time(value))
|
||||
.context("immutable CultMesh event requires RFC3339 ordering time")?;
|
||||
let latest = node.get::<T>(latest_key)?;
|
||||
let advances_latest = match latest.as_ref() {
|
||||
Some(current) => {
|
||||
candidate_time
|
||||
> DateTime::parse_from_rfc3339(event_time(current))
|
||||
.context("persisted immutable CultMesh event has invalid ordering time")?
|
||||
}
|
||||
None => true,
|
||||
};
|
||||
if existing.is_some() && !advances_latest {
|
||||
return Ok(existing.expect("existing checked"));
|
||||
}
|
||||
|
||||
let mut expected = Vec::new();
|
||||
if advances_latest && let Some(envelope) = node.cache().get_envelope::<T>(latest_key)? {
|
||||
expected.push(envelope);
|
||||
}
|
||||
let mut replacements = Vec::new();
|
||||
if existing.is_none() {
|
||||
replacements.push(node.cache().prepare_entry(identity_key, value)?.0);
|
||||
}
|
||||
if advances_latest {
|
||||
replacements.push(node.cache().prepare_entry(latest_key, value)?.0);
|
||||
}
|
||||
let backing = SingleFileMessagePackBackingStore::new(store_path);
|
||||
if backing.compare_and_swap_batch(&expected, replacements)? {
|
||||
return Ok(value.clone());
|
||||
}
|
||||
let refreshed = open_epiphany_cultmesh_node(store_path, node.runtime_id())?;
|
||||
match refreshed.get::<T>(identity_key)? {
|
||||
Some(current)
|
||||
if current == *value
|
||||
&& refreshed
|
||||
.get::<T>(latest_key)?
|
||||
.as_ref()
|
||||
.is_some_and(|latest| {
|
||||
DateTime::parse_from_rfc3339(event_time(latest)).ok()
|
||||
>= Some(candidate_time)
|
||||
}) =>
|
||||
{
|
||||
Ok(current)
|
||||
}
|
||||
Some(_) => Err(anyhow!(
|
||||
"immutable CultMesh identity collision for type {:?} key {:?}",
|
||||
T::TYPE,
|
||||
identity_key
|
||||
)),
|
||||
None => Err(anyhow!(
|
||||
"immutable CultMesh write lost compare-and-swap for type {:?} key {:?}",
|
||||
T::TYPE,
|
||||
identity_key
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_latest_epiphany_cultmesh_daemon_poke_intent(
|
||||
|
|
@ -4008,6 +4111,16 @@ fn validate_daemon_poke_intent(intent: &EpiphanyCultMeshDaemonPokeIntentEntry) -
|
|||
if intent.reason.trim().is_empty() {
|
||||
return Err(anyhow!("daemon poke intents require a reason"));
|
||||
}
|
||||
for (label, value) in [
|
||||
(
|
||||
"observed provider heartbeat",
|
||||
intent.observed_last_heartbeat_utc.as_str(),
|
||||
),
|
||||
("request timestamp", intent.requested_at_utc.as_str()),
|
||||
] {
|
||||
DateTime::parse_from_rfc3339(value)
|
||||
.with_context(|| format!("daemon poke intent requires RFC3339 {label}"))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -4028,6 +4141,15 @@ fn validate_daemon_poke_receipt(receipt: &EpiphanyCultMeshDaemonPokeReceiptEntry
|
|||
if receipt.status.trim().is_empty() || receipt.resulting_status.trim().is_empty() {
|
||||
return Err(anyhow!("daemon poke receipts require status results"));
|
||||
}
|
||||
let attempted = DateTime::parse_from_rfc3339(&receipt.attempted_at_utc)
|
||||
.context("daemon poke receipt requires RFC3339 attempt timestamp")?;
|
||||
let completed = DateTime::parse_from_rfc3339(&receipt.completed_at_utc)
|
||||
.context("daemon poke receipt requires RFC3339 completion timestamp")?;
|
||||
if completed < attempted {
|
||||
return Err(anyhow!(
|
||||
"daemon poke receipt completion cannot precede its attempt"
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -8489,15 +8611,54 @@ mod tests {
|
|||
|
||||
write_epiphany_cultmesh_daemon_poke_intent(&store, "epiphany-test", intent.clone())?;
|
||||
write_epiphany_cultmesh_daemon_poke_receipt(&store, "epiphany-test", receipt.clone())?;
|
||||
assert_eq!(
|
||||
write_epiphany_cultmesh_daemon_poke_intent(&store, "epiphany-test", intent.clone())?,
|
||||
intent
|
||||
);
|
||||
assert_eq!(
|
||||
write_epiphany_cultmesh_daemon_poke_receipt(&store, "epiphany-test", receipt.clone())?,
|
||||
receipt
|
||||
);
|
||||
|
||||
let mut colliding_intent = intent.clone();
|
||||
colliding_intent.reason = "counterfeit replacement".to_string();
|
||||
let error =
|
||||
write_epiphany_cultmesh_daemon_poke_intent(&store, "epiphany-test", colliding_intent)
|
||||
.expect_err("non-identical intent identity collision must be refused");
|
||||
assert!(error.to_string().contains("identity collision"));
|
||||
|
||||
let mut colliding_receipt = receipt.clone();
|
||||
colliding_receipt.resulting_status = "counterfeit-ready".to_string();
|
||||
let error =
|
||||
write_epiphany_cultmesh_daemon_poke_receipt(&store, "epiphany-test", colliding_receipt)
|
||||
.expect_err("non-identical receipt identity collision must be refused");
|
||||
assert!(error.to_string().contains("identity collision"));
|
||||
|
||||
let mut newer_intent = intent.clone();
|
||||
newer_intent.intent_id = "daemon-poke-intent-newer".to_string();
|
||||
newer_intent.requested_at_utc = "2099-06-17T00:02:00Z".to_string();
|
||||
let mut newer_receipt = receipt.clone();
|
||||
newer_receipt.receipt_id = "daemon-poke-receipt-newer".to_string();
|
||||
newer_receipt.intent_id = newer_intent.intent_id.clone();
|
||||
newer_receipt.attempted_at_utc = "2099-06-17T00:02:00Z".to_string();
|
||||
newer_receipt.completed_at_utc = "2099-06-17T00:03:00Z".to_string();
|
||||
write_epiphany_cultmesh_daemon_poke_intent(&store, "epiphany-test", newer_intent.clone())?;
|
||||
write_epiphany_cultmesh_daemon_poke_receipt(
|
||||
&store,
|
||||
"epiphany-test",
|
||||
newer_receipt.clone(),
|
||||
)?;
|
||||
write_epiphany_cultmesh_daemon_poke_intent(&store, "epiphany-test", intent.clone())?;
|
||||
write_epiphany_cultmesh_daemon_poke_receipt(&store, "epiphany-test", receipt.clone())?;
|
||||
assert_eq!(
|
||||
load_latest_epiphany_cultmesh_daemon_poke_intent(&store, "epiphany-test")?,
|
||||
Some(intent.clone())
|
||||
Some(newer_intent)
|
||||
);
|
||||
assert_eq!(
|
||||
load_latest_epiphany_cultmesh_daemon_poke_receipt(&store, "epiphany-test")?,
|
||||
Some(receipt)
|
||||
Some(newer_receipt)
|
||||
);
|
||||
|
||||
let context = query_epiphany_local_verse_context(&store, "epiphany-test")?;
|
||||
assert_eq!(
|
||||
context
|
||||
|
|
|
|||
|
|
@ -37,13 +37,16 @@
|
|||
- Dependent invariant: collaboration feedback may cite only a persisted provider receipt; a consumer request is not acceptance.
|
||||
- Negative proof: provider receipt remains absent after request, response-shaped fields fail, and feedback without provider acceptance fails.
|
||||
|
||||
## Daemon lifecycle request and heartbeat paths (2026-07-12)
|
||||
## Daemon lifecycle request and heartbeat paths (updated 2026-07-15)
|
||||
|
||||
- Request owner: Self/operator owns a daemon-poke intent; Idunn or the target daemon owns its receipt and resulting status.
|
||||
- Poke output: pending intent with observed status and null receipt/result fields, shared by single, batch, and triage paths.
|
||||
- Forbidden writers: poke callers cannot provide receipt id/status, resulting status, or artifact; the generic Verse CLI daemon-status writer no longer exists.
|
||||
- Heartbeat owner: `epiphany-cluster-daemon` writes status. On its first run it derives identity/routing fields from persisted topology and authors the first heartbeat itself.
|
||||
- Negative proof: a real provider heartbeat can precede a pending poke; no poke receipt appears, counterfeit `ready` result is rejected, and `set-daemon-status` is unavailable.
|
||||
- Owners: Self/operator requests intervention; Idunn owns poke intent, command-attempt receipt, restart policy, and backoff; `epiphany-cluster-daemon` alone owns its provider heartbeat/status envelope.
|
||||
- Inputs: persisted provider status, the heartbeat observed before intervention, restart policy, scheduler staleness observation, and the real command result.
|
||||
- Outputs: immutable poke intent/receipt v1 events plus an atomically advanced chronological latest pointer. Exit zero yields `awaiting-provider-heartbeat`; command failure yields `restart-failed`.
|
||||
- Derived state: scheduler staleness, lifecycle attention, receipt-directory resolution, and Idunn backoff are observations of provider state and attempts. They are not provider status.
|
||||
- Forbidden writers: poke callers and the supervisor cannot assign provider status, operator action, or `last_heartbeat_utc`; command success cannot mint `ready`; stale status cannot be resolved by a heartbeat older than the completed attempt.
|
||||
- Shared paths: manual reconcile and scheduled reconciliation use the same attempt primitive. Both retain restart pressure until a provider-authored heartbeat causally newer than the completed attempt proves recovery.
|
||||
- Cut line: the supervisor's provider-status writer and synthetic heartbeat advancement are removed. Generated attempts use unique identities; exact retry is idempotent, identity collision is refused, and delayed replay cannot rewind `latest`.
|
||||
- Verification: the survival rehearsal preserves the provider envelope across two successful restart commands, observes two distinct awaiting receipts, then publishes a real provider heartbeat and proves receipt resolution plus failure-count reset.
|
||||
|
||||
## Persona feedback and Imagination consensus boundary (2026-07-12)
|
||||
|
||||
|
|
|
|||
|
|
@ -1169,3 +1169,28 @@ Next: cut Idunn supervisor writes to provider-owned daemon heartbeat/status;
|
|||
then publish derived semantic health through CultMesh and add typed Idunn
|
||||
executor/recovery authority plus open-obligation discovery. Recovery remains
|
||||
withheld until that authority exists.
|
||||
|
||||
## Idunn/provider-status ownership cut (2026-07-15)
|
||||
|
||||
The supervisor no longer writes provider heartbeat/status. Idunn owns only
|
||||
staleness observation, immutable poke intent/receipt events, restart command
|
||||
execution, policy, and backoff. The target `epiphany-cluster-daemon` remains the
|
||||
sole production owner of its status, operator action, and heartbeat timestamp.
|
||||
Command exit zero now records `awaiting-provider-heartbeat`, never `ready`, and
|
||||
restart pressure remains until a provider heartbeat newer than the completed
|
||||
attempt proves recovery.
|
||||
|
||||
Poke intent/receipt v1 binds the pre-intervention heartbeat and request,
|
||||
attempt, and completion times. Immutable identity and chronological `latest`
|
||||
advance in one CAS: exact retry is idempotent, collision is refused, and late
|
||||
replay cannot rewind sight. Receipt-directory resolution is derived only; it
|
||||
cannot repair provider truth. The bounded survival rehearsal proves two
|
||||
successful restart commands leave the provider envelope unchanged and produce
|
||||
distinct awaiting receipts, then a real provider heartbeat resolves the
|
||||
lifecycle observation and clears restart pressure.
|
||||
|
||||
Next: publish renderer-neutral semantic projection health derived from
|
||||
canonical Mind/Modeling evidence through CultMesh; then 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.
|
||||
|
|
|
|||
|
|
@ -473,20 +473,33 @@ does not invent that grant.
|
|||
### Provider-Status Ownership Cut
|
||||
|
||||
`epiphany-cluster-daemon` is the legitimate production writer of its typed
|
||||
heartbeat/status. The current daemon supervisor contains two obsolete writers
|
||||
that must be removed before its liveness model is trusted:
|
||||
heartbeat/status. Idunn records stale observation, command execution, restart,
|
||||
and awaiting-provider-heartbeat in scheduler/poke/recovery state without
|
||||
rewriting provider status, operator action, or heartbeat time. A restarted
|
||||
provider becomes ready only when that provider publishes a newer authentic
|
||||
heartbeat; synthetic provider writers remain confined to test/quarantine
|
||||
bodies.
|
||||
|
||||
- scheduler staleness handling rewrites the provider status to `degraded` and
|
||||
adds a supervisor-authored heartbeat note;
|
||||
- restart reconciliation rewrites provider status to `ready` or `down` and
|
||||
advances `last_heartbeat_utc` from the child command's exit result.
|
||||
|
||||
Idunn should instead record stale observation, command execution, restart, and
|
||||
awaiting-provider-heartbeat in its own scheduler/poke/recovery receipts. A
|
||||
restarted provider becomes ready only when that provider publishes a newer
|
||||
authentic heartbeat. The generic daemon-status writer should be narrowed so
|
||||
production callers cannot counterfeit provider liveness; synthetic writers
|
||||
remain confined to test/quarantine bodies.
|
||||
This ownership cut is now landed. Scheduler staleness forces Idunn
|
||||
reconciliation without changing the provider envelope. Command success records
|
||||
`awaiting-provider-heartbeat`; failure records `restart-failed`. The persisted
|
||||
poke intent binds the observed stale heartbeat and configured threshold, while
|
||||
provider status, operator action, and `last_heartbeat_utc` remain unchanged.
|
||||
Only a later provider-authored heartbeat can establish readiness.
|
||||
Poke intent/receipt v1 binds the heartbeat observed before intervention and the
|
||||
attempt/completion timestamps. Receipt-directory sight resolves
|
||||
`awaiting-provider-heartbeat` only when the same provider publishes a heartbeat
|
||||
newer than both that observation and the completed attempt. Command attempts
|
||||
increase restart backoff pressure regardless of exit code; a causally newer
|
||||
provider heartbeat is the sole event that clears the failure count. The bounded
|
||||
survival rehearsal proves the provider envelope remains unchanged across two
|
||||
successful restart commands while the lifecycle receipt remains awaiting,
|
||||
then publishes a real provider heartbeat and proves the receipt resolves and
|
||||
restart pressure resets.
|
||||
Generated supervisor attempts use unique intent identities and receipt identity
|
||||
derives from the intent. Identity plus latest-pointer publication is one CAS:
|
||||
non-identical reuse is refused, exact retry is idempotent, and a delayed retry
|
||||
cannot rewind the latest lifecycle observation.
|
||||
|
||||
### Shared Paths And Verification Layer
|
||||
|
||||
|
|
|
|||
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, and exact query gate. Mind and Modeling now emit canonical obligations; live `gamecult.epiphany.main` projections are isolated in Qdrant by obligation, claim, and epoch, and readiness authenticates the complete succeeded claim/attempt/receipt chain. First cut Idunn supervisor writes to provider-owned daemon heartbeat/status. Then publish provider-owned derived pending/failed/stale/ready health through CultMesh, 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, and provider-status ownership cut. 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. Idunn now 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 publish renderer-neutral derived pending/failed/stale/ready health through CultMesh, 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.
|
||||
|
|
|
|||
Reference in a new issue