From 2698fb2860a142c71b8a01a36d7b712f8f706997 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 12 Jul 2026 13:25:28 +0100 Subject: [PATCH] Run managed services under Idunn scheduler --- .../src/bin/epiphany-daemon-supervisor.rs | 64 ++++++++++++++---- epiphany-core/src/cultmesh_integration.rs | 12 ++++ epiphany-core/src/lib.rs | 1 + notes/epiphany-current-algorithmic-map.md | 11 +++ notes/fresh-workspace-handoff.md | 12 ++++ notes/perfect-machine-audit-roadmap.md | 9 +++ state/ledgers.msgpack | Bin 425759 -> 426160 bytes state/map.yaml | 2 +- 8 files changed, 95 insertions(+), 16 deletions(-) diff --git a/epiphany-core/src/bin/epiphany-daemon-supervisor.rs b/epiphany-core/src/bin/epiphany-daemon-supervisor.rs index 33c6e499..e0b1c37c 100644 --- a/epiphany-core/src/bin/epiphany-daemon-supervisor.rs +++ b/epiphany-core/src/bin/epiphany-daemon-supervisor.rs @@ -11,6 +11,7 @@ use epiphany_core::EpiphanyCultMeshDaemonRestartPolicyEntry; use epiphany_core::EpiphanyCultMeshDaemonSchedulerReceiptEntry; use epiphany_core::EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry; use epiphany_core::EpiphanyCultMeshManagedServicePolicyEntry; +use epiphany_core::EpiphanyCultMeshSwarmBrakeEntry; use epiphany_core::EpiphanyCultMeshDaemonStatusEntry; use epiphany_core::EpiphanyLocalVerseContext; use epiphany_core::EpiphanyServiceExecutionAuditReport; @@ -21,6 +22,8 @@ use epiphany_core::epiphany_service_execution_audit_report; use epiphany_core::load_epiphany_cultmesh_daemon_restart_policy; use epiphany_core::load_epiphany_cultmesh_daemon_service_lifecycle_receipts; use epiphany_core::load_epiphany_cultmesh_managed_service_policy; +use epiphany_core::load_epiphany_cultmesh_managed_service_policies; +use epiphany_core::load_epiphany_cultmesh_swarm_brake; use epiphany_core::query_epiphany_local_verse_context; use epiphany_core::seed_epiphany_local_verse_context; use epiphany_core::write_epiphany_cultmesh_daemon_poke_intent; @@ -49,6 +52,7 @@ fn main() -> Result<()> { "reconcile" | "poke" | "restart" => reconcile(args), "tick" | "schedule" | "reconcile-all" => tick(args), "serve" | "loop" | "daemon" => serve(args), + "managed-service-serve" | "service-desired-state-serve" => managed_service_serve(args), "service-plan" | "install-service" => service_plan(args), "service-launch" | "launch-service" | "start-service" => service_launch(args), "managed-service-policy" | "service-desired-state" => managed_service_policy(args), @@ -182,14 +186,40 @@ fn serve(args: Args) -> Result<()> { Ok(()) } +fn managed_service_serve(args: Args) -> Result<()> { + let mut iteration = 0_u64; + loop { + iteration = iteration.saturating_add(1); + let policies = load_epiphany_cultmesh_managed_service_policies( + &args.store, + args.runtime_id.clone(), + )?; + for policy in &policies { + let mut service_args = args.clone(); + service_args.service_id = policy.service_id.clone(); + managed_service_reconcile(service_args)?; + } + println!("{}", serde_json::to_string_pretty(&json!({ + "schemaVersion": "epiphany.cultmesh.managed_service_scheduler_pulse.v0", + "status": "completed", + "owner": "Idunn", + "iteration": iteration, + "policyCount": policies.len(), + "privateStateExposed": false, + }))?); + if args.max_iterations != 0 && iteration >= args.max_iterations { + break; + } + std::thread::sleep(std::time::Duration::from_secs( + args.loop_interval_seconds.max(0) as u64, + )); + } + Ok(()) +} + fn service_plan(args: Args) -> Result<()> { - 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())?; - assert_swarm_brake_allows_service_lifecycle(&context)?; + let brake = load_epiphany_cultmesh_swarm_brake(&args.store, args.runtime_id.clone())?; + assert_swarm_brake_allows_service_lifecycle_entry(brake.as_ref())?; let started_at = Utc::now(); let command = service_command_path(&args)?; let service_args = service_serve_args(&args); @@ -227,13 +257,8 @@ fn service_plan(args: Args) -> Result<()> { } fn service_launch(args: Args) -> Result<()> { - 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())?; - assert_swarm_brake_allows_service_lifecycle(&context)?; + let brake = load_epiphany_cultmesh_swarm_brake(&args.store, args.runtime_id.clone())?; + assert_swarm_brake_allows_service_lifecycle_entry(brake.as_ref())?; if !args.required_document_types.is_empty() && (!args.schema_preflight_passed || args.executable_sha256.as_deref().is_none_or(str::is_empty) @@ -3424,7 +3449,13 @@ fn assert_swarm_brake_allows_scheduler_tick(context: &EpiphanyLocalVerseContext) } fn assert_swarm_brake_allows_service_lifecycle(context: &EpiphanyLocalVerseContext) -> Result<()> { - let Some(brake) = context.swarm_brake.as_ref() else { + assert_swarm_brake_allows_service_lifecycle_entry(context.swarm_brake.as_ref()) +} + +fn assert_swarm_brake_allows_service_lifecycle_entry( + brake: Option<&EpiphanyCultMeshSwarmBrakeEntry>, +) -> Result<()> { + let Some(brake) = brake else { return Ok(()); }; if brake.status != "engaged" { @@ -3462,6 +3493,7 @@ struct RestartOutput { stderr_len: usize, } +#[derive(Clone)] struct Args { command: String, store: PathBuf, @@ -3744,6 +3776,8 @@ impl Args { | "serve" | "loop" | "daemon" + | "managed-service-serve" + | "service-desired-state-serve" | "service-plan" | "install-service" | "service-launch" diff --git a/epiphany-core/src/cultmesh_integration.rs b/epiphany-core/src/cultmesh_integration.rs index 270802da..39ac682e 100644 --- a/epiphany-core/src/cultmesh_integration.rs +++ b/epiphany-core/src/cultmesh_integration.rs @@ -3665,6 +3665,18 @@ pub fn load_epiphany_cultmesh_managed_service_policy( node.get(&epiphany_cultmesh_managed_service_policy_key(service_id)) } +pub fn load_epiphany_cultmesh_managed_service_policies( + store_path: impl AsRef, + runtime_id: impl Into, +) -> Result> { + let node = open_epiphany_cultmesh_node(store_path, runtime_id)?; + Ok(node + .get_all_with_keys::()? + .into_iter() + .map(|(_, policy)| policy) + .collect()) +} + pub fn write_epiphany_cultmesh_idunn_deployment_receipt( store_path: impl AsRef, runtime_id: impl Into, diff --git a/epiphany-core/src/lib.rs b/epiphany-core/src/lib.rs index fc0b78aa..97d5d36f 100644 --- a/epiphany-core/src/lib.rs +++ b/epiphany-core/src/lib.rs @@ -416,6 +416,7 @@ pub use cultmesh_integration::load_epiphany_cultmesh_daemon_restart_policy; pub use cultmesh_integration::load_epiphany_cultmesh_daemon_restart_policy_directory; pub use cultmesh_integration::load_epiphany_cultmesh_daemon_service_lifecycle_receipts; pub use cultmesh_integration::load_epiphany_cultmesh_managed_service_policy; +pub use cultmesh_integration::load_epiphany_cultmesh_managed_service_policies; pub use cultmesh_integration::load_epiphany_cultmesh_daemon_tool_directory; pub use cultmesh_integration::load_epiphany_cultmesh_eve_surface_directory; pub use cultmesh_integration::load_epiphany_cultmesh_idunn_aftercare_audit_receipt; diff --git a/notes/epiphany-current-algorithmic-map.md b/notes/epiphany-current-algorithmic-map.md index a6e46901..4bb2b73a 100644 --- a/notes/epiphany-current-algorithmic-map.md +++ b/notes/epiphany-current-algorithmic-map.md @@ -387,6 +387,17 @@ proved restart receipt and PID `19736` were observed alive after the prior process was killed. Next fold this reconcile into Idunn's own serve loop and cut the full-context Verse load from service launch. +Both cuts are landed. Service plan/launch now load only the typed swarm brake +and rely on their own typed writers to open/register the store; they do not +reseed or serialize the local Verse. `managed-service-serve` is a distinct Idunn +loop from standing-daemon `serve`, so child service desired state is not blocked +by absent topology restart policies. Live root +`C:\Users\Meta\AppData\Local\Temp\epiphany-idunn-unattended-3394ecfaa03f41d8935f9fb70411ca75` +proved PID `44276` was observed alive without duplication, then after forced +death the next pulse launched PID `40532` under unique receipt +`daemon-service-lifecycle-receipt-idunn-managed-heartbeat-launch-1783859054234`. +The next boundary is Gjallar/Eve sight over managed service desired/observed +state. This map must change when ownership changes. Historical scars belong in git, evidence, or an explicitly archived note—not in the machine's proprioception. diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 3c680e45..6da637f9 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -2229,6 +2229,18 @@ the test harness then killed it deliberately. The first combined smoke exceeded its harness window because `service_launch` loads the entire local Verse merely to inspect the swarm brake. Next use the narrow brake loader and integrate managed-service reconcile into Idunn's native serve scheduler. +That unattended boundary is complete. Service launch/plan now use the narrow +swarm-brake loader and no full Verse seed/query. A separate +`managed-service-serve` scheduler enumerates service-id policies without +requiring standing-daemon restart policies. Live root +`C:\Users\Meta\AppData\Local\Temp\epiphany-idunn-unattended-3394ecfaa03f41d8935f9fb70411ca75` +proved one pulse observed PID `44276` alive without a new receipt; after the +test harness killed it, the next pulse restarted heartbeat as PID `40532` with +unique receipt +`daemon-service-lifecycle-receipt-idunn-managed-heartbeat-launch-1783859054234`. +The same heartbeat store survived and no child remains running. Next expose +compact managed-service policy/lifecycle/process rows through Gjallar/Eve so +operators can see Idunn physiology without invoking the supervisor CLI. ## Immediate Re-entry Instruction diff --git a/notes/perfect-machine-audit-roadmap.md b/notes/perfect-machine-audit-roadmap.md index cd1b435f..3bcf8078 100644 --- a/notes/perfect-machine-audit-roadmap.md +++ b/notes/perfect-machine-audit-roadmap.md @@ -162,6 +162,15 @@ Reconciliation is complete as an explicit Idunn command. The remaining unattended boundary is to include managed-service reconciliation in Idunn's native `serve` scheduler and replace `service-launch`'s full local-Verse context load with the narrow swarm-brake query it actually needs. +That boundary is now complete. Service plan/launch use the narrow typed brake +loader and no longer reseed the full local Verse. A dedicated +`managed-service-serve` loop enumerates only managed-service policies and runs +their reconcile reflex independently of standing-daemon topology. Live proof +observed a heartbeat alive without duplicate launch, killed it, and the next +Idunn pulse restarted it from the same store with a distinct PID and immutable +lifecycle receipt. The next gap is inspectability: publish compact managed +service desired/observed rows through Gjallar/Eve without opening command +payloads or routine artifacts. ### Forbidden writers diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 018a00cc05c72d7e3bd1543e65d5c5a5e3e2cae8..a9a943affc7032125ef157292666f323373b45e4 100644 GIT binary patch delta 426 zcmYk1KT88a5XHTyX{^;~HDG-)IW$6SZLAa&3%j}9x!mI3?zw+*1e72af}o8COYs{7 zEW|J1C$bjz&c@;~JIi~I-@N{8%x^a5ooFT58SW0wzZTllhxe`MGK#)$XRW(gD+;RT zV$f31^2e;zzQ0<1{!DtwAnxtO{p7Tt44eGZ+j=KrFOS#lwW(z}aW91$fv})-1zw?Z zq&RUv#lcdE1|30WbOF|dzhI6zQlS+%U23UElP;W)84E@r(JPj3ml73tOQ6u0&}u6* zMVuPEATWg7LM2=dQ>7vEQoGfA4YRQD0RUYa>4;-jtpelu&{GF!T`~bASkNf`0${~h@$WgQyGdxMr^{u V%Mc?`I;hXi2`m=>5v