Guard Idunn service health readback

This commit is contained in:
Meta Vens 2026-06-19 01:52:20 +01:00
commit eff4a21267
4 changed files with 112 additions and 45 deletions

View file

@ -2612,6 +2612,26 @@ fn run_cli() -> Result<()> {
},
)?;
let service_overview = load_swarm_overview_report(&args)?;
let (service_health_readback, service_health_private_state_exposed) =
service_health_readback_from_idunn(&args)?;
let service_health_action_rows = service_health_readback["serviceActionRows"]
.as_array()
.context("service-health readback lost service action rows")?;
let service_health_action_tui_rows = service_health_readback["serviceActionTuiRows"]
.as_array()
.context("service-health readback lost service action TUI rows")?;
let service_health_diagnostic = format!(
"status={:?}, mode={:?}, command={:?}, attention={:?}, failed={:?}, missing={:?}, actions={}, privateHelper={}, privateJson={:?}",
service_health_readback["status"].as_str(),
service_health_readback["recommendedWrapperMode"].as_str(),
service_health_readback["recommendedWrapperCommand"].as_str(),
service_health_readback["serviceLifecycleAttentionCount"].as_u64(),
service_health_readback["serviceExecutionFailedCheckCount"].as_u64(),
service_health_readback["serviceExecutionMissingCheckCount"].as_u64(),
service_health_action_rows.len(),
service_health_private_state_exposed,
service_health_readback["privateStateExposed"].as_bool(),
);
let service_receipt_directory = {
let context =
query_epiphany_local_verse_context(&args.store, args.runtime_id.clone())?;
@ -2853,9 +2873,52 @@ fn run_cli() -> Result<()> {
)
&& row.contains("followUp=tools/epiphany_local_run.ps1 -Mode service-execution-readiness")
})
|| service_health_readback["status"].as_str() != Some("attention")
|| service_health_readback["recommendedWrapperMode"].as_str()
!= Some("cluster-service-execution-audit")
|| service_health_readback["recommendedWrapperCommand"].as_str()
!= Some(WRAPPER_CLUSTER_SERVICE_EXECUTION_AUDIT_COMMAND)
|| service_health_readback["serviceLifecycleAttentionCount"].as_u64() != Some(2)
|| service_health_readback["serviceExecutionFailedCheckCount"].as_u64()
!= Some(11)
|| service_health_readback["serviceExecutionMissingCheckCount"].as_u64()
!= Some(10)
|| service_health_action_rows.len() != 4
|| service_health_private_state_exposed
|| service_health_readback["privateStateExposed"].as_bool() != Some(false)
|| !service_health_action_rows.iter().any(|row| {
row["family"].as_str() == Some("service-lifecycle")
&& row["lifecycleOwner"].as_str() == Some(SERVICE_LIFECYCLE_OWNER)
&& row["hostedBody"].as_str() == Some(SERVICE_LIFECYCLE_HOSTED_BODY)
&& row["effectClass"].as_str() == Some("service-lifecycle-readback")
&& row["mutatesState"].as_bool() == Some(false)
&& row["requiresElevatedAuthority"].as_bool() == Some(false)
&& row["serviceExecutionFailedCheckCount"].as_u64() == Some(5)
&& row["privateStateExposed"].as_bool() == Some(false)
})
|| !service_health_action_rows.iter().any(|row| {
row["family"].as_str() == Some("service-execution-authority")
&& row["lifecycleOwner"].as_str() == Some(SERVICE_LIFECYCLE_OWNER)
&& row["hostedBody"].as_str() == Some(SERVICE_LIFECYCLE_HOSTED_BODY)
&& row["effectClass"].as_str() == Some("elevated-service-control")
&& row["mutatesState"].as_bool() == Some(true)
&& row["requiresElevatedAuthority"].as_bool() == Some(true)
&& row["operatorAftercareCommand"].as_str()
== Some(WRAPPER_CLUSTER_SERVICE_EXECUTION_AUDIT_COMMAND)
&& row["serviceExecutionFailedCheckCount"].as_u64() == Some(5)
&& row["privateStateExposed"].as_bool() == Some(false)
})
|| !service_health_action_tui_rows.iter().any(|row| {
row.as_str().is_some_and(|row| {
row.contains("service-lifecycle")
&& row.contains("owner=Idunn")
&& row.contains("hostedBody=Epiphany")
&& row.contains("failedChecks=5")
})
})
{
anyhow::bail!(
"local Verse query smoke did not expose sealed service lifecycle readback plus cluster and service execution failed-check anatomy"
"local Verse query smoke did not expose sealed Idunn-owned service lifecycle readback plus service-health payload anatomy: {service_health_diagnostic}"
);
}
let readiness_follow_up_receipt = EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry {
@ -6040,48 +6103,7 @@ fn run_invoke_tool_command(args: &Args) -> Result<()> {
.unwrap_or(host_cluster_from_directory);
let (service_health_readback, service_health_readback_private_state_exposed) =
if is_service_health_capability(capability) {
let overview = load_swarm_overview_report(args)?;
let service_action_rows = overview
.swarm_action_rows
.iter()
.filter(|row| {
row.family == "service-lifecycle" || row.family == "service-execution-authority"
})
.cloned()
.collect::<Vec<_>>();
let service_action_tui_rows = service_action_rows
.iter()
.map(swarm_action_tui_row)
.collect::<Vec<_>>();
let private_state_exposed = overview
.service_lifecycle_attention_rows
.iter()
.any(|row| row.private_state_exposed)
|| overview
.service_execution_failed_check_rows
.iter()
.any(|check| !check.private_state_sealed)
|| service_action_rows
.iter()
.any(|row| row.private_state_exposed);
(
json!({
"status": overview.recovery_status,
"recommendedWrapperMode": overview.service_lifecycle_recommended_wrapper_mode,
"recommendedWrapperCommand": overview.service_lifecycle_recommended_wrapper_command,
"serviceLifecycleAttentionCount": overview.service_lifecycle_attention_rows.len(),
"serviceLifecycleAttentionRows": overview.service_lifecycle_attention_rows,
"serviceLifecycleAttentionTuiRows": overview.service_lifecycle_attention_tui_rows,
"serviceExecutionFailedCheckCount": overview.service_execution_failed_check_count,
"serviceExecutionMissingCheckCount": overview.service_execution_missing_check_count,
"serviceExecutionFailedCheckRows": overview.service_execution_failed_check_rows,
"serviceExecutionFailedCheckTuiRows": overview.service_execution_failed_check_tui_rows,
"serviceActionRows": service_action_rows,
"serviceActionTuiRows": service_action_tui_rows,
"privateStateExposed": private_state_exposed,
}),
private_state_exposed,
)
service_health_readback_from_idunn(args)?
} else {
(serde_json::Value::Null, false)
};
@ -6160,6 +6182,51 @@ fn default_daemon_tool_receipt_status(
}
}
fn service_health_readback_from_idunn(args: &Args) -> Result<(serde_json::Value, bool)> {
let overview = load_swarm_overview_report(args)?;
let service_action_rows = overview
.swarm_action_rows
.iter()
.filter(|row| {
row.family == "service-lifecycle" || row.family == "service-execution-authority"
})
.cloned()
.collect::<Vec<_>>();
let service_action_tui_rows = service_action_rows
.iter()
.map(swarm_action_tui_row)
.collect::<Vec<_>>();
let private_state_exposed = overview
.service_lifecycle_attention_rows
.iter()
.any(|row| row.private_state_exposed)
|| overview
.service_execution_failed_check_rows
.iter()
.any(|check| !check.private_state_sealed)
|| service_action_rows
.iter()
.any(|row| row.private_state_exposed);
Ok((
json!({
"status": overview.recovery_status,
"recommendedWrapperMode": overview.service_lifecycle_recommended_wrapper_mode,
"recommendedWrapperCommand": overview.service_lifecycle_recommended_wrapper_command,
"serviceLifecycleAttentionCount": overview.service_lifecycle_attention_rows.len(),
"serviceLifecycleAttentionRows": overview.service_lifecycle_attention_rows,
"serviceLifecycleAttentionTuiRows": overview.service_lifecycle_attention_tui_rows,
"serviceExecutionFailedCheckCount": overview.service_execution_failed_check_count,
"serviceExecutionMissingCheckCount": overview.service_execution_missing_check_count,
"serviceExecutionFailedCheckRows": overview.service_execution_failed_check_rows,
"serviceExecutionFailedCheckTuiRows": overview.service_execution_failed_check_tui_rows,
"serviceActionRows": service_action_rows,
"serviceActionTuiRows": service_action_tui_rows,
"privateStateExposed": private_state_exposed,
}),
private_state_exposed,
))
}
fn default_daemon_tool_result_ref(
capability: &EpiphanyCultMeshDaemonToolCapabilityEntry,
receipt_id: &str,

File diff suppressed because one or more lines are too long

Binary file not shown.

View file

@ -123,7 +123,7 @@ active_subgoals:
accepted_design:
- Distributed Epiphany dreaming is a CultMesh typed-document problem, not prompt folklore. CultCache owns local typed documents, Epiphany owns export/import/adoption policy, CultNet owns wire/provenance/shard delivery, and CultMesh owns Verses, peer exchange, leases, shard logs, replicas, and watchable runtime surfaces. Start with local dream document types and a local store before public Verse wiring.
- The local CultMesh daemon tool directory now has both discovery and invocation receipts at the operator edge. `epiphany-verse-query tools` lists globally available, receipt-gated daemon capabilities; `epiphany-verse-query invoke-tool --capability-id <id>` records `epiphany.cultmesh.daemon_tool_invocation_intent.v0` plus `epiphany.cultmesh.daemon_tool_invocation_receipt.v0` from the advertised capability, reports requesting/host display names, body domains, private Verse ids, and Eve surfaces from cluster topology, and refuses when the host daemon is not ready. `tools/epiphany_local_run.ps1 -Mode tool-invoke` wraps the same path with explicit requester/capability/intent/receipt parameters; wrapper proof routed Persona to Hands `repo-action` and returned `availableToAllAgents=true`, `requiresReceipt=true`, and `privateStateExposed=false`. Tool availability is global across local agents, but execution and authority remain with the hosting daemon and its typed receipt contract. The Self-hosted `service-health` tool now embeds `serviceHealthReadback` in the invocation result instead of only pointing at receipt-directory: live wrapper proof `local-20260619-013750-366-f5ad69b0` returned status `attention`, two service lifecycle attention rows, four service action rows, eleven failed checks, zero missing checks, and no private-state exposure.
- The local CultMesh daemon tool directory now has both discovery and invocation receipts at the operator edge. `epiphany-verse-query tools` lists globally available, receipt-gated daemon capabilities; `epiphany-verse-query invoke-tool --capability-id <id>` records `epiphany.cultmesh.daemon_tool_invocation_intent.v0` plus `epiphany.cultmesh.daemon_tool_invocation_receipt.v0` from the advertised capability, reports requesting/host display names, body domains, private Verse ids, and Eve surfaces from cluster topology, and refuses when the host daemon is not ready. `tools/epiphany_local_run.ps1 -Mode tool-invoke` wraps the same path with explicit requester/capability/intent/receipt parameters; wrapper proof routed Persona to Hands `repo-action` and returned `availableToAllAgents=true`, `requiresReceipt=true`, and `privateStateExposed=false`. Tool availability is global across local agents, but execution and authority remain with the hosting daemon and its typed receipt contract. The Self-hosted `service-health` tool now embeds `serviceHealthReadback` in the invocation result instead of only pointing at receipt-directory: live wrapper proof `local-20260619-013750-366-f5ad69b0` returned status `attention`, two service lifecycle attention rows, four service action rows, eleven failed checks, zero missing checks, and no private-state exposure. Production invocation and source smoke now share `service_health_readback_from_idunn`, and the smoke rejects payloads that lose Idunn ownership, service lifecycle/action rows, failed-check anatomy, or the private-state seal.
- The local Verse swarm brake is now operator-writable from the same CLI surface and enforced at the main local wrapper plus direct coordinator/heartbeat runner edges. `epiphany-verse-query swarm-brake --brake-status engaged|released` writes the typed `epiphany.cultmesh.swarm_brake.v0` document with scope, reason, operator id, affected clusters, protected surfaces, expiry, and private-state seal. `tools/epiphany_local_run.ps1` queries that document before live `plan`, `run`, or `mvp` work and fails closed when engaged; `status` remains readable. `epiphany-mvp-coordinator --local-verse-store <path>` refuses before app-server startup when the brake is engaged, and `epiphany-heartbeat-store tick|pump|heat|queue-mention|routine --local-verse-store <path>` refuses heartbeat-driving work while leaving init/status/complete/repair-stale outside that live-run brake.
- The first Rust CultMesh integration slice is landed and repaired to compile from repo-contained vendored crates. `vendor/cultmesh-rs` is a small Rust node/database facade over vendored CultCache and CultNet with document-set registration and durable typed put/get/delete. `vendor/cultcache-rs` now reads and writes the `cultcache.store.v1` snapshot format used by `state/ledgers.msgpack`, so `epiphany-state status` is a working re-entry rite again. `epiphany-core` depends on `vendor/cultcache-rs`, `vendor/cultnet-rs`, and `vendor/cultmesh-rs`, exposes an `EpiphanyCultMeshStatusEntry`, records typed `EpiphanyCultMeshVersePolicyEntry` documents for the internal/local-area/global Verse tiers, and records typed `EpiphanyCultMeshGlobalRoomPolicyEntry` documents for threaded public global rooms such as dreams, architecture, research, Personas, GameCult, and governance. Native operator status is now a typed `EpiphanyCultMeshOperatorStatusEntry` in the internal Verse; it names Codex as bridge transport, Epiphany as authority owner, prompt-authority separation, and the quarantined Rider/Unity optional surfaces. Native operator snapshots are typed `EpiphanyCultMeshOperatorSnapshotEntry` documents distilled from operator-safe status artifacts; local status runs write operator run intent, operator snapshot, and run receipt into `.epiphany-run/cultmesh/local-verse.ccmp`, leaving JSON artifacts as display/evidence rather than the local-run read authority.
- Mind's CultNet contract surface is native enough for the next Aquarium/CultMesh cut: `epiphany-core::mind_gateway` defines thought, state-effect proposal, gateway-review, commit-receipt, rejection-receipt, and Verse-adoption document contracts; runtime-spine advertises those mutation/read contracts; CultMesh persists matching `EpiphanyCultMeshMindContractEntry` policy documents so the private state guardian boundary is inspectable as typed state.