diff --git a/epiphany-core/src/bin/epiphany-cluster-daemon.rs b/epiphany-core/src/bin/epiphany-cluster-daemon.rs index 6b4bbec4..0c62f36d 100644 --- a/epiphany-core/src/bin/epiphany-cluster-daemon.rs +++ b/epiphany-core/src/bin/epiphany-cluster-daemon.rs @@ -1,10 +1,12 @@ use anyhow::Context; use anyhow::Result; use chrono::Utc; -use epiphany_core::EpiphanyCultMeshDaemonStatusEntry; +use epiphany_core::load_epiphany_cultmesh_cluster_topology; use epiphany_core::query_epiphany_local_verse_context; use epiphany_core::seed_epiphany_local_verse_context; use epiphany_core::write_epiphany_cultmesh_daemon_status; +use epiphany_core::EpiphanyCultMeshDaemonStatusEntry; +use epiphany_core::EPIPHANY_CULTMESH_DAEMON_STATUS_SCHEMA_VERSION; use serde_json::json; use std::env; use std::path::PathBuf; @@ -48,12 +50,32 @@ fn write_heartbeat(args: &Args, iteration: u64) -> Result Result<()> { ); } "poke-daemon" | "daemon-poke" => { + reject_daemon_poke_response_fields(&args)?; seed_epiphany_local_verse_context( &args.store, args.runtime_id.clone(), @@ -666,43 +667,21 @@ fn run_cli() -> Result<()> { .collect::() ) }); - let receipt_id = args - .receipt_id - .clone() - .unwrap_or_else(|| intent_id.replace("intent", "receipt")); - let resulting_status = args - .resulting_status - .clone() - .unwrap_or_else(|| daemon_status.status.clone()); - let receipt_status = args - .receipt_status - .clone() - .unwrap_or_else(|| "recorded".to_string()); - let artifact_ref = args - .artifact_ref - .clone() - .unwrap_or_else(|| format!("cultmesh://epiphany-local/daemon-poke/{intent_id}")); - let poke_result = write_daemon_poke_receipts( + let poke_result = write_daemon_poke_intent( &args, &context, daemon_status, intent_id, - receipt_id, reason, - resulting_status, - receipt_status, - artifact_ref, )?; let context = query_epiphany_local_verse_context(&args.store, args.runtime_id.clone())?; - if context.latest_daemon_poke_intent.is_none() - || context.latest_daemon_poke_receipt.is_none() - { - anyhow::bail!("local Verse query lost daemon poke intent/receipt after write"); + if context.latest_daemon_poke_intent.is_none() { + anyhow::bail!("local Verse query lost daemon poke intent after write"); } println!( "{}", serde_json::to_string_pretty(&json!({ - "status": "ok", + "status": "pending-lifecycle-owner", "store": args.store, "runtimeId": context.runtime_id, "targetDaemonId": poke_result["targetDaemonId"], @@ -712,29 +691,31 @@ fn run_cli() -> Result<()> { "receiptId": poke_result["receiptId"], "receiptStatus": poke_result["receiptStatus"], "resultingStatus": poke_result["resultingStatus"], + "responseOwner": poke_result["responseOwner"], "privateStateRequested": poke_result["privateStateRequested"], "privateStateExposed": poke_result["privateStateExposed"], }))? ); } "poke-down-daemons" | "poke-unready-daemons" | "daemon-poke-down" => { + reject_daemon_poke_response_fields(&args)?; seed_epiphany_local_verse_context( &args.store, args.runtime_id.clone(), Utc::now().to_rfc3339(), )?; let context = query_epiphany_local_verse_context(&args.store, args.runtime_id.clone())?; - let pokes = write_poke_receipts_for_non_ready_daemons(&args, &context)?; + let pokes = write_poke_intents_for_non_ready_daemons(&args, &context)?; let poke_tui_rows = pokes.iter().map(poke_result_tui_row).collect::>(); let context = query_epiphany_local_verse_context(&args.store, args.runtime_id.clone())?; println!( "{}", serde_json::to_string_pretty(&json!({ - "status": if pokes.is_empty() { "noop" } else { "ok" }, + "status": if pokes.is_empty() { "noop" } else { "pending-lifecycle-owner" }, "store": args.store, "runtimeId": context.runtime_id, "observedDaemonCount": context.daemon_statuses.len(), - "pokedDaemonCount": pokes.len(), + "requestedDaemonCount": pokes.len(), "pokes": pokes, "pokeRows": poke_tui_rows, "tuiRows": poke_tui_rows, @@ -864,77 +845,12 @@ fn run_cli() -> Result<()> { } else { let context = query_epiphany_local_verse_context(&args.store, args.runtime_id.clone())?; - write_poke_receipts_for_non_ready_daemons(&args, &context)? + write_poke_intents_for_non_ready_daemons(&args, &context)? }; let output = SwarmTriageOutput::from_report(args.store, args.runtime_id, overview, pokes); println!("{}", serde_json::to_string_pretty(&output)?); } - "daemon-status" | "set-daemon-status" => { - seed_epiphany_local_verse_context( - &args.store, - args.runtime_id.clone(), - Utc::now().to_rfc3339(), - )?; - let context = query_epiphany_local_verse_context(&args.store, args.runtime_id.clone())?; - let daemon_id = args - .daemon_id - .as_deref() - .context("daemon-status requires --daemon-id, for example epiphany-daemon-hands")?; - let current = context - .daemon_statuses - .iter() - .find(|status| status.daemon_id == daemon_id) - .with_context(|| format!("local Verse has no daemon status for {daemon_id:?}"))?; - let status = args - .daemon_status - .clone() - .or_else(|| args.resulting_status.clone()) - .unwrap_or_else(|| "ready".to_string()); - let operator_action = args - .operator_action - .clone() - .or_else(|| args.requested_action.clone()) - .unwrap_or_else(|| { - if status == "ready" { - "none".to_string() - } else { - "pokeDaemon".to_string() - } - }); - let mut next = current.clone(); - next.status = status; - next.last_heartbeat_utc = Utc::now().to_rfc3339(); - next.operator_action = operator_action; - if let Some(reason) = args.reason.clone() { - next.notes.push(format!("Status update reason: {reason}")); - } - let written = - write_epiphany_cultmesh_daemon_status(&args.store, args.runtime_id.clone(), next)?; - let context = query_epiphany_local_verse_context(&args.store, args.runtime_id.clone())?; - let projected = context - .daemon_statuses - .iter() - .find(|status| status.daemon_id == written.daemon_id) - .context("local Verse query lost daemon status after write")?; - if projected.status != written.status { - anyhow::bail!("local Verse projected a different daemon status after write"); - } - println!( - "{}", - serde_json::to_string_pretty(&json!({ - "status": "ok", - "store": args.store, - "runtimeId": context.runtime_id, - "daemonId": written.daemon_id, - "clusterId": written.cluster_id, - "daemonStatus": written.status, - "operatorAction": written.operator_action, - "lastHeartbeatUtc": written.last_heartbeat_utc, - "privateStateExposed": written.private_state_exposed, - }))? - ); - } "bifrost-publication" | "publish-body-change" => { if args.receipt_id.is_some() || args.receipt_status.is_some() @@ -2468,7 +2384,7 @@ fn run_cli() -> Result<()> { "local Verse query smoke lost Eve surface readback for globally invokable eve-connect tools" ); } - let no_op_pokes = write_poke_receipts_for_non_ready_daemons(&args, &context)?; + let no_op_pokes = write_poke_intents_for_non_ready_daemons(&args, &context)?; if !no_op_pokes.is_empty() { anyhow::bail!("local Verse query smoke poked ready daemons during no-op sweep"); } @@ -2612,7 +2528,7 @@ fn run_cli() -> Result<()> { "local Verse query smoke degraded overview lost wrapper poke command" ); } - let batch_pokes = write_poke_receipts_for_non_ready_daemons(&args, &context)?; + let batch_pokes = write_poke_intents_for_non_ready_daemons(&args, &context)?; if batch_pokes.len() != 1 { anyhow::bail!( "local Verse query smoke expected exactly one batch daemon poke, got {}", @@ -2666,7 +2582,7 @@ fn run_cli() -> Result<()> { let triage_pokes = if triage_overview.liveness_status == "ready" { Vec::new() } else { - write_poke_receipts_for_non_ready_daemons(&args, &context)? + write_poke_intents_for_non_ready_daemons(&args, &context)? }; if triage_overview.status != "attention" || triage_overview.attention_daemon_ids != vec!["epiphany-daemon-hands".to_string()] @@ -9770,16 +9686,25 @@ fn compact_tui_text(value: &str, max_chars: usize) -> String { + "..." } -fn write_daemon_poke_receipts( +fn reject_daemon_poke_response_fields(args: &Args) -> Result<()> { + if args.receipt_id.is_some() + || args.receipt_status.is_some() + || args.resulting_status.is_some() + || args.artifact_ref.is_some() + { + anyhow::bail!( + "daemon poke commands accept requester intent fields only; the lifecycle owner owns receipt id/status, resulting daemon status, and result artifacts" + ); + } + Ok(()) +} + +fn write_daemon_poke_intent( args: &Args, context: &EpiphanyLocalVerseContext, daemon_status: &EpiphanyCultMeshDaemonStatusEntry, intent_id: String, - receipt_id: String, reason: String, - resulting_status: String, - receipt_status: String, - artifact_ref: String, ) -> Result { assert_swarm_brake_allows_surface( context, @@ -9798,18 +9723,6 @@ fn write_daemon_poke_receipts( args.runtime_id.clone(), poke_intent.clone(), )?; - let poke_receipt = epiphany_cultmesh_daemon_poke_receipt_for_intent( - receipt_id, - &poke_intent, - receipt_status, - resulting_status, - artifact_ref, - ); - let written_receipt = write_epiphany_cultmesh_daemon_poke_receipt( - &args.store, - args.runtime_id.clone(), - poke_receipt, - )?; let cluster = cluster_topology_for_id(context, &written_intent.target_cluster_id)?; Ok(json!({ "targetDaemonId": written_intent.target_daemon_id, @@ -9820,15 +9733,16 @@ fn write_daemon_poke_receipts( "eveSurfaceId": cluster.eve_surface_id.clone(), "observedStatus": written_intent.observed_status, "intentId": written_intent.intent_id, - "receiptId": written_receipt.receipt_id, - "receiptStatus": written_receipt.status, - "resultingStatus": written_receipt.resulting_status, + "receiptId": null, + "receiptStatus": null, + "resultingStatus": null, + "responseOwner": "Idunn/target-daemon", "privateStateRequested": written_intent.private_state_requested, - "privateStateExposed": written_receipt.private_state_exposed, + "privateStateExposed": false, })) } -fn write_poke_receipts_for_non_ready_daemons( +fn write_poke_intents_for_non_ready_daemons( args: &Args, context: &EpiphanyLocalVerseContext, ) -> Result> { @@ -9842,35 +9756,18 @@ fn write_poke_receipts_for_non_ready_daemons( for daemon_status in statuses { let safe_daemon_id = sanitize_id(&daemon_status.daemon_id); let intent_id = format!("daemon-poke-intent-{safe_daemon_id}-{issued_at}"); - let receipt_id = format!("daemon-poke-receipt-{safe_daemon_id}-{issued_at}"); let reason = args.reason.clone().unwrap_or_else(|| { format!( "Operator requested typed lifecycle poke sweep after observing {} status {}.", daemon_status.daemon_id, daemon_status.status ) }); - let resulting_status = args - .resulting_status - .clone() - .unwrap_or_else(|| daemon_status.status.clone()); - let receipt_status = args - .receipt_status - .clone() - .unwrap_or_else(|| "recorded".to_string()); - let artifact_ref = args - .artifact_ref - .clone() - .unwrap_or_else(|| format!("cultmesh://epiphany-local/daemon-poke-sweep/{intent_id}")); - pokes.push(write_daemon_poke_receipts( + pokes.push(write_daemon_poke_intent( args, context, daemon_status, intent_id, - receipt_id, reason, - resulting_status, - receipt_status, - artifact_ref, )?); } Ok(pokes) @@ -10576,8 +10473,6 @@ struct Args { smoke_default_store: bool, agent_store: Option, daemon_id: Option, - daemon_status: Option, - operator_action: Option, capability_id: Option, requesting_agent_id: Option, brake_id: Option, @@ -10637,8 +10532,6 @@ impl Args { let mut runtime_id_overridden = false; let mut agent_store = None; let mut daemon_id = None; - let mut daemon_status = None; - let mut operator_action = None; let mut capability_id = None; let mut requesting_agent_id = None; let mut brake_id = None; @@ -10705,13 +10598,6 @@ impl Args { "--daemon-id" => { daemon_id = Some(values.next().context("missing --daemon-id value")?); } - "--daemon-status" => { - daemon_status = Some(values.next().context("missing --daemon-status value")?); - } - "--operator-action" => { - operator_action = - Some(values.next().context("missing --operator-action value")?); - } "--capability-id" => { capability_id = Some(values.next().context("missing --capability-id value")?); } @@ -10959,8 +10845,6 @@ impl Args { smoke_default_store, agent_store, daemon_id, - daemon_status, - operator_action, capability_id, requesting_agent_id, brake_id, diff --git a/notes/epiphany-current-algorithmic-map.md b/notes/epiphany-current-algorithmic-map.md index 20a494f4..d886f7b5 100644 --- a/notes/epiphany-current-algorithmic-map.md +++ b/notes/epiphany-current-algorithmic-map.md @@ -37,6 +37,14 @@ - 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) + +- 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. + This is the source-grounded map of the live machine. Historical route and bridge anatomy belongs in git history and evidence ledgers, not here. diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 1c764eac..99011c62 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -16,6 +16,10 @@ The conceptual-substitution audit found observation manufacturing the body it cl `connect-eve` and wrapper mode `eve-connect` now persist only `epiphany.cultmesh.eve_connection_intent`, return `pending-provider`, name the target cluster as response owner, and leave receipt fields null. Consumer-supplied connection receipt id/status is rejected. The request path no longer projects repo-work queue data as if the provider had accepted and returned a surface. `collaboration-feedback` now requires the cited Eve connection receipt to exist in CultMesh, and the wrapper no longer invokes `connect-eve` then cites a receipt that the same command fabricated. Physical proof shows intent present, provider receipt absent, counterfeit receipt fields rejected, and feedback refused without a genuine provider receipt. +## 2026-07-12 daemon lifecycle requester/provider split + +Single poke, batch poke, and swarm triage now write only `epiphany.cultmesh.daemon_poke_intent`. They report `pending-lifecycle-owner`, leave receipt/result fields null, and reject caller-supplied receipt id/status, resulting daemon status, or artifact result. The generic `daemon-status` / `set-daemon-status` CLI writer was deleted because it let callers proclaim readiness and stamp a heartbeat. `epiphany-cluster-daemon`, the provider body, now creates its own initial status from persisted topology after bootstrap rather than depending on a seeded fake heartbeat. Physical proof: provider heartbeat `degraded`, poke intent observes `degraded`, provider receipt absent, caller-supplied `ready` result rejected, and generic status writer unavailable. + This is the re-entry rite for `E:\Projects\EpiphanyAgent`: the waking chant for the local machine-spirit before it touches the forge. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 5c454daa..410bf10b 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index 3810a072..f3424ad2 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -70,7 +70,7 @@ data_flow: - move historical proof to git, commits, smoke artifacts, or distilled evidence rather than plan prose active_subgoals: - - Use `notes/conceptual-substitution-audit-2026-07-12.md` as the current authority-corrosion audit. The June 18 typed swarm-surface pass collapsed bootstrap, observation, request routing, and provider receipt authorship into one local CLI. Diagnostics no longer seed state or manufacture missing provider/liveness truth. Bifrost publication, daemon tool invocation, and Eve connection are requester-only: each persists an intent, reports a pending owner, rejects caller-supplied result fields, and leaves provider receipts absent. Collaboration feedback now requires an actual persisted Eve provider receipt; its wrapper no longer manufactures its own prerequisite. Next cut daemon poke, collaboration consensus response, public-proof publication, artifact acceptance, and metrics. + - Use `notes/conceptual-substitution-audit-2026-07-12.md` as the current authority-corrosion audit. The June 18 typed swarm-surface pass collapsed bootstrap, observation, request routing, and provider receipt authorship into one local CLI. Diagnostics no longer manufacture missing truth. Bifrost publication, daemon tool invocation, Eve connection, and daemon lifecycle poke are requester-only: each persists an intent, reports a pending owner, rejects caller-supplied result fields, and leaves provider receipts absent. The generic CLI daemon-status writer is deleted; the owning cluster-daemon now constructs its first heartbeat from persisted topology. Collaboration feedback requires a real Eve provider receipt. Next cut collaboration consensus response, public-proof publication, artifact acceptance, and metrics. - `swarm-overview` is an Epiphany-local, renderer-neutral diagnostic projection over provider-owned typed state. It owns no lifecycle, discovery, composition, or mutation authority. Epiphany publishes clean provider-owned Eve surfaces; Odin may discover them; downstream lowerers and compositors remain outside Epiphany's concern. - Idunn owns daemon survival and service lifecycle physiology. Codex/operator sessions may inspect, generate runbooks, and route explicit operator authority, but keeping daemons alive belongs to Idunn-owned service lifecycle receipts, scheduler policy, audits, and aftercare. Do not let Self, diagnostic projections, or ad hoc wrapper summaries become a second daemon-keeper. Global tool readbacks for Self `service-health`, `service-policy-directory`, and `swarm-online-runbook` state `lifecycleOwner=Idunn` and `hostedBody=Epiphany` without service mutation or private-state exposure. - Use `notes/epiphany-cultmesh-dreaming-roadmap.md` as the design authority for distributed Epiphany dreaming. Public dreams are separately authored typed documents distributed through CultMesh/CultNet; private state remains local and cannot be shared by flipping a visibility flag. Foreign dreams are external thought weather until a reviewed local adoption receipt digests them into memory, planning, doctrine, or governance.