Move provider state into cluster daemons

This commit is contained in:
Meta Vens 2026-07-12 21:06:27 +01:00
commit 9972825a43
10 changed files with 141 additions and 65 deletions

View file

@ -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<EpiphanyCultMeshDaemon
args.runtime_id.clone(),
Utc::now().to_rfc3339(),
)?;
publish_epiphany_cultmesh_provider_state(
&args.store,
args.runtime_id.clone(),
&args.daemon_id,
)?;
let context = query_epiphany_local_verse_context(&args.store, args.runtime_id.clone())?;
let current = context
.daemon_statuses

View file

@ -67,12 +67,10 @@ use epiphany_core::write_epiphany_cultmesh_daemon_status;
use epiphany_core::write_epiphany_cultmesh_daemon_statuses;
use epiphany_core::write_epiphany_cultmesh_daemon_tool_invocation_intent;
use epiphany_core::write_epiphany_cultmesh_daemon_tool_invocation_receipt;
use epiphany_core::write_epiphany_cultmesh_daemon_tool_capabilities;
use epiphany_core::write_epiphany_cultmesh_eve_connection_intent;
use epiphany_core::write_epiphany_cultmesh_eve_connection_receipt;
use epiphany_core::write_epiphany_cultmesh_eve_surface_states;
use epiphany_core::write_epiphany_cultmesh_imagination_consensus_receipt;
use epiphany_core::write_epiphany_cultmesh_odin_advertisements;
use epiphany_core::publish_epiphany_cultmesh_provider_state;
use epiphany_core::write_epiphany_cultmesh_swarm_brake;
use epiphany_core::write_epiphany_cultmesh_work_loop_telemetry;
use epiphany_core::EpiphanyAgentStateSoaEntry;
@ -1350,18 +1348,16 @@ fn run_cli() -> 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(),

View file

@ -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<EpiphanyCultMeshOdinAdvert
.collect()
}
pub fn write_epiphany_cultmesh_odin_advertisements(
store_path: impl AsRef<Path>,
runtime_id: impl Into<String>,
) -> Result<Vec<EpiphanyCultMeshOdinAdvertisementEntry>> {
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<EpiphanyCultMeshEveSurfaceStateEntry> {
epiphany_cultmesh_cluster_topology()
.into_iter()
@ -6649,20 +6635,6 @@ pub fn epiphany_cultmesh_eve_surface_states() -> Vec<EpiphanyCultMeshEveSurfaceS
.collect()
}
pub fn write_epiphany_cultmesh_eve_surface_states(
store_path: impl AsRef<Path>,
runtime_id: impl Into<String>,
) -> Result<Vec<EpiphanyCultMeshEveSurfaceStateEntry>> {
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<Path>,
runtime_id: impl Into<String>,
) -> Result<Vec<EpiphanyCultMeshDaemonToolCapabilityEntry>> {
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<EpiphanyCultMeshMindContractEntry> {
@ -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::<EpiphanyCultMeshOdinAdvertisementEntry>(
@ -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::<EpiphanyCultMeshOdinAdvertisementEntry>(
@ -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::<EpiphanyCultMeshDaemonToolCapabilityEntry>(
@ -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::<EpiphanyCultMeshDaemonToolCapabilityEntry>(
@ -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()?;

View file

@ -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;

View file

@ -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

View file

@ -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.

View file

@ -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.

View file

@ -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.

Binary file not shown.

View file

@ -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.