Publish Idunn RUDP runtime self-check

This commit is contained in:
Meta Vens 2026-06-15 22:35:00 +01:00
commit a754db74c7
7 changed files with 151 additions and 6 deletions

1
Cargo.lock generated
View file

@ -422,6 +422,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"cultmesh-rs",
"cultnet-rs",
"odin-core",
]

View file

@ -12,4 +12,5 @@ path = "src/main.rs"
[dependencies]
anyhow = "1"
cultmesh-rs = { path = "../../vendor/cultmesh-rs" }
cultnet-rs = { path = "../../vendor/cultnet-rs" }
odin-core = { path = "../odin-core" }

View file

@ -1,11 +1,17 @@
use anyhow::{Context, Result, anyhow};
use cultmesh_rs::{CultMesh, CultMeshNode, CultMeshNodeOptions};
use cultnet_rs::{
CULTNET_RUDP_PROTOCOL_ID, CultNetMessage, CultNetRudpOptions, recv_cultnet_message_rudp,
send_cultnet_message_rudp,
};
use odin_core::{
IdunnCommandBoundaryRecord, IdunnDaemonHealthRecord, IdunnDaemonSurgeryPlanRecord,
IdunnDaemonTransportProfileRecord, IdunnDeploymentResultRecord, IdunnDesiredDaemonRecord,
IdunnOperatorAlarmRecord, IdunnRestartResultRecord, OdinDocuments, plan_keepalive,
IdunnOperatorAlarmRecord, IdunnRestartResultRecord, IdunnRuntimeTransportCheckRecord,
OdinDocuments, plan_keepalive,
};
use std::env;
use std::net::UdpSocket;
use std::path::PathBuf;
use std::process::{Child, Command, Stdio};
use std::sync::{Arc, Mutex};
@ -76,6 +82,8 @@ fn main() -> Result<()> {
match &options.mode {
Mode::Single(target) => {
let store_lock = Arc::new(Mutex::new(()));
let now = timestamp()?;
publish_runtime_transport_check(&options.common, &store_lock, &now)?;
run_target_cycle(target, &options.common, &store_lock)
}
Mode::Swarm(swarm) => run_swarm(swarm, &options.common),
@ -101,6 +109,7 @@ fn run_swarm(options: &SwarmOptions, common: &CommonOptions) -> Result<()> {
let store_lock = Arc::new(Mutex::new(()));
let now = timestamp()?;
publish_runtime_transport_check(common, &store_lock, &now)?;
publish_daemon_surgery_plans(&targets, common, &store_lock, &now)?;
let mut workers = Vec::with_capacity(targets.len());
@ -315,6 +324,81 @@ where
write(&mut node)
}
fn publish_runtime_transport_check(
options: &CommonOptions,
store_lock: &Arc<Mutex<()>>,
observed_at: &str,
) -> Result<()> {
let check = runtime_transport_check(observed_at);
with_store_node(options, store_lock, |node| {
node.put(&check.check_id, &check)?;
Ok(())
})
}
fn runtime_transport_check(observed_at: &str) -> IdunnRuntimeTransportCheckRecord {
match verify_rudp_loopback() {
Ok(transfer_id) => IdunnRuntimeTransportCheckRecord {
check_id: "idunn-runtime-rudp-loopback".to_string(),
runtime_id: "idunn-daemon".to_string(),
transport: CULTNET_RUDP_PROTOCOL_ID.to_string(),
state: "available".to_string(),
detail: format!("loopback CultNet RUDP message acknowledged as transfer {transfer_id}"),
observed_at: observed_at.to_string(),
},
Err(error) => IdunnRuntimeTransportCheckRecord {
check_id: "idunn-runtime-rudp-loopback".to_string(),
runtime_id: "idunn-daemon".to_string(),
transport: CULTNET_RUDP_PROTOCOL_ID.to_string(),
state: "failed".to_string(),
detail: format!("loopback CultNet RUDP check failed: {error}"),
observed_at: observed_at.to_string(),
},
}
}
fn verify_rudp_loopback() -> Result<String> {
let sender = UdpSocket::bind("127.0.0.1:0")?;
let receiver = UdpSocket::bind("127.0.0.1:0")?;
let receiver_addr = receiver.local_addr()?;
let options = CultNetRudpOptions {
ack_timeout: Duration::from_millis(100),
retries: 3,
..CultNetRudpOptions::default()
};
let receiver_options = options.clone();
let handle = thread::spawn(move || -> Result<()> {
let (message, _source, _transfer_id) =
recv_cultnet_message_rudp(&receiver, &receiver_options)?;
match message {
CultNetMessage::Hello { runtime_id, .. } if runtime_id == "idunn-daemon" => Ok(()),
other => Err(anyhow!("unexpected loopback CultNet message: {other:?}")),
}
});
let transfer_id = send_cultnet_message_rudp(
&sender,
receiver_addr,
&CultNetMessage::Hello {
runtime_id: "idunn-daemon".to_string(),
runtime_kind: "keepalive".to_string(),
agent_id: None,
role: Some("idunn.runtime-transport-self-check".to_string()),
display_name: Some("Idunn RUDP self-check".to_string()),
supported_document_types: Some(vec!["idunn.runtime_transport_check".to_string()]),
supported_mutation_contracts: None,
supported_message_versions: Some(vec!["cultnet.hello.v0".to_string()]),
supports_schema_catalog: Some(false),
},
&options,
)?;
handle
.join()
.map_err(|_| anyhow!("Idunn RUDP loopback receiver thread panicked"))??;
Ok(transfer_id)
}
fn publish_daemon_surgery_plans(
targets: &[DaemonTarget],
options: &CommonOptions,
@ -1314,4 +1398,13 @@ mod tests {
"dependency-unavailable"
);
}
#[test]
fn runtime_transport_check_proves_rudp_loopback() {
let check = runtime_transport_check("2026-06-15T00:00:00Z");
assert_eq!(check.check_id, "idunn-runtime-rudp-loopback");
assert_eq!(check.transport, CULTNET_RUDP_PROTOCOL_ID);
assert_eq!(check.state, "available");
}
}

View file

@ -22,6 +22,7 @@ pub const IDUNN_OPERATOR_ALARM_SCHEMA: &str = "idunn.operator_alarm.v1";
pub const IDUNN_DAEMON_SURGERY_PLAN_SCHEMA: &str = "idunn.daemon_surgery_plan.v1";
pub const IDUNN_DAEMON_TRANSPORT_PROFILE_SCHEMA: &str = "idunn.daemon_transport_profile.v1";
pub const IDUNN_COMMAND_BOUNDARY_SCHEMA: &str = "idunn.command_boundary.v1";
pub const IDUNN_RUNTIME_TRANSPORT_CHECK_SCHEMA: &str = "idunn.runtime_transport_check.v1";
pub const MUNINN_TELEMETRY_SURFACE_SCHEMA: &str = "muninn.telemetry_surface.v1";
pub const MUNINN_CAPTURE_STREAM_SCHEMA: &str = "muninn.capture_stream.v1";
pub const MUNINN_OBS_STREAM_CATALOG_SCHEMA: &str = "muninn.obs_stream_catalog.v1";
@ -433,6 +434,26 @@ pub struct IdunnCommandBoundaryRecord {
pub observed_at: String,
}
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "idunn.runtime_transport_check",
schema = "idunn.runtime_transport_check.v1"
)]
pub struct IdunnRuntimeTransportCheckRecord {
#[cultcache(key = 0)]
pub check_id: String,
#[cultcache(key = 1)]
pub runtime_id: String,
#[cultcache(key = 2)]
pub transport: String,
#[cultcache(key = 3)]
pub state: String,
#[cultcache(key = 4)]
pub detail: String,
#[cultcache(key = 5)]
pub observed_at: String,
}
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
#[cultcache(type = "muninn.capture_stream", schema = "muninn.capture_stream.v1")]
pub struct MuninnCaptureStreamRecord {
@ -671,6 +692,7 @@ cultmesh_rs::cultmesh_documents!(OdinDocuments {
IdunnDaemonSurgeryPlanRecord => IDUNN_DAEMON_SURGERY_PLAN_SCHEMA,
IdunnDaemonTransportProfileRecord => IDUNN_DAEMON_TRANSPORT_PROFILE_SCHEMA,
IdunnCommandBoundaryRecord => IDUNN_COMMAND_BOUNDARY_SCHEMA,
IdunnRuntimeTransportCheckRecord => IDUNN_RUNTIME_TRANSPORT_CHECK_SCHEMA,
MuninnTelemetrySurfaceRecord => MUNINN_TELEMETRY_SURFACE_SCHEMA,
MuninnCaptureStreamRecord => MUNINN_CAPTURE_STREAM_SCHEMA,
MuninnObsStreamCatalogRecord => MUNINN_OBS_STREAM_CATALOG_SCHEMA,

View file

@ -179,7 +179,7 @@ mod tests {
IDUNN_COMMAND_BOUNDARY_SCHEMA, IDUNN_DAEMON_SURGERY_PLAN_SCHEMA,
IDUNN_DAEMON_TRANSPORT_PROFILE_SCHEMA, IDUNN_DESIRED_DAEMON_SCHEMA,
IdunnCommandBoundaryRecord, IdunnDaemonSurgeryPlanRecord,
IdunnDaemonTransportProfileRecord, OdinDocuments,
IdunnDaemonTransportProfileRecord, IdunnRuntimeTransportCheckRecord, OdinDocuments,
};
use anyhow::Result;
use cultmesh_rs::{CultMesh, CultMeshNodeOptions};
@ -379,6 +379,15 @@ mod tests {
observed_at: "2026-06-04T00:00:02Z".to_string(),
};
node.put(&command_boundary.boundary_id, &command_boundary)?;
let runtime_check = IdunnRuntimeTransportCheckRecord {
check_id: "idunn-runtime-rudp-loopback".to_string(),
runtime_id: "idunn-daemon".to_string(),
transport: "cultnet.transport.rudp.v0".to_string(),
state: "available".to_string(),
detail: "loopback acknowledged".to_string(),
observed_at: "2026-06-04T00:00:02Z".to_string(),
};
node.put(&runtime_check.check_id, &runtime_check)?;
let reloaded = CultMesh::create_node(
&store_path,
@ -452,6 +461,12 @@ mod tests {
.health_authority,
"compatibility.probe-only"
);
assert_eq!(
reloaded
.get_required::<IdunnRuntimeTransportCheckRecord>(&runtime_check.check_id)?
.state,
"available"
);
assert_eq!(
reloaded
.get_required::<IdunnRestartRequestRecord>(&request.request_id)?

View file

@ -89,6 +89,7 @@ idunn.operator_alarm.v1
idunn.daemon_surgery_plan.v1
idunn.daemon_transport_profile.v1
idunn.command_boundary.v1
idunn.runtime_transport_check.v1
```
## Invariants
@ -134,6 +135,10 @@ idunn.command_boundary.v1
excuse. It does not make any daemon fully migrated until that daemon publishes
its health and command boundary through the RUDP path and Idunn consumes that
daemon-owned publication instead of the compatibility command.
- Idunn publishes `idunn.runtime_transport_check.v1` at startup. The current
check sends a CultNet hello over loopback `cultnet.transport.rudp.v0` and
records whether the acknowledgement path works in Idunn's own Rust runtime.
This proves Idunn's local substrate, not fleet migration.
- Idunn publishes the transport migration plan as
`idunn.daemon_surgery_plan.v1` records in the keepalive store. Each daemon
plan names severity, status, owner, objective, current mechanism, intended
@ -212,10 +217,12 @@ The local swarm mode owns:
4. a typed `idunn.daemon_transport_profile.v1` and
`idunn.command_boundary.v1` record per target, so compatibility probes and
local commands cannot pretend to be daemon-owned CultNet/RUDP truth;
5. one in-process schedule per target instead of one watchdog process per target;
6. shared typed keepalive records in one CultMesh store;
7. deploy/restart/alarm execution through the same Rust decision engine;
8. recovery of fast local targets like Odin without waiting behind slow remote
5. a startup `idunn.runtime_transport_check.v1` witness proving Idunn's own
Rust RUDP loopback path;
6. one in-process schedule per target instead of one watchdog process per target;
7. shared typed keepalive records in one CultMesh store;
8. deploy/restart/alarm execution through the same Rust decision engine;
9. recovery of fast local targets like Odin without waiting behind slow remote
Yggdrasil checks.
Next: update daemon CultLib dependencies to the cross-runtime

View file

@ -160,6 +160,7 @@ Pages remains external-owned.
- `idunn.daemon_surgery_plan.v1`
- `idunn.daemon_transport_profile.v1`
- `idunn.command_boundary.v1`
- `idunn.runtime_transport_check.v1`
Idunn publishes one `idunn.daemon_surgery_plan.v1` record per swarm target when
the swarm starts. Those records make the CultNet/RUDP migration queue explicit:
@ -172,6 +173,11 @@ both. The transport profile names `cultnet.transport.rudp.v0` as the target and
marks the current command probe as compatibility evidence. The command boundary
names restart, deploy, health, and alarm authority separately.
At startup Idunn also publishes `idunn.runtime_transport_check.v1`, currently a
loopback CultNet hello over `cultnet.transport.rudp.v0`. That proves Idunn's
Rust body can use the RUDP substrate before it asks the rest of the swarm to
walk through the same door.
The next cuts are updating daemon CultLib dependencies so health and command
boundaries publish through `cultnet.transport.rudp.v0`, switching Idunn to those
daemon-owned records, promoting the built-in target catalog into Odin-ingested