From 9972825a4318c2f20e760c4b235c2e975771b530 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 12 Jul 2026 21:06:27 +0100 Subject: [PATCH] Move provider state into cluster daemons --- .../src/bin/epiphany-cluster-daemon.rs | 6 + epiphany-core/src/bin/epiphany-verse-query.rs | 22 ++- epiphany-core/src/cultmesh_integration.rs | 135 ++++++++++++------ epiphany-core/src/lib.rs | 4 +- epiphany-core/src/prompt_context.rs | 15 +- ...onceptual-substitution-audit-2026-07-12.md | 15 ++ notes/epiphany-current-algorithmic-map.md | 4 + notes/fresh-workspace-handoff.md | 3 + state/ledgers.msgpack | Bin 434670 -> 435122 bytes state/map.yaml | 2 +- 10 files changed, 141 insertions(+), 65 deletions(-) diff --git a/epiphany-core/src/bin/epiphany-cluster-daemon.rs b/epiphany-core/src/bin/epiphany-cluster-daemon.rs index 0c62f36d..8e72f4b7 100644 --- a/epiphany-core/src/bin/epiphany-cluster-daemon.rs +++ b/epiphany-core/src/bin/epiphany-cluster-daemon.rs @@ -2,6 +2,7 @@ use anyhow::Context; use anyhow::Result; use chrono::Utc; use epiphany_core::load_epiphany_cultmesh_cluster_topology; +use epiphany_core::publish_epiphany_cultmesh_provider_state; use epiphany_core::query_epiphany_local_verse_context; use epiphany_core::seed_epiphany_local_verse_context; use epiphany_core::write_epiphany_cultmesh_daemon_status; @@ -45,6 +46,11 @@ fn write_heartbeat(args: &Args, iteration: u64) -> Result Result<()> { args.runtime_id.clone(), "2026-06-02T00:00:00Z", )?; - write_epiphany_cultmesh_odin_advertisements( + for cluster in load_epiphany_cultmesh_cluster_topology( &args.store, args.runtime_id.clone(), - )?; - write_epiphany_cultmesh_eve_surface_states( - &args.store, - args.runtime_id.clone(), - )?; - write_epiphany_cultmesh_daemon_tool_capabilities( - &args.store, - args.runtime_id.clone(), - )?; + )? { + publish_epiphany_cultmesh_provider_state( + &args.store, + args.runtime_id.clone(), + &cluster.daemon_id, + )?; + } write_epiphany_cultmesh_daemon_statuses( &args.store, args.runtime_id.clone(), diff --git a/epiphany-core/src/cultmesh_integration.rs b/epiphany-core/src/cultmesh_integration.rs index 460794e4..2d110436 100644 --- a/epiphany-core/src/cultmesh_integration.rs +++ b/epiphany-core/src/cultmesh_integration.rs @@ -5,7 +5,6 @@ use crate::default_hands_cultnet_contracts; use crate::default_mind_cultnet_contracts; use crate::default_soul_cultnet_contracts; use crate::default_substrate_gate_cultnet_contracts; -#[cfg(test)] use anyhow::Context; use anyhow::Result; use anyhow::anyhow; @@ -6578,19 +6577,6 @@ pub fn epiphany_cultmesh_odin_advertisements() -> Vec, - runtime_id: impl Into, -) -> Result> { - let mut node = open_epiphany_cultmesh_node(store_path, runtime_id)?; - let mut written = Vec::new(); - for advertisement in epiphany_cultmesh_odin_advertisements() { - written.push(node.put(advertisement.advertisement_id.clone(), &advertisement)?); - } - node.flush()?; - Ok(written) -} - pub fn epiphany_cultmesh_eve_surface_states() -> Vec { epiphany_cultmesh_cluster_topology() .into_iter() @@ -6649,20 +6635,6 @@ pub fn epiphany_cultmesh_eve_surface_states() -> Vec, - runtime_id: impl Into, -) -> Result> { - let mut node = open_epiphany_cultmesh_node(store_path, runtime_id)?; - let mut written = Vec::new(); - for surface in epiphany_cultmesh_eve_surface_states() { - validate_eve_surface_state(&surface)?; - written.push(node.put(surface.surface_id.clone(), &surface)?); - } - node.flush()?; - Ok(written) -} - fn validate_eve_surface_state(surface: &EpiphanyCultMeshEveSurfaceStateEntry) -> Result<()> { if surface.private_state_exposed { return Err(anyhow!("Eve surface states must not expose private state")); @@ -6873,17 +6845,36 @@ fn epiphany_cultmesh_daemon_tool_capability( } } -pub fn write_epiphany_cultmesh_daemon_tool_capabilities( +pub fn publish_epiphany_cultmesh_provider_state( store_path: impl AsRef, runtime_id: impl Into, -) -> Result> { + daemon_id: &str, +) -> Result<()> { + let cluster = epiphany_cultmesh_cluster_topology() + .into_iter() + .find(|cluster| cluster.daemon_id == daemon_id) + .with_context(|| format!("no declared provider topology for daemon {daemon_id:?}"))?; + let advertisement = epiphany_cultmesh_odin_advertisements() + .into_iter() + .find(|advertisement| advertisement.cluster_id == cluster.cluster_id) + .with_context(|| format!("daemon {daemon_id:?} has no Odin advertisement contract"))?; + let surface = epiphany_cultmesh_eve_surface_states() + .into_iter() + .find(|surface| surface.cluster_id == cluster.cluster_id) + .with_context(|| format!("daemon {daemon_id:?} has no Eve surface contract"))?; + validate_eve_surface_state(&surface)?; + let mut node = open_epiphany_cultmesh_node(store_path, runtime_id)?; - let mut written = Vec::new(); - for capability in epiphany_cultmesh_daemon_tool_capabilities() { - written.push(node.put(capability.capability_id.clone(), &capability)?); + node.put(advertisement.advertisement_id.clone(), &advertisement)?; + node.put(surface.surface_id.clone(), &surface)?; + for capability in epiphany_cultmesh_daemon_tool_capabilities() + .into_iter() + .filter(|capability| capability.host_daemon_id == daemon_id) + { + node.put(capability.capability_id.clone(), &capability)?; } node.flush()?; - Ok(written) + Ok(()) } pub fn epiphany_cultmesh_mind_contracts() -> Vec { @@ -7186,6 +7177,17 @@ mod tests { use super::*; use pretty_assertions::assert_eq; + fn publish_all_test_provider_state(store: &Path) -> Result<()> { + for cluster in epiphany_cultmesh_cluster_topology() { + publish_epiphany_cultmesh_provider_state( + store, + "epiphany-test", + &cluster.daemon_id, + )?; + } + Ok(()) + } + #[test] fn epiphany_status_round_trips_through_cultmesh() -> Result<()> { let temp = tempfile::tempdir()?; @@ -8010,8 +8012,7 @@ mod tests { fn odin_advertisements_expose_eve_metadata_without_private_state() -> Result<()> { let temp = tempfile::tempdir()?; let store = temp.path().join("epiphany-odin-advertisements.ccmp"); - let written = write_epiphany_cultmesh_odin_advertisements(&store, "epiphany-test")?; - assert_eq!(written.len(), 7); + publish_all_test_provider_state(&store)?; let node = open_epiphany_cultmesh_node(&store, "epiphany-test")?; let persona = node.get_required::( @@ -8045,8 +8046,9 @@ mod tests { let temp = tempfile::tempdir()?; let store = temp.path().join("epiphany-eve-surface-states.ccmp"); write_epiphany_cultmesh_cluster_topology(&store, "epiphany-test")?; - let advertisements = write_epiphany_cultmesh_odin_advertisements(&store, "epiphany-test")?; - let surfaces = write_epiphany_cultmesh_eve_surface_states(&store, "epiphany-test")?; + publish_all_test_provider_state(&store)?; + let advertisements = epiphany_cultmesh_odin_advertisements(); + let surfaces = epiphany_cultmesh_eve_surface_states(); assert_eq!(surfaces.len(), advertisements.len()); for advertisement in advertisements { @@ -8487,7 +8489,11 @@ mod tests { fn eve_connection_intent_and_receipt_route_feedback_without_private_state() -> Result<()> { let temp = tempfile::tempdir()?; let store = temp.path().join("epiphany-eve-connection.ccmp"); - write_epiphany_cultmesh_odin_advertisements(&store, "epiphany-test")?; + publish_epiphany_cultmesh_provider_state( + &store, + "epiphany-test", + "epiphany-daemon-persona", + )?; let node = open_epiphany_cultmesh_node(&store, "epiphany-test")?; let persona = node.get_required::( @@ -8556,8 +8562,7 @@ mod tests { fn daemon_tool_capabilities_make_every_local_tool_available_to_all_agents() -> Result<()> { let temp = tempfile::tempdir()?; let store = temp.path().join("epiphany-daemon-tools.ccmp"); - let written = write_epiphany_cultmesh_daemon_tool_capabilities(&store, "epiphany-test")?; - assert!(written.len() >= 19); + publish_all_test_provider_state(&store)?; let node = open_epiphany_cultmesh_node(&store, "epiphany-test")?; let persona_status = node.get_required::( @@ -8654,7 +8659,11 @@ mod tests { fn daemon_tool_invocation_intent_and_receipt_round_trip_for_any_agent() -> Result<()> { let temp = tempfile::tempdir()?; let store = temp.path().join("epiphany-daemon-tool-invocation.ccmp"); - write_epiphany_cultmesh_daemon_tool_capabilities(&store, "epiphany-test")?; + publish_epiphany_cultmesh_provider_state( + &store, + "epiphany-test", + "epiphany-daemon-hands", + )?; let node = open_epiphany_cultmesh_node(&store, "epiphany-test")?; let hands_action = node.get_required::( @@ -9319,6 +9328,48 @@ mod tests { Ok(()) } + #[test] + fn provider_publication_is_bounded_to_the_owning_daemon() -> Result<()> { + let temp = tempfile::tempdir()?; + let store = temp.path().join("epiphany-provider-boundary.ccmp"); + seed_epiphany_local_verse_context(&store, "epiphany-test", "2026-07-12T00:00:00Z")?; + + publish_epiphany_cultmesh_provider_state( + &store, + "epiphany-test", + "epiphany-daemon-hands", + )?; + let context = query_epiphany_local_verse_context(&store, "epiphany-test")?; + assert_eq!(context.odin_advertisements.len(), 1); + assert_eq!(context.eve_surface_states.len(), 1); + assert_eq!(context.daemon_tool_capabilities.len(), 3); + assert!(context + .odin_advertisements + .iter() + .all(|entry| entry.cluster_id == "epiphany.cluster.hands")); + assert!(context + .eve_surface_states + .iter() + .all(|entry| entry.cluster_id == "epiphany.cluster.hands")); + assert!(context + .daemon_tool_capabilities + .iter() + .all(|entry| entry.host_daemon_id == "epiphany-daemon-hands")); + + let error = publish_epiphany_cultmesh_provider_state( + &store, + "epiphany-test", + "epiphany-daemon-counterfeit", + ) + .expect_err("unknown daemons must not publish provider state"); + assert!(error.to_string().contains("no declared provider topology")); + let unchanged = query_epiphany_local_verse_context(&store, "epiphany-test")?; + assert_eq!(unchanged.odin_advertisements.len(), 1); + assert_eq!(unchanged.eve_surface_states.len(), 1); + assert_eq!(unchanged.daemon_tool_capabilities.len(), 3); + Ok(()) + } + #[test] fn mind_contracts_use_verses_to_keep_state_guarded() -> Result<()> { let temp = tempfile::tempdir()?; diff --git a/epiphany-core/src/lib.rs b/epiphany-core/src/lib.rs index cc70ff6f..38717735 100644 --- a/epiphany-core/src/lib.rs +++ b/epiphany-core/src/lib.rs @@ -483,12 +483,10 @@ pub use cultmesh_integration::write_epiphany_cultmesh_daemon_service_lifecycle_r pub use cultmesh_integration::write_epiphany_cultmesh_managed_service_policy; pub use cultmesh_integration::write_epiphany_cultmesh_daemon_status; pub use cultmesh_integration::write_epiphany_cultmesh_daemon_statuses; -pub use cultmesh_integration::write_epiphany_cultmesh_daemon_tool_capabilities; pub use cultmesh_integration::write_epiphany_cultmesh_daemon_tool_invocation_intent; pub use cultmesh_integration::write_epiphany_cultmesh_daemon_tool_invocation_receipt; pub use cultmesh_integration::write_epiphany_cultmesh_eve_connection_intent; pub use cultmesh_integration::write_epiphany_cultmesh_eve_connection_receipt; -pub use cultmesh_integration::write_epiphany_cultmesh_eve_surface_states; pub use cultmesh_integration::write_epiphany_cultmesh_eyes_contracts; pub use cultmesh_integration::write_epiphany_cultmesh_global_room_policies; pub use cultmesh_integration::write_epiphany_cultmesh_hands_action_gate; @@ -496,7 +494,7 @@ pub use cultmesh_integration::write_epiphany_cultmesh_hands_contracts; pub use cultmesh_integration::write_epiphany_cultmesh_idunn_aftercare_audit_receipt; pub use cultmesh_integration::write_epiphany_cultmesh_idunn_deployment_receipt; pub use cultmesh_integration::write_epiphany_cultmesh_imagination_consensus_receipt; -pub use cultmesh_integration::write_epiphany_cultmesh_odin_advertisements; +pub use cultmesh_integration::publish_epiphany_cultmesh_provider_state; pub use cultmesh_integration::write_epiphany_cultmesh_mind_contracts; pub use cultmesh_integration::write_epiphany_cultmesh_operator_run_intent; pub use cultmesh_integration::write_epiphany_cultmesh_operator_run_receipt; diff --git a/epiphany-core/src/prompt_context.rs b/epiphany-core/src/prompt_context.rs index 564e01d1..f442c0d6 100644 --- a/epiphany-core/src/prompt_context.rs +++ b/epiphany-core/src/prompt_context.rs @@ -405,9 +405,8 @@ mod tests { use crate::write_epiphany_cultmesh_bifrost_github_publication_receipt; use crate::write_epiphany_cultmesh_daemon_tool_invocation_intent; use crate::write_epiphany_cultmesh_daemon_tool_invocation_receipt; - use crate::write_epiphany_cultmesh_daemon_tool_capabilities; - use crate::write_epiphany_cultmesh_eve_surface_states; - use crate::write_epiphany_cultmesh_odin_advertisements; + use crate::load_epiphany_cultmesh_cluster_topology; + use crate::publish_epiphany_cultmesh_provider_state; use crate::write_epiphany_cultmesh_work_loop_telemetry; use epiphany_state_model::EpiphanyMemoryContextPacket; use epiphany_state_model::EpiphanyMemoryFreshnessStatus; @@ -418,9 +417,13 @@ mod tests { let temp = tempfile::tempdir()?; let store = temp.path().join("epiphany-local-verse.ccmp"); seed_epiphany_local_verse_context(&store, "epiphany-test", "2026-06-02T00:00:00Z")?; - write_epiphany_cultmesh_odin_advertisements(&store, "epiphany-test")?; - write_epiphany_cultmesh_eve_surface_states(&store, "epiphany-test")?; - write_epiphany_cultmesh_daemon_tool_capabilities(&store, "epiphany-test")?; + for cluster in load_epiphany_cultmesh_cluster_topology(&store, "epiphany-test")? { + publish_epiphany_cultmesh_provider_state( + &store, + "epiphany-test", + &cluster.daemon_id, + )?; + } let seeded_verse = query_epiphany_local_verse_context(&store, "epiphany-test")?; let hands_action = seeded_verse .daemon_tool_capabilities diff --git a/notes/conceptual-substitution-audit-2026-07-12.md b/notes/conceptual-substitution-audit-2026-07-12.md index cdbc3799..f87f705b 100644 --- a/notes/conceptual-substitution-audit-2026-07-12.md +++ b/notes/conceptual-substitution-audit-2026-07-12.md @@ -109,3 +109,18 @@ query CLI has no Odin network publication capability. Provider discovery must remain empty until provider-owned bodies publish evidence of their own presence; a future provider publisher must live at that provider boundary and derive status from its runtime, not from central topology. + +## Provider publication ownership transfer + +The network command was not the final obsolete authority. The library still +exported three bulk writers able to stamp every Odin advertisement, Eve +surface, and daemon-hosted tool in one call. Those all-provider writers are +deleted. + +`publish_epiphany_cultmesh_provider_state` accepts one persisted daemon ID, +validates that it names a declared cluster, and writes exactly that cluster's +advertisement, Eve surface, and hosted capabilities. `epiphany-cluster-daemon` +calls this primitive on the shared heartbeat/serve path before writing its own +liveness. An unknown daemon is refused before any provider document is written. +The quarantined aggregate smoke iterates the same one-daemon primitive rather +than using a privileged fixture shortcut. diff --git a/notes/epiphany-current-algorithmic-map.md b/notes/epiphany-current-algorithmic-map.md index e87a0cd3..e3965a8c 100644 --- a/notes/epiphany-current-algorithmic-map.md +++ b/notes/epiphany-current-algorithmic-map.md @@ -90,6 +90,10 @@ publication command. Provider bodies must publish their own discovery state; central declared topology cannot be lowered into `active`/`daemon-live` compatibility presence. +- `epiphany-cluster-daemon` owns provider presence beside heartbeat liveness. + Each heartbeat/serve lane publishes only its daemon's Odin advertisement, + Eve surface, and hosted tools through a daemon-ID-bounded primitive. There is + no all-provider writer; an unknown daemon publishes nothing. - Store/runtime overrides fail before fixture seeding or receipt construction. - Negative proof: targeting `state/local-verse.ccmp` was rejected and its SHA-256 did not change. - Positive proof: the built-in quarantined smoke completes successfully and reports its quarantine coordinates. diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index b5f18034..3df496ec 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -18,6 +18,9 @@ The confirmed conceptual substitutions have been cut: Eve surfaces, or hosted tools; provider absence survives bootstrap. - the central `provider-advertisements` / `publish-odin` compatibility mouth is deleted; only provider-owned bodies may publish presence to Odin. +- bulk provider-state writers are deleted. Each `epiphany-cluster-daemon` + heartbeat publishes only its own advertisement, Eve surface, and hosted + tools; unknown daemon identities are refused before writes. The presentation boundary is now plain: `swarm overview` is a generic compact read-only projection. Gjallar is a downstream TUI application on Nightwing and is not an Epiphany organ, provider, owner, runtime, or architectural dependency. Eve/CultUI graphs may be lowered or composited downstream without Epiphany caring which presentation client does it. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 955586af33b6e71fd8011b397201adb0b22a482e..882a65e09d01d5f94c066ac51dfa22d9b36897ba 100644 GIT binary patch delta 452 zcmZ8dyGjE=6m=7gHrn|hHWzI~;u-}7W1B$i6l}Dc-Mz~UnaphF&L*TvVIf#(W7tyg z3w#uQfS}*u5BLqvu0h4(Fa!6Td(OF^uhpmb>cgV9uv>4`_ZvG0=WkP$`33usZv=DzA)uXt9t3M`mn*%x)8!K0?AQha?T8AdUoD$sq_!kT|&@>o!LWyIR3f z6Ij$oV+COsm90U`$tg843$X@FMZk3-uv$wxgj98ui!srU2x2BA1Q=_BFfhU*`Orj( zxe1eQl*-Oek8g%?lw&?55i$vF=Rv;(a%z-@POOy+;%cW6 iA9nZZAVpx98D=Nfm8Iog%G`OaP|kq5x|5%Z$o~S~;h@|A delta 60 zcmdmVTNz=K}y*rxMWs diff --git a/state/map.yaml b/state/map.yaml index 756313dd..17c5732b 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` plus `notes/receipt-writer-provenance-audit-2026-07-12.md` as the current authority-corrosion maps. Snapshot promotion, synthetic smoke escape, unbound operator completion, hidden service execution flags, generic-bootstrap publication of provider advertisements/Eve surfaces/hosted tools, and the central topology-derived Odin publisher are cut. Provider absence now survives bootstrap and the query CLI cannot proclaim seven providers active over RUDP. Next remove or test-gate dead public receipt constructors where provider binaries are absent and audit remaining projections, caches, schedulers, adapters, and non-receipt smokes for borrowed authority or path escape. + - Use `notes/conceptual-substitution-audit-2026-07-12.md` plus `notes/receipt-writer-provenance-audit-2026-07-12.md` as the current authority-corrosion maps. Snapshot promotion, synthetic smoke escape, unbound operator completion, hidden service execution flags, generic-bootstrap publication of provider advertisements/Eve surfaces/hosted tools, the central topology-derived Odin publisher, and all-provider state writers are cut. Provider absence survives bootstrap; the query CLI cannot proclaim seven providers active over RUDP; each cluster daemon publishes only its own advertisement, surface, tools, and heartbeat. Next remove or test-gate dead public receipt constructors where provider binaries are absent and audit remaining projections, caches, schedulers, adapters, and non-receipt smokes for borrowed authority or path escape. - `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.