From 0b8d738f780a1f77b6379d973c955d55e9d91f78 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 11 Sep 2026 00:52:19 +0200 Subject: [PATCH] A translated request is stamped by Muninn's clock The command engine orders commands by comparing updated_at strings. A consumer's RFC 3339 stamp sorts below every `unix-` stamp Muninn writes, so the first stop request sent tonight lost to a start command stored in July and Raven kept encoding to nobody. Translated commands now carry Muninn's own stamp; the test pins the ordering. Idunn daemon health on the Raven launch is optional now and omitted by default: no Idunn manages this host, and the publisher only filled yggdrasil's firewall log. Co-Authored-By: Claude Fable 5.1 --- crates/muninn-daemon/src/main.rs | 10 +++++++++- scripts/restart-muninn.ps1 | 28 +++++++++++++++------------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/crates/muninn-daemon/src/main.rs b/crates/muninn-daemon/src/main.rs index f6b831a..a4ba1a4 100644 --- a/crates/muninn-daemon/src/main.rs +++ b/crates/muninn-daemon/src/main.rs @@ -851,7 +851,10 @@ fn command_from_media_stream_request( media_packet_bytes: if request.media_packet_bytes == 0 { options.media_packet_bytes as u32 } else { request.media_packet_bytes }, requested_by: request.receiver_id.clone(), detail: format!("media stream request {}", request.request_id), - updated_at: request.updated_at.clone(), + // Muninn's own clock, in Muninn's own format. The command engine orders + // commands by comparing these strings; a consumer's RFC 3339 stamp sorts + // below every `unix-` stamp and would lose to any command ever stored. + updated_at: timestamp()?, rudp_video_bitrate_kbps: request.video_bitrate_kbps, rudp_latency_budget_ms: request.latency_budget_ms, video_source_id: if request.video_source_id.is_empty() { MUNINN_DISABLED_VIDEO_SOURCE_ID.to_string() } else { request.video_source_id.clone() }, @@ -11003,6 +11006,11 @@ mod tests { assert_eq!(command.media_packet_bytes, options.media_packet_bytes as u32, "zero takes the producer default"); assert_eq!(command.video_source_id, "display:0"); assert_eq!(command.requested_by, "starfire.obs"); + assert!(command.updated_at.starts_with("unix-"), "stamped by Muninn's clock, not the consumer's: {}", command.updated_at); + assert!( + command.updated_at.as_str() > "unix-1783295838", + "a fresh request must outrank a command stored in July; the tick orders by this string" + ); } #[test] diff --git a/scripts/restart-muninn.ps1 b/scripts/restart-muninn.ps1 index 7671d05..1254cff 100644 --- a/scripts/restart-muninn.ps1 +++ b/scripts/restart-muninn.ps1 @@ -37,9 +37,9 @@ if ($env:IDUNN_ACTUATOR -ne "1" -or $env:IDUNN_COMMAND_AUTHORITY -ne "idunn-daem if (-not (Test-Path -LiteralPath $LocalLoopbackScript)) { throw "Local Muninn loopback script not found at $LocalLoopbackScript" } -if ([string]::IsNullOrWhiteSpace($IdunnRudpHealth)) { - throw "Idunn RUDP health endpoint must be supplied by -IdunnRudpHealth or IDUNN_RUDP_HEALTH; no Starfire LAN default is allowed." -} +# Idunn daemon health is published only when an Idunn actually manages this +# host. None does today (no Windows-host driver exists), so the flags are +# optional; supplying an endpoint nobody admits just fills a firewall log. if ([string]::IsNullOrWhiteSpace($MediaTargetUri) -or -not $MediaTargetUri.StartsWith("cultmesh://", [System.StringComparison]::OrdinalIgnoreCase)) { throw "Muninn media target URI must be supplied by -MediaTargetUri or MUNINN_MEDIA_TARGET_URI and must start with cultmesh://." } @@ -439,11 +439,18 @@ $serveArguments += @( "--audio-device", $AudioDevice, "--ffmpeg", $Ffmpeg, "--loopback-script", $LoopbackScript, - "--interval-seconds", "15", - "--idunn-rudp-health", $IdunnRudpHealth, - "--idunn-daemon", $IdunnDaemon, - "--idunn-health-contract", $IdunnHealthContract + "--interval-seconds", "15" ) +$idunnHealthArguments = @() +if (-not [string]::IsNullOrWhiteSpace($IdunnRudpHealth)) { + $idunnHealthArguments = @( + "--idunn-rudp-health", $IdunnRudpHealth, + "--idunn-daemon", $IdunnDaemon, + "--idunn-health-contract", $IdunnHealthContract + ) + $serveArguments += $idunnHealthArguments +} +$serveCheckPatternsLiteral = (@("--interval-seconds") + $idunnHealthArguments | ForEach-Object { '"' + $_ + '"' }) -join ",`n " $serveDynamicArgumentsScript = @' function Test-LikelyVirtualDisplayToken { param([Parameter(Mandatory = $true)] [string] $Token) @@ -884,12 +891,7 @@ if (`$null -eq `$process) { throw "Muninn serve process did not start on Raven within $ServeStartTimeoutSeconds seconds" } foreach (`$pattern in @( - "--idunn-rudp-health", - "$IdunnRudpHealth", - "--idunn-daemon", - "$IdunnDaemon", - "--idunn-health-contract", - "$IdunnHealthContract" + $serveCheckPatternsLiteral )) { if (`$process.CommandLine -notlike "*`$pattern*") { throw "Muninn Raven serve command line is missing `${pattern}: `$(`$process.CommandLine)"