Separate daemon heartbeat from bootstrap

This commit is contained in:
Meta Vens 2026-07-12 21:09:24 +01:00
commit cc00f361f7
6 changed files with 54 additions and 38 deletions

View file

@ -2,9 +2,8 @@ use anyhow::Context;
use anyhow::Result;
use chrono::Utc;
use epiphany_core::load_epiphany_cultmesh_cluster_topology;
use epiphany_core::load_epiphany_cultmesh_daemon_liveness;
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;
use epiphany_core::EpiphanyCultMeshDaemonStatusEntry;
use epiphany_core::EPIPHANY_CULTMESH_DAEMON_STATUS_SCHEMA_VERSION;
@ -41,47 +40,43 @@ fn serve(args: Args) -> Result<()> {
}
fn write_heartbeat(args: &Args, iteration: u64) -> Result<EpiphanyCultMeshDaemonStatusEntry> {
seed_epiphany_local_verse_context(
&args.store,
args.runtime_id.clone(),
Utc::now().to_rfc3339(),
)?;
let topology = load_epiphany_cultmesh_cluster_topology(&args.store, args.runtime_id.clone())?;
let cluster = topology
.into_iter()
.find(|cluster| cluster.daemon_id == args.daemon_id)
.with_context(|| {
format!(
"local Verse has no persisted topology for {}; run explicit bootstrap before starting cluster daemons",
args.daemon_id
)
})?;
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
.iter()
let current = load_epiphany_cultmesh_daemon_liveness(&args.store, args.runtime_id.clone())?
.into_iter()
.map(|(_, status)| status)
.find(|status| status.daemon_id == args.daemon_id)
.cloned()
.or_else(|| {
load_epiphany_cultmesh_cluster_topology(&args.store, args.runtime_id.clone())
.ok()?
.into_iter()
.find(|cluster| cluster.daemon_id == args.daemon_id)
.map(|cluster| EpiphanyCultMeshDaemonStatusEntry {
schema_version: EPIPHANY_CULTMESH_DAEMON_STATUS_SCHEMA_VERSION.to_string(),
daemon_id: cluster.daemon_id,
cluster_id: cluster.cluster_id,
body_domain: cluster.body_domain,
daemon_surface_id: cluster.daemon_surface_id,
eve_surface_id: cluster.eve_surface_id,
status: "unknown".to_string(),
last_heartbeat_utc: "unknown".to_string(),
supported_actions: vec![
"inspectStatus".to_string(),
"pokeDaemon".to_string(),
"watchHeartbeat".to_string(),
],
operator_action: "pokeDaemon".to_string(),
private_state_exposed: false,
notes: vec!["Initial status constructed by the owning cluster daemon from persisted topology.".to_string()],
})
})
.with_context(|| format!("local Verse has no persisted topology for {}", args.daemon_id))?;
.unwrap_or_else(|| EpiphanyCultMeshDaemonStatusEntry {
schema_version: EPIPHANY_CULTMESH_DAEMON_STATUS_SCHEMA_VERSION.to_string(),
daemon_id: cluster.daemon_id,
cluster_id: cluster.cluster_id,
body_domain: cluster.body_domain,
daemon_surface_id: cluster.daemon_surface_id,
eve_surface_id: cluster.eve_surface_id,
status: "unknown".to_string(),
last_heartbeat_utc: "unknown".to_string(),
supported_actions: vec![
"inspectStatus".to_string(),
"pokeDaemon".to_string(),
"watchHeartbeat".to_string(),
],
operator_action: "pokeDaemon".to_string(),
private_state_exposed: false,
notes: vec!["Initial status constructed by the owning cluster daemon from persisted topology.".to_string()],
});
let mut next = current.clone();
next.status = args.daemon_status.clone();
next.last_heartbeat_utc = Utc::now().to_rfc3339();

View file

@ -124,3 +124,17 @@ 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.
## Heartbeat/bootstrap split
After provider publication moved into `epiphany-cluster-daemon`, its heartbeat
path still called the generic local Verse bootstrap. A daemon could therefore
repaint Self-owned policy, topology, contracts, brake initialization, and
operator status merely by emitting liveness.
Heartbeat and serve no longer bootstrap or query the full Verse context. They
require persisted topology, load only narrow liveness rows, publish only the
owning daemon's provider state, and write only its heartbeat. An unbootstrapped
daemon fails before creating the CultCache store and tells the operator to run
explicit bootstrap. The wrapper already performs that bootstrap at the
operator boundary.

View file

@ -94,6 +94,10 @@
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.
- Cluster daemons never bootstrap the local Verse and never load its full
context. They require persisted topology, read narrow liveness, then write
only their bounded provider state and heartbeat. Explicit operator bootstrap
owns policy/topology/contract initialization.
- 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

@ -21,6 +21,9 @@ The confirmed conceptual substitutions have been cut:
- 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.
- cluster daemons do not bootstrap or query the full Verse. Missing persisted
topology is a pre-write refusal; explicit operator bootstrap owns shared
policy, topology, contracts, brake initialization, and operator status.
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, 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.
- 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, all-provider state writers, and daemon-side generic bootstrap are cut. Provider absence survives bootstrap; the query CLI cannot proclaim seven providers active over RUDP; each cluster daemon requires persisted topology and writes only its own advertisement, surface, tools, and heartbeat through narrow reads. 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.